From: Michal Suchanek Date: Wed, 4 Sep 2024 06:54:06 +0000 (+0200) Subject: depmod: Add option to override MODULE_DIRECTORY X-Git-Tag: v34~378 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c36ddb62c8ee9045b84be70cc6dc0b6f931e3291;p=thirdparty%2Fkmod.git depmod: Add option to override MODULE_DIRECTORY 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 Link: https://github.com/kmod-project/kmod/pull/100 Signed-off-by: Lucas De Marchi --- diff --git a/man/depmod.8.scd b/man/depmod.8.scd index c0610851..c872b0a8 100644 --- a/man/depmod.8.scd +++ b/man/depmod.8.scd @@ -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. diff --git a/tools/depmod.c b/tools/depmod.c index d019bd82..e10da685 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -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; diff --git a/tools/kmod.pc.in b/tools/kmod.pc.in index 97215c8e..2d9f885f 100644 --- a/tools/kmod.pc.in +++ b/tools/kmod.pc.in @@ -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