summaryrefslogtreecommitdiff
blob: 43adf5afac799432bd098e506e39bffcb307aa11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Copyright 2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

PYTHON_COMPAT=( python3_{9..11} pypy3 )
DISTUTILS_USE_SETUPTOOLS=rdepend

inherit distutils-r1 systemd

MY_PN="github.com/GoogleCloudPlatform/compute-image-packages"
MY_P="${P}"

if [[ "${PV}" == "9999" ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://${MY_PN}"
	EGIT_SUBMODULES=()
else
	EGIT_COMMIT="v${PV}"
	MY_P="compute-image-packages-tags-${EGIT_COMMIT}"
	SRC_URI="https://${MY_PN}/archive/tags/${EGIT_COMMIT}.tar.gz -> ${P}.tar.gz
		https://${MY_PN}/raw/20190124/google_compute_engine_init/sysvinit/google-accounts-daemon -> google-accounts-daemon.${EGIT_COMMIT}
		https://${MY_PN}/raw/20190124/google_compute_engine_init/systemd/google-accounts-daemon.service -> google-accounts-daemon.service.${EGIT_COMMIT}
		https://${MY_PN}/raw/20190124/google_compute_engine_init/sysvinit/google-clock-skew-daemon -> google-clock-skew-daemon.${EGIT_COMMIT}
		https://${MY_PN}/raw/20190124/google_compute_engine_init/systemd/google-clock-skew-daemon.service -> google-clock-skew-daemon.service.${EGIT_COMMIT}
		https://${MY_PN}/raw/20190124/google_compute_engine_init/sysvinit/google-instance-setup -> google-instance-setup.${EGIT_COMMIT}
		https://${MY_PN}/raw/20190124/google_compute_engine_init/systemd/google-instance-setup.service -> google-instance-setup.service.${EGIT_COMMIT}
		https://${MY_PN}/raw/20190124/google_compute_engine_init/sysvinit/google-network-daemon -> google-network-daemon.${EGIT_COMMIT}
		https://${MY_PN}/raw/20190124/google_compute_engine_init/systemd/google-network-daemon.service -> google-network-daemon.service.${EGIT_COMMIT}
		https://${MY_PN}/raw/20190124/google_compute_engine_init/sysvinit/google-shutdown-scripts -> google-shutdown-scripts.${EGIT_COMMIT}
		https://${MY_PN}/raw/20190124/google_compute_engine_init/systemd/google-shutdown-scripts.service -> google-shutdown-scripts.service.${EGIT_COMMIT}
		https://${MY_PN}/raw/20190124/google_compute_engine_init/sysvinit/google-startup-scripts -> google-startup-scripts.${EGIT_COMMIT}
		https://${MY_PN}/raw/20190124/google_compute_engine_init/systemd/google-startup-scripts.service -> google-startup-scripts.service.${EGIT_COMMIT}"
fi

DESCRIPTION="Scripts and tools for Google Compute Engine Linux images."
HOMEPAGE="https://github.com/GoogleCloudPlatform/compute-image-packages"

LICENSE="Apache-2.0"
SLOT="0/${PVR}"
KEYWORDS="~amd64 ~x86"
IUSE="test"
REQUIRED_USE="${PYTHON_REQUIRED_USE}"
RESTRICT="mirror"

distutils_enable_tests pytest

DEPEND="dev-python/setuptools[${PYTHON_USEDEP}]"
RDEPEND="${DEPEND}
	dev-python/distro[${PYTHON_USEDEP}]"
BDEPEND="${RDEPEND}"

S="${WORKDIR}/${MY_P}/packages/python-google-compute-engine"

INIT=(
	"google-accounts-daemon"
	"google-clock-skew-daemon"
	"google-instance-setup"
	"google-network-daemon"
	"google-shutdown-scripts"
	"google-startup-scripts")

python_install_all() {
	for _s in "${INIT[@]}"
	do
		newinitd "${DISTDIR}/${_s}.${EGIT_COMMIT}" "${_s}"
		systemd_newunit "${DISTDIR}/${_s}.service.${EGIT_COMMIT}" "${_s}.service"
	done

	# Install google-compute-engine python modules.
	distutils-r1_python_install_all
}

pkg_postinst() {
	ewarn
	ewarn "Systems using systemd can do the following:"
	ewarn "    # Stop existing daemons."
	ewarn "    systemctl stop --no-block google-accounts-daemon"
	ewarn "    systemctl stop --no-block google-clock-skew-daemon"
	ewarn "    systemctl stop --no-block google-network-daemon"
	ewarn
	ewarn "    # Enable systemd services."
	ewarn "    systemctl enable google-accounts-daemon.service"
	ewarn "    systemctl enable google-clock-skew-daemon.service"
	ewarn "    systemctl enable google-instance-setup.service"
	ewarn "    systemctl enable google-network-daemon.service"
	ewarn "    systemctl enable google-shutdown-scripts.service"
	ewarn "    systemctl enable google-startup-scripts.service"
	ewarn
	ewarn "    # Run instance setup manually to prevent startup script execution."
	ewarn "    /usr/bin/google_instance_setup"
	ewarn
	ewarn "    # Start daemons."
	ewarn "    systemctl start --no-block google-network-daemon"
	ewarn "    systemctl start --no-block google-accounts-daemon"
	ewarn "    systemctl start --no-block google-clock-skew-daemon"
	ewarn
}