blob: 3e92c98fda9f8f26af32422225b77236cedc2c14 (
plain)
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
215
216
217
218
219
220
221
222
223
224
|
## template: cheetah
%{!?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}
BuildRequires: python-devel
BuildRequires: python-setuptools
%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}
#end for
# System util packages needed
%ifarch %{?ix86} x86_64 ia64
Requires: dmidecode
%endif
Requires: shadow-utils
Requires: rsyslog
Requires: iproute
Requires: e2fsprogs
Requires: net-tools
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}
#end for
# Custom patches
#set $size = 0
#for $p in $patches
Patch${size}: $p
#set $size += 1
#end for
%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
#set $size = 0
#for $p in $patches
%patch${size} -p1
#set $size += 1
#end for
%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}
%if "%{init_system}" == "systemd"
mkdir -p \$RPM_BUILD_ROOT/%{_unitdir}
cp -p systemd/* \$RPM_BUILD_ROOT/%{_unitdir}
%endif
%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*
# 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
%{_libexecdir}/%{name}
%dir %{_sharedstatedir}/cloud
# Python code is here...
%{python_sitelib}/*
|