| # Copyright 2015 The ChromiumOS Authors |
| # Distributed under the terms of the GNU General Public License v2 |
| |
| EAPI="7" |
| |
| CROS_WORKON_COMMIT="8b6e11a069e490c761cdab7ab3ff59434806cd9c" |
| CROS_WORKON_TREE=("41d899585b7a07ea908a0cca2944a7b8a4d13655" "9dbbe059a64bdb3260dc088895573df5ea421399" "0d9d2046eb78dc8620f7594f245298f9fd964832" "faa5b8036561b66b5b9d79ea1af8a95927a0ae0f" "989acbd33fd18024396e010b1be43d25cbdf942d" "f73f25bb045d099841b3ac929b6d3218060216df" "f91b6afd5f2ae04ee9a2c19109a3a4a36f7659e6") |
| CROS_WORKON_INCREMENTAL_BUILD=1 |
| CROS_WORKON_LOCALNAME="platform2" |
| CROS_WORKON_PROJECT="chromiumos/platform2" |
| CROS_WORKON_OUTOFTREE_BUILD=1 |
| # TODO(crbug.com/809389): Avoid directly including headers from other packages. |
| CROS_WORKON_SUBTREE="common-mk libhwsec libhwsec-foundation metrics tpm_manager trunks .gn" |
| |
| PLATFORM_SUBDIR="tpm_manager" |
| |
| inherit cros-workon platform user |
| |
| DESCRIPTION="Daemon to manage TPM ownership." |
| HOMEPAGE="https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/tpm_manager/" |
| |
| LICENSE="BSD-Google" |
| KEYWORDS="*" |
| IUSE="cr50_onboard double_extend_pcr_issue pinweaver_csme profiling test ti50_onboard |
| tpm tpm_dynamic tpm_insecure_fallback tpm2 tpm2_simulator fuzzer os_install_service |
| " |
| |
| REQUIRED_USE=" |
| ?? ( cr50_onboard pinweaver_csme ) |
| tpm_dynamic? ( tpm tpm2 ) |
| !tpm_dynamic? ( ?? ( tpm tpm2 ) ) |
| " |
| |
| RDEPEND=" |
| tpm? ( app-crypt/trousers:= ) |
| tpm2? ( |
| chromeos-base/trunks:= |
| ) |
| tpm2_simulator? ( chromeos-base/tpm2-simulator:= ) |
| >=chromeos-base/metrics-0.0.1-r3152 |
| chromeos-base/minijail:= |
| chromeos-base/libhwsec:=[test?] |
| chromeos-base/libhwsec-foundation:= |
| chromeos-base/system_api:=[fuzzer?] |
| chromeos-base/tpm_manager-client:= |
| dev-libs/openssl:0= |
| " |
| |
| DEPEND="${RDEPEND} |
| tpm2? ( chromeos-base/trunks[test?] ) |
| fuzzer? ( dev-libs/libprotobuf-mutator ) |
| " |
| |
| BDEPEND=" |
| dev-libs/protobuf |
| chromeos-base/chromeos-dbus-bindings |
| chromeos-base/minijail |
| " |
| |
| pkg_preinst() { |
| enewuser tpm_manager |
| enewgroup tpm_manager |
| } |
| |
| src_install() { |
| # TODO: move installation & test configs from ebuild to GN |
| platform_src_install |
| |
| # Install D-Bus configuration file. |
| insinto /etc/dbus-1/system.d |
| doins server/org.chromium.TpmManager.conf |
| |
| # Install upstart config file. |
| insinto /etc/init |
| doins server/tpm_managerd.conf |
| if use tpm_dynamic; then |
| conds=("started no-tpm-checker") |
| if use tpm; then |
| conds+=("started tcsd") |
| fi |
| if use tpm2; then |
| conds+=("started trunksd") |
| fi |
| cond=$(printf " or %s" "${conds[@]}") |
| cond=${cond:4} |
| sed -i "s/started tcsd/(${cond})/" \ |
| "${D}/etc/init/tpm_managerd.conf" || |
| die "Can't replace 'started tcsd' with '${cond}' in tpm_managerd.conf" |
| elif use tpm2; then |
| dep_job="trunksd" |
| if use pinweaver_csme; then |
| dep_job="tpm_tunneld" |
| fi |
| sed -i "s/started tcsd/started ${dep_job}/" \ |
| "${D}/etc/init/tpm_managerd.conf" || |
| die "Can't replace tcsd with ${dep_job} in tpm_managerd.conf" |
| fi |
| |
| # Install the executables provided by TpmManager |
| dosbin "${OUT}"/tpm_managerd |
| dosbin "${OUT}"/local_data_migration |
| |
| # Install seccomp policy files. |
| insinto /usr/share/policy |
| newins "server/tpm_managerd-seccomp-${ARCH}.policy" tpm_managerd-seccomp.policy |
| |
| # Install fuzzer. |
| platform_fuzzer_install "${S}"/OWNERS "${OUT}"/tpm_manager_service_fuzzer |
| |
| # Allow specific syscalls for profiling. |
| # TODO (b/242806964): Need a better approach for fixing up the seccomp policy |
| # related issues (i.e. fix with a single function call) |
| if use profiling; then |
| echo -e "\n# Syscalls added for profiling case only.\nmkdir: 1\nftruncate: 1\n" >> \ |
| "${D}/usr/share/policy/tpm_managerd-seccomp.policy" |
| fi |
| } |
| |
| platform_pkg_test() { |
| local tests=( |
| tpm_manager_testrunner |
| ) |
| |
| local test_bin |
| for test_bin in "${tests[@]}"; do |
| platform_test "run" "${OUT}/${test_bin}" |
| done |
| } |