summaryrefslogtreecommitdiff
path: root/packages/redhat/cloud-init.spec.in
blob: 30bcd050e1695eb8f76685bca8497f5fe9426a0f (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
## This is a cheetah template
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}

# 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

#for $d in $defines
%define ${d}
#end for

Name:           cloud-init
Version:        ${version}
Release:        ${release}${subrelease}%{?dist}
Summary:        Cloud instance init scripts

Group:          System Environment/Base
License:        GPLv3
URL:            http://launchpad.net/cloud-init

Source0:        ${archive_name}
BuildArch:      noarch
BuildRoot:      %{_tmppath}

BuildRequires:        python-devel
BuildRequires:        python-setuptools
BuildRequires:        python-cheetah

# System util packages needed
Requires:       shadow-utils
Requires:       rsyslog
Requires:       iproute
Requires:       e2fsprogs
Requires:       net-tools
Requires:       procps
Requires:       shadow-utils

# 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 $sysvinit
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

%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 %{name}-%{version}~${release}

# Custom patches activation
#set $size = 0
#for $p in $patches
%patch${size} -p1
#set $size += 1
#end for

%build
%{__python} setup.py build

%install
rm -rf \$RPM_BUILD_ROOT
%{__python} setup.py install -O1 \
            --skip-build --root \$RPM_BUILD_ROOT \
            --init-system=${init_sys}

# 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

%clean
rm -rf \$RPM_BUILD_ROOT

%post

#if $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
#end if

#if $sysvinit
/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

%preun

#if $sysvinit
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
#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

%postun

#if $systemd
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
#end if

%files

#if $sysvinit
%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
%{_unitdir}/cloud-*
#end if

# Program binaries
%{_bindir}/cloud-init*

# There doesn't seem to be an agreed upon place for these
# although it appears the standard says /usr/lib but rpmbuild
# will try /usr/lib64 ??
/usr/lib/%{name}/uncloud-init
/usr/lib/%{name}/write-ssh-key-fingerprints

# Docs
%doc TODO LICENSE ChangeLog Requires
%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

# Python code is here...
%{python_sitelib}/*

%changelog

${changelog}