forked from vmware/pmd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpmd.spec.in
302 lines (259 loc) · 8.53 KB
/
pmd.spec.in
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
%define _mech_file /etc/gss/mech
%define _mech_id 1.3.6.1.4.1.6876.11711.2.1.2
%define _python3_sitearch %(python3 -c "from distutils.sysconfig import get_python_lib; import sys; sys.stdout.write(get_python_lib(1))")
Summary: Photon Management Daemon
Name: pmd
Version: @VERSION@
Release: 1%{?dist}
License: Apache 2.0
URL: https://www.github.com/vmware/pmd
Group: Applications/System
Requires: likewise-open >= 6.2.9
Requires: netmgmt
Requires: systemd
Requires: tdnf >= 1.2.0
Requires: c-rest-engine
Requires: lightwave-client-libs
Requires: jansson
Requires: copenapi
Requires: %{name}-libs = %{version}-%{release}
BuildRequires: popt-devel
BuildRequires: rpm-devel
BuildRequires: tdnf-devel >= 1.2.0
BuildRequires: c-rest-engine-devel
BuildRequires: lightwave-devel
BuildRequires: netmgmt-devel
BuildRequires: jansson-devel
BuildRequires: copenapi-devel
BuildRequires: likewise-open-devel >= 6.2.9
BuildRequires: krb5-devel
BuildRequires: glib-devel
BuildRequires: curl-devel
Source0: %{name}-%{version}.tar.gz
%description
Photon Management Daemon
%package libs
Summary: photon management daemon libs
Requires: likewise-open >= 6.2.0
%description libs
photon management daemon libs used by server and clients
%package cli
BuildRequires: netmgmt-cli-devel >= 1.0.4-2
Summary: photon management daemon cmd line cli
Requires: %{name}-libs = %{version}-%{release}
Requires: likewise-open >= 6.2.0
Requires: lightwave-client-libs
%description cli
photon management daemon cmd line cli
%package devel
Summary: photon management daemon client devel
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
%description devel
photon management daemon client devel
%package python2
Summary: Python2 bindings for photon management daemon
Group: Development/Libraries
Requires: python2 >= 2.7
Requires: %{name}-cli = %{version}-%{release}
BuildRequires: python2-devel >= 2.7
%description python2
Python2 bindings for photon management daemon
%package python3
Summary: Python3 bindings for photon management daemon
Group: Development/Libraries
Requires: python3 >= 3.5
Requires: %{name}-cli = %{version}-%{release}
BuildRequires: python3-devel >= 3.5
%description python3
Python3 bindings for photon management daemon
%prep
%setup -q
%build
cd $RPM_BUILD_DIR/%{name}-%{version}
autoreconf -mif
./configure \
--prefix=%{_prefix} \
--bindir=%{_bindir} \
--libdir=%{_libdir} \
--sysconfdir=/etc \
--with-likewise=/opt/likewise \
--enable-python=no \
--enable-demo=yes \
--disable-static
make
pushd python
python2 setup.py build
python3 setup.py build
popd
%install
cd $RPM_BUILD_DIR/%{name}-%{version}
make DESTDIR=%{buildroot} install
rm -f %{buildroot}%{_libdir}/*.la
pushd python
python2 setup.py install --skip-build --root %{buildroot}
rm -f %{buildroot}%{python_sitearch}/pmd.so
python3 setup.py install --skip-build --root %{buildroot}
popd
install -d $RPM_BUILD_ROOT/var/log/pmd
install -D -m 444 pmd.service %{buildroot}/lib/systemd/system/pmd.service
install -D -m 444 pmdprivsepd.service %{buildroot}/lib/systemd/system/pmdprivsepd.service
install -D -m 444 conf/restapispec.json %{buildroot}/etc/pmd/restapispec.json
install -D -m 444 conf/api_sddl.conf %{buildroot}/etc/pmd/api_sddl.conf
install -D -m 444 conf/restconfig.txt %{buildroot}/etc/pmd/restconfig.txt
install -d -m 0755 %{buildroot}/usr/lib/tmpfiles.d/
install -m 0644 conf/pmd-tmpfiles.conf %{buildroot}/usr/lib/tmpfiles.d/%{name}.conf
# Pre-install
%pre
if ! getent group %{name} >/dev/null; then
/sbin/groupadd -r %{name}
fi
if ! getent passwd %{name} >/dev/null; then
/sbin/useradd -g %{name} %{name} -s /sbin/nologin
fi
# Post-install
%post
# First argument is 1 => New Installation
# First argument is 2 => Upgrade
sed -i "s/IPADDRESS_MARKER/`ifconfig eth0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'`/g" /etc/pmd/restapispec.json
/sbin/ldconfig
%systemd_post pmd.service
if [ ! -d "%{_libdir}/gss" ] ; then
mkdir %{_libdir}/gss
fi
# Add libgssapi_unix.so to GSSAPI plugin directory
if [ ! -h %{_libdir}/gss/libgssapi_unix.so ]; then
/bin/ln -sf %{_libdir}/libgssapi_unix.so %{_libdir}/gss/libgssapi_unix.so
fi
# Add gssapi_unix plugin configuration to GSS mech file
if [ -f "%{_mech_file}" ]; then
if [ `grep -c "%{_mech_id}" "%{_mech_file}"` -lt 1 ]; then
echo "unix %{_mech_id} libgssapi_unix.so" >> "%{_mech_file}"
fi
fi
if [ "$1" = 1 ]; then
openssl req \
-new \
-newkey rsa:2048 \
-days 365 \
-nodes \
-x509 \
-subj "/C=US/ST=WA/L=Bellevue/O=vmware/CN=photon-pmd-default" \
-keyout /etc/pmd/server.key \
-out /etc/pmd/server.crt
chmod 0400 /etc/pmd/server.key
chown %{name} /etc/pmd/server.key
openssl genrsa -out /etc/pmd/privsep_priv.key 2048
openssl rsa -in /etc/pmd/privsep_priv.key -pubout > /etc/pmd/privsep_pub.key
chmod 0400 /etc/pmd/privsep*.key
chown %{name} /etc/pmd/privsep_pub.key
fi
%tmpfiles_create %_tmpfilesdir/%{name}.conf
# Pre-uninstall
%preun
# First argument is 0 => Uninstall
# First argument is 1 => Upgrade
%systemd_preun pmd.service
%systemd_preun pmdprivsepd.service
if [ "$1" = 0 ]; then
if [ ! -e %{_bindir}/pmd-cli ]; then
# Cleanup GSSAPI UNIX symlink
if [ -h %{_libdir}/gss/libgssapi_unix.so ]; then
rm -f %{_libdir}/gss/libgssapi_unix.so
fi
# Remove GSSAPI SRP plugin configuration from GSS mech file
if [ -f "%{_mech_file}" ]; then
if [ `grep -c "%{_mech_id}" "%{_mech_file}"` -gt 0 ]; then
cat "%{_mech_file}" | sed '/%{_mech_id}/d' > "/tmp/mech-$$"
if [ -s /tmp/mech-$$ ]; then
mv "/tmp/mech-$$" "%{_mech_file}"
fi
fi
fi
fi
fi
# Post-uninstall
%postun
/sbin/ldconfig
%systemd_postun_with_restart pmd.service
%systemd_postun_with_restart pmdprivsepd.service
# First argument is 0 => Uninstall
# First argument is 1 => Upgrade
if [ $1 -eq 0 ] ; then
if getent passwd %{name} >/dev/null; then
/sbin/userdel %{name}
fi
if getent group %{name} >/dev/null; then
/sbin/groupdel %{name}
fi
mv /var/log/%{name}/restServer.log /var/log/%{name}/restServer.log.old
fi
# Post pmd-cli
%post cli
if [ ! -d "%{_libdir}/gss" ] ; then
mkdir %{_libdir}/gss
fi
# Add libgssapi_unix.so to GSSAPI plugin directory
if [ ! -h %{_libdir}/gss/libgssapi_unix.so ]; then
/bin/ln -sf %{_libdir}/libgssapi_unix.so %{_libdir}/gss/libgssapi_unix.so
fi
# Add gssapi_unix plugin configuration to GSS mech file
if [ -f "%{_mech_file}" ]; then
if [ `grep -c "%{_mech_id}" "%{_mech_file}"` -lt 1 ]; then
echo "unix %{_mech_id} libgssapi_unix.so" >> "%{_mech_file}"
fi
fi
# Pre-uninstall cli
%preun cli
# First argument is 0 => Uninstall
# First argument is 1 => Upgrade
if [ "$1" = 0 ]; then
if [ ! -e %{_bindir}/pmd ]; then
# Cleanup GSSAPI UNIX symlink
if [ -h %{_libdir}/gss/libgssapi_unix.so ]; then
rm -f %{_libdir}/gss/libgssapi_unix.so
fi
# Remove GSSAPI SRP plugin configuration from GSS mech file
if [ -f "%{_mech_file}" ]; then
if [ `grep -c "%{_mech_id}" "%{_mech_file}"` -gt 0 ]; then
cat "%{_mech_file}" | sed '/%{_mech_id}/d' > "/tmp/mech-$$"
if [ -s /tmp/mech-$$ ]; then
mv "/tmp/mech-$$" "%{_mech_file}"
fi
fi
fi
fi
fi
# Post-uninstall
%postun cli
/sbin/ldconfig
%clean
rm -rf %{buildroot}/*
%files
%defattr(-,root,root,0755)
%{_bindir}/pmd
%{_bindir}/pmdprivsepd
/lib/systemd/system/pmd.service
/lib/systemd/system/pmdprivsepd.service
/etc/pmd/pmd.conf
/etc/pmd/api_sddl.conf
/etc/pmd/restapispec.json
/etc/pmd/restconfig.txt
%attr(0766, %{name}, %{name}) %dir /var/log/%{name}
%_tmpfilesdir/%{name}.conf
%files libs
%{_libdir}/libpmdclient.so*
%files cli
%{_bindir}/pmd-cli
%files devel
%{_includedir}/pmd/*.h
%{_libdir}/pkgconfig/pmdclient.pc
%files python2
%{python_sitearch}/%{name}/
%{python_sitearch}/%{name}_python-*.egg-info
%files python3
%{_python3_sitearch}/%{name}/
%{_python3_sitearch}/%{name}_python-*.egg-info
%changelog
* Thu May 04 2017 Priyesh Padmavilasom <[email protected]> 0.1-1
- Initial build. First version