Moving modprobe.d files to (/usr)/lib
Historically, modprobe configuration files have been installed in /etc/modprobe.d on openSUSE. This has a number of disadvantages. - packages should generally avoid shipping files under /etc - customization requires %config or %config(noreplace), with the well-known issues this may cause on upgrades. The more "modern" style to enable user customization is to place distribution-shipped configuration files under /lib/modprobe.d or /usr/lib/modprobe.d, and let users override them by files of the same name under /etc/modprobe.d if they desire. This technique has been supported by kmod for years, and is well established these days by systemd, udev, dracut, etc., which use the same scheme. I've started an effort to move all modprobe configuration files shipped by packages into /usr/lib/modprobe.d on Factory, and /lib/modprobe.d on Leap. The %config or %config(noreplace) file attributes for the distribution-shipped defaults are removed. If the user has modified some of the distro-shipped %config files, they'll be renamed to .rpmsave by rpm when the update package moves the config file out of /etc. This would undo user customizations, which is undesirable. To avoid it, code is added to the spec files of affected packages, which looks like this (example from "bluez"): %global modprobe_d_files 50-bluetooth.conf %pre # Avoid restoring pre-existing .rpmsave files in %posttrans later by renaming them for _f in %{?modprobe_d_files}; do [ ! -f "%{_sysconfdir}/modprobe.d/${_f}.rpmsave" ] || \ mv -f "%{_sysconfdir}/modprobe.d/${_f}.rpmsave" "%{_sysconfdir}/modprobe.d/${_f}.rpmsave.%{name}-%{VERSION}-%{RELEASE}" || : done %posttrans # Modified config files are renamed to .rpmsave by rpm when moved to /usr/lib. # Restore the user's customizations. for _f in %{?modprobe_d_files}; do [ ! -f "%{_sysconfdir}/modprobe.d/${_f}.rpmsave" ] || \ mv -fv "%{_sysconfdir}/modprobe.d/${_f}.rpmsave" "%{_sysconfdir}/modprobe.d/${_f}" || : done The current status can be seen on OBS in the home:mwilck:modprobe.d project (currently WIP). There has been some confusion about the correct path (/usr/lib/modprobe.d vs. /lib/modprobe.d). Here's a short summary of the discussion: - upstream kmod does supports /lib/modprobe.d only. - SUSE's kmod is currently patched to support both /lib/modprobe.d and /usr/lib/modprobe.d. - On usr-merged Factory, /lib/modprobe.d is an alias for /usr/lib/modprobe.d, thus they can be used interchangeably. For correctness and to avoid filename clashes, we use /usr/lib. - on non-usr-merged distros, we keep the upstream path /lib/modprobe.d. Scripts and "consumers" of modprobe.d files can safely look them up under /lib/modprobe.d, which will "work" on both usr-merged and non- usr-merged variants. In the future, %_modprobedir should be used by packages. Currently though, %_modprobedir is (wrongly) set to /usr/lib/modprobe.d in the systemd-rpm-macros package on SLE/Leap up to 15.3. Likewise, the filesystem package on Leap currently contains /usr/lib/modprobe.d but not /lib/modprobe.d. This will be fixed sooner or later, but spec files currently need to work around this issue with a conditional. packages that install into %_modprobedir should add a "%dir %{_modprobedir}" line to the %files list to avoid build errors. Furthermore, discussion is ongoing whether the definition of %_modprobedir should be moved to a different package, and which. Regards Martin PS: @maintainers of affected packages: I've sent a bunch of OBS requests on Friday and revoked them, because I hadn't added the code for restoring user modifications yet and I figured I should rather do that first.
Sun, 6 Mar 2022 21:55:00 +0000 Martin Wilck <martin.wilck@suse.com>:
mv -f "%{_sysconfdir}/modprobe.d/${_f}.rpmsave" "%{_sysconfdir}/modprobe.d/${_f}.rpmsave.%{name}-%{VERSION}-%{RELEASE}" || :
This pattern can not be detected by build-compare. Just move the files back and forth unconditionally, like it is done already elsewhere. Olaf
On Sun, 2022-03-06 at 23:24 +0100, Olaf Hering wrote:
Sun, 6 Mar 2022 21:55:00 +0000 Martin Wilck <martin.wilck@suse.com>:
mv -f "%{_sysconfdir}/modprobe.d/${_f}.rpmsave" "%{_sysconfdir}/modprobe.d/${_f}.rpmsave.%{name}-%{VERSION}- %{RELEASE}" || :
This pattern can not be detected by build-compare.
Do you mean I should drop the "-%{RELEASE}" part?
Just move the files back and forth unconditionally, like it is done already elsewhere.
Forgive me for being dense, I fail to parse this sentence. I can't just blindly move $x.rpmsave to $x; I might restore an ancient, long- forgotten configuration just because of a left-over .rpmsave file. Martin
Mon, 7 Mar 2022 07:51:16 +0000 Martin Wilck <martin.wilck@suse.com>:
This pattern can not be detected by build-compare. Do you mean I should drop the "-%{RELEASE}" part?
No, such pattern has to be at the end of the line (see trim_release_old/new in build-compare/functions.sh). But for the purpose of .rpmsave handling no variables are required.
Just move the files back and forth unconditionally, like it is done already elsewhere. Forgive me for being dense, I fail to parse this sentence. I can't just blindly move $x.rpmsave to $x; I might restore an ancient, long- forgotten configuration just because of a left-over .rpmsave file.
Just look at i3lock,kbd,libvirt,lightdm,openssh,...spec how to do it in %pre/%posttrans. Are these common patterns really not documented in our wiki? After all a few thousand %config entries have to be handled properly at some point... Olaf
On Mon, 2022-03-07 at 09:02 +0100, Olaf Hering wrote:
Just look at i3lock,kbd,libvirt,lightdm,openssh,...spec how to do it in %pre/%posttrans.
Are these common patterns really not documented in our wiki?
Thanks for the hint, they are, if one knows where to look. https://en.opensuse.org/openSUSE:Packaging_UsrEtc I used to be aware of that page actually, but it didn't occur to me to look there. I'll use the code from that page, then. I just uses ".rpmsave.old". Martin
On Sunday 2022-03-06 22:55, Martin Wilck wrote:
Furthermore, discussion is ongoing whether the definition of %_modprobedir should be moved to a different package, and which.
if upstream does not provide the macro, /usr/lib/rpm/suse/macros looks like a workable dumping ground.
On Sun, Mar 6, 2022 at 6:03 PM Jan Engelhardt <jengelh@inai.de> wrote:
On Sunday 2022-03-06 22:55, Martin Wilck wrote:
Furthermore, discussion is ongoing whether the definition of %_modprobedir should be moved to a different package, and which.
if upstream does not provide the macro, /usr/lib/rpm/suse/macros looks like a workable dumping ground.
%_modprobedir is already part of systemd upstream macros. The openSUSE systemd package currently maintains an old custom fork of the macros in the systemd-rpm-macros package. I hope that one day we can just use the upstream ones... -- 真実はいつも一つ!/ Always, there's only one truth!
participants (4)
-
Jan Engelhardt
-
Martin Wilck
-
Neal Gompa
-
Olaf Hering