guest: import cloud-init from meta-openstack

Bringing cloud-init from meta-openstack into meta-virtualization to make
it more visible/obvious for use with Xen and k*s images.

Not only is this an import, it is a significant update to the package
and the way it is built.

Out of the box, it installs either systemd or sysvinit startup services,
templates and the main script/binary.

It is not expected that this will be useful out of the box, but will
need to be bbappended and have variables added to the main recipe to
make it flexible for more use cases.

But we can't gather those use cases, without the package being
available, so we integrate this as a starting point.

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
This commit is contained in:
Bruce Ashfield 2020-11-05 09:17:01 -05:00
parent afef7f0635
commit 515f39e453
3 changed files with 153 additions and 0 deletions

View File

@ -0,0 +1,34 @@
From 5c96379a4727c07fb5222208525013ec8b878184 Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <bruce.ashfield@gmail.com>
Date: Wed, 4 Nov 2020 21:15:50 -0500
Subject: [PATCH] setup.py: check for 'install' anywhere in args
The python3distutils bbclass calls setup.py in a different way then
cloud-init expects .. the 'install' is not argument 1, but is in fact
after a 'build' and some other options.
So rather than checking for install to be argv[1], we check for it
anywhere in the arguments are trigger the template replacement to
happen.
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
---
setup.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index cbacf48e..5f13d9eb 100755
--- a/setup.py
+++ b/setup.py
@@ -87,7 +87,7 @@ def render_tmpl(template, mode=None):
# older versions of tox use bdist (xenial), and then install from there.
# newer versions just use install.
- if not (sys.argv[1] == 'install' or sys.argv[1].startswith('bdist*')):
+ if not ('install' in sys.argv or sys.argv[1].startswith('bdist*')):
return template
tmpl_ext = ".tmpl"
--
2.25.1

View File

@ -0,0 +1,64 @@
From 72dd3b4b38705442d821fe97a40061f23e748769 Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <bruce.ashfield@windriver.com>
Date: Thu, 6 Mar 2014 01:55:09 -0500
Subject: [PATCH] cloud-init: source local lsb functions
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
---
sysvinit/debian/cloud-config | 1 +
sysvinit/debian/cloud-final | 1 +
sysvinit/debian/cloud-init | 1 +
sysvinit/debian/cloud-init-local | 1 +
4 files changed, 4 insertions(+)
diff --git a/sysvinit/debian/cloud-config b/sysvinit/debian/cloud-config
index 53322748ac65..7874dcfab9b0 100644
--- a/sysvinit/debian/cloud-config
+++ b/sysvinit/debian/cloud-config
@@ -30,6 +30,7 @@ SCRIPTNAME=/etc/init.d/$NAME
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
+. /etc/init.d/functions
if init_is_upstart; then
case "$1" in
diff --git a/sysvinit/debian/cloud-final b/sysvinit/debian/cloud-final
index 55afc8b0678a..661314f0b64c 100644
--- a/sysvinit/debian/cloud-final
+++ b/sysvinit/debian/cloud-final
@@ -32,6 +32,7 @@ SCRIPTNAME=/etc/init.d/$NAME
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
+. /etc/init.d/functions
if init_is_upstart; then
case "$1" in
diff --git a/sysvinit/debian/cloud-init b/sysvinit/debian/cloud-init
index 48fa04233f00..d3ccec99bacc 100755
--- a/sysvinit/debian/cloud-init
+++ b/sysvinit/debian/cloud-init
@@ -30,6 +30,7 @@ SCRIPTNAME=/etc/init.d/$NAME
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
+. /etc/init.d/functions
if init_is_upstart; then
case "$1" in
diff --git a/sysvinit/debian/cloud-init-local b/sysvinit/debian/cloud-init-local
index 802ee8e9f386..c309e8347324 100644
--- a/sysvinit/debian/cloud-init-local
+++ b/sysvinit/debian/cloud-init-local
@@ -29,6 +29,7 @@ SCRIPTNAME=/etc/init.d/$NAME
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
+. /etc/init.d/functions
if init_is_upstart; then
case "$1" in
--
1.7.10.4

View File

@ -0,0 +1,55 @@
DESCRIPTION = "Init scripts for use on cloud images"
HOMEPAGE = "https://github.com/canonical/cloud-init"
SECTION = "devel/python"
LICENSE = "GPLv3"
LIC_FILES_CHKSUM = "file://LICENSE;md5=c6dd79b6ec2130a3364f6fa9d6380408"
SRCREV = "1431c8a1bddaabf85e1bbb32bf316a3aef20036e"
SRC_URI = "git://github.com/canonical/cloud-init \
file://cloud-init-source-local-lsb-functions.patch \
file://0001-setup.py-check-for-install-anywhere-in-args.patch \
"
S = "${WORKDIR}/git"
DISTUTILS_INSTALL_ARGS_append = " ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', '--init-system=sysvinit_deb', '', d)}"
DISTUTILS_INSTALL_ARGS_append = " ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '--init-system=systemd', '', d)}"
do_install_append() {
ln -s ${libdir}/${BPN}/uncloud-init ${D}${sysconfdir}/cloud/uncloud-init
ln -s ${libdir}/${BPN}/write-ssh-key-fingerprints ${D}${sysconfdir}/cloud/write-ssh-key-fingerprints
}
inherit pkgconfig
inherit setuptools3
inherit update-rc.d
inherit systemd
inherit python3native
PACKAGES += "${PN}-systemd"
FILES_${PN} += "${sysconfdir}/* \
${datadir}/*"
FILES_${PN}-systemd += "${systemd_unitdir}/*"
RDEPENDS_${PN}-systemd += " ${PN}"
INITSCRIPT_PACKAGES = "${PN}"
INITSCRIPT_NAME_${BPN} = "cloud-init"
DEPENDS += "python3-pyyaml-native \
python3-requests-native \
python3-jinja2-native \
"
RDEPENDS_${PN} = "python3 \
python3-jinja2 \
python3-configobj \
python3-requests \
python3-jsonpatch \
python3-jsonschema \
python3-pyyaml \
python3-oauthlib \
"