forked from openSUSE/suse-module-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
suse-module-tools.spec
257 lines (227 loc) · 9.41 KB
/
suse-module-tools.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
#
# spec file for package suse-module-tools
#
# Copyright (c) 2021 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/
#
# Location for modprobe and depmod .conf files
#
# This assumes post-usr-merge (20210527) for Tumbleweed
%global modprobe_dir /usr/lib/modprobe.d
%global depmod_dir /usr/lib/depmod.d
%global dracutlibdir %{_prefix}/lib/dracut
%global with_kernel_sysctl 1
# boot_sysctl may be dropped on TW when we can assume that nobody keeps
# kernel packages around that store sysctl files under /boot
%bcond_without boot_sysctl
%global sysctl_dropin %{_unitdir}/systemd-sysctl.service.d/50-kernel-uname_r.conf
%global systemd_units %{?with_boot_sysctl:boot-sysctl.service} %{?with_kernel_sysctl:kernel-sysctl.service}
# List of legacy file systems to be blacklisted by default
%global fs_blacklist adfs affs bfs befs cramfs efs erofs exofs f2fs freevxfs hfs hfsplus hpfs jffs2 jfs kafs minix nilfs2 ntfs ntfs3 omfs orangefs pstore qnx4 qnx6 reiserfs romfs sysv ufs zonefs
# List of all files installed under modprobe.d
# Note: this list contains files installed by previous versions, like 00-system-937216.conf!
%global modprobe_conf_files 00-system 00-system-937216 10-unsupported-modules 50-blacklist 60-blacklist_fs-* 99-local
%global modprobe_conf_rpmsave %(echo "%{modprobe_conf_files}" | sed 's,\\([^ ]*\\),%{_sysconfdir}/modprobe.d/\\1.conf.rpmsave,g')
Name: suse-module-tools
Version: 16.0.52
Release: 0
Summary: Configuration for module loading and SUSE-specific utilities for KMPs
License: GPL-2.0-or-later
Group: System/Base
URL: https://github.com/openSUSE/suse-module-tools
Source0: %{name}-%{version}.tar.xz
Source1: %{name}.rpmlintrc
BuildRequires: systemd-rpm-macros
Requires: /usr/bin/grep
Requires: /usr/bin/gzip
Requires: /usr/bin/sed
Requires: coreutils
Requires: findutils
Requires: systemd-rpm-macros
Requires: rpm
Requires(post): /usr/bin/grep
Requires(post): /usr/bin/sed
Requires(post): coreutils
Provides: udev-extra-rules = 0.3.0
Obsoletes: udev-extra-rules < 0.3.0
Provides: system-tuning-common-SUSE = 0.3.0
Obsoletes: system-tuning-common-SUSE < 0.3.0
# Use weak dependencies for dracut and kmod in order to
# keep Ring0 lean. In normal deployments, these packages
# will be available anyway.
Recommends: dracut
Recommends: kmod
# This release requires the dracut module 90nvdimm
Conflicts: dracut < 49.1
# TW: conflict with pre-usrmerge
Conflicts: filesystem < 16
# Adds an ordering edge (from @mls)
Suggests: sdbootutil
Requires: (sdbootutil > 1+git20240829 if sdbootutil)
%description
This package contains helper scripts for KMP installation and
uninstallation, as well as default configuration files for depmod and
modprobe.
%package scriptlets
Summary: Kernel rpm scriptlets
Provides: suse-kernel-rpm-scriptlets = 0
Requires: suse-module-tools = %{version}
Provides: suse-module-tools:/usr/lib/module-init-tools/kernel-scriptlets
Provides: sdbootutil-rpm-scriptlets = 2.0
Obsoletes: sdbootutil-rpm-scriptlets < 2.0
%description scriptlets
Scripts called by the SUSE kernel packages on installation
%prep
%setup -q
%build
sed -i 's/@FS_BLACKLIST@.*/%{fs_blacklist}/' README.md
%install
install -d -m 755 "%{buildroot}%{modprobe_dir}"
install -d -m 755 "%{buildroot}%{_sysconfdir}/modprobe.d"
install -pm644 -t "%{buildroot}%{modprobe_dir}" modprobe.conf/common/*.conf
if [ -d modprobe.conf/%{_arch} ]; then
install -pm644 -t "%{buildroot}%{modprobe_dir}" modprobe.conf/%{_arch}/*.conf
fi
%ifarch i386
install -pm644 -t "%{buildroot}%{modprobe_dir}" modprobe.conf/x86_64/*.conf
%endif
%ifarch ppc64le
install -pm644 -t "%{buildroot}%{modprobe_dir}" modprobe.conf/ppc64/*.conf
%endif
install -d -m 755 "%{buildroot}/%{depmod_dir}"
install -d -m 755 "%{buildroot}%{_sysconfdir}/depmod.d"
install -pm 644 "depmod-00-system.conf" "%{buildroot}%{depmod_dir}/00-system.conf"
# "/usr/lib/module-init-tools" name hardcoded in other packages
install -d -m 755 "%{buildroot}/usr/lib/module-init-tools"
install -pm 755 -t "%{buildroot}/usr/lib/module-init-tools/" \
weak-modules2 driver-check.sh unblacklist lsinitrd-quick get_dracut_drivers
install -pm 755 "dracut-posttrans" "%{buildroot}/usr/lib/module-init-tools/"
install -pm 755 "mkosi-initrd-posttrans" "%{buildroot}/usr/lib/module-init-tools/"
install -pm 755 "regenerate-initrd-posttrans" "%{buildroot}/usr/lib/module-init-tools/"
install -d -m 755 "%{buildroot}/usr/lib/module-init-tools/kernel-scriptlets"
install -pm 755 "kernel-scriptlets/cert-script" "%{buildroot}/usr/lib/module-init-tools/kernel-scriptlets"
install -pm 755 "kernel-scriptlets/inkmp-script" "%{buildroot}/usr/lib/module-init-tools/kernel-scriptlets"
install -pm 755 "kernel-scriptlets/kmp-script" "%{buildroot}/usr/lib/module-init-tools/kernel-scriptlets"
install -pm 755 "kernel-scriptlets/rpm-script" "%{buildroot}/usr/lib/module-init-tools/kernel-scriptlets"
for i in "pre" "preun" "post" "posttrans" "postun" ; do
ln -s cert-script %{buildroot}/usr/lib/module-init-tools/kernel-scriptlets/cert-$i
ln -s inkmp-script %{buildroot}/usr/lib/module-init-tools/kernel-scriptlets/inkmp-$i
ln -s kmp-script %{buildroot}/usr/lib/module-init-tools/kernel-scriptlets/kmp-$i
ln -s rpm-script %{buildroot}/usr/lib/module-init-tools/kernel-scriptlets/rpm-$i
done
install -d -m 755 %{buildroot}%{dracutlibdir}/dracut.conf.d
install -pm 644 10-unblacklist.conf %{buildroot}%{dracutlibdir}/dracut.conf.d
install -d -m 755 "%{buildroot}%{_prefix}/bin"
# systemd service(s) to load kernel-specific sysctl settings
install -d -m 755 "%{buildroot}%{_unitdir}/systemd-sysctl.service.d"
echo '[Unit]' >"%{buildroot}%{sysctl_dropin}"
%if %{with kernel_sysctl}
install -pm 644 kernel-sysctl.service "%{buildroot}%{_unitdir}"
echo 'Wants=kernel-sysctl.service' >>"%{buildroot}%{sysctl_dropin}"
%endif
%if %{with boot_sysctl}
install -pm 644 boot-sysctl.service "%{buildroot}%{_unitdir}"
echo 'Wants=boot-sysctl.service' >>"%{buildroot}%{sysctl_dropin}"
%endif
install -d -m 755 "%{buildroot}%{_modulesloaddir}"
for _x in modules-load.d/*.conf; do
[ -e "$_x" ] || continue
install -pm 644 -t "%{buildroot}%{_modulesloaddir}" "$_x"
done
%ifarch ppc64 ppc64le
install -d -m 755 %{buildroot}/usr/lib/systemd/system-generators
install -pm 755 udev-trigger-generator %{buildroot}/usr/lib/systemd/system-generators
%endif
# udev rules (formerly system-tuning-common-SUSE, udev-extra-rules)
install -d -m 755 %{buildroot}%{_udevrulesdir}
install -pm 644 udevrules/*.rules %{buildroot}%{_udevrulesdir}
mkdir -p %{buildroot}%{_defaultlicensedir}
for mod in %{fs_blacklist}; do
echo "\
# DO NOT EDIT THIS FILE!
#
# The $mod file system is blacklisted by default because it isn't actively
# supported by SUSE.
blacklist $mod
# The filesystem can be un-blacklisted by running \"modprobe $mod\".
# See README.md in the %{name} package for details.
install $mod /usr/lib/module-init-tools/unblacklist $mod; /sbin/modprobe --ignore-install $mod
" \
>%{buildroot}%{modprobe_dir}/60-blacklist_fs-"$mod".conf
done
%pre
%service_add_pre %{systemd_units}
# Avoid restoring old .rpmsave files in %posttrans
for f in %{modprobe_conf_rpmsave}; do
if [ -f ${f} ]; then
mv -f ${f} ${f}.%{name}
fi
done
if [ -f %{_sysconfdir}/depmod.d/00-system.conf.rpmsave ]; then
mv -f %{_sysconfdir}/depmod.d/00-system.conf.rpmsave \
%{_sysconfdir}/depmod.d/00-system.conf.rpmsave.%{name}
fi
exit 0
%post
%udev_rules_update
%service_add_post %{systemd_units}
exit 0
%preun
%service_del_preun %{systemd_units}
exit 0
%postun
%udev_rules_update
%service_del_postun_without_restart %{systemd_units}
exit 0
%posttrans
# If the user had modified any of the configuration files installed under
# /etc, they'll now be renamed to .rpmsave files. Restore them.
for f in %{modprobe_conf_rpmsave}; do
if [ -f ${f} ]; then
mv -fv ${f} ${f%.rpmsave}
fi
done
if [ -f %{_sysconfdir}/depmod.d/00-system.conf.rpmsave ]; then
mv -fv %{_sysconfdir}/depmod.d/00-system.conf.rpmsave \
%{_sysconfdir}/depmod.d/00-system.conf
fi
exit 0
%files
%defattr(-,root,root)
%license LICENSE
%doc README.md
%{modprobe_dir}
%dir %{_sysconfdir}/modprobe.d
%{depmod_dir}
%dir %{_sysconfdir}/depmod.d
%dir /usr/lib/module-init-tools
/usr/lib/module-init-tools/driver-check.sh
/usr/lib/module-init-tools/lsinitrd-quick
/usr/lib/module-init-tools/unblacklist
/usr/lib/module-init-tools/weak-modules2
/usr/lib/module-init-tools/get_dracut_drivers
%{_unitdir}/*.service
%{_unitdir}/systemd-sysctl.service.d
%{_modulesloaddir}
%{_udevrulesdir}
%dir %{dracutlibdir}
%{dracutlibdir}/dracut.conf.d
%ifarch ppc64 ppc64le
/usr/lib/systemd/system-generators
%endif
#
%files scriptlets
/usr/lib/module-init-tools/kernel-scriptlets
/usr/lib/module-init-tools/dracut-posttrans
/usr/lib/module-init-tools/mkosi-initrd-posttrans
/usr/lib/module-init-tools/regenerate-initrd-posttrans
%changelog