Andrew Geissler | f1e4406 | 2021-04-15 15:52:46 -0500 | [diff] [blame] | 1 | SUMMARY = "Platform AbstRaction for SECurity Daemon" |
| 2 | HOMEPAGE = "https://github.com/parallaxsecond/parsec" |
| 3 | LICENSE = "Apache-2.0" |
| 4 | |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame] | 5 | inherit cargo pkgconfig |
| 6 | DEPENDS = "clang-native" |
Andrew Geissler | f1e4406 | 2021-04-15 15:52:46 -0500 | [diff] [blame] | 7 | |
| 8 | SRC_URI += "crate://crates.io/parsec-service/${PV} \ |
| 9 | file://parsec_init \ |
| 10 | file://systemd.patch \ |
| 11 | file://parsec-tmpfiles.conf \ |
| 12 | " |
| 13 | |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame] | 14 | PACKAGECONFIG ??= "PKCS11 MBED-CRYPTO" |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 15 | have_TPM = "${@bb.utils.contains('DISTRO_FEATURES', 'tpm2', 'TPM', '', d)}" |
| 16 | PACKAGECONFIG:append = " ${@bb.utils.contains('BBFILE_COLLECTIONS', 'tpm-layer', '${have_TPM}', '', d)}" |
| 17 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame^] | 18 | PACKAGECONFIG[ALL] = "all-providers cryptoki/generate-bindings tss-esapi/generate-bindings,,tpm2-tss libts,tpm2-tss libtss2-tcti-device libts" |
| 19 | PACKAGECONFIG[TPM] = "tpm-provider tss-esapi/generate-bindings,,tpm2-tss,tpm2-tss libtss2-tcti-device" |
Patrick Williams | 53961c2 | 2022-01-20 11:06:23 -0600 | [diff] [blame] | 20 | PACKAGECONFIG[PKCS11] = "pkcs11-provider cryptoki/generate-bindings," |
Patrick Williams | 93c203f | 2021-10-06 16:15:23 -0500 | [diff] [blame] | 21 | PACKAGECONFIG[MBED-CRYPTO] = "mbed-crypto-provider," |
| 22 | PACKAGECONFIG[CRYPTOAUTHLIB] = "cryptoauthlib-provider," |
| 23 | PACKAGECONFIG[TS] = "trusted-service-provider,,libts,libts" |
| 24 | |
Patrick Williams | 53961c2 | 2022-01-20 11:06:23 -0600 | [diff] [blame] | 25 | PARSEC_FEATURES = "${@d.getVar('PACKAGECONFIG_CONFARGS',True).strip().replace(' ', ',')}" |
| 26 | CARGO_BUILD_FLAGS += " --features ${PARSEC_FEATURES}" |
Andrew Geissler | f1e4406 | 2021-04-15 15:52:46 -0500 | [diff] [blame] | 27 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame^] | 28 | export BINDGEN_EXTRA_CLANG_ARGS |
| 29 | target = "${@d.getVar('TARGET_SYS',True).replace('-', ' ')}" |
| 30 | BINDGEN_EXTRA_CLANG_ARGS = "${@bb.utils.contains('target', 'arm', \ |
| 31 | '--sysroot=${WORKDIR}/recipe-sysroot -I${WORKDIR}/recipe-sysroot/usr/include -mfloat-abi=hard', \ |
| 32 | '--sysroot=${WORKDIR}/recipe-sysroot -I${WORKDIR}/recipe-sysroot/usr/include', \ |
| 33 | d)}" |
| 34 | |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame] | 35 | inherit systemd |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 36 | SYSTEMD_SERVICE:${PN} = "parsec.service" |
Andrew Geissler | f1e4406 | 2021-04-15 15:52:46 -0500 | [diff] [blame] | 37 | |
| 38 | inherit update-rc.d |
| 39 | INITSCRIPT_NAME = "parsec" |
| 40 | |
| 41 | # A local file can be defined in build/local.conf |
| 42 | # The file should also be included into SRC_URI then |
| 43 | PARSEC_CONFIG ?= "${S}/config.toml" |
| 44 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame^] | 45 | do_install () { |
Andrew Geissler | f1e4406 | 2021-04-15 15:52:46 -0500 | [diff] [blame] | 46 | # Binaries |
| 47 | install -d -m 700 -o parsec -g parsec "${D}${libexecdir}/parsec" |
| 48 | install -m 700 -o parsec -g parsec "${WORKDIR}/build/target/${CARGO_TARGET_SUBDIR}/parsec" ${D}${libexecdir}/parsec/parsec |
| 49 | |
| 50 | # Config file |
| 51 | install -d -m 700 -o parsec -g parsec "${D}${sysconfdir}/parsec" |
| 52 | install -m 400 -o parsec -g parsec "${PARSEC_CONFIG}" ${D}${sysconfdir}/parsec/config.toml |
| 53 | |
Andrew Geissler | f1e4406 | 2021-04-15 15:52:46 -0500 | [diff] [blame] | 54 | if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then |
| 55 | install -d ${D}${systemd_unitdir}/system |
| 56 | install -m 644 ${S}/systemd-daemon/parsec.service ${D}${systemd_unitdir}/system |
| 57 | |
| 58 | install -d ${D}${libdir}/tmpfiles.d |
| 59 | install -m 644 ${WORKDIR}/parsec-tmpfiles.conf ${D}${libdir}/tmpfiles.d |
| 60 | fi |
| 61 | |
| 62 | if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then |
| 63 | install -d ${D}${sysconfdir}/init.d |
| 64 | install -m 755 ${WORKDIR}/parsec_init ${D}${sysconfdir}/init.d/parsec |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame^] | 65 | # Data dir |
| 66 | install -d -m 700 -o parsec -g parsec "${D}${localstatedir}/lib/parsec" |
Andrew Geissler | f1e4406 | 2021-04-15 15:52:46 -0500 | [diff] [blame] | 67 | fi |
| 68 | } |
| 69 | |
| 70 | inherit useradd |
| 71 | USERADD_PACKAGES = "${PN}" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 72 | USERADD_PARAM:${PN} = "-r -g parsec -s /bin/false -d ${localstatedir}/lib/parsec parsec" |
| 73 | GROUPADD_PARAM:${PN} = "-r parsec" |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame^] | 74 | GROUPMEMS_PARAM:${PN} = "${@bb.utils.contains('PACKAGECONFIG_CONFARGS', 'tpm-provider', '-a parsec -g tss', '', d)}" |
Andrew Geissler | f1e4406 | 2021-04-15 15:52:46 -0500 | [diff] [blame] | 75 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 76 | FILES:${PN} += " \ |
Andrew Geissler | f1e4406 | 2021-04-15 15:52:46 -0500 | [diff] [blame] | 77 | ${sysconfdir}/parsec/config.toml \ |
| 78 | ${libexecdir}/parsec/parsec \ |
| 79 | ${systemd_unitdir}/system/parsec.service \ |
Andrew Geissler | f1e4406 | 2021-04-15 15:52:46 -0500 | [diff] [blame] | 80 | ${libdir}/tmpfiles.d/parsec-tmpfiles.conf \ |
| 81 | ${sysconfdir}/init.d/parsec \ |
| 82 | " |
| 83 | |
| 84 | require parsec-service_${PV}.inc |