11## template: jinja
2- %define use_systemd (0%{?fedora} && 0%{?fedora} >= 18) || (0%{?rhel} && 0%{?rhel} >= 7)
3-
4- %if %{use_systemd}
5- %define init_system systemd
6- %else
7- %define init_system sysvinit
8- %endif
92
103# See: http://www.zarb.org/~jasonc/macros.php
114# Or: http://fedoraproject.org/wiki/Packaging:ScriptletSnippets
147Name: cloud-init
158Version: {{rpm_upstream_version}}
169Release: 1{{subrelease}}%{?dist}
17- Summary: Cloud instance initilization tool
10+ Summary: Cloud instance initialization tool
1811
1912Group: System Environment/Base
2013License: Dual-licesed GPLv3 or Apache 2.0
@@ -24,20 +17,10 @@ Source0: {{archive_name}}
2417BuildArch: noarch
2518BuildRoot: %{_tmppath}
2619
27- %if "%{?el6}" == "1"
28- BuildRequires: python-argparse
29- %endif
30- %if %{use_systemd}
31- Requires: systemd
32- BuildRequires: systemd
33- Requires: systemd-units
34- BuildRequires: systemd-units
35- %else
36- Requires: initscripts >= 8.36
37- Requires(postun): initscripts
38- Requires(post): chkconfig
39- Requires(preun): chkconfig
40- %endif
20+ Requires: systemd
21+ BuildRequires: pkgconfig(systemd)
22+ Requires: systemd-units
23+ BuildRequires: systemd-units
4124
4225{% for r in buildrequires %}
4326BuildRequires: {{r}}
@@ -61,16 +44,9 @@ Requires: {{r}}
6144Patch{{loop.index0}}: {{p}}
6245{% endfor %}
6346
64- %if "%{init_system}" == "systemd"
6547Requires(post): systemd
6648Requires(preun): systemd
6749Requires(postun): systemd
68- %else
69- Requires(post): chkconfig
70- Requires(postun): initscripts
71- Requires(preun): chkconfig
72- Requires(preun): initscripts
73- %endif
7450
7551%description
7652Cloud-init is a set of init scripts for cloud instances. Cloud instances
@@ -86,7 +62,7 @@ ssh keys and to let the user run various scripts.
8662{% endfor %}
8763
8864%build
89- %meson -Dinit_system=systemd
65+ %meson -Dinit_system=systemd -Ddistro_templates=chef_client.rb.tmpl,chrony.conf.rhel.tmpl,hosts.redhat.tmpl,ntp.conf.rhel.tmpl,resolv.conf.tmpl,timesyncd.conf.tmpl
9066%meson_build
9167
9268%install
@@ -113,68 +89,23 @@ version_pys=$(cd "$RPM_BUILD_ROOT" && find . -name version.py -type f)
11389rm -rf $RPM_BUILD_ROOT
11490
11591%post
92+ %systemd_post cloud-init-main.service cloud-config.service cloud-config.target cloud-final.service cloud-init-network.service cloud-init.target cloud-init-local.service
11693
117- %if "%{init_system}" == "systemd"
118- if [ $1 -eq 1 ]
119- then
120- /bin/systemctl enable cloud-init-main.service >/dev/null 2>&1 || :
121- /bin/systemctl enable cloud-init-local.service >/dev/null 2>&1 || :
122- /bin/systemctl enable cloud-init-network.service >/dev/null 2>&1 || :
123- /bin/systemctl enable cloud-config.service >/dev/null 2>&1 || :
124- /bin/systemctl enable cloud-final.service >/dev/null 2>&1 || :
125- fi
126- %else
127- /sbin/chkconfig --add %{_initrddir}/cloud-init-local
128- /sbin/chkconfig --add %{_initrddir}/cloud-init
129- /sbin/chkconfig --add %{_initrddir}/cloud-config
130- /sbin/chkconfig --add %{_initrddir}/cloud-final
131- %endif
13294
13395%preun
96+ %systemd_preun cloud-init-main.service cloud-config.service cloud-config.target cloud-final.service cloud-init-network.service cloud-init.target cloud-init-local.service
13497
135- %if "%{init_system}" == "systemd"
136- if [ $1 -eq 0 ]
137- then
138- /bin/systemctl --no-reload disable cloud-init-main.service >/dev/null 2>&1 || :
139- /bin/systemctl --no-reload disable cloud-init-local.service >/dev/null 2>&1 || :
140- /bin/systemctl --no-reload disable cloud-init-network.service >/dev/null 2>&1 || :
141- /bin/systemctl --no-reload disable cloud-config.service >/dev/null 2>&1 || :
142- /bin/systemctl --no-reload disable cloud-final.service >/dev/null 2>&1 || :
143- fi
144- %else
145- if [ $1 -eq 0 ]
146- then
147- /sbin/service cloud-init stop >/dev/null 2>&1 || :
148- /sbin/chkconfig --del cloud-init || :
149- /sbin/service cloud-init-local stop >/dev/null 2>&1 || :
150- /sbin/chkconfig --del cloud-init-local || :
151- /sbin/service cloud-config stop >/dev/null 2>&1 || :
152- /sbin/chkconfig --del cloud-config || :
153- /sbin/service cloud-final stop >/dev/null 2>&1 || :
154- /sbin/chkconfig --del cloud-final || :
155- fi
156- %endif
15798
15899%postun
159-
160- %if "%{init_system}" == "systemd"
161- /bin/systemctl daemon-reload >/dev/null 2>&1 || :
162- %endif
100+ %systemd_postun cloud-init-main.service cloud-config.service cloud-config.target cloud-final.service cloud-init-network.service cloud-init.target cloud-init-local.service
163101
164102%files
165103
166104%{_udevrulesdir}/66-azure-ephemeral.rules
167105
168- %if "%{init_system}" == "systemd"
169106/usr/lib/systemd/system-generators/cloud-init-generator
170107/usr/lib/systemd/system/
[email protected] /disable-sshd-keygen-if-cloud-init-active.conf
171108%{_unitdir}/cloud-*
172- %else
173- %attr(0755, root, root) %{_initddir}/cloud-config
174- %attr(0755, root, root) %{_initddir}/cloud-final
175- %attr(0755, root, root) %{_initddir}/cloud-init-local
176- %attr(0755, root, root) %{_initddir}/cloud-init
177- %endif
178109
179110# Program binaries
180111%{_bindir}/cloud-init*
0 commit comments