]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
meson: disable automatic shell completion on prefix missmatch
authorEmil Velikov <emil.l.velikov@gmail.com>
Thu, 24 Oct 2024 12:46:47 +0000 (13:46 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Thu, 24 Oct 2024 23:10:12 +0000 (18:10 -0500)
Currently one can choose a prefix completely different from the one
bash-completion and fish use, as per their pkg-config file.

In such cases, flag a warning and disable it. People can always manually
provide the completion directory/ies to re-enable.

    $ meson setup --prefix=/tmp/example build/
    ...
    WARNING: User provided prefix '/tmp/example' differs from bash-completion one '/usr'. Disabling completion.
    ...
    WARNING: User provided prefix '/tmp/example' differs from fish one '/usr'. Disabling completion.

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

index 3a7146092b15bc0b5a67c6e829c57262c2f39237..179783389700d35a8dfbc4871b38064db563df98 100644 (file)
@@ -240,7 +240,16 @@ foreach tuple : _completiondirs
   if completiondir == ''
     completion = dependency(pkg_dep, required : false)
     if completion.found()
-      completiondir = completion.get_variable(pkgconfig : 'completionsdir')
+      completion_prefix = completion.get_variable(pkgconfig : 'prefix')
+      if completion_prefix != prefixdir
+        warning('User provided prefix \'@0@\' differs from @1@ one \'@2@\'.'
+                .format(prefixdir, pkg_dep, completion_prefix))
+        warning('Not installing completion. To re-enable, manually set @0@.'
+                .format(dir_option))
+        completiondir = 'no'
+      else
+        completiondir = completion.get_variable(pkgconfig : 'completionsdir')
+      endif
     else
       completiondir = datadir / def_path
     endif