commit:     9fdb3acb257e7103a89e8f47fe8cb23e614efe84
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Sun Aug  2 10:44:56 2020 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Sun Aug  2 22:40:14 2020 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=9fdb3acb

Make use of expand_file() for --linuxrc option

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

 gen_determineargs.sh | 13 +++++++++++++
 gen_initramfs.sh     | 13 +++++--------
 genkernel.conf       |  3 +++
 3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index 0a404ee..3a7882d 100755
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -353,6 +353,7 @@ determine_real_args() {
        set_config_with_override BOOL   RAMDISKMODULES                        
CMD_RAMDISKMODULES                        "yes"
        set_config_with_override BOOL   ALLRAMDISKMODULES                     
CMD_ALLRAMDISKMODULES                     "no"
        set_config_with_override STRING INITRAMFS_OVERLAY                     
CMD_INITRAMFS_OVERLAY
+       set_config_with_override STRING LINUXRC                               
CMD_LINUXRC
        set_config_with_override BOOL   MOUNTBOOT                             
CMD_MOUNTBOOT                             "yes"
        set_config_with_override BOOL   BUILD_STATIC                          
CMD_STATIC                                "no"
        set_config_with_override BOOL   SAVE_CONFIG                           
CMD_SAVE_CONFIG                           "yes"
@@ -1145,6 +1146,18 @@ determine_real_args() {
                        fi
                fi
 
+               if [ -n "${LINUXRC}" ]
+               then
+                       LINUXRC=$(expand_file "${CMD_LINUXRC}" 2>/dev/null)
+                       if [ -z "${LINUXRC}" ]
+                       then
+                               gen_die "--linuxrc value '${CMD_LINUXRC}' 
failed to expand!"
+                       elif [ ! -e "${LINUXRC}" ]
+                       then
+                               gen_die "--linuxrc file '${LINUXRC}' does not 
exist!"
+                       fi
+               fi
+
                need_tar=yes
        fi
 

diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index 24ddcb5..3cd535c 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -1795,18 +1795,14 @@ append_auxilary() {
        done
 
        local mylinuxrc=
-       if [ -f "${CMD_LINUXRC}" ]
+       if [ -n "${LINUXRC}" ]
        then
-               mylinuxrc="${CMD_LINUXRC}"
+               mylinuxrc="${LINUXRC}"
                print_info 2 "$(get_indent 2)>> Copying user specified linuxrc 
'${mylinuxrc}' to '/init' ..."
-               cp -aL "${mylinuxrc}" "${TDIR}"/init 2>/dev/null \
-                       || gen_die "Failed to copy '${mylinuxrc}' to 
'${TDIR}/init'!"
        elif isTrue "${NETBOOT}"
        then
                mylinuxrc="${GK_SHARE}/netboot/linuxrc.x"
                print_info 2 "$(get_indent 2)>> Copying netboot specific 
linuxrc '${mylinuxrc}' to '/init' ..."
-               cp -aL "${mylinuxrc}" "${TDIR}"/init 2>/dev/null \
-                       || gen_die "Failed to copy '${mylinuxrc}' to 
'${TDIR}/init'!"
        else
                if [ -f "${GK_SHARE}/arch/${ARCH}/linuxrc" ]
                then
@@ -1816,10 +1812,11 @@ append_auxilary() {
                fi
 
                print_info 2 "$(get_indent 2)>> Copying '${mylinuxrc}' to 
'/init' ..."
-               cp -aL "${mylinuxrc}" "${TDIR}"/init 2>/dev/null \
-                       || gen_die "Failed to copy '${mylinuxrc}' to 
'${TDIR}/init'!"
        fi
 
+       cp -aL "${mylinuxrc}" "${TDIR}"/init 2>/dev/null \
+               || gen_die "Failed to copy '${mylinuxrc}' to '${TDIR}/init'!"
+
        # Make sure it's executable
        chmod 0755 "${TDIR}"/init || gen_die "Failed to chmod of '${TDIR}/init' 
to 0755!"
 

diff --git a/genkernel.conf b/genkernel.conf
index 93cf8e7..654f185 100644
--- a/genkernel.conf
+++ b/genkernel.conf
@@ -363,6 +363,9 @@ DEFAULT_KERNEL_SOURCE="/usr/src/linux"
 #MODULES_group1="some-module"
 #MODULES_group2="" # Load no modules for this group
 
+# Override the default used linuxrc script.
+#LINUXRC="/path/to/custom/linuxrc"
+
 # Archive file created using tar containing modules after
 # the callbacks have run
 #MODULESPACKAGE="/path/to/file.tar.xz"

Reply via email to