From: Kay Sievers Date: Tue, 20 Dec 2011 16:58:05 +0000 (+0100) Subject: introduce --with-rootprefix=DIR X-Git-Tag: v2~11 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fkmod.git;a=commitdiff_plain;h=a308abec371364eec8344681cfe1fb50d624e43e introduce --with-rootprefix=DIR Configure the location of the rootfs directories and use it to find (/usr)/lib/modules and (/usr)/lib/modprobe.d. --- diff --git a/Makefile.am b/Makefile.am index 79e12db..46c025a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,6 +6,7 @@ AM_MAKEFLAGS = --no-print-directory AM_CPPFLAGS = \ -include $(top_builddir)/config.h \ -I$(top_srcdir)/libkmod \ + -DROOTPREFIX=\""$(rootprefix)"\" \ -DSYSCONFDIR=\""$(sysconfdir)"\" \ -DLIBEXECDIR=\""$(libexecdir)"\" diff --git a/configure.ac b/configure.ac index 8999de8..e9eb08d 100644 --- a/configure.ac +++ b/configure.ac @@ -27,6 +27,11 @@ AC_C_BIGENDIAN required_private_libs="" +AC_ARG_WITH([rootprefix], + AS_HELP_STRING([--with-rootprefix=DIR], [rootfs directory prefix for config files and kernel modules]), + [], [with_rootprefix=$prefix]) +AC_SUBST([rootprefix], [$with_rootprefix]) + AC_ARG_ENABLE([tools], AS_HELP_STRING([--disable-tools], [disable building tools that provide same functionality as module-init-tools @<:@default=enabled@:>@]), [], enable_tools=yes) @@ -147,6 +152,7 @@ AC_MSG_RESULT([ ======== prefix: ${prefix} + rootprefix: ${rootprefix} sysconfdir: ${sysconfdir} libdir: ${libdir} includedir: ${includedir} diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c index b519b90..699a17e 100644 --- a/libkmod/libkmod.c +++ b/libkmod/libkmod.c @@ -60,8 +60,8 @@ static const char* index_files[] = { static const char *default_config_paths[] = { "/run/modprobe.d", - "/etc/modprobe.d", - "/lib/modprobe.d", + SYSCONFDIR "/modprobe.d", + ROOTPREFIX "/lib/modprobe.d", NULL }; @@ -159,7 +159,7 @@ static int log_priority(const char *priority) return 0; } -static const char *dirname_default_prefix = "/lib/modules"; +static const char *dirname_default_prefix = ROOTPREFIX "/lib/modules"; static char *get_kernel_release(const char *dirname) { @@ -188,12 +188,12 @@ static char *get_kernel_release(const char *dirname) * release the resources of the kmod library context. * * @dirname: what to consider as linux module's directory, if NULL - * defaults to /lib/modules/`uname -r`. + * defaults to $rootprefix/lib/modules/`uname -r`. * @config_paths: ordered array of paths (directories or files) where * to load from user-defined configuration parameters such as * alias, blacklists, commands (install, remove). If * NULL defaults to /run/modprobe.d, /etc/modprobe.d and - * /lib/modprobe.d. Give an empty vector if configuration should + * $rootprefix/lib/modprobe.d. Give an empty vector if configuration should * not be read. This array must be null terminated. * * Returns: a new kmod library context diff --git a/tools/kmod-modinfo.c b/tools/kmod-modinfo.c index a827437..fa91682 100644 --- a/tools/kmod-modinfo.c +++ b/tools/kmod-modinfo.c @@ -320,7 +320,7 @@ static void help(const char *progname) "\t-0, --null Use \\0 instead of \\n\n" "\t-F, --field=FIELD Print only provided FIELD\n" "\t-k, --set-version=VERSION Use VERSION instead of `uname -r`\n" - "\t-b, --basedir=DIR Use DIR as filesystem root for /lib/modules\n" + "\t-b, --basedir=DIR Use DIR as filesystem root for " ROOTPREFIX "/lib/modules\n" "\t-V, --version Show version\n" "\t-h, --help Show this help\n", progname); @@ -402,7 +402,7 @@ int main(int argc, char *argv[]) } kversion = u.release; } - snprintf(dirname_buf, sizeof(dirname_buf), "%s/lib/modules/%s", + snprintf(dirname_buf, sizeof(dirname_buf), "%s" ROOTPREFIX "/lib/modules/%s", root, kversion); dirname = dirname_buf; } diff --git a/tools/kmod-modprobe.c b/tools/kmod-modprobe.c index f78a7ac..6fa1066 100644 --- a/tools/kmod-modprobe.c +++ b/tools/kmod-modprobe.c @@ -125,8 +125,8 @@ static void help(const char *progname) "\t-n, --dry-run Do not execute operations, just print out\n" "\t-n, --show Same as --dry-run\n" - "\t-C, --config=FILE Use FILE instead of /etc/modprobe.d\n" - "\t-d, --dirname=DIR Use DIR as filesystem root for /lib/modules\n" + "\t-C, --config=FILE Use FILE instead of " SYSCONFDIR "/modprobe.d\n" + "\t-d, --dirname=DIR Use DIR as filesystem root for " ROOTPREFIX "/lib/modules\n" "\t-S, --set-version=VERSION Use VERSION instead of `uname -r`\n" "\t-s, --syslog print to syslog, not stderr\n" @@ -1252,7 +1252,7 @@ int main(int argc, char **orig_argv) } kversion = u.release; } - snprintf(dirname_buf, sizeof(dirname_buf), "%s/lib/modules/%s", + snprintf(dirname_buf, sizeof(dirname_buf), "%s" ROOTPREFIX "/lib/modules/%s", root, kversion); dirname = dirname_buf; }