Patrick Williams | ac13d5f | 2023-11-24 18:59:46 -0600 | [diff] [blame] | 1 | SUMMARY = "Platform AbstRaction for SECurity Daemon" |
| 2 | HOMEPAGE = "https://github.com/parallaxsecond/parsec" |
| 3 | LICENSE = "Apache-2.0" |
| 4 | LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" |
| 5 | |
| 6 | inherit cargo pkgconfig cargo-update-recipe-crates |
| 7 | |
| 8 | DEPENDS += "clang-native" |
| 9 | |
| 10 | SRC_URI += "crate://crates.io/parsec-service/${PV} \ |
| 11 | file://parsec_init \ |
| 12 | file://systemd.patch \ |
| 13 | file://parsec-tmpfiles.conf \ |
| 14 | " |
| 15 | SRC_URI[parsec-service-1.3.0.sha256sum] = "6e171f6394f900e0356947fb7ee42f825fba7ad8cada44b520b4bec5f1c853c8" |
| 16 | |
| 17 | B = "${CARGO_VENDORING_DIRECTORY}/${BP}" |
| 18 | |
| 19 | PACKAGECONFIG ??= "PKCS11 MBED-CRYPTO" |
| 20 | have_TPM = "${@bb.utils.contains('DISTRO_FEATURES', 'tpm2', 'TPM', '', d)}" |
| 21 | PACKAGECONFIG:append = " ${@bb.utils.contains('BBFILE_COLLECTIONS', 'tpm-layer', '${have_TPM}', '', d)}" |
| 22 | |
| 23 | PACKAGECONFIG[ALL] = "all-providers cryptoki/generate-bindings tss-esapi/generate-bindings,,tpm2-tss libts,tpm2-tss libtss2-tcti-device libts" |
| 24 | PACKAGECONFIG[TPM] = "tpm-provider tss-esapi/generate-bindings,,tpm2-tss,tpm2-tss libtss2-tcti-device" |
| 25 | PACKAGECONFIG[PKCS11] = "pkcs11-provider cryptoki/generate-bindings," |
| 26 | PACKAGECONFIG[MBED-CRYPTO] = "mbed-crypto-provider," |
| 27 | PACKAGECONFIG[CRYPTOAUTHLIB] = "cryptoauthlib-provider," |
| 28 | PACKAGECONFIG[TS] = "trusted-service-provider,,libts,libts" |
| 29 | |
| 30 | PARSEC_FEATURES = "${@d.getVar('PACKAGECONFIG_CONFARGS',True).strip().replace(' ', ',')}" |
| 31 | CARGO_BUILD_FLAGS += " --features ${PARSEC_FEATURES}" |
| 32 | |
| 33 | export BINDGEN_EXTRA_CLANG_ARGS |
| 34 | target = "${@d.getVar('TARGET_SYS',True).replace('-', ' ')}" |
| 35 | BINDGEN_EXTRA_CLANG_ARGS = "${@bb.utils.contains('target', 'arm', \ |
| 36 | '--sysroot=${WORKDIR}/recipe-sysroot -I${WORKDIR}/recipe-sysroot/usr/include -mfloat-abi=hard', \ |
| 37 | '--sysroot=${WORKDIR}/recipe-sysroot -I${WORKDIR}/recipe-sysroot/usr/include', \ |
| 38 | d)}" |
| 39 | |
| 40 | inherit systemd |
| 41 | SYSTEMD_SERVICE:${PN} = "parsec.service" |
| 42 | |
| 43 | inherit update-rc.d |
| 44 | INITSCRIPT_NAME = "parsec" |
| 45 | |
| 46 | # A local file can be defined in build/local.conf |
| 47 | # The file should also be included into SRC_URI then |
| 48 | PARSEC_CONFIG ?= "${S}/config.toml" |
| 49 | |
| 50 | do_install () { |
| 51 | # Binaries |
| 52 | install -d -m 700 -o parsec -g parsec "${D}${libexecdir}/parsec" |
| 53 | install -m 700 -o parsec -g parsec "${B}/target/${CARGO_TARGET_SUBDIR}/parsec" ${D}${libexecdir}/parsec/parsec |
| 54 | |
| 55 | # Config file |
| 56 | install -d -m 700 -o parsec -g parsec "${D}${sysconfdir}/parsec" |
| 57 | install -m 400 -o parsec -g parsec "${PARSEC_CONFIG}" ${D}${sysconfdir}/parsec/config.toml |
| 58 | |
| 59 | if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then |
| 60 | install -d ${D}${systemd_unitdir}/system |
| 61 | install -m 644 ${S}/systemd-daemon/parsec.service ${D}${systemd_unitdir}/system |
| 62 | |
| 63 | install -d ${D}${libdir}/tmpfiles.d |
| 64 | install -m 644 ${WORKDIR}/parsec-tmpfiles.conf ${D}${libdir}/tmpfiles.d |
| 65 | fi |
| 66 | |
| 67 | if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then |
| 68 | install -d ${D}${sysconfdir}/init.d |
| 69 | install -m 755 ${WORKDIR}/parsec_init ${D}${sysconfdir}/init.d/parsec |
| 70 | # Data dir |
| 71 | install -d -m 700 -o parsec -g parsec "${D}${localstatedir}/lib/parsec" |
| 72 | fi |
| 73 | } |
| 74 | |
| 75 | inherit useradd |
| 76 | USERADD_PACKAGES = "${PN}" |
| 77 | GROUPADD_PARAM:${PN} = "-r parsec" |
| 78 | USERADD_PARAM:${PN} = "-r -g parsec -s /bin/false -d ${localstatedir}/lib/parsec parsec" |
| 79 | GROUPMEMS_PARAM:${PN} = "${@bb.utils.contains('PACKAGECONFIG_CONFARGS', 'tpm-provider', '-a parsec -g tss ;', '', d)}" |
| 80 | GROUPMEMS_PARAM:${PN} += "${@bb.utils.contains('PACKAGECONFIG_CONFARGS', 'trusted-service-provider', '-a parsec -g teeclnt', '', d)}" |
| 81 | |
| 82 | FILES:${PN} += " \ |
| 83 | ${sysconfdir}/parsec/config.toml \ |
| 84 | ${libexecdir}/parsec/parsec \ |
| 85 | ${systemd_unitdir}/system/parsec.service \ |
| 86 | ${libdir}/tmpfiles.d/parsec-tmpfiles.conf \ |
| 87 | ${sysconfdir}/init.d/parsec \ |
| 88 | " |
| 89 | |
| 90 | require parsec-service-crates.inc |
| 91 | |
| 92 | # The QA check has been temporarily disabled. An issue has been created |
| 93 | # upstream to fix this. |
| 94 | # https://github.com/parallaxsecond/parsec/issues/645 |
| 95 | INSANE_SKIP:${PN}-dbg += "buildpaths" |
| 96 | |