]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
meson.build: install kmod symlinks to /usr/sbin/
authorEmil Velikov <emil.l.velikov@gmail.com>
Thu, 7 Nov 2024 14:17:28 +0000 (14:17 +0000)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Mon, 11 Nov 2024 22:12:09 +0000 (16:12 -0600)
With earlier commit we added support for kmod itself to install the
symlinks to kmod. While it works across the board, some distributions
still support (to varying degree) split /usr/bin and /usr/sbin.

This commit changes the location where those are created and bears no
functional change for merged bin-sbin users. While for split ones, it
follows what distributions are doing to a varying extend:

 - Fedora, Alpine - this commit matches exactly what they do
 - Debian, Yocto - they have an extra /bin/lsmod -> ../sbin/kmod symlink
 - Gentoo - as Debian plus an extra /bin/modinfo -> ../sbin/kmod symlink

Loosely based on a Debian patch by Marco d'Itri.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/231
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Makefile.am
meson.build

index 554409fcd5f8f149faebc84d7ac727cd8d632c09..a7eb1b200a904f876be0fc2ba5ddba3e967a6563 100644 (file)
@@ -145,7 +145,8 @@ dist_zshcompletion_DATA = \
 install-exec-hook:
 if BUILD_TOOLS
        for tool in insmod lsmod rmmod depmod modprobe modinfo; do \
-               $(LN_S) -f kmod $(DESTDIR)$(bindir)/$$tool; \
+               $(MKDIR_P) $(DESTDIR)$(sbindir); \
+               $(LN_S) --force --relative $(DESTDIR)$(bindir)/kmod $(DESTDIR)$(sbindir)/$$tool; \
        done
 endif
 
index b4789df452610d6f9cbd8760ed9cf3f2b5a6df2e..483d7afa7408bb72a2f5895b2726a66ea23d20aa 100644 (file)
@@ -181,6 +181,7 @@ features = []
 prefixdir = get_option('prefix')
 sysconfdir = get_option('sysconfdir')
 bindir = prefixdir / get_option('bindir')
+sbindir = prefixdir / get_option('sbindir')
 includedir = prefixdir / get_option('includedir')
 libdir = prefixdir / get_option('libdir')
 datadir = prefixdir / get_option('datadir')
@@ -473,11 +474,15 @@ _tools = [
   'rmmod',
 ]
 
-foreach tool : _tools
-  if get_option('tools')
-    install_symlink(tool, pointing_to: 'kmod', install_dir: bindir)
-  endif
-endforeach
+if get_option('tools')
+  mkdir_p = 'mkdir -p "$DESTDIR@0@"'
+  meson.add_install_script('sh', '-c', mkdir_p.format(sbindir))
+
+  ln_s = 'ln --symbolic --force --relative "$DESTDIR@0@/kmod" "$DESTDIR@1@"'
+  foreach tool : _tools
+    meson.add_install_script('sh', '-c', ln_s.format(bindir, sbindir / tool))
+  endforeach
+endif
 
 internal_kmod_symlinks = []
 
@@ -522,6 +527,7 @@ summary({
   'prefix'      : prefixdir,
   'sysconfdir'  : sysconfdir,
   'bindir'      : bindir,
+  'sbindir'     : sbindir,
   'includedir'  : includedir,
   'libdir'      : libdir,
   'datadir'     : datadir,