1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
## 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-licesed GPLv3 or Apache 2.0
URL: http://launchpad.net/cloud-init
Source0: {{archive_name}}
BuildArch: noarch
BuildRoot: %{_tmppath}
%if "%{?el6}" == "1"
BuildRequires: python-argparse
%endif
%if %{use_systemd}
Requires: systemd
BuildRequires: systemd
Requires: systemd-units
BuildRequires: systemd-units
%else
Requires: initscripts >= 8.36
Requires(postun): initscripts
Requires(post): chkconfig
Requires(preun): chkconfig
%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}}
{% endfor %}
# System util packages needed
%ifarch %{?ix86} x86_64 ia64
Requires: dmidecode
%endif
# python2.6 needs argparse
%if "%{?el6}" == "1"
Requires: python-argparse
%endif
# Install 'dynamic' runtime reqs from *requirements.txt and pkg-deps.json
{% for r in requires %}
Requires: {{r}}
{% endfor %}
# Custom patches
{% for p in patches %}
Patch{{loop.index0}}: {{p}}
{% endfor %}
%if "%{init_system}" == "systemd"
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%else
Requires(post): chkconfig
Requires(postun): initscripts
Requires(preun): chkconfig
Requires(preun): initscripts
%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}}
# Custom patches activation
{% for p in patches %}
%patch{{loop.index0}} -p1
{% endfor %}
%build
%{__python} setup.py build
%install
%{__python} setup.py install -O1 \
--skip-build --root $RPM_BUILD_ROOT \
--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
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d
cp -p tools/21-cloudinit.conf \
$RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d/21-cloudinit.conf
# Remove the tests
rm -rf $RPM_BUILD_ROOT%{python_sitelib}/tests
# Required dirs...
mkdir -p $RPM_BUILD_ROOT/%{_sharedstatedir}/cloud
mkdir -p $RPM_BUILD_ROOT/%{_libexecdir}/%{name}
# 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 )
%clean
rm -rf $RPM_BUILD_ROOT
%post
%if "%{init_system}" == "systemd"
if [ $1 -eq 1 ]
then
/bin/systemctl enable cloud-config.service >/dev/null 2>&1 || :
/bin/systemctl enable cloud-final.service >/dev/null 2>&1 || :
/bin/systemctl enable cloud-init.service >/dev/null 2>&1 || :
/bin/systemctl enable cloud-init-local.service >/dev/null 2>&1 || :
fi
%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
%endif
%preun
%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 || :
/sbin/chkconfig --del cloud-init || :
/sbin/service cloud-init-local stop >/dev/null 2>&1 || :
/sbin/chkconfig --del cloud-init-local || :
/sbin/service cloud-config stop >/dev/null 2>&1 || :
/sbin/chkconfig --del cloud-config || :
/sbin/service cloud-final stop >/dev/null 2>&1 || :
/sbin/chkconfig --del cloud-final || :
fi
%endif
%postun
%if "%{init_system}" == "systemd"
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
%endif
%files
/lib/udev/rules.d/66-azure-ephemeral.rules
%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
%endif
%{_sysconfdir}/NetworkManager/dispatcher.d/hook-network-manager
%{_sysconfdir}/dhcp/dhclient-exit-hooks.d/hook-dhclient
# Program binaries
%{_bindir}/cloud-init*
%{_bindir}/cloud-id*
# Docs
%doc LICENSE ChangeLog TODO.rst requirements.txt
%doc %{_defaultdocdir}/cloud-init/*
# Configs
%config(noreplace) %{_sysconfdir}/cloud/cloud.cfg
%dir %{_sysconfdir}/cloud/cloud.cfg.d
%config(noreplace) %{_sysconfdir}/cloud/cloud.cfg.d/*.cfg
%config(noreplace) %{_sysconfdir}/cloud/cloud.cfg.d/README
%dir %{_sysconfdir}/cloud/templates
%config(noreplace) %{_sysconfdir}/cloud/templates/*
%config(noreplace) %{_sysconfdir}/rsyslog.d/21-cloudinit.conf
%{_sysconfdir}/bash_completion.d/cloud-init
%{_libexecdir}/%{name}
%dir %{_sharedstatedir}/cloud
# Python code is here...
%{python_sitelib}/*
|