summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2017-06-07 11:32:56 -0400
committerScott Moser <smoser@brickies.net>2017-06-08 13:02:55 -0400
commit914822a765007be7e17539e456b3e6ff12b19442 (patch)
tree9dc1355aded2856e6f97bfc580084e58949b1c2a /packages
parent41d46bfb85929c79dabcec3cf21c8d71401fd2b8 (diff)
downloadvyos-cloud-init-914822a765007be7e17539e456b3e6ff12b19442.tar.gz
vyos-cloud-init-914822a765007be7e17539e456b3e6ff12b19442.zip
rhel/centos spec cleanups.
Many changes here to get us able to build rpms on CentOS 5 or 6 and RHEL. * add 'Requires' as 'BuildRequires' also. This allows us to run cloud-init tools in the build environment, and also will allow us to run tests in the build process. * build for both systemd and upstart (centos 5) init systems. * Add 'centos' as a variant Adding the variant means we can use the 'centos' user as default on centos rather than a 'fedora' or 'rhel'. * drop argparse from the requirements. On any system other than python 2.6, having a 'requirements' that mentions argparse just causes problems. Instead we add that Requires to the spec directly. * list dependency on dmidecode (as redhat distro spec had) * remove duplicate line in files section ({_unitdir}/cloud-*) * Use rpm macros for init-system chunks and drop use of init_system variable template * Add el6 only build-req on python-argparse * python-cheetah is not required in the build environment as the the spec is already rendered. (We will soon move the spec to jinja).
Diffstat (limited to 'packages')
-rw-r--r--packages/redhat/cloud-init.spec.in92
1 files changed, 52 insertions, 40 deletions
diff --git a/packages/redhat/cloud-init.spec.in b/packages/redhat/cloud-init.spec.in
index fd3cf938..1939ca88 100644
--- a/packages/redhat/cloud-init.spec.in
+++ b/packages/redhat/cloud-init.spec.in
@@ -1,6 +1,12 @@
## template: cheetah
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
+%if %{undefined systemd_requires}
+%define init_system sysvinit
+%else
+%define init_system systemd
+%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
@@ -20,9 +26,20 @@ BuildRoot: %{_tmppath}
BuildRequires: python-devel
BuildRequires: python-setuptools
-BuildRequires: python-cheetah
+%if "%{?el6}" == "1"
+BuildRequires: python-argparse
+%endif
+# These are runtime dependencies, but declared as BuildRequires so that
+# - tests can be run here.
+# - parts of cloud-init such (setup.py) use these dependencies.
+#for $r in $requires
+BuildRequires: ${r}
+#end for
# System util packages needed
+%ifarch %{?ix86} x86_64 ia64
+Requires: dmidecode
+%endif
Requires: shadow-utils
Requires: rsyslog
Requires: iproute
@@ -32,6 +49,12 @@ Requires: procps
Requires: shadow-utils
Requires: sudo >= 1.7.2p2-3
+Requires: python-setuptools
+# python2.6 needs argparse
+%if "%{?el6}" == "1"
+Requires: python-argparse
+%endif
+
# Install pypi 'dynamic' requirements
#for $r in $requires
Requires: ${r}
@@ -44,19 +67,15 @@ Patch${size}: $p
#set $size += 1
#end for
-#if $sysvinit
+%if "%{init_system}" == "systemd"
+BuildRequires: systemd-units
+%{systemd_requires}
+%else
Requires(post): chkconfig
Requires(postun): initscripts
Requires(preun): chkconfig
Requires(preun): initscripts
-#end if
-
-#if $systemd
-BuildRequires: systemd-units
-Requires(post): systemd-units
-Requires(postun): systemd-units
-Requires(preun): systemd-units
-#end if
+%endif
%description
Cloud-init is a set of init scripts for cloud instances. Cloud instances
@@ -80,7 +99,7 @@ ssh keys and to let the user run various scripts.
%{__python} setup.py install -O1 \
--skip-build --root \$RPM_BUILD_ROOT \
- --init-system=${init_sys}
+ --init-system=%{init_system}
# Note that /etc/rsyslog.d didn't exist by default until F15.
# el6 request: https://bugzilla.redhat.com/show_bug.cgi?id=740420
@@ -95,17 +114,17 @@ rm -rf \$RPM_BUILD_ROOT%{python_sitelib}/tests
mkdir -p \$RPM_BUILD_ROOT/%{_sharedstatedir}/cloud
mkdir -p \$RPM_BUILD_ROOT/%{_libexecdir}/%{name}
-#if $systemd
+%if "%{init_system}" == "systemd"
mkdir -p \$RPM_BUILD_ROOT/%{_unitdir}
cp -p systemd/* \$RPM_BUILD_ROOT/%{_unitdir}
-#end if
+%endif
%clean
rm -rf \$RPM_BUILD_ROOT
%post
-#if $systemd
+%if "%{init_system}" == "systemd"
if [ \$1 -eq 1 ]
then
/bin/systemctl enable cloud-config.service >/dev/null 2>&1 || :
@@ -113,18 +132,24 @@ then
/bin/systemctl enable cloud-init.service >/dev/null 2>&1 || :
/bin/systemctl enable cloud-init-local.service >/dev/null 2>&1 || :
fi
-#end if
-
-#if $sysvinit
+%else
/sbin/chkconfig --add %{_initrddir}/cloud-init-local
/sbin/chkconfig --add %{_initrddir}/cloud-init
/sbin/chkconfig --add %{_initrddir}/cloud-config
/sbin/chkconfig --add %{_initrddir}/cloud-final
-#end if
+%endif
%preun
-#if $sysvinit
+%if "%{init_system}" == "systemd"
+if [ \$1 -eq 0 ]
+then
+ /bin/systemctl --no-reload disable cloud-config.service >/dev/null 2>&1 || :
+ /bin/systemctl --no-reload disable cloud-final.service >/dev/null 2>&1 || :
+ /bin/systemctl --no-reload disable cloud-init.service >/dev/null 2>&1 || :
+ /bin/systemctl --no-reload disable cloud-init-local.service >/dev/null 2>&1 || :
+fi
+%else
if [ \$1 -eq 0 ]
then
/sbin/service cloud-init stop >/dev/null 2>&1 || :
@@ -136,40 +161,27 @@ then
/sbin/service cloud-final stop >/dev/null 2>&1 || :
/sbin/chkconfig --del cloud-final || :
fi
-#end if
-
-#if $systemd
-if [ \$1 -eq 0 ]
-then
- /bin/systemctl --no-reload disable cloud-config.service >/dev/null 2>&1 || :
- /bin/systemctl --no-reload disable cloud-final.service >/dev/null 2>&1 || :
- /bin/systemctl --no-reload disable cloud-init.service >/dev/null 2>&1 || :
- /bin/systemctl --no-reload disable cloud-init-local.service >/dev/null 2>&1 || :
-fi
-#end if
+%endif
%postun
-#if $systemd
+%if "%{init_system}" == "systemd"
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
-#end if
+%endif
%files
/lib/udev/rules.d/66-azure-ephemeral.rules
-#if $sysvinit
+%if "%{init_system}" == "systemd"
+/usr/lib/systemd/system-generators/cloud-init-generator
+%{_unitdir}/cloud-*
+%else
%attr(0755, root, root) %{_initddir}/cloud-config
%attr(0755, root, root) %{_initddir}/cloud-final
%attr(0755, root, root) %{_initddir}/cloud-init-local
%attr(0755, root, root) %{_initddir}/cloud-init
-#end if
-
-#if $systemd
-/usr/lib/systemd/system-generators/cloud-init-generator
-%{_unitdir}/cloud-*
-%{_unitdir}/cloud-*
-#end if
+%endif
%{_sysconfdir}/NetworkManager/dispatcher.d/hook-network-manager
%{_sysconfdir}/dhcp/dhclient-exit-hooks.d/hook-dhclient