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
|
%global tftpboot_dir %{_sharedstatedir}/tftpboot/
%global vendor_lower `echo %{_vendor}|tr 'A-Z' 'a-z'`
%global selinuxtype targeted
Name: cobbler
Version: 3.3.7
Release: 4%{?dist}
Summary: Boot server configurator
URL: https://cobbler.github.io/
# Automatically converted from old format: GPLv2+ - review is highly recommended.
License: GPL-2.0-or-later
Source0: https://github.com/cobbler/cobbler/archive/v%{version}/%{name}-%{version}.tar.gz
Source1: migrate-settings.sh
Source2: %{name}.te
Source3: %{name}.if
Source4: %{name}.fc
Source5: mkgrub.sh
# Do not run coverage tests
Patch0: cobbler-nocov.patch
Patch1: 0001-adapt-to-openEuler.patch
Patch2: 0001-modify-the-templates-etc-dhcp.template.patch
BuildArch: noarch
BuildRequires: make
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-dns
BuildRequires: python%{python3_pkgversion}-magic
# Cheetah switched names from Cheetah3 to CT3 in its metadata in version 3.3.0.
# https://github.com/CheetahTemplate3/cheetah3/commit/673259b2d139b4ea970b1c2da12607b7ac39cbec
BuildRequires: %{py3_dist cheetah3}
BuildRequires: %{py3_dist distro}
BuildRequires: %{py3_dist netaddr}
BuildRequires: %{py3_dist pyyaml}
BuildRequires: %{py3_dist requests}
BuildRequires: %{py3_dist schema}
BuildRequires: %{py3_dist setuptools}
# For docs
BuildRequires: %{py3_dist sphinx}
# This ensures that the *-selinux package and all it’s dependencies are not pulled
# into containers and other systems that do not use SELinux
Requires: (%{name}-selinux if selinux-policy-%{selinuxtype})
Requires: httpd
Requires: tftp-server
Requires: dosfstools
Requires: createrepo_c
Requires: rsync
Requires: xorriso
Requires: genisoimage
# Not everyone wants bash-completion...?
Recommends: bash-completion
Requires: dnf-plugins-core
# syslinux is only available on x86
Requires: (syslinux if (filesystem.x86_64 or filesystem.i686))
# grub2 efi stuff is only available on x86
Recommends: grub2-efi-ia32
Recommends: grub2-efi-x64
Recommends: logrotate
Recommends: %{py3_dist librepo}
# https://github.com/cobbler/cobbler/issues/1685
Requires: /sbin/service
Obsoletes: cobbler-web < 3.3
BuildRequires: systemd
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%description
Cobbler is a network install server. Cobbler supports PXE, ISO
virtualized installs, and re-installing existing Linux machines. The
last two modes use a helper tool, 'koan', that integrates with cobbler.
Cobbler's advanced features include importing distributions from DVDs
and rsync mirrors, kickstart templating, integrated yum mirroring, and
built-in DHCP/DNS Management. Cobbler has a XML-RPC API for integration
with other applications.
%package selinux
Summary: SELinux policies for %{name}
Requires: selinux-policy-%{selinuxtype}
Requires(post): selinux-policy-%{selinuxtype}
BuildRequires: selinux-policy-devel
BuildArch: noarch
%{?selinux_requires}
%description selinux
SELinux policies for %{name}.
%package tests
Summary: Unit tests for cobbler
Requires: cobbler = %{version}-%{release}
%description tests
Unit test files from the Cobbler project.
%package tests-containers
Summary: Dockerfiles and scripts to setup testing containers
Requires: cobbler = %{version}-%{release}
%description tests-containers
Dockerfiles and scripts to setup testing containers.
%prep
%autosetup -p1
mkdir -p selinux
cp -p %{SOURCE2} %{SOURCE3} %{SOURCE4} selinux/
sed -i "s/generic_os/%{_vendor}/g" distro_build_configs.sh
sed -i "s/generic_os/%{_vendor}/g" config/cobbler/distro_signatures.json
sed -i "s/generic_lower_os/%{vendor_lower}/g" cobbler/actions/check.py
sed -i "s/generic_lower_os/%{vendor_lower}/g" cobbler/utils.py
sed -i "s/generic_lower_os/%{vendor_lower}/g" config/cobbler/distro_signatures.json
sed -i "s/generic_lower_os/%{vendor_lower}/g" cobbler/tftpgen.py
sed -i "s/generic_lower_os/%{vendor_lower}/g" cobbler/autoinstallgen.py
%build
. ./distro_build_configs.sh
%py3_build
make man
# SELinux
make -f %{_datadir}/selinux/devel/Makefile %{name}.pp
bzip2 -9 %{name}.pp
%install
. ./distro_build_configs.sh
# bypass install errors ( don't chown in install step)
%py3_install ||:
# cobbler
rm %{buildroot}%{_sysconfdir}/cobbler/cobbler.conf
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
mv %{buildroot}%{_sysconfdir}/cobbler/cobblerd_rotate %{buildroot}%{_sysconfdir}/logrotate.d/cobblerd
# Create data directories in tftpboot_dir
mkdir -p %{buildroot}%{tftpboot_dir}/{boot,etc,grub/system{,_link},images{,2},ppc,pxelinux.cfg,s390x}
# systemd - move to proper location
mkdir -p %{buildroot}%{_unitdir}
mv %{buildroot}%{_sysconfdir}/cobbler/cobblerd.service %{buildroot}%{_unitdir}
# ghosted files
touch %{buildroot}%{_sharedstatedir}/cobbler/web.ss
# migrate-settings.sh
install -p -m0755 %SOURCE1 %{buildroot}%{_datadir}/cobbler/bin/migrate-settings.sh
# mkgrub.sh
install -p -m0755 %SOURCE5 %{buildroot}%{_datadir}/cobbler/bin/mkgrub.sh
# SELinux
install -D -m 0644 %{name}.pp.bz2 %{buildroot}%{_datadir}/selinux/packages/%{selinuxtype}/%{name}.pp.bz2
install -D -p -m 0644 selinux/%{name}.if %{buildroot}%{_datadir}/selinux/devel/include/distributed/%{name}.if
%check
# These require an installed system with root access
#pytest -v
%pre
if [ $1 -ge 2 ]; then
# package upgrade: backup configuration
DATE=$(date "+%%Y%%m%%d-%%H%%M%%S")
if [ ! -d "%{_sharedstatedir}/cobbler/backup/upgrade-${DATE}" ]; then
mkdir -p "%{_sharedstatedir}/cobbler/backup/upgrade-${DATE}"
fi
for i in "config" "snippets" "templates" "triggers" "scripts"; do
if [ -d "%{_sharedstatedir}/cobbler/${i}" ]; then
cp -r "%{_sharedstatedir}/cobbler/${i}" "%{_sharedstatedir}/cobbler/backup/upgrade-${DATE}"
fi
done
if [ -d %{_sysconfdir}/cobbler ]; then
cp -r %{_sysconfdir}/cobbler "%{_sharedstatedir}/cobbler/backup/upgrade-${DATE}"
fi
fi
%post
%systemd_post cobblerd.service
# Fixup permission for world readable settings files
chmod 640 %{_sysconfdir}/cobbler/settings.yaml
chmod 600 %{_sysconfdir}/cobbler/mongodb.conf
chmod 600 %{_sysconfdir}/cobbler/modules.conf
chmod 640 %{_sysconfdir}/cobbler/users.conf
chmod 640 %{_sysconfdir}/cobbler/users.digest
chmod 750 %{_sysconfdir}/cobbler/settings.d
chmod 640 %{_sysconfdir}/cobbler/settings.d/*
chgrp apache %{_sysconfdir}/cobbler/settings.yaml
chgrp apache %{_sysconfdir}/cobbler/users.conf
chgrp apache %{_sysconfdir}/cobbler/users.digest
chgrp apache %{_sysconfdir}/cobbler/settings.d
chgrp apache %{_sysconfdir}/cobbler/settings.d/*
# Change from apache
if [ -f %{_sharedstatedir}/cobbler/web.ss ]; then
chown root %{_sharedstatedir}/cobbler/web.ss
fi
%posttrans
# Migrate pre-3.2.1 settings to settings.yaml
if [ -f %{_sysconfdir}/cobbler/settings.rpmsave ]; then
echo warning: migrating old settings to settings.yaml
mv %{_sysconfdir}/cobbler/settings.yaml{,.rpmnew}
cp -a %{_sysconfdir}/cobbler/settings.{rpmsave,rpmorig}
mv %{_sysconfdir}/cobbler/settings.{rpmsave,yaml}
%{_datadir}/cobbler/bin/migrate-settings.sh
fi
# Add some missing options if needed
grep -q '^reposync_rsync_flags:' %{_sysconfdir}/cobbler/settings.yaml || echo -e '#ADDED:\nreposync_rsync_flags: "-rltDv --copy-unsafe-links"' >> %{_sysconfdir}/cobbler/settings.yaml
# Migrate pre-3 configuration data if needed
if [ -d %{_sharedstatedir}/cobbler/kickstarts -a $(find %{_sharedstatedir}/cobbler/collections -type f | wc -l) -eq 0 ]; then
echo warning: migrating pre cobbler 3 configuration data
%{_datadir}/cobbler/bin/migrate-data-v2-to-v3.py
fi
%preun
%systemd_preun cobblerd.service
%postun
%systemd_postun_with_restart cobblerd.service
%pre selinux
%selinux_relabel_pre -s %{selinuxtype}
%post selinux
%selinux_modules_install -s %{selinuxtype} %{_datadir}/selinux/packages/%{selinuxtype}/%{name}.pp.bz2
%selinux_relabel_post -s %{selinuxtype}
if [ "$1" -le "1" ]; then # First install
# the daemon needs to be restarted for the custom label to be applied
%systemd_postun_with_restart cobblerd.service
fi
%postun selinux
if [ $1 -eq 0 ]; then
%selinux_modules_uninstall -s %{selinuxtype} %{name}
%selinux_relabel_post -s %{selinuxtype}
fi
%files
%license COPYING
%doc AUTHORS.in README.md
%doc docs/developer-guide.rst docs/quickstart-guide.rst docs/installation-guide.rst
%dir %{_sysconfdir}/cobbler
%config(noreplace) %{_sysconfdir}/cobbler/auth.conf
%config(noreplace) %{_sysconfdir}/cobbler/boot_loader_conf/
%config(noreplace) %{_sysconfdir}/cobbler/cheetah_macros
%config(noreplace) %{_sysconfdir}/cobbler/dhcp.template
%config(noreplace) %{_sysconfdir}/cobbler/dhcp6.template
%config(noreplace) %{_sysconfdir}/cobbler/dnsmasq.template
%config(noreplace) %{_sysconfdir}/cobbler/genders.template
%config(noreplace) %{_sysconfdir}/cobbler/import_rsync_whitelist
%config(noreplace) %{_sysconfdir}/cobbler/iso/
%config(noreplace) %{_sysconfdir}/cobbler/logging_config.conf
%attr(600, root, root) %config(noreplace) %{_sysconfdir}/cobbler/modules.conf
%attr(600, root, root) %config(noreplace) %{_sysconfdir}/cobbler/mongodb.conf
%config(noreplace) %{_sysconfdir}/cobbler/named.template
%config(noreplace) %{_sysconfdir}/cobbler/ndjbdns.template
%config(noreplace) %{_sysconfdir}/cobbler/reporting/
%config(noreplace) %{_sysconfdir}/cobbler/rsync.exclude
%config(noreplace) %{_sysconfdir}/cobbler/rsync.template
%config(noreplace) %{_sysconfdir}/cobbler/secondary.template
%attr(640, root, apache) %config(noreplace) %{_sysconfdir}/cobbler/settings.yaml
%attr(750, root, apache) %dir %{_sysconfdir}/cobbler/settings.d
%attr(640, root, apache) %config(noreplace) %{_sysconfdir}/cobbler/settings.d/bind_manage_ipmi.settings
%attr(640, root, apache) %config(noreplace) %{_sysconfdir}/cobbler/settings.d/manage_genders.settings
%attr(640, root, apache) %config(noreplace) %{_sysconfdir}/cobbler/settings.d/nsupdate.settings
%attr(640, root, apache) %config(noreplace) %{_sysconfdir}/cobbler/settings.d/windows.settings
%attr(640, root, apache) %config(noreplace) %{_sysconfdir}/cobbler/users.conf
%attr(640, root, apache) %config(noreplace) %{_sysconfdir}/cobbler/users.digest
%config(noreplace) %{_sysconfdir}/cobbler/version
%config(noreplace) %{_sysconfdir}/cobbler/windows/
%config(noreplace) %{_sysconfdir}/cobbler/zone.template
%config(noreplace) %{_sysconfdir}/cobbler/zone_templates/
%config(noreplace) %{_sysconfdir}/logrotate.d/cobblerd
%config(noreplace) /etc/httpd/conf.d/cobbler.conf
%{_bindir}/cobbler
%{_bindir}/cobbler-settings
%{_bindir}/cobbler-ext-nodes
%{_bindir}/cobblerd
%{_datadir}/bash-completion/
%dir %{_datadir}/cobbler
%{_datadir}/cobbler/bin
%{_mandir}/man1/cobbler.1*
%{_mandir}/man5/cobbler.conf.5*
%{_mandir}/man8/cobblerd.8*
%{python3_sitelib}/cobbler/
%{python3_sitelib}/cobbler*.egg-info
%{_unitdir}/cobblerd.service
%{tftpboot_dir}/*
/var/www/cobbler
%dir %{_sharedstatedir}/cobbler
%ghost %attr(0755,root,root) %{_sharedstatedir}/cobbler/backup/
%config(noreplace) %{_sharedstatedir}/cobbler/collections/
%config(noreplace) %{_sharedstatedir}/cobbler/distro_signatures.json
%config(noreplace) %{_sharedstatedir}/cobbler/grub_config/
%config(noreplace) %{_sharedstatedir}/cobbler/loaders/
%config(noreplace) %{_sharedstatedir}/cobbler/scripts/
%config(noreplace) %{_sharedstatedir}/cobbler/snippets/
%config(noreplace) %{_sharedstatedir}/cobbler/templates/
%config(noreplace) %{_sharedstatedir}/cobbler/triggers/
%ghost %attr(0644,root,root) %{_sharedstatedir}/cobbler/lock
# Currently used for cli auth
%ghost %attr(0644,root,root) %{_sharedstatedir}/cobbler/web.ss
/var/log/cobbler
%files selinux
%{_datadir}/selinux/packages/%{selinuxtype}/%{name}.pp.*
%{_datadir}/selinux/devel/include/distributed/%{name}.if
%ghost %verify(not md5 size mode mtime) %{_sharedstatedir}/selinux/%{selinuxtype}/active/modules/200/%{name}
%files tests
%{_datadir}/cobbler/tests/
%files tests-containers
%{_datadir}/cobbler/docker/
%changelog
* Wed Mar 19 2025 YanZhicong <mryanzhicong@163.com> - 3.3.7-4
- add the mkgrub.sh
* Wed Mar 19 2025 YanZhicong <mryanzhicong@163.com> - 3.3.7-3
- modify the templates/etc/dhcp.template
* Wed Mar 19 2025 YanZhicong <mryanzhicong@163.com> - 3.3.7-2
- adapt to openEuler
* Sun Nov 17 2024 Orion Poplawski <orion@nwra.com> - 3.3.7-1
- Update to 3.3.7 (CVE-2024-47533)
|