blob: 61cd6c0fb43358327414dd4f6c41c303fb13b408 [file] [log] [blame]
#
# Copyright 2021 Google LLC
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
EAPI=7
inherit cros-constants
CROS_WORKON_REPO="https://cos.googlesource.com"
CROS_WORKON_PROJECT="cos/policymanager"
CROS_WORKON_LOCALNAME="policymanager"
CROS_WORKON_DESTDIR="${S}/src/policy-manager"
inherit cros-workon cros-go systemd
DESCRIPTION="Policy Manager Client for managing Lakitu updates"
LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="~*"
IUSE="stackdriver_alpha"
RDEPEND="chromeos-base/update_engine
!chromeos-base/chromeos-login"
DEPEND="${RDEPEND}
dev-go/gcp-compute
dev-go/glog
dev-go/mock
dev-go/net
dev-go/oauth2
dev-go/protobuf"
src_compile() {
ebegin "Building Policy Manager ${CROS_WORKON_COMMIT}"
# Compile protobuf definitions.
pushd "${CROS_WORKON_DESTDIR}" || die
./gen_proto.sh
popd || die
cros_go build -v -o device_policy_manager "policy-manager" || die
# Compile install_attributes proto for "enterprise enrollment"
protoc -I "${FILESDIR}" \
--encode=cryptohome.SerializedInstallAttributes \
"${FILESDIR}/install_attributes.proto" \
< "${FILESDIR}/install_attributes.textproto" \
> install_attributes.pb
eend ${?}
}
# Unit tests for Policy Manager.
# The tests are run as part of the build process.
src_test() {
ebegin "Running Policy Manager unit tests"
cros_go test -v policy-manager/...
if [ $? -ne 0 ]
then
die "Policy Manager unit tests failed :("
fi
eend ${?}
}
src_install() {
ebegin "Installing Policy Manager"
dosbin device_policy_manager
systemd_dounit "${FILESDIR}"/device_policy_manager.service
systemd_enable_service multi-user.target device_policy_manager.service
systemd_dounit "${FILESDIR}"/setup-install-attributes.service
systemd_enable_service sysinit.target setup-install-attributes.service
insinto /usr/share/cloud
doins install_attributes.pb
eend ${?}
}