cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #06320
[Merge] ~raharper/cloud-init:fix/fedora-build into cloud-init:master
Ryan Harper has proposed merging ~raharper/cloud-init:fix/fedora-build into cloud-init:master.
Commit message:
Add a fedora packaging specfile and adjust tools
Fedora has a python3 version of cloud-init downstream available. This branch
takes that as a starting point and adjusts it to work with our jinja template
format and building from master.
This branch also updates the systemd/cloud-init-generator.tmpl file to specify
the path to ds-identify with the libexec prefix used on redhat based systems.
For non-systemd versions of redhat el. al, this is a non issue, however for python3
systems, it means that the systemd generator does not invoke ds-identify and will
keep cloud-init disabled.
Requested reviews:
cloud-init commiters (cloud-init-dev)
For more details, see:
https://code.launchpad.net/~raharper/cloud-init/+git/cloud-init/+merge/368845
--
Your team cloud-init commiters is requested to review the proposed merge of ~raharper/cloud-init:fix/fedora-build into cloud-init:master.
diff --git a/packages/brpm b/packages/brpm
index a154ef2..5c56a2c 100755
--- a/packages/brpm
+++ b/packages/brpm
@@ -108,7 +108,7 @@ def main():
parser.add_argument("-d", "--distro", dest="distro",
help="select distro (default: %(default)s)",
metavar="DISTRO", default='redhat',
- choices=('redhat', 'suse'))
+ choices=('fedora', 'redhat', 'suse'))
parser.add_argument('--srpm',
help='Produce a source rpm',
action='store_true')
diff --git a/packages/fedora/cloud-init.spec.in b/packages/fedora/cloud-init.spec.in
new file mode 100644
index 0000000..0487d90
--- /dev/null
+++ b/packages/fedora/cloud-init.spec.in
@@ -0,0 +1,170 @@
+## template: jinja
+%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
+
+%define use_systemd (0%{?fedora} && 0%{?fedora} >= 18) || (0%{?rhel} && 0%{?rhel} >= 7)
+
+%if %{use_systemd}
+%define init_system systemd
+%else
+%define init_system sysvinit
+%endif
+
+# See: http://www.zarb.org/~jasonc/macros.php
+# Or: http://fedoraproject.org/wiki/Packaging:ScriptletSnippets
+# Or: http://www.rpm.org/max-rpm/ch-rpm-inside.html
+
+Name: cloud-init
+Version: {{rpm_upstream_version}}
+Release: 1{{subrelease}}%{?dist}
+Summary: Cloud instance init scripts
+
+Group: System Environment/Base
+License: Dual-licensed GPLv3 or Apache 2.0
+URL: http://launchpad.net/cloud-init
+
+Source0: {{archive_name}}
+BuildArch: noarch
+BuildRoot: %{_tmppath}
+
+BuildRequires: pkgconfig(systemd)
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: systemd
+
+# For tests
+BuildRequires: iproute
+BuildRequires: python3-configobj
+# https://bugzilla.redhat.com/show_bug.cgi?id=1695953
+BuildRequires: python3-distro
+# https://bugzilla.redhat.com/show_bug.cgi?id=1417029
+BuildRequires: python3-httpretty >= 0.8.14-2
+BuildRequires: python3-jinja2
+BuildRequires: python3-jsonpatch
+BuildRequires: python3-jsonschema
+BuildRequires: python3-mock
+BuildRequires: python3-nose
+BuildRequires: python3-oauthlib
+BuildRequires: python3-prettytable
+BuildRequires: python3-pyserial
+BuildRequires: python3-PyYAML
+BuildRequires: python3-requests
+BuildRequires: python3-six
+BuildRequires: python3-unittest2
+# dnf is needed to make cc_ntp unit tests work
+# https://bugs.launchpad.net/cloud-init/+bug/1721573
+BuildRequires: /usr/bin/dnf
+
+Requires: e2fsprogs
+Requires: iproute
+Requires: libselinux-python3
+Requires: net-tools
+Requires: policycoreutils-python3
+Requires: procps
+Requires: python3-configobj
+# https://bugzilla.redhat.com/show_bug.cgi?id=1695953
+Requires: python3-distro
+Requires: python3-jinja2
+Requires: python3-jsonpatch
+Requires: python3-jsonschema
+Requires: python3-oauthlib
+Requires: python3-prettytable
+Requires: python3-pyserial
+Requires: python3-PyYAML
+Requires: python3-requests
+Requires: python3-six
+Requires: shadow-utils
+Requires: util-linux
+Requires: xfsprogs
+
+%{?systemd_requires}
+
+# System util packages needed
+%ifarch %{?ix86} x86_64 ia64
+Requires: dmidecode
+%endif
+
+
+%description
+Cloud-init is a set of init scripts for cloud instances. Cloud instances
+need special scripts to run during initialization to retrieve and install
+ssh keys and to let the user run various scripts.
+
+
+%prep
+%setup -q -n {{source_name}}
+
+# Change shebangs
+sed -i -e 's|#!/usr/bin/env python|#!/usr/bin/env python3|' \
+ -e 's|#!/usr/bin/python|#!/usr/bin/python3|' tools/* cloudinit/ssh_util.py
+
+
+%build
+%py3_build
+
+
+%install
+%py3_install -- --init-system=systemd
+
+python3 tools/render-cloudcfg --variant fedora > $RPM_BUILD_ROOT/%{_sysconfdir}/cloud/cloud.cfg
+
+mkdir -p $RPM_BUILD_ROOT/var/lib/cloud
+
+mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d
+cp -p tools/21-cloudinit.conf $RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d/21-cloudinit.conf
+
+# patch in the full version to version.py
+version_pys=$(cd "$RPM_BUILD_ROOT" && find . -name version.py -type f)
+[ -n "$version_pys" ] ||
+ { echo "failed to find 'version.py' to patch with version." 1>&2; exit 1; }
+( cd "$RPM_BUILD_ROOT" &&
+ sed -i "s,@@PACKAGED_VERSION@@,%{version}-%{release}," $version_pys )
+
+%check
+nosetests-%{python3_version} tests/unittests/
+
+
+%post
+%systemd_post cloud-config.service cloud-config.target cloud-final.service cloud-init.service cloud-init.target cloud-init-local.service
+
+
+%preun
+%systemd_preun cloud-config.service cloud-config.target cloud-final.service cloud-init.service cloud-init.target cloud-init-local.service
+
+
+%postun
+%systemd_postun cloud-config.service cloud-config.target cloud-final.service cloud-init.service cloud-init.target cloud-init-local.service
+
+
+%files
+%license LICENSE LICENSE-Apache2.0 LICENSE-GPLv3
+%doc ChangeLog
+%doc doc/*
+%config(noreplace) %{_sysconfdir}/cloud/cloud.cfg
+%dir %{_sysconfdir}/cloud/cloud.cfg.d
+%config(noreplace) %{_sysconfdir}/cloud/cloud.cfg.d/*.cfg
+%doc %{_sysconfdir}/cloud/cloud.cfg.d/README
+%dir %{_sysconfdir}/cloud/templates
+%config(noreplace) %{_sysconfdir}/cloud/templates/*
+%dir %{_sysconfdir}/rsyslog.d
+%config(noreplace) %{_sysconfdir}/rsyslog.d/21-cloudinit.conf
+%{_sysconfdir}/NetworkManager/dispatcher.d/hook-network-manager
+%{_sysconfdir}/dhcp/dhclient-exit-hooks.d/hook-dhclient
+/lib/udev/rules.d/66-azure-ephemeral.rules
+%{_unitdir}/cloud-config.service
+%{_unitdir}/cloud-final.service
+%{_unitdir}/cloud-init.service
+%{_unitdir}/cloud-init-local.service
+%{_unitdir}/cloud-config.target
+%{_unitdir}/cloud-init.target
+/usr/lib/systemd/system-generators/cloud-init-generator
+%{python3_sitelib}/*
+%{_libexecdir}/%{name}
+%{_bindir}/cloud-init*
+%{_bindir}/cloud-id
+%{_datadir}/bash-completion/completions/cloud-init
+%dir /var/lib/cloud
+
+
+%changelog
+* Fri Jun 14 2019 Ryan Harper <ryan.harper@xxxxxxxxxxxxx>
+- Adapt Fedora cloud-init.spec for upstream
diff --git a/packages/pkg-deps.json b/packages/pkg-deps.json
index 72409dd..9257199 100644
--- a/packages/pkg-deps.json
+++ b/packages/pkg-deps.json
@@ -62,6 +62,51 @@
"sudo"
]
},
+ "fedora" : {
+ "build-requires" : [
+ "python3-devel",
+ "python3-distro",
+ "python3-prettytable",
+ "python3-pyserial",
+ "python3-setuptools",
+ "rpm-build"
+ ],
+ "renames" : {
+ "jinja2" : {
+ "3" : "python3-jinja2"
+ },
+ "jsonschema" : {
+ "3" : "python3-jsonschema"
+ },
+ "pyflakes" : {
+ "2" : "pyflakes",
+ "3" : "python3-pyflakes"
+ },
+ "pyyaml" : {
+ "2" : "PyYAML",
+ "3" : "python3-PyYAML"
+ },
+ "pyserial" : {
+ "2" : "pyserial",
+ "3" : "python3-pyserial"
+ },
+ "requests" : {
+ "3" : "python3-requests"
+ },
+ "six" : {
+ "3" : "python3-six"
+ }
+ },
+ "requires" : [
+ "e2fsprogs",
+ "iproute",
+ "net-tools",
+ "procps",
+ "rsyslog",
+ "shadow-utils",
+ "sudo"
+ ]
+ },
"suse" : {
"renames" : {
"pyyaml" : {
diff --git a/systemd/cloud-init-generator.tmpl b/systemd/cloud-init-generator.tmpl
index cfa5eb5..45efa24 100755
--- a/systemd/cloud-init-generator.tmpl
+++ b/systemd/cloud-init-generator.tmpl
@@ -82,7 +82,12 @@ default() {
}
check_for_datasource() {
- local ds_rc="" dsidentify="/usr/lib/cloud-init/ds-identify"
+ local ds_rc=""
+{% if variant in ["redhat", "fedora", "centos"] %}
+ local dsidentify="/usr/libexec/cloud-init/ds-identify"
+{% else %}
+ local dsidentify="/usr/lib/cloud-init/ds-identify"
+{% endif %}
if [ ! -x "$dsidentify" ]; then
debug 1 "no ds-identify in $dsidentify. _RET=$FOUND"
return 0
diff --git a/tools/read-dependencies b/tools/read-dependencies
index b4656e6..0b94880 100755
--- a/tools/read-dependencies
+++ b/tools/read-dependencies
@@ -23,6 +23,7 @@ DEFAULT_REQUIREMENTS = 'requirements.txt'
# Map the appropriate package dir needed for each distro choice
DISTRO_PKG_TYPE_MAP = {
'centos': 'redhat',
+ 'fedora': 'fedora',
'redhat': 'redhat',
'debian': 'debian',
'ubuntu': 'debian',
@@ -51,17 +52,41 @@ MAYBE_RELIABLE_YUM_INSTALL = [
""",
'reliable-yum-install']
+MAYBE_RELIABLE_DNF_INSTALL = [
+ 'sh', '-c',
+ """
+ error() { echo "$@" 1>&2; }
+ n=0; max=10;
+ bcmd="dnf install --downloadonly --assumeyes --setopt=keepcache=1"
+ while n=$(($n+1)); do
+ error ":: running $bcmd $* [$n/$max]"
+ $bcmd "$@"
+ r=$?
+ [ $r -eq 0 ] && break
+ [ $n -ge $max ] && { error "gave up on $bcmd"; exit $r; }
+ nap=$(($n*5))
+ error ":: failed [$r] ($n/$max). sleeping $nap."
+ sleep $nap
+ done
+ error ":: running dnf install --cacheonly --assumeyes $*"
+ dnf install --cacheonly --assumeyes "$@"
+ """,
+ 'reliable-dnf-install']
+
+
ZYPPER_INSTALL = [
'zypper', '--non-interactive', '--gpg-auto-import-keys', 'install',
'--auto-agree-with-licenses']
DRY_DISTRO_INSTALL_PKG_CMD = {
'centos': ['yum', 'install', '--assumeyes'],
+ 'fedora': ['dnf', 'install', '--assumeyes'],
'redhat': ['yum', 'install', '--assumeyes'],
}
DISTRO_INSTALL_PKG_CMD = {
'centos': MAYBE_RELIABLE_YUM_INSTALL,
+ 'fedora': MAYBE_RELIABLE_DNF_INSTALL,
'redhat': MAYBE_RELIABLE_YUM_INSTALL,
'debian': ['apt', 'install', '-y'],
'ubuntu': ['apt', 'install', '-y'],
@@ -73,6 +98,7 @@ DISTRO_INSTALL_PKG_CMD = {
# List of base system packages required to enable ci automation
CI_SYSTEM_BASE_PKGS = {
'common': ['make', 'sudo', 'tar'],
+ 'fedora': ['python3-tox'],
'redhat': ['python-tox'],
'centos': ['python-tox'],
'ubuntu': ['devscripts', 'python3-dev', 'libssl-dev', 'tox', 'sbuild'],
diff --git a/tools/run-container b/tools/run-container
index 1d24e15..1aa7c09 100755
--- a/tools/run-container
+++ b/tools/run-container
@@ -218,9 +218,10 @@ get_os_info() {
{ error "Unable to determine OS_NAME/OS_VERSION"; return 1; }
}
-yum_install() {
+_rpm_install() {
+ install_cmd="$1"; shift;
local n=0 max=10 ret
- bcmd="yum install --downloadonly --assumeyes --setopt=keepcache=1"
+ bcmd="$install_cmd install --downloadonly --assumeyes --setopt=keepcache=1"
while n=$((n+1)); do
error ":: running $bcmd $* [$n/$max]"
$bcmd "$@"
@@ -231,8 +232,16 @@ yum_install() {
error ":: failed [$ret] ($n/$max). sleeping $nap."
sleep $nap
done
- error ":: running yum install --cacheonly --assumeyes $*"
- yum install --cacheonly --assumeyes "$@"
+ error ":: running $install_cmd install --cacheonly --assumeyes $*"
+ $install_cmd install --cacheonly --assumeyes "$@"
+}
+
+yum_install() {
+ _rpm_install "yum" "$@"
+}
+
+dnf_install() {
+ _rpm_install "dnf" "$@"
}
zypper_install() {
@@ -250,6 +259,7 @@ apt_install() {
install_packages() {
get_os_info || return
case "$OS_NAME" in
+ fedora) dnf_install "$@";;
centos) yum_install "$@";;
opensuse) zypper_install "$@";;
debian|ubuntu) apt_install "$@";;
@@ -517,15 +527,16 @@ main() {
local build_pkg="" build_srcpkg="" pkg_ext="" distflag=""
case "$OS_NAME" in
centos) distflag="--distro=redhat";;
+ fedora) distflag="--distro=fedora";;
opensuse) distflag="--distro=suse";;
esac
case "$OS_NAME" in
debian|ubuntu)
- build_pkg="./packages/bddeb -d"
+ build_pkg="./packages/bddeb -d"
build_srcpkg="./packages/bddeb -S -d"
pkg_ext=".deb";;
- centos|opensuse)
+ centos|fedora|opensuse|redhat)
build_pkg="./packages/brpm $distflag"
build_srcpkg="./packages/brpm $distflag --srpm"
pkg_ext=".rpm";;