blob: 477988e97a848cb28d4b028c65a5ef5931a2aaa4 [file] [log] [blame]
Patrick Williamsac13d5f2023-11-24 18:59:46 -06001SUMMARY = "Platform AbstRaction for SECurity Daemon"
2HOMEPAGE = "https://github.com/parallaxsecond/parsec"
3LICENSE = "Apache-2.0"
4LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
5
6inherit cargo pkgconfig cargo-update-recipe-crates
7
8DEPENDS += "clang-native"
9
10SRC_URI += "crate://crates.io/parsec-service/${PV} \
11 file://parsec_init \
12 file://systemd.patch \
13 file://parsec-tmpfiles.conf \
14"
15SRC_URI[parsec-service-1.3.0.sha256sum] = "6e171f6394f900e0356947fb7ee42f825fba7ad8cada44b520b4bec5f1c853c8"
16
17B = "${CARGO_VENDORING_DIRECTORY}/${BP}"
18
19PACKAGECONFIG ??= "PKCS11 MBED-CRYPTO"
20have_TPM = "${@bb.utils.contains('DISTRO_FEATURES', 'tpm2', 'TPM', '', d)}"
21PACKAGECONFIG:append = " ${@bb.utils.contains('BBFILE_COLLECTIONS', 'tpm-layer', '${have_TPM}', '', d)}"
22
23PACKAGECONFIG[ALL] = "all-providers cryptoki/generate-bindings tss-esapi/generate-bindings,,tpm2-tss libts,tpm2-tss libtss2-tcti-device libts"
24PACKAGECONFIG[TPM] = "tpm-provider tss-esapi/generate-bindings,,tpm2-tss,tpm2-tss libtss2-tcti-device"
25PACKAGECONFIG[PKCS11] = "pkcs11-provider cryptoki/generate-bindings,"
26PACKAGECONFIG[MBED-CRYPTO] = "mbed-crypto-provider,"
27PACKAGECONFIG[CRYPTOAUTHLIB] = "cryptoauthlib-provider,"
28PACKAGECONFIG[TS] = "trusted-service-provider,,libts,libts"
29
30PARSEC_FEATURES = "${@d.getVar('PACKAGECONFIG_CONFARGS',True).strip().replace(' ', ',')}"
31CARGO_BUILD_FLAGS += " --features ${PARSEC_FEATURES}"
32
33export BINDGEN_EXTRA_CLANG_ARGS
34target = "${@d.getVar('TARGET_SYS',True).replace('-', ' ')}"
35BINDGEN_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
40inherit systemd
41SYSTEMD_SERVICE:${PN} = "parsec.service"
42
43inherit update-rc.d
44INITSCRIPT_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
48PARSEC_CONFIG ?= "${S}/config.toml"
49
50do_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
75inherit useradd
76USERADD_PACKAGES = "${PN}"
77GROUPADD_PARAM:${PN} = "-r parsec"
78USERADD_PARAM:${PN} = "-r -g parsec -s /bin/false -d ${localstatedir}/lib/parsec parsec"
79GROUPMEMS_PARAM:${PN} = "${@bb.utils.contains('PACKAGECONFIG_CONFARGS', 'tpm-provider', '-a parsec -g tss ;', '', d)}"
80GROUPMEMS_PARAM:${PN} += "${@bb.utils.contains('PACKAGECONFIG_CONFARGS', 'trusted-service-provider', '-a parsec -g teeclnt', '', d)}"
81
82FILES:${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
90require 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
95INSANE_SKIP:${PN}-dbg += "buildpaths"
96