summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas K. Hüttel <dilfridge@gentoo.org>2024-12-13 14:05:10 +0100
committerAndreas K. Hüttel <dilfridge@gentoo.org>2024-12-13 14:05:10 +0100
commita62ed6da941bdc577d772dfba62ec46677e8f1fb (patch)
tree861c3de6dd07ef92c7ccee2837c1f7728bb5507a /app-emulation/cloud-init
parentwww-apps/moodle: Bumps to 4.3.9, 4.4.5, 4.5.1 (diff)
downloadgentoo-a62ed6da941bdc577d772dfba62ec46677e8f1fb.tar.gz
gentoo-a62ed6da941bdc577d772dfba62ec46677e8f1fb.tar.bz2
gentoo-a62ed6da941bdc577d772dfba62ec46677e8f1fb.zip
app-emulation/cloud-init: revbump to backport gentoo/systemd support
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
Diffstat (limited to 'app-emulation/cloud-init')
-rw-r--r--app-emulation/cloud-init/cloud-init-24.2-r1.ebuild105
-rw-r--r--app-emulation/cloud-init/files/cloud-init-24.2-systemd.patch152
2 files changed, 257 insertions, 0 deletions
diff --git a/app-emulation/cloud-init/cloud-init-24.2-r1.ebuild b/app-emulation/cloud-init/cloud-init-24.2-r1.ebuild
new file mode 100644
index 000000000000..8c137fe19521
--- /dev/null
+++ b/app-emulation/cloud-init/cloud-init-24.2-r1.ebuild
@@ -0,0 +1,105 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+# Disabled for now: bug #850628
+#DISTUTILS_USE_PEP517=setuptools
+# https://bugs.launchpad.net/cloud-init/+bug/1978328
+PYTHON_COMPAT=( python3_10 python3_11 python3_12 )
+
+inherit distutils-r1 udev
+
+if [[ ${PV} == *9999 ]]; then
+ inherit git-r3
+ EGIT_REPO_URI="https://git.launchpad.net/cloud-init"
+else
+ SRC_URI="https://launchpad.net/${PN}/trunk/${PV}/+download/${P}.tar.gz"
+ KEYWORDS="~amd64 ~arm64 ~loong ~ppc64 ~x86"
+fi
+
+DESCRIPTION="Cloud instance initialisation magic"
+HOMEPAGE="https://launchpad.net/cloud-init"
+
+LICENSE="GPL-3"
+SLOT="0"
+IUSE="selinux"
+
+CDEPEND="
+ dev-python/jinja2[${PYTHON_USEDEP}]
+ dev-python/oauthlib[${PYTHON_USEDEP}]
+ dev-python/pyserial[${PYTHON_USEDEP}]
+ >=dev-python/configobj-5.0.2[${PYTHON_USEDEP}]
+ dev-python/pyyaml[${PYTHON_USEDEP}]
+ dev-python/requests[${PYTHON_USEDEP}]
+ dev-python/jsonpatch[${PYTHON_USEDEP}]
+ dev-python/jsonschema[${PYTHON_USEDEP}]
+ dev-python/netifaces[${PYTHON_USEDEP}]
+"
+BDEPEND="
+ ${CDEPEND}
+ test? (
+ dev-python/mock[${PYTHON_USEDEP}]
+ dev-python/passlib[${PYTHON_USEDEP}]
+ dev-python/pytest-mock[${PYTHON_USEDEP}]
+ dev-python/responses[${PYTHON_USEDEP}]
+ dev-python/setuptools[${PYTHON_USEDEP}]
+ )
+"
+RDEPEND="
+ ${CDEPEND}
+ net-analyzer/macchanger
+ sys-apps/iproute2
+ sys-fs/growpart
+ virtual/logger
+ selinux? ( sec-policy/selinux-cloudinit )
+"
+
+EPYTEST_IGNORE=(
+ # Can't find file
+ tests/unittests/config/test_apt_configure_sources_list_v1.py
+ tests/unittests/config/test_apt_configure_sources_list_v3.py
+)
+
+PATCHES=(
+ "${FILESDIR}/${PN}-24.2-systemd.patch"
+)
+
+distutils_enable_tests pytest
+
+python_prepare_all() {
+ # Fix location of documentation installation
+ sed -i "s:USR + '/share/doc/cloud-init:USR + '/share/doc/${PF}:" setup.py || die
+
+ if [[ ${PV} == *9999 ]] ; then
+ sed -i 's/version=get_version(),/version=9999,/g' setup.py || die
+ fi
+
+ distutils-r1_python_prepare_all
+}
+
+python_install() {
+ distutils-r1_python_install --init-system=sysvinit_openrc,systemd --distro gentoo
+}
+
+python_install_all() {
+ keepdir /etc/cloud
+
+ distutils-r1_python_install_all
+
+ # installs as non-executable
+ chmod +x "${D}"/etc/init.d/* || die
+}
+
+pkg_prerm() {
+ udev_reload
+}
+
+pkg_postinst() {
+ udev_reload
+
+ elog "cloud-init-local needs to be run in the boot runlevel because it"
+ elog "modifies services in the default runlevel. When a runlevel is started"
+ elog "it is cached, so modifications that happen to the current runlevel"
+ elog "while you are in it are not acted upon."
+}
diff --git a/app-emulation/cloud-init/files/cloud-init-24.2-systemd.patch b/app-emulation/cloud-init/files/cloud-init-24.2-systemd.patch
new file mode 100644
index 000000000000..62840bafe2d3
--- /dev/null
+++ b/app-emulation/cloud-init/files/cloud-init-24.2-systemd.patch
@@ -0,0 +1,152 @@
+From 3f97be6df5c59339e09ff50e97a94869c29741d0 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Andreas=20K=2E=20H=C3=BCttel?= <dilfridge@gentoo.org>
+Date: Fri, 6 Dec 2024 22:46:31 +0100
+Subject: [PATCH] feat(gentoo): Add compatibility for Gentoo with systemd
+ (#5918)
+
+---
+ cloudinit/distros/gentoo.py | 37 +++++++++++++++++---------
+ tests/unittests/distros/test_gentoo.py | 34 ++++++++++++++++-------
+ 2 files changed, 48 insertions(+), 23 deletions(-)
+
+diff --git a/cloudinit/distros/gentoo.py b/cloudinit/distros/gentoo.py
+index 5ab41bbd9db..94fa6f7aa01 100644
+--- a/cloudinit/distros/gentoo.py
++++ b/cloudinit/distros/gentoo.py
+@@ -1,8 +1,10 @@
+ # Copyright (C) 2014 Rackspace, US Inc.
+ # Copyright (C) 2016 Matthew Thode.
++# Copyright (C) 2024 Andreas K. Huettel
+ #
+ # Author: Nate House <nathan.house@rackspace.com>
+ # Author: Matthew Thode <prometheanfire@gentoo.org>
++# Author: Andreas K. Huettel <dilfridge@gentoo.org>
+ #
+ # This file is part of cloud-init. See LICENSE file for license information.
+
+@@ -18,7 +20,6 @@
+
+ class Distro(distros.Distro):
+ locale_gen_fn = "/etc/locale.gen"
+- hostname_conf_fn = "/etc/conf.d/hostname"
+ default_locale = "en_US.UTF-8"
+
+ # C.UTF8 makes sense to generate, but is not selected
+@@ -27,20 +28,23 @@ class Distro(distros.Distro):
+
+ def __init__(self, name, cfg, paths):
+ distros.Distro.__init__(self, name, cfg, paths)
++
++ if distros.uses_systemd():
++ self.hostname_conf_fn = "/etc/hostname"
++ else:
++ self.hostname_conf_fn = "/etc/conf.d/hostname"
++
+ # This will be used to restrict certain
+ # calls from repeatedly happening (when they
+ # should only happen say once per instance...)
+ self._runner = helpers.Runners(paths)
+ self.osfamily = "gentoo"
+- # Fix sshd restarts
+- cfg["ssh_svcname"] = "/etc/init.d/sshd"
+- if distros.uses_systemd():
+- LOG.error("Cloud-init does not support systemd with gentoo")
++ if not distros.uses_systemd():
++ # Fix sshd restarts (openrc-specific?)
++ cfg["ssh_svcname"] = "/etc/init.d/sshd"
+
+ def apply_locale(self, _, out_fn=None):
+- """rc-only - not compatible with systemd
+-
+- Locales need to be added to /etc/locale.gen and generated prior
++ """Locales need to be added to /etc/locale.gen and generated prior
+ to selection. Default to en_US.UTF-8 for simplicity.
+ """
+ util.write_file(self.locale_gen_fn, "\n".join(self.locales), mode=644)
+@@ -48,7 +52,7 @@ def apply_locale(self, _, out_fn=None):
+ # generate locales
+ subp.subp(["locale-gen"], capture=False)
+
+- # select locale
++ # select locale, works for both openrc and systemd
+ subp.subp(
+ ["eselect", "locale", "set", self.default_locale], capture=False
+ )
+@@ -77,10 +81,17 @@ def _write_hostname(self, hostname, filename):
+ if not conf:
+ conf = HostnameConf("")
+
+- # Many distro's format is the hostname by itself, and that is the
+- # way HostnameConf works but gentoo expects it to be in
+- # hostname="the-actual-hostname"
+- conf.set_hostname('hostname="%s"' % hostname)
++ if distros.uses_systemd():
++ # Gentoo uses the same format for /etc/hostname as everyone else-
++ # only the hostname by itself. Works for openrc and systemd, but
++ # openrc has its own config file and /etc/hostname is generated.
++ conf.set_hostname(hostname)
++ else:
++ # Openrc generates /etc/hostname from /etc/conf.d/hostname with the
++ # differing format
++ # hostname="the-actual-hostname"
++ conf.set_hostname('hostname="%s"' % hostname)
++
+ util.write_file(filename, str(conf), 0o644)
+
+ def _read_system_hostname(self):
+diff --git a/tests/unittests/distros/test_gentoo.py b/tests/unittests/distros/test_gentoo.py
+index a307b9a29ba..979e6d82638 100644
+--- a/tests/unittests/distros/test_gentoo.py
++++ b/tests/unittests/distros/test_gentoo.py
+@@ -2,27 +2,41 @@
+
+ from cloudinit import atomic_helper, util
+ from tests.unittests.distros import _get_distro
+-from tests.unittests.helpers import CiTestCase
++from tests.unittests.helpers import CiTestCase, mock
+
+
+ class TestGentoo(CiTestCase):
+- def test_write_hostname(self):
++ def test_write_hostname(self, whatever=False):
+ distro = _get_distro("gentoo")
+ hostname = "myhostname"
+ hostfile = self.tmp_path("hostfile")
+ distro._write_hostname(hostname, hostfile)
+- self.assertEqual(
+- 'hostname="myhostname"\n', util.load_text_file(hostfile)
+- )
++ if distro.uses_systemd():
++ self.assertEqual("myhostname\n", util.load_text_file(hostfile))
++ else:
++ self.assertEqual(
++ 'hostname="myhostname"\n', util.load_text_file(hostfile)
++ )
+
+- def test_write_existing_hostname_with_comments(self):
++ def test_write_existing_hostname_with_comments(self, whatever=False):
+ distro = _get_distro("gentoo")
+ hostname = "myhostname"
+ contents = '#This is the hostname\nhostname="localhost"'
+ hostfile = self.tmp_path("hostfile")
+ atomic_helper.write_file(hostfile, contents, omode="w")
+ distro._write_hostname(hostname, hostfile)
+- self.assertEqual(
+- '#This is the hostname\nhostname="myhostname"\n',
+- util.load_text_file(hostfile),
+- )
++ if distro.uses_systemd():
++ self.assertEqual(
++ "#This is the hostname\nmyhostname\n",
++ util.load_text_file(hostfile),
++ )
++ else:
++ self.assertEqual(
++ '#This is the hostname\nhostname="myhostname"\n',
++ util.load_text_file(hostfile),
++ )
++
++
++@mock.patch("cloudinit.distros.uses_systemd", return_value=False)
++class TestGentooOpenRC(TestGentoo):
++ pass