app-emulation/cloud-init: update gentoo fixes
authorGilles Dartiguelongue <eva@gentoo.org>
Tue, 20 Nov 2018 11:12:16 +0000 (12:12 +0100)
committerGilles Dartiguelongue <eva@gentoo.org>
Tue, 20 Nov 2018 11:13:15 +0000 (12:13 +0100)
Package-Manager: Portage-2.3.51, Repoman-2.3.12
Signed-off-by: Gilles Dartiguelongue <eva@gentoo.org>
app-emulation/cloud-init/cloud-init-18.4-r1.ebuild [new file with mode: 0644]
app-emulation/cloud-init/cloud-init-9999.ebuild
app-emulation/cloud-init/files/18.4-add-support-for-package_upgrade.patch [new file with mode: 0644]
app-emulation/cloud-init/files/18.4-fix-filename-for-storing-locale.patch [new file with mode: 0644]
app-emulation/cloud-init/files/18.4-fix-update_package_sources-function.patch [new file with mode: 0644]
app-emulation/cloud-init/files/cloud-init-18.4-gentoo-support-upstream-templates.patch

diff --git a/app-emulation/cloud-init/cloud-init-18.4-r1.ebuild b/app-emulation/cloud-init/cloud-init-18.4-r1.ebuild
new file mode 100644 (file)
index 0000000..34fd8b7
--- /dev/null
@@ -0,0 +1,88 @@
+# Copyright 1999-2018 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+PYTHON_COMPAT=( python2_7 python3_4 python3_5 python3_6 )
+
+inherit distutils-r1
+
+DESCRIPTION="Cloud instance initialisation magic"
+HOMEPAGE="https://launchpad.net/cloud-init"
+SRC_URI="https://launchpad.net/${PN}/trunk/${PV}/+download/${P}.tar.gz"
+
+LICENSE="GPL-3"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE="test"
+
+CDEPEND="
+       dev-python/jinja[${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/six[${PYTHON_USEDEP}]
+"
+DEPEND="
+       dev-python/setuptools[${PYTHON_USEDEP}]
+       test? (
+               ${CDEPEND}
+               >=dev-python/httpretty-0.7.1[${PYTHON_USEDEP}]
+               dev-python/mock[${PYTHON_USEDEP}]
+               dev-python/nose[${PYTHON_USEDEP}]
+               dev-python/unittest2[${PYTHON_USEDEP}]
+               dev-python/coverage[${PYTHON_USEDEP}]
+               dev-python/contextlib2[${PYTHON_USEDEP}]
+       )
+"
+RDEPEND="
+       ${CDEPEND}
+       net-analyzer/macchanger
+       sys-apps/iproute2
+       sys-fs/growpart
+       virtual/logger
+"
+
+PATCHES=(
+       # Fix Gentoo support
+       # https://code.launchpad.net/~gilles-dartiguelongue/cloud-init/+git/cloud-init/+merge/358777
+       "${FILESDIR}"/${P}-fix-packages-module.patch
+       "${FILESDIR}"/${P}-gentoo-support-upstream-templates.patch
+       "${FILESDIR}"/${PV}-fix-filename-for-storing-locale.patch
+       "${FILESDIR}"/${PV}-fix-update_package_sources-function.patch
+       "${FILESDIR}"/${PV}-add-support-for-package_upgrade.patch
+)
+
+src_prepare() {
+       # Fix location of documentation installation
+       sed -i "s:USR + '/share/doc/cloud-init:USR + '/share/doc/${PF}:" setup.py || die
+       distutils-r1_src_prepare
+}
+
+python_test() {
+       # Do not use Makefile target as it does not setup environment correclty
+       esetup.py nosetests -v --where cloudinit --where tests/unittests || die
+}
+
+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/*
+}
+
+pkg_postinst() {
+       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."
+}
index 0b0b7bcaac951659a0a63a547b4d5f1fecaf5e1f..141eb23c883acde7eba04d49f45d4c6f4c1cbfd5 100644 (file)
@@ -47,8 +47,13 @@ RDEPEND="
 "
 
 PATCHES=(
+       # Fix Gentoo support
+       # https://code.launchpad.net/~gilles-dartiguelongue/cloud-init/+git/cloud-init/+merge/358777
        "${FILESDIR}"/${PN}-18.4-fix-packages-module.patch
        "${FILESDIR}"/${PN}-18.4-gentoo-support-upstream-templates.patch
+       "${FILESDIR}"/18.4-fix-filename-for-storing-locale.patch
+       "${FILESDIR}"/18.4-fix-update_package_sources-function.patch
+       "${FILESDIR}"/18.4-add-support-for-package_upgrade.patch
 )
 
 python_prepare_all() {
diff --git a/app-emulation/cloud-init/files/18.4-add-support-for-package_upgrade.patch b/app-emulation/cloud-init/files/18.4-add-support-for-package_upgrade.patch
new file mode 100644 (file)
index 0000000..9c542cf
--- /dev/null
@@ -0,0 +1,54 @@
+From 7868b97507d0dd7d7721ad5c4539e22c67635f92 Mon Sep 17 00:00:00 2001
+From: Gilles Dartiguelongue <eva@gentoo.org>
+Date: Wed, 14 Nov 2018 15:58:30 +0100
+Subject: [PATCH 5/5] gentoo: add support for package_upgrade
+
+---
+ cloudinit/distros/gentoo.py | 25 ++++++++++++++-----------
+ 1 file changed, 14 insertions(+), 11 deletions(-)
+
+diff --git a/cloudinit/distros/gentoo.py b/cloudinit/distros/gentoo.py
+index 7b838e82..22ad2cf3 100644
+--- a/cloudinit/distros/gentoo.py
++++ b/cloudinit/distros/gentoo.py
+@@ -189,23 +189,26 @@ class Distro(distros.Distro):
+         distros.set_etc_timezone(tz=tz, tz_file=self._find_tz_file(tz))
+     def package_command(self, command, args=None, pkgs=None):
+-        if pkgs is None:
+-            pkgs = []
+-
+         cmd = ['emerge']
+         # Redirect output
+         cmd.append("--quiet")
+-        if args and isinstance(args, str):
+-            cmd.append(args)
+-        elif args and isinstance(args, list):
+-            cmd.extend(args)
++        if command == "upgrade":
++            cmd.extend(["--update", "world"])
++        else:
++            if pkgs is None:
++                pkgs = []
++
++            if args and isinstance(args, str):
++                cmd.append(args)
++            elif args and isinstance(args, list):
++                cmd.extend(args)
+-        if command:
+-            cmd.append(command)
++            if command:
++                cmd.append(command)
+-        pkglist = util.expand_package_list('%s-%s', pkgs)
+-        cmd.extend(pkglist)
++            pkglist = util.expand_package_list('%s-%s', pkgs)
++            cmd.extend(pkglist)
+         # Allow the output of this to flow outwards (ie not be captured)
+         util.subp(cmd, capture=False)
+-- 
+2.19.1
+
diff --git a/app-emulation/cloud-init/files/18.4-fix-filename-for-storing-locale.patch b/app-emulation/cloud-init/files/18.4-fix-filename-for-storing-locale.patch
new file mode 100644 (file)
index 0000000..a5bbf60
--- /dev/null
@@ -0,0 +1,30 @@
+From 3756cdea3e844b9611de321a8075df80e7dbf74d Mon Sep 17 00:00:00 2001
+From: Gilles Dartiguelongue <eva@gentoo.org>
+Date: Wed, 14 Nov 2018 15:28:22 +0100
+Subject: [PATCH 3/5] gentoo: fix filename for storing locale
+
+There must have been a misunderstanding as locale.gen is meant to
+contain locales to be generated if no argument is passed to locale-gen.
+
+When using openrc, Gentoo stores system locale in /etc/env.d/02locale
+which is generally manipulated through eselect.
+---
+ cloudinit/distros/gentoo.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/cloudinit/distros/gentoo.py b/cloudinit/distros/gentoo.py
+index 98ac41ca..50bb61fb 100644
+--- a/cloudinit/distros/gentoo.py
++++ b/cloudinit/distros/gentoo.py
+@@ -20,7 +20,7 @@ LOG = logging.getLogger(__name__)
+ class Distro(distros.Distro):
+-    locale_conf_fn = '/etc/locale.gen'
++    locale_conf_fn = '/etc/env.d/02locale'
+     network_conf_fn = '/etc/conf.d/net'
+     resolve_conf_fn = '/etc/resolv.conf'
+     hostname_conf_fn = '/etc/conf.d/hostname'
+-- 
+2.19.1
+
diff --git a/app-emulation/cloud-init/files/18.4-fix-update_package_sources-function.patch b/app-emulation/cloud-init/files/18.4-fix-update_package_sources-function.patch
new file mode 100644 (file)
index 0000000..d90258d
--- /dev/null
@@ -0,0 +1,26 @@
+From b15c4c4b24c894b3c8d444466110c881c35525e2 Mon Sep 17 00:00:00 2001
+From: Gilles Dartiguelongue <eva@gentoo.org>
+Date: Wed, 14 Nov 2018 15:35:37 +0100
+Subject: [PATCH 4/5] gentoo: fix update_package_sources function
+
+Method is meant to update packages repository, not to update the system.
+---
+ cloudinit/distros/gentoo.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/cloudinit/distros/gentoo.py b/cloudinit/distros/gentoo.py
+index 50bb61fb..7b838e82 100644
+--- a/cloudinit/distros/gentoo.py
++++ b/cloudinit/distros/gentoo.py
+@@ -212,7 +212,7 @@ class Distro(distros.Distro):
+     def update_package_sources(self):
+         self._runner.run("update-sources", self.package_command,
+-                         ["-u", "world"], freq=PER_INSTANCE)
++                         ["--sync"], freq=PER_INSTANCE)
+ def convert_resolv_conf(settings):
+-- 
+2.19.1
+
index 60d9da600557b572bec8bab1df4ea4b7d605453f..6f87399af94bc50c884a179a527f4384de6730ed 100644 (file)
@@ -1,7 +1,7 @@
-From 946ce2b005a71e9922654af79bce51fefa16c3d4 Mon Sep 17 00:00:00 2001
+From 823454f1ea140ec47f5f9c5c3c5ad62eb458eb8a Mon Sep 17 00:00:00 2001
 From: Gilles Dartiguelongue <eva@gentoo.org>
 Date: Wed, 24 Oct 2018 10:52:46 +0200
-Subject: [PATCH 2/2] Add support for gentoo in cloud.cfg and templates
+Subject: [PATCH 2/5] Add support for gentoo in cloud.cfg and templates
 
 ---
  config/cloud.cfg.tmpl       |  8 ++++++--
@@ -11,7 +11,7 @@ Subject: [PATCH 2/2] Add support for gentoo in cloud.cfg and templates
  create mode 100644 templates/hosts.gentoo.tmpl
 
 diff --git a/config/cloud.cfg.tmpl b/config/cloud.cfg.tmpl
-index 1fef133a..f66b5f7e 100644
+index 1fef133a..3f5a41a2 100644
 --- a/config/cloud.cfg.tmpl
 +++ b/config/cloud.cfg.tmpl
 @@ -134,7 +134,7 @@ cloud_final_modules:
@@ -39,7 +39,7 @@ index 1fef133a..f66b5f7e 100644
 +{% elif variant == "gentoo" %}
 +     groups: [users, wheel]
 +     primary_group: users
-+     no-user-group: true
++     no_user_group: true
  {% else %}
       groups: [wheel, adm, systemd-journal]
  {% endif %}
@@ -87,5 +87,5 @@ index 8b7cb875..d109044e 100755
  if "avoid-pep8-E402-import-not-top-of-file":
      _tdir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
 -- 
-2.19.0
+2.19.1