Richard Marian Thomaiyar | 14fddef | 2018-07-13 23:55:56 +0530 | [diff] [blame] | 1 | SUMMARY = "SWTPM - OpenEmbedded wrapper scripts for native swtpm tools" |
| 2 | LICENSE = "MIT" |
| 3 | DEPENDS = "swtpm-native tpm-tools-native net-tools-native" |
| 4 | |
| 5 | inherit native |
| 6 | |
| 7 | # The whole point of the recipe is to make files available |
| 8 | # for use after the build is done, so don't clean up... |
| 9 | RM_WORK_EXCLUDE += "${PN}" |
| 10 | |
| 11 | do_create_wrapper () { |
| 12 | # Wrap (almost) all swtpm binaries. Some get special wrappers and some |
| 13 | # are not needed. |
| 14 | for i in `find ${bindir} ${base_bindir} ${sbindir} ${base_sbindir} -name 'swtpm*' -perm /+x -type f`; do |
| 15 | exe=`basename $i` |
| 16 | case $exe in |
| 17 | swtpm_setup.sh) |
| 18 | cat >${WORKDIR}/swtpm_setup_oe.sh <<EOF |
| 19 | #! /bin/sh |
| 20 | # |
| 21 | # Wrapper around swtpm_setup.sh which adds parameters required to |
| 22 | # run the setup as non-root directly from the native sysroot. |
| 23 | |
| 24 | PATH="${bindir}:${base_bindir}:${sbindir}:${base_sbindir}:\$PATH" |
| 25 | export PATH |
| 26 | |
| 27 | # tcsd only allows to be run as root or tss. Pretend to be root... |
| 28 | exec env ${FAKEROOTENV} ${FAKEROOTCMD} swtpm_setup.sh --config ${STAGING_DIR_NATIVE}/etc/swtpm_setup.conf "\$@" |
| 29 | EOF |
| 30 | ;; |
| 31 | swtpm_setup) |
| 32 | true |
| 33 | ;; |
| 34 | *) |
| 35 | cat >${WORKDIR}/${exe}_oe.sh <<EOF |
| 36 | #! /bin/sh |
| 37 | # |
| 38 | # Wrapper around $exe which makes it easier to invoke |
| 39 | # the right binary. |
| 40 | |
| 41 | PATH="${bindir}:${base_bindir}:${sbindir}:${base_sbindir}:\$PATH" |
| 42 | export PATH |
| 43 | |
| 44 | exec ${exe} "\$@" |
| 45 | EOF |
| 46 | ;; |
| 47 | esac |
| 48 | done |
| 49 | |
| 50 | chmod a+rx ${WORKDIR}/*.sh |
| 51 | } |
| 52 | |
| 53 | addtask do_create_wrapper before do_build after do_prepare_recipe_sysroot |