Ubuntu Pastebin

Paste from rharper at Wed, 7 Jun 2017 18:00:57 +0000

Download as text
  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
commit 28eb9340a31434987b1119a5fa4d1e729ff7c02b (HEAD -> centos-spec-build-deps)
Author: Ryan Harper <ryan.harper@canonical.com>
Date:   Wed Jun 7 12:00:14 2017 -0500

    Update redhat specfile template to work on el6 and el7
    
    - Use rpm macros for init-system chunks and drop use
      of init_system variable template
    - Don't pass boot parameter when building srpm
    - Add el6 only build-req on python-argparse

diff --git a/Makefile b/Makefile
index 877b949..043a284 100644
--- a/Makefile
+++ b/Makefile
@@ -87,7 +87,7 @@ rpm:
 	$(PYVER) ./packages/brpm --distro=$(distro) --boot=$(INIT_SYSTEM)
 
 srpm:
-	$(PYVER) ./packages/brpm --srpm --distro=$(distro) --boot=$(INIT_SYSTEM)
+	$(PYVER) ./packages/brpm --srpm --distro=$(distro)
 
 deb:
 	@which debuild || \
diff --git a/packages/redhat/cloud-init.spec.in b/packages/redhat/cloud-init.spec.in
index b16b0f6..2894602 100644
--- a/packages/redhat/cloud-init.spec.in
+++ b/packages/redhat/cloud-init.spec.in
@@ -1,6 +1,12 @@
 ## template: cheetah
 %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
 
+%if %{undefined systemd_requires}
+%define init_system sysvinit
+%else
+%define init_system systemd
+%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
@@ -21,6 +27,9 @@ BuildRoot:      %{_tmppath}
 BuildRequires:  python-devel
 BuildRequires:  python-setuptools
 BuildRequires:  python-cheetah
+%if "%{?el6}" == "1"
+BuildRequires:  python-argparse
+%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.
@@ -53,19 +62,15 @@ Patch${size}: $p
 #set $size += 1
 #end for
 
-#if $sysvinit
+%if "%{init_system}" == "systemd"
+BuildRequires:  systemd-units
+%{systemd_requires}
+%else
 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
+%endif
 
 %description
 Cloud-init is a set of init scripts for cloud instances.  Cloud instances
@@ -89,7 +94,7 @@ ssh keys and to let the user run various scripts.
 
 %{__python} setup.py install -O1 \
             --skip-build --root \$RPM_BUILD_ROOT \
-            --init-system=${init_sys}
+            --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
@@ -104,17 +109,17 @@ rm -rf \$RPM_BUILD_ROOT%{python_sitelib}/tests
 mkdir -p \$RPM_BUILD_ROOT/%{_sharedstatedir}/cloud
 mkdir -p \$RPM_BUILD_ROOT/%{_libexecdir}/%{name}
 
-#if $systemd
+%if "%{init_system}" == "systemd"
 mkdir -p         \$RPM_BUILD_ROOT/%{_unitdir}
 cp -p systemd/*  \$RPM_BUILD_ROOT/%{_unitdir}
-#end if
+%endif
 
 %clean
 rm -rf \$RPM_BUILD_ROOT
 
 %post
 
-#if $systemd
+%if "%{init_system}" == "systemd"
 if [ \$1 -eq 1 ]
 then
     /bin/systemctl enable cloud-config.service     >/dev/null 2>&1 || :
@@ -122,18 +127,24 @@ then
     /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
+%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
-#end if
+%endif
 
 %preun
 
-#if $sysvinit
+%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 || :
@@ -145,39 +156,27 @@ then
     /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
+%endif
 
 %postun
 
-#if $systemd
+%if "%{init_system}" == "systemd"
 /bin/systemctl daemon-reload >/dev/null 2>&1 || :
-#end if
+%endif
 
 %files
 
 /lib/udev/rules.d/66-azure-ephemeral.rules
 
-#if $sysvinit
+%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
-#end if
-
-#if $systemd
-/usr/lib/systemd/system-generators/cloud-init-generator
-%{_unitdir}/cloud-*
-#end if
+%endif
 
 %{_sysconfdir}/NetworkManager/dispatcher.d/hook-network-manager
 %{_sysconfdir}/dhcp/dhclient-exit-hooks.d/hook-dhclient
Download as text