forked from uyuni-project/uyuni
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsusemanager.spec
358 lines (323 loc) · 11.5 KB
/
susemanager.spec
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
#
# spec file for package susemanager
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%if 0%{?suse_version} > 1320 || 0%{?rhel} >= 8
# SLE15 and RHEL8 build on Python 3
%global build_py3 1
%endif
%define pythonX %{?build_py3:python3}%{!?build_py3:python2}
%if 0%{?rhel}
%global apache_user root
%global apache_group root
%global tftp_group root
%global salt_user root
%global salt_group root
%global serverdir %{_sharedstatedir}
%global wwwroot %{_localstatedir}/www
%global wwwdocroot %{wwwroot}/html
%endif
%if 0%{?suse_version}
%global apache_user wwwrun
%global apache_group www
%global tftp_group tftp
%global salt_user salt
%global salt_group salt
%global serverdir /srv
%global wwwroot %{serverdir}/www
%global wwwdocroot %{wwwroot}/htdocs
%endif
%global debug_package %{nil}
Name: susemanager
Version: 4.4.2
Release: 1
Summary: SUSE Manager specific scripts
License: GPL-2.0-only
Group: Applications/System
URL: https://github.com/uyuni-project/uyuni
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-build
#BuildArch: noarch - not noarch because of ifarch usage!!!!
%if 0%{?rhel}
BuildRequires: gettext
%endif
%if 0%{?build_py3}
BuildRequires: python3-devel
%else
BuildRequires: python-devel
%endif
# check section
%if 0%{?build_py3}
BuildRequires: python3-pycurl
%else
BuildRequires: python-curl
BuildRequires: python-mock
%endif
BuildRequires: python2
%if !0%{?rhel}
BuildRequires: pyxml
%endif
BuildRequires: spacewalk-backend >= 1.7.38.20
BuildRequires: spacewalk-backend-server
BuildRequires: spacewalk-backend-sql-postgresql
BuildRequires: suseRegisterInfo
%if 0%{?suse_version}
BuildRequires: %fillup_prereq
BuildRequires: %insserv_prereq
BuildRequires: postgresql-init
BuildRequires: tftp
Requires(pre): %fillup_prereq %insserv_prereq tftp postgresql-init
Requires(preun):%fillup_prereq %insserv_prereq tftp postgresql-init
Requires(post): user(%{apache_user})
Requires: yast2-users
%endif
Requires(pre): salt
Requires: cobbler
Requires: openslp-server
Requires: spacewalk-admin
Requires: spacewalk-setup
%ifarch %ix86 x86_64
Requires: syslinux
%endif
%ifarch s390x ppc64le
Requires: syslinux-x86_64
%endif
Requires: less
Requires: rsync
Requires: spacewalk-schema
Requires: susemanager-tools
# migration.sh need either sqlplus or psql
Requires: spacewalk-db-virtual
Recommends: susemanager-branding
BuildRequires: uyuni-base-server
Requires(pre): uyuni-base-server
# yast module dependency
%if 0%{?suse_version} > 1320
Requires: firewalld
%endif
Requires: postfix
Requires: reprepro >= 5.4
# mgr-setup want to call mksubvolume for btrfs filesystems
Recommends: snapper
# mgr-setup calls dig
Requires: bind-utils
%define python_sitelib %(%{pythonX} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
%global pythonsmroot %{python_sitelib}/spacewalk
%description
A collection of scripts for managing SUSE Manager's initial
setup tasks, re-installation, upgrades and managing.
%package tools
Summary: SUSE Manager Tools
Group: Productivity/Other
%if 0%{?build_py3}
Requires: createrepo_c
Requires: python3
Requires: python3-configobj
Requires: python3-uyuni-common-libs
BuildRequires: python3-configobj
%else
Requires: createrepo
Requires: python
Requires: python-argparse
Requires: python-configobj
Requires: python2-uyuni-common-libs
BuildRequires: python-configobj
Requires: python-enum34
BuildRequires: python-enum34
%endif
Requires: spacewalk-backend >= 2.1.55.11
Requires: spacewalk-backend-sql
Requires: spacewalk-common
Requires: suseRegisterInfo
Requires: susemanager-build-keys
Requires: susemanager-sync-data
BuildRequires: docbook-utils
%description tools
This package contains SUSE Manager tools
%prep
%setup -q
%build
# Fixing shebang for Python 3
%if 0%{?build_py3}
for i in `find . -type f`;
do
sed -i '1s=^#!/usr/bin/\(python\|env python\)[0-9.]*=#!/usr/bin/python3=' $i;
done
%endif
%install
mkdir -p %{buildroot}/%{_prefix}/lib/susemanager/bin/
mkdir -p %{buildroot}/%{_prefix}/lib/susemanager/hooks/
install -m 0755 bin/* %{buildroot}/%{_prefix}/lib/susemanager/bin/
ln -s mgr-setup %{buildroot}/%{_prefix}/lib/susemanager/bin/migration.sh
ln -s pg-migrate-94-to-96.sh %{buildroot}/%{_prefix}/lib/susemanager/bin/pg-migrate.sh
mkdir -p %{buildroot}/%{_prefix}/share/rhn/config-defaults
mkdir -p %{buildroot}/%{_sysconfdir}/slp.reg.d
mkdir -p %{buildroot}/%{_sysconfdir}/logrotate.d
install -m 0644 rhn-conf/rhn_server_susemanager.conf %{buildroot}/%{_prefix}/share/rhn/config-defaults
install -m 0644 etc/logrotate.d/susemanager-tools %{buildroot}/%{_sysconfdir}/logrotate.d
install -m 0644 etc/slp.reg.d/susemanager.reg %{buildroot}/%{_sysconfdir}/slp.reg.d
make -C src install PREFIX=$RPM_BUILD_ROOT PYTHON_BIN=%{pythonX} MANDIR=%{_mandir}
install -d -m 755 %{buildroot}/%{wwwroot}/os-images/
# empty repo for rhel base channels
mkdir -p %{buildroot}%{wwwdocroot}/pub/repositories/
cp -r pub/empty %{buildroot}%{wwwdocroot}/pub/repositories/
# empty repo for Ubuntu base fake channel
cp -r pub/empty-deb %{buildroot}%{wwwdocroot}/pub/repositories/
# YaST configuration
mkdir -p %{buildroot}%{_datadir}/YaST2/clients
mkdir -p %{buildroot}%{_datadir}/YaST2/scrconf
mkdir -p %{buildroot}%{_datadir}/applications/YaST2
mkdir -p %{buildroot}/etc/YaST2
install -m 0644 yast/*.rb %{buildroot}%{_datadir}/YaST2/clients
install -m 0644 yast/*.scr %{buildroot}%{_datadir}/YaST2/scrconf
%if 0%{?is_opensuse}
install -m 0644 yast/org.uyuni-project.yast2.Uyuni.desktop %{buildroot}%{_datadir}/applications/YaST2/org.uyuni-project.yast2.Uyuni.desktop
%else
install -m 0644 yast/com.suse.yast2.SUSEManager.desktop %{buildroot}%{_datadir}/applications/YaST2/com.suse.yast2.SUSEManager.desktop
%endif
%if 0%{?suse_version} > 1320
mkdir -p %{buildroot}/%{_prefix}/lib/firewalld/services
install -m 0644 etc/firewalld/services/suse-manager-server.xml %{buildroot}/%{_prefix}/lib/firewalld/services
%else
mkdir -p %{buildroot}/%{_sysconfdir}/firewalld/services
install -m 0644 etc/firewalld/services/suse-manager-server.xml %{buildroot}/%{_sysconfdir}/firewalld/services
%endif
%if 0%{?sle_version} && !0%{?is_opensuse}
# this script migrate the server to Uyuni. It should not be available on SUSE Manager
rm -f %{buildroot}/%{_prefix}/lib/susemanager/bin/server-migrator.sh
%endif
make -C po install PREFIX=$RPM_BUILD_ROOT
%find_lang susemanager
%check
# we need to build a fake python dir. python did not work with
# two site-package/spacewalk dirs having different content
mkdir -p /var/tmp/fakepython/spacewalk
cp -a %{python_sitelib}/spacewalk/* /var/tmp/fakepython/spacewalk/
cp -a %{buildroot}%{python_sitelib}/spacewalk/* /var/tmp/fakepython/spacewalk/
export PYTHONPATH=/var/tmp/fakepython/:%{_datadir}/rhn
make -f Makefile.susemanager PYTHON_BIN=%{pythonX} unittest
unset PYTHONPATH
rm -rf /var/tmp/fakepython
%if !0%{?build_py3}
pushd %{buildroot}
find -name '*.py' -print0 | xargs -0 python %py_libdir/py_compile.py
popd
%endif
%post
POST_ARG=$1
if [ -f /etc/sysconfig/atftpd ]; then
. /etc/sysconfig/atftpd
if [ $ATFTPD_DIRECTORY = "/tftpboot" ]; then
sysconf_addword -r /etc/sysconfig/atftpd ATFTPD_DIRECTORY "/tftpboot"
sysconf_addword /etc/sysconfig/atftpd ATFTPD_DIRECTORY "%{serverdir}/tftpboot"
fi
fi
if [ ! -d %{serverdir}/tftpboot ]; then
mkdir -p %{serverdir}/tftpboot
chmod 750 %{serverdir}/tftpboot
chown %{apache_user}:%{tftp_group} %{serverdir}/tftpboot
fi
# XE appliance overlay file created this with different user
chown root.root /etc/sysconfig
if [ $POST_ARG -eq 2 ] ; then
# when upgrading make sure /var/spacewalk/systems has the correct perms and owner
MOUNT_POINT=$(grep -oP "^mount_point =\s*\K([^ ]+)" /etc/rhn/rhn.conf || echo "/var/spacewalk")
SYSTEMS_DIR="$MOUNT_POINT/systems"
if [[ -d "$MOUNT_POINT" && ! -d "$SYSTEMS_DIR" ]]; then
mkdir $SYSTEMS_DIR
fi
if [ -d "$SYSTEMS_DIR" ]; then
chmod 775 "$SYSTEMS_DIR"
chown %{apache_user}:%{apache_group} "$SYSTEMS_DIR"
fi
fi
# else new install and the systems dir should be created by spacewalk-setup
# Fix permissions for existing swapfiles (bsc#1131954, CVE-2019-3684)
if [[ -f /SWAPFILE && $(stat -c "%a" "/SWAPFILE") != "600" ]]; then
chmod 600 /SWAPFILE
fi
%if !0%{?suse_version}
sed -i 's/su wwwrun www/su apache apache/' /etc/logrotate.d/susemanager-tools
%endif
%posttrans
%postun
%if 0%{?suse_version}
%{insserv_cleanup}
%endif
# Cleanup
sed -i '/You can access .* via https:\/\//d' /tmp/motd 2> /dev/null ||:
%files -f susemanager.lang
%defattr(-,root,root,-)
%doc COPYING
%dir %{_prefix}/lib/susemanager
%dir %{_prefix}/lib/susemanager/bin/
%dir %{_prefix}/lib/susemanager/hooks/
%dir /etc/YaST2
%dir %{_datadir}/YaST2
%dir %{_datadir}/YaST2/clients
%dir %{_datadir}/YaST2/scrconf
%dir %{_datadir}/applications/YaST2
%dir %{_sysconfdir}/slp.reg.d
%{_prefix}/lib/susemanager/bin/*
%{_datadir}/YaST2/clients/*.rb
%{_datadir}/YaST2/scrconf/*.scr
%config %{_sysconfdir}/slp.reg.d/susemanager.reg
%if 0%{?is_opensuse}
%{_datadir}/applications/YaST2/org.uyuni-project.yast2.Uyuni.desktop
%else
%{_datadir}/applications/YaST2/com.suse.yast2.SUSEManager.desktop
%endif
%attr(775,%{salt_user},susemanager) %dir %{wwwroot}/os-images/
%if 0%{?suse_version} > 1320
%{_prefix}/lib/firewalld/services/suse-manager-server.xml
%else
%{_sysconfdir}/firewalld/services/suse-manager-server.xml
%endif
%files tools
%defattr(-,root,root,-)
%dir %{pythonsmroot}
%dir %{pythonsmroot}/susemanager
%dir %{_prefix}/share/rhn/
%dir %{_datadir}/susemanager
%dir %{wwwdocroot}/pub
%dir %{wwwdocroot}/pub/repositories
%dir %{wwwdocroot}/pub/repositories/empty
%dir %{wwwdocroot}/pub/repositories/empty/repodata
%dir %{wwwdocroot}/pub/repositories/empty-deb
%config(noreplace) %{_sysconfdir}/logrotate.d/susemanager-tools
%{_prefix}/share/rhn/config-defaults/rhn_*.conf
%attr(0755,root,root) %{_bindir}/mgr-salt-ssh
%attr(0755,root,root) %{_sbindir}/mgr-clean-old-patchnames
%attr(0755,root,root) %{_sbindir}/mgr-create-bootstrap-repo
%attr(0755,root,root) %{_sbindir}/mgr-delete-patch
%attr(0755,root,root) %{_sbindir}/mgr-sync
%{pythonsmroot}/susemanager/__init__.py*
%{pythonsmroot}/susemanager/mgr_clean_old_patchnames.py*
%{pythonsmroot}/susemanager/mgr_delete_patch.py*
%{pythonsmroot}/susemanager/authenticator.py*
%{pythonsmroot}/susemanager/errata_helper.py*
%{pythonsmroot}/susemanager/helpers.py*
%{pythonsmroot}/susemanager/package_helper.py*
%{pythonsmroot}/susemanager/mgr_sync
%{_datadir}/susemanager/mgr_bootstrap_data.py*
%if 0%{?rhel} || 0%{?build_py3}
%{pythonsmroot}/susemanager/__pycache__/
%{pythonsmroot}/susemanager/mgr_sync/__pycache__/
%{_datadir}/susemanager/__pycache__/
%endif
%{_mandir}/man8/mgr-sync.8*
%{wwwdocroot}/pub/repositories/empty/repodata/*.xml*
%{wwwdocroot}/pub/repositories/empty-deb/Packages
%{wwwdocroot}/pub/repositories/empty-deb/Release
%changelog