]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
depmod: Add option to override MODULE_DIRECTORY
authorMichal Suchanek <msuchanek@suse.de>
Wed, 4 Sep 2024 06:54:06 +0000 (08:54 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 10 Sep 2024 18:25:46 +0000 (13:25 -0500)
This a compile time option. When building modules for a different system
that uses a different value of this option it is useful to be able to
override it without rebuilding kmod.

Closes: https://github.com/kmod-project/kmod/issues/85
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Link: https://github.com/kmod-project/kmod/pull/100
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
man/depmod.8.scd
tools/depmod.c
tools/kmod.pc.in

index c06108511d39a32e0d3db7559f01baa78f19bbbd..c872b0a8000483425111d98f7460285655cb8d2e 100644 (file)
@@ -6,7 +6,7 @@ depmod - Generate modules.dep and map files.
 
 # SYNOPSIS
 
-*depmod* [*-b* _basedir_] [*-o* _outdir_] [*-e*] [*-E* _Module.symvers_]
+*depmod* [*-b* _basedir_] [*-m* _moduledir_] [*-o* _outdir_][*-o* _outdir_] [*-e*] [*-E* _Module.symvers_]
 \ \ \ \ \ \ \ \[*-F* _System.map_] [*-n*] [*-v*] [*-A*] [*-P* _prefix_] [*-w*] [_version_]
 
 *depmod* [*-e*] [*-E* _Module.symvers_] [*-F* _System.map_] [*-n*] [*-v*] [*-P* _prefix_]
@@ -56,6 +56,13 @@ rather than the current kernel version (as returned by *uname -r*).
        distribution vendor who needs to pre-generate the meta-data files rather
        than running *depmod* again later.
 
+*-m* _moduledir_
+*--moduledir* _moduledir_
+       Override the @MODULE_DIRECTORY@ prefix set at build time. This is useful
+       when building *modules.dep* file in _basedir_ for a system that uses a
+       different prefix. The alternative is to move the modules and
+       *modules.dep* inside _basedir_ to adjust for the different prefix.
+
 *-o* _outdir_
 *--outdir* _outdir_
        Set the output directory where *depmod* will store any generated file.
index d019bd82925225c96a87778a5a67f4c38fb2aaa4..e10da6850137d2cc7aab613d26a49dfe88dda4df 100644 (file)
@@ -36,6 +36,7 @@
 #define DEFAULT_VERBOSE LOG_WARNING
 static int verbose = DEFAULT_VERBOSE;
 
+static const char *module_directory = MODULE_DIRECTORY;
 static const char CFG_BUILTIN_KEY[] = "built-in";
 static const char CFG_EXTERNAL_KEY[] = "external";
 static const char *const default_cfg_paths[] = {
@@ -49,11 +50,12 @@ static const char *const default_cfg_paths[] = {
        // clang-format on
 };
 
-static const char cmdopts_s[] = "aAb:o:C:E:F:evnP:wVh";
+static const char cmdopts_s[] = "aAb:m:o:C:E:F:evnP:wVh";
 static const struct option cmdopts[] = {
        { "all", no_argument, 0, 'a' },
        { "quick", no_argument, 0, 'A' },
        { "basedir", required_argument, 0, 'b' },
+       { "moduledir", required_argument, 0, 'm' },
        { "outdir", required_argument, 0, 'o' },
        { "config", required_argument, 0, 'C' },
        { "symvers", required_argument, 0, 'E' },
@@ -92,6 +94,7 @@ static void help(void)
                "\n"
                "The following options are useful for people managing distributions:\n"
                "\t-b, --basedir=DIR    Use an image of a module tree.\n"
+               "\t-m, --moduledir=DIR  Override MODULE_DIRECTORY.\n"
                "\t-o, --outdir=DIR     Output directory for generated files.\n"
                "\t-F, --filesyms=FILE  Use the file instead of the\n"
                "\t                     current kernel symbols.\n"
@@ -2939,6 +2942,9 @@ static int do_depmod(int argc, char *argv[])
                                goto cmdline_failed;
                        }
                        break;
+               case 'm':
+                       module_directory = optarg;
+                       break;
                case 'o':
                        free(out_root);
                        out_root = path_make_absolute_cwd(optarg);
@@ -3017,12 +3023,12 @@ static int do_depmod(int argc, char *argv[])
        }
 
        cfg.dirnamelen = snprintf(cfg.dirname, PATH_MAX,
-                                 "%s" MODULE_DIRECTORY "/%s",
-                                 root ?: "", cfg.kversion);
+                                 "%s%s/%s",
+                                 root ?: "", module_directory, cfg.kversion);
 
        cfg.outdirnamelen = snprintf(cfg.outdirname, PATH_MAX,
-                                    "%s" MODULE_DIRECTORY "/%s",
-                                    out_root ?: (root ?: ""), cfg.kversion);
+                                    "%s%s/%s",
+                                    out_root ?: (root ?: ""), module_directory, cfg.kversion);
 
        if (optind == argc)
                all = 1;
index 97215c8ed48f3c92d534c4038155d0072f5510e4..2d9f885fbb2450756a1d10a56790d5789974835a 100644 (file)
@@ -4,6 +4,7 @@ distconfdir=@distconfdir@
 module_directory=@module_directory@
 module_compressions=@module_compressions@
 module_signatures=@module_signatures@
+depmod_module_directory_override=true
 
 Name: kmod
 Description: Tools to deal with kernel modules