commit:     febeae936c626eb4c0a44654cda2a6351671098b
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Sun Aug  2 22:01:21 2020 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Sun Aug  2 22:42:11 2020 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=febeae93

gen_determineargs.sh: determine_real_args(): Set KERNEL_MODULES_PREFIX to 
temporary location when --no-install is set

This will ensure that we won't install anything on user's system when
--no-install was set.

While here, make use of expand_file() for --kernel-modules-prefix.

Bug: https://bugs.gentoo.org/505810
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 gen_determineargs.sh | 25 +++++++++++++++++++++++++
 genkernel            | 15 ---------------
 2 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index 3a7882d..4457fe4 100755
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -1170,6 +1170,31 @@ determine_real_args() {
                fi
        fi
 
+       if ! isTrue "${CMD_INSTALL}"
+       then
+               if [ -n "${KERNEL_MODULES_PREFIX}" ]
+               then
+                       print_warning 1 '--no-install is set; Ignoring 
--kernel-modules-prefix ...'
+               fi
+
+               # User does not want that anything will get installed
+               # so install modules into our temporary directory instead.
+               KERNEL_MODULES_PREFIX="${TEMP}/mod_prefix"
+       elif [ -n "${KERNEL_MODULES_PREFIX}" ]
+       then
+               KERNEL_MODULES_PREFIX=$(expand_file 
"${CMD_KERNEL_MODULES_PREFIX}")
+               if [ -z "${KERNEL_MODULES_PREFIX}" ]
+               then
+                       gen_die "Failed to expand set --kernel-modules-prefix 
'${CMD_KERNEL_MODULES_PREFIX}'!"
+               fi
+
+               if [ ! -d "${KERNEL_MODULES_PREFIX}" ]
+               then
+                       print_warning 3 "Set --kernel-modules-prefix 
'${KERNEL_MODULES_PREFIX}' does not exist; Will try to create ..."
+                       mkdir -p "${KERNEL_MODULES_PREFIX}" || gen_die "Failed 
to create '${KERNEL_MODULES_PREFIX}'!"
+               fi
+       fi
+
        MICROCODE=${MICROCODE,,}
        case "${MICROCODE}" in
                all|amd|intel) ;;

diff --git a/genkernel b/genkernel
index a155a9c..575ba2b 100755
--- a/genkernel
+++ b/genkernel
@@ -296,21 +296,6 @@ then
 
        if ! isTrue "${BUILD_STATIC}"
        then
-               if ! isTrue "${CMD_INSTALL}" && [ -z "${KERNEL_MODULE_PREFIX}" ]
-               then
-                       # We have to set $KERNEL_MODULE_PREFIX to avoid 
installing files
-                       # to /lib/modules because --no-install was set
-                       KERNEL_MODULE_PREFIX="$(mktemp -d -p "${TEMP}" 
kerncache-modules_XXXXXXX 2>/dev/null)"
-                       if [ -z "${KERNEL_MODULE_PREFIX}" ]
-                       then
-                               gen_die "Internal error: Variable 
'KERNEL_MODULE_PREFIX' is empty; mktemp() for kerncache modules failed!"
-                       else
-                               print_info 5 '' 1 0
-                               print_info 5 "KERNEL_MODULE_PREFIX set to 
'${KERNEL_MODULE_PREFIX}' because --kerncache is used but --no-install was set 
..."
-                               mkdir "${KERNEL_MODULE_PREFIX}/lib" || gen_die 
"Failed to create '${KERNEL_MODULE_PREFIX}/lib'!"
-                       fi
-               fi
-
                print_info 1 '' 1 0
                gen_kerncache_extract_modules
        fi

Reply via email to