1SUMMARY = "SWTPM - OpenEmbedded wrapper scripts for native swtpm tools"
2LICENSE = "MIT"
3DEPENDS = "swtpm-native tpm-tools-native net-tools-native"
4
5inherit 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...
9RM_WORK_EXCLUDE += "${PN}"
10
11do_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
24PATH="${bindir}:${base_bindir}:${sbindir}:${base_sbindir}:\$PATH"
25export PATH
26
27# tcsd only allows to be run as root or tss. Pretend to be root...
28exec env ${FAKEROOTENV} ${FAKEROOTCMD} swtpm_setup.sh --config ${STAGING_DIR_NATIVE}/etc/swtpm_setup.conf "\$@"
29EOF
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
41PATH="${bindir}:${base_bindir}:${sbindir}:${base_sbindir}:\$PATH"
42export PATH
43
44exec ${exe} "\$@"
45EOF
46                ;;
47        esac
48    done
49
50    chmod a+rx ${WORKDIR}/*.sh
51}
52
53addtask do_create_wrapper before do_build after do_prepare_recipe_sysroot
54