Merge ~smoser/cloud-init:feature/redhat-spec-improvements into cloud-init:master

Proposed by Scott Moser
Status: Merged
Approved by: Scott Moser
Approved revision: 8ecb7ad780754f4877d4f03e7b8d51e1d94340dd
Merge reported by: Scott Moser
Merged at revision: 914822a765007be7e17539e456b3e6ff12b19442
Proposed branch: ~smoser/cloud-init:feature/redhat-spec-improvements
Merge into: cloud-init:master
Diff against target: 230 lines (+65/-44)
4 files modified
cloudinit/distros/__init__.py (+1/-1)
cloudinit/distros/centos.py (+12/-0)
packages/redhat/cloud-init.spec.in (+52/-40)
requirements.txt (+0/-3)
Reviewer Review Type Date Requested Status
Ryan Harper Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+325311@code.launchpad.net

Commit message

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.
 * 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.

 * Add 'centos' as a variant
   **FIXME**: This needs to add to cloudinit/util.py 'system_info' that is pulled in from the cloud-cfg-tmpl branch.

   Adding the variant means we can use the 'centos' user as default on centos
   rather than a 'fedora' or 'rhel'.

To post a comment you must log in.
Revision history for this message
Scott Moser (smoser) wrote :

Do we actually need the centos variant now?

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

We need centos as the distro.variant value is used to set the default distro user and gecos names.

Revision history for this message
Ryan Harper (raharper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
2index f56c0cf..1fd48a7 100755
3--- a/cloudinit/distros/__init__.py
4+++ b/cloudinit/distros/__init__.py
5@@ -32,7 +32,7 @@ from cloudinit.distros.parsers import hosts
6
7 OSFAMILIES = {
8 'debian': ['debian', 'ubuntu'],
9- 'redhat': ['fedora', 'rhel'],
10+ 'redhat': ['centos', 'fedora', 'rhel'],
11 'gentoo': ['gentoo'],
12 'freebsd': ['freebsd'],
13 'suse': ['sles'],
14diff --git a/cloudinit/distros/centos.py b/cloudinit/distros/centos.py
15new file mode 100644
16index 0000000..4b803d2
17--- /dev/null
18+++ b/cloudinit/distros/centos.py
19@@ -0,0 +1,12 @@
20+# This file is part of cloud-init. See LICENSE file for license information.
21+
22+from cloudinit.distros import rhel
23+from cloudinit import log as logging
24+
25+LOG = logging.getLogger(__name__)
26+
27+
28+class Distro(rhel.Distro):
29+ pass
30+
31+# vi: ts=4 expandtab
32diff --git a/packages/redhat/cloud-init.spec.in b/packages/redhat/cloud-init.spec.in
33index fd3cf93..1939ca8 100644
34--- a/packages/redhat/cloud-init.spec.in
35+++ b/packages/redhat/cloud-init.spec.in
36@@ -1,6 +1,12 @@
37 ## template: cheetah
38 %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
39
40+%if %{undefined systemd_requires}
41+%define init_system sysvinit
42+%else
43+%define init_system systemd
44+%endif
45+
46 # See: http://www.zarb.org/~jasonc/macros.php
47 # Or: http://fedoraproject.org/wiki/Packaging:ScriptletSnippets
48 # Or: http://www.rpm.org/max-rpm/ch-rpm-inside.html
49@@ -20,9 +26,20 @@ BuildRoot: %{_tmppath}
50
51 BuildRequires: python-devel
52 BuildRequires: python-setuptools
53-BuildRequires: python-cheetah
54+%if "%{?el6}" == "1"
55+BuildRequires: python-argparse
56+%endif
57+# These are runtime dependencies, but declared as BuildRequires so that
58+# - tests can be run here.
59+# - parts of cloud-init such (setup.py) use these dependencies.
60+#for $r in $requires
61+BuildRequires: ${r}
62+#end for
63
64 # System util packages needed
65+%ifarch %{?ix86} x86_64 ia64
66+Requires: dmidecode
67+%endif
68 Requires: shadow-utils
69 Requires: rsyslog
70 Requires: iproute
71@@ -32,6 +49,12 @@ Requires: procps
72 Requires: shadow-utils
73 Requires: sudo >= 1.7.2p2-3
74
75+Requires: python-setuptools
76+# python2.6 needs argparse
77+%if "%{?el6}" == "1"
78+Requires: python-argparse
79+%endif
80+
81 # Install pypi 'dynamic' requirements
82 #for $r in $requires
83 Requires: ${r}
84@@ -44,19 +67,15 @@ Patch${size}: $p
85 #set $size += 1
86 #end for
87
88-#if $sysvinit
89+%if "%{init_system}" == "systemd"
90+BuildRequires: systemd-units
91+%{systemd_requires}
92+%else
93 Requires(post): chkconfig
94 Requires(postun): initscripts
95 Requires(preun): chkconfig
96 Requires(preun): initscripts
97-#end if
98-
99-#if $systemd
100-BuildRequires: systemd-units
101-Requires(post): systemd-units
102-Requires(postun): systemd-units
103-Requires(preun): systemd-units
104-#end if
105+%endif
106
107 %description
108 Cloud-init is a set of init scripts for cloud instances. Cloud instances
109@@ -80,7 +99,7 @@ ssh keys and to let the user run various scripts.
110
111 %{__python} setup.py install -O1 \
112 --skip-build --root \$RPM_BUILD_ROOT \
113- --init-system=${init_sys}
114+ --init-system=%{init_system}
115
116 # Note that /etc/rsyslog.d didn't exist by default until F15.
117 # el6 request: https://bugzilla.redhat.com/show_bug.cgi?id=740420
118@@ -95,17 +114,17 @@ rm -rf \$RPM_BUILD_ROOT%{python_sitelib}/tests
119 mkdir -p \$RPM_BUILD_ROOT/%{_sharedstatedir}/cloud
120 mkdir -p \$RPM_BUILD_ROOT/%{_libexecdir}/%{name}
121
122-#if $systemd
123+%if "%{init_system}" == "systemd"
124 mkdir -p \$RPM_BUILD_ROOT/%{_unitdir}
125 cp -p systemd/* \$RPM_BUILD_ROOT/%{_unitdir}
126-#end if
127+%endif
128
129 %clean
130 rm -rf \$RPM_BUILD_ROOT
131
132 %post
133
134-#if $systemd
135+%if "%{init_system}" == "systemd"
136 if [ \$1 -eq 1 ]
137 then
138 /bin/systemctl enable cloud-config.service >/dev/null 2>&1 || :
139@@ -113,18 +132,24 @@ then
140 /bin/systemctl enable cloud-init.service >/dev/null 2>&1 || :
141 /bin/systemctl enable cloud-init-local.service >/dev/null 2>&1 || :
142 fi
143-#end if
144-
145-#if $sysvinit
146+%else
147 /sbin/chkconfig --add %{_initrddir}/cloud-init-local
148 /sbin/chkconfig --add %{_initrddir}/cloud-init
149 /sbin/chkconfig --add %{_initrddir}/cloud-config
150 /sbin/chkconfig --add %{_initrddir}/cloud-final
151-#end if
152+%endif
153
154 %preun
155
156-#if $sysvinit
157+%if "%{init_system}" == "systemd"
158+if [ \$1 -eq 0 ]
159+then
160+ /bin/systemctl --no-reload disable cloud-config.service >/dev/null 2>&1 || :
161+ /bin/systemctl --no-reload disable cloud-final.service >/dev/null 2>&1 || :
162+ /bin/systemctl --no-reload disable cloud-init.service >/dev/null 2>&1 || :
163+ /bin/systemctl --no-reload disable cloud-init-local.service >/dev/null 2>&1 || :
164+fi
165+%else
166 if [ \$1 -eq 0 ]
167 then
168 /sbin/service cloud-init stop >/dev/null 2>&1 || :
169@@ -136,40 +161,27 @@ then
170 /sbin/service cloud-final stop >/dev/null 2>&1 || :
171 /sbin/chkconfig --del cloud-final || :
172 fi
173-#end if
174-
175-#if $systemd
176-if [ \$1 -eq 0 ]
177-then
178- /bin/systemctl --no-reload disable cloud-config.service >/dev/null 2>&1 || :
179- /bin/systemctl --no-reload disable cloud-final.service >/dev/null 2>&1 || :
180- /bin/systemctl --no-reload disable cloud-init.service >/dev/null 2>&1 || :
181- /bin/systemctl --no-reload disable cloud-init-local.service >/dev/null 2>&1 || :
182-fi
183-#end if
184+%endif
185
186 %postun
187
188-#if $systemd
189+%if "%{init_system}" == "systemd"
190 /bin/systemctl daemon-reload >/dev/null 2>&1 || :
191-#end if
192+%endif
193
194 %files
195
196 /lib/udev/rules.d/66-azure-ephemeral.rules
197
198-#if $sysvinit
199+%if "%{init_system}" == "systemd"
200+/usr/lib/systemd/system-generators/cloud-init-generator
201+%{_unitdir}/cloud-*
202+%else
203 %attr(0755, root, root) %{_initddir}/cloud-config
204 %attr(0755, root, root) %{_initddir}/cloud-final
205 %attr(0755, root, root) %{_initddir}/cloud-init-local
206 %attr(0755, root, root) %{_initddir}/cloud-init
207-#end if
208-
209-#if $systemd
210-/usr/lib/systemd/system-generators/cloud-init-generator
211-%{_unitdir}/cloud-*
212-%{_unitdir}/cloud-*
213-#end if
214+%endif
215
216 %{_sysconfdir}/NetworkManager/dispatcher.d/hook-network-manager
217 %{_sysconfdir}/dhcp/dhclient-exit-hooks.d/hook-dhclient
218diff --git a/requirements.txt b/requirements.txt
219index 60abab1..59ec06d 100644
220--- a/requirements.txt
221+++ b/requirements.txt
222@@ -27,9 +27,6 @@ configobj>=5.0.2
223 # All new style configurations are in the yaml format
224 pyyaml
225
226-# The new main entrypoint uses argparse instead of optparse
227-argparse
228-
229 # Requests handles ssl correctly!
230 requests
231

Subscribers

People subscribed via source and target branches