blob: d1d6c07ad010bdb2f6b6753da90f850d324f13ac [file] [log] [blame]
Andrew Geisslerf1e44062021-04-15 15:52:46 -05001SUMMARY = "Platform AbstRaction for SECurity Daemon"
2HOMEPAGE = "https://github.com/parallaxsecond/parsec"
3LICENSE = "Apache-2.0"
4
Patrick Williams03907ee2022-05-01 06:28:52 -05005inherit cargo pkgconfig
6DEPENDS = "clang-native"
Andrew Geisslerf1e44062021-04-15 15:52:46 -05007
8SRC_URI += "crate://crates.io/parsec-service/${PV} \
9 file://parsec_init \
10 file://systemd.patch \
11 file://parsec-tmpfiles.conf \
12"
13
Patrick Williams03907ee2022-05-01 06:28:52 -050014PACKAGECONFIG ??= "PKCS11 MBED-CRYPTO"
Andrew Geissler9aee5002022-03-30 16:27:02 +000015have_TPM = "${@bb.utils.contains('DISTRO_FEATURES', 'tpm2', 'TPM', '', d)}"
16PACKAGECONFIG:append = " ${@bb.utils.contains('BBFILE_COLLECTIONS', 'tpm-layer', '${have_TPM}', '', d)}"
17
Patrick Williams53961c22022-01-20 11:06:23 -060018PACKAGECONFIG[ALL] = "all-providers cryptoki/generate-bindings tss-esapi/generate-bindings,,tpm2-tss libts,libts"
19PACKAGECONFIG[TPM] = "tpm-provider tss-esapi/generate-bindings,,tpm2-tss"
20PACKAGECONFIG[PKCS11] = "pkcs11-provider cryptoki/generate-bindings,"
Patrick Williams93c203f2021-10-06 16:15:23 -050021PACKAGECONFIG[MBED-CRYPTO] = "mbed-crypto-provider,"
22PACKAGECONFIG[CRYPTOAUTHLIB] = "cryptoauthlib-provider,"
23PACKAGECONFIG[TS] = "trusted-service-provider,,libts,libts"
24
Patrick Williams53961c22022-01-20 11:06:23 -060025PARSEC_FEATURES = "${@d.getVar('PACKAGECONFIG_CONFARGS',True).strip().replace(' ', ',')}"
26CARGO_BUILD_FLAGS += " --features ${PARSEC_FEATURES}"
Andrew Geisslerf1e44062021-04-15 15:52:46 -050027
Patrick Williams03907ee2022-05-01 06:28:52 -050028inherit systemd
Patrick Williams213cb262021-08-07 19:21:33 -050029SYSTEMD_SERVICE:${PN} = "parsec.service"
Andrew Geisslerf1e44062021-04-15 15:52:46 -050030
31inherit update-rc.d
32INITSCRIPT_NAME = "parsec"
33
34# A local file can be defined in build/local.conf
35# The file should also be included into SRC_URI then
36PARSEC_CONFIG ?= "${S}/config.toml"
37
Patrick Williams213cb262021-08-07 19:21:33 -050038do_install:append () {
Andrew Geisslerf1e44062021-04-15 15:52:46 -050039 # Binaries
40 install -d -m 700 -o parsec -g parsec "${D}${libexecdir}/parsec"
41 install -m 700 -o parsec -g parsec "${WORKDIR}/build/target/${CARGO_TARGET_SUBDIR}/parsec" ${D}${libexecdir}/parsec/parsec
42
43 # Config file
44 install -d -m 700 -o parsec -g parsec "${D}${sysconfdir}/parsec"
45 install -m 400 -o parsec -g parsec "${PARSEC_CONFIG}" ${D}${sysconfdir}/parsec/config.toml
46
47 # Data dir
48 install -d -m 700 -o parsec -g parsec "${D}${localstatedir}/lib/parsec"
49
50 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
51 install -d ${D}${systemd_unitdir}/system
52 install -m 644 ${S}/systemd-daemon/parsec.service ${D}${systemd_unitdir}/system
53
54 install -d ${D}${libdir}/tmpfiles.d
55 install -m 644 ${WORKDIR}/parsec-tmpfiles.conf ${D}${libdir}/tmpfiles.d
56 fi
57
58 if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
59 install -d ${D}${sysconfdir}/init.d
60 install -m 755 ${WORKDIR}/parsec_init ${D}${sysconfdir}/init.d/parsec
61 fi
62}
63
64inherit useradd
65USERADD_PACKAGES = "${PN}"
Patrick Williams213cb262021-08-07 19:21:33 -050066USERADD_PARAM:${PN} = "-r -g parsec -s /bin/false -d ${localstatedir}/lib/parsec parsec"
67GROUPADD_PARAM:${PN} = "-r parsec"
Andrew Geisslerf1e44062021-04-15 15:52:46 -050068
Patrick Williams213cb262021-08-07 19:21:33 -050069FILES:${PN} += " \
Andrew Geisslerf1e44062021-04-15 15:52:46 -050070 ${sysconfdir}/parsec/config.toml \
71 ${libexecdir}/parsec/parsec \
72 ${systemd_unitdir}/system/parsec.service \
Patrick Williams03907ee2022-05-01 06:28:52 -050073 ${localstatedir}/lib/parsec \
Andrew Geisslerf1e44062021-04-15 15:52:46 -050074 ${libdir}/tmpfiles.d/parsec-tmpfiles.conf \
75 ${sysconfdir}/init.d/parsec \
76"
77
78require parsec-service_${PV}.inc