| # Copyright 2019 The Chromium OS Authors. All rights reserved. |
| # Distributed under the terms of the GNU General Public License v2 |
| |
| EAPI=6 |
| |
| CROS_WORKON_INCREMENTAL_BUILD="1" |
| CROS_WORKON_LOCALNAME="platform2" |
| CROS_WORKON_PROJECT="chromiumos/platform2" |
| CROS_WORKON_OUTOFTREE_BUILD=1 |
| CROS_WORKON_SUBTREE="common-mk arc/keymaster .gn" |
| |
| PLATFORM_NATIVE_TEST="yes" |
| PLATFORM_SUBDIR="arc/keymaster" |
| |
| # This BoringSSL integration follows go/boringssl-cros. |
| # DO NOT COPY TO OTHER PACKAGES WITHOUT CONSULTING SECURITY TEAM. |
| BORINGSSL_PN="boringssl" |
| BORINGSSL_PV="3359" |
| BORINGSSL_P="${BORINGSSL_PN}-${BORINGSSL_PV}" |
| BORINGSSL_OUTDIR="${WORKDIR}/boringssl_outputs/" |
| |
| CMAKE_USE_DIR="${WORKDIR}/${BORINGSSL_P}" |
| BUILD_DIR="${WORKDIR}/${BORINGSSL_P}_build" |
| |
| inherit flag-o-matic cmake-utils multilib cros-workon platform user |
| |
| DESCRIPTION="Android keymaster service in Chrome OS." |
| HOMEPAGE="https://chromium.googlesource.com/chromiumos/platform2/+/master/arc/keymaster" |
| SRC_URI="https://github.com/google/${BORINGSSL_PN}/archive/${BORINGSSL_PV}.tar.gz -> ${BORINGSSL_P}.tar.gz" |
| |
| LICENSE="BSD-Google" |
| SLOT="0" |
| KEYWORDS="~*" |
| IUSE="+seccomp" |
| |
| RDEPEND=" |
| chromeos-base/libbrillo:= |
| chromeos-base/minijail" |
| |
| DEPEND="${RDEPEND}" |
| |
| HEADER_TAINT="#ifdef CHROMEOS_OPENSSL_IS_OPENSSL |
| #error \"Do not mix OpenSSL and BoringSSL headers.\" |
| #endif |
| #define CHROMEOS_OPENSSL_IS_BORINGSSL\n" |
| |
| src_unpack() { |
| platform_src_unpack |
| unpack "${BORINGSSL_P}.tar.gz" |
| # Taint BoringSSL headers so they don't silently mix with OpenSSL. |
| find "${BORINGSSL_P}/include/openssl" -type f -exec awk -i inplace -v \ |
| "taint=${HEADER_TAINT}" 'NR == 1 {print taint} {print}' {} \; |
| } |
| |
| src_prepare() { |
| cmake-utils_src_prepare |
| # Expose BoringSSL headers and outputs. |
| append-cxxflags "-I${WORKDIR}/${BORINGSSL_P}/include" |
| append-ldflags "-L${BORINGSSL_OUTDIR}" |
| } |
| |
| src_configure() { |
| local mycmakeargs=( |
| -DCMAKE_BUILD_TYPE=Release |
| ) |
| cmake-utils_src_configure |
| platform_src_configure |
| } |
| |
| src_compile() { |
| # Compile BoringSSL and expose libcrypto.a. |
| cmake-utils_src_compile |
| mkdir -p "${BORINGSSL_OUTDIR}" || die |
| cp -p "${BUILD_DIR}/crypto/libcrypto.a" "${BORINGSSL_OUTDIR}/libboringcrypto.a" || die |
| |
| platform_src_compile |
| } |
| |
| src_install() { |
| insinto /etc/init |
| doins init/arc-keymasterd.conf |
| |
| # Install DBUS configuration file. |
| insinto /etc/dbus-1/system.d |
| doins dbus_permissions/org.chromium.ArcKeymaster.conf |
| |
| # Install seccomp policy file. |
| insinto /usr/share/policy |
| use seccomp && newins \ |
| "seccomp/arc-keymasterd-seccomp-${ARCH}.policy" \ |
| arc-keymasterd-seccomp.policy |
| |
| dosbin "${OUT}/arc-keymasterd" |
| } |
| |
| pkg_preinst() { |
| enewuser "arc-keymasterd" |
| enewgroup "arc-keymasterd" |
| } |
| |
| platform_pkg_test() { |
| platform_test "run" "${OUT}/arc-keymasterd_testrunner" |
| } |