aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Deutschmann <whissi@gentoo.org>2019-07-28 16:33:25 +0200
committerThomas Deutschmann <whissi@gentoo.org>2019-07-29 22:00:24 +0200
commit769a07fd3e947ffb216ea94887d752a27ea212d9 (patch)
tree055af5d9402ab9cb59438c0719be73b6eb559be3
parentkeymaps: Add bepo and colemak keymap (diff)
downloadgenkernel-769a07fd3e947ffb216ea94887d752a27ea212d9.tar.gz
genkernel-769a07fd3e947ffb216ea94887d752a27ea212d9.tar.bz2
genkernel-769a07fd3e947ffb216ea94887d752a27ea212d9.zip
Make initramfs and kernel filename customizable
New options like --initramfs-filename or --kernel-filename will allow user to customize filenames used when installing initramfs or kernel into $BOOTDIR. Therefore --kernelname (KNAME) option was removed. Filename can contain placeholders like '%%ARCH%%' which will get replaced at runtime. Man page contains more information. Bug: https://bugs.gentoo.org/395095 Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
-rw-r--r--defaults/config.sh7
-rw-r--r--doc/genkernel.8.txt90
-rwxr-xr-xgen_bootloader.sh12
-rwxr-xr-xgen_cmdline.sh40
-rwxr-xr-xgen_compile.sh26
-rwxr-xr-xgen_configkernel.sh2
-rwxr-xr-xgen_determineargs.sh169
-rwxr-xr-xgen_funcs.sh7
-rwxr-xr-xgen_initramfs.sh10
-rwxr-xr-xgen_package.sh98
-rwxr-xr-xgenkernel33
-rw-r--r--genkernel.conf22
12 files changed, 407 insertions, 109 deletions
diff --git a/defaults/config.sh b/defaults/config.sh
index 3546299..7232671 100644
--- a/defaults/config.sh
+++ b/defaults/config.sh
@@ -21,6 +21,13 @@ KERNEL_SUPPORT_MICROCODE=no
# Arch-specific defaults that can be overridden in the config file or on the
# command line.
#
+DEFAULT_INITRAMFS_FILENAME="initramfs-genkernel-%%ARCH%%-%%KV%%"
+DEFAULT_INITRAMFS_SYMLINK_NAME="initramfs"
+DEFAULT_KERNEL_FILENAME="kernel-genkernel-%%ARCH%%-%%KV%%"
+DEFAULT_KERNEL_SYMLINK_NAME="kernel"
+DEFAULT_SYSTEMMAP_FILENAME="System.map-%%ARCH%%-%%KV%%"
+DEFAULT_SYSTEMMAP_SYMLINK_NAME="System.map"
+
DEFAULT_COMPRESS_INITRD=yes
DEFAULT_COMPRESS_INITRD_TYPE=best
diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index f1ccbe6..e94fa12 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -150,16 +150,20 @@ KERNEL COMPILATION
are copied over.
*--*[*no-*]*symlink*::
- Manages, or does not manage, symlinks in '/boot' like the manual
- kernel "make install" process does. A kernel (or, depending on
- options, kernelz) symlink will link to the most recently built
- kernel image and a kernel.old (or kernelz.old) symlink will link
- to the second most recently built image, if one exists. Similar
- symlinks (both * and *.old) are managed for initramfs and System.map.
- The corresponding work products (i.e., the actual kernel
- and initramfs images, and System.map) are also managed accordingly.
- NOTE: Specifying *--symlink* does nothing unless
- *--install* is also specified.
+Manages, or does not manage, symlinks in '/boot' like the manual
+kernel "make install" process does. A 'kernel' (or, depending on
+options, 'kernelz') symlink will link to the most recently built
+kernel image and a 'kernel.old' (or 'kernelz.old') symlink will link
+to the second most recently built image, if one exists. Similar
+symlinks (with and without '.old' suffix) are managed for initramfs and
+System.map. The corresponding work products (i.e., the actual kernel
+and initramfs images, and System.map) are also managed accordingly.
++
+The symlink name can be controlled via *--kernel-symlink-name* and/or
+*--initramfs-symlink-name* option.
+
+NOTE: Specifying *--symlink* does nothing unless *--install* is also
+specified.
*--*[*no-*]*oldconfig*::
Runs, or does not run, "make oldconfig" before compilation. Specifying
@@ -428,9 +432,22 @@ INTERNALS
OUTPUT SETTINGS
~~~~~~~~~~~~~~~
-*--kernname*=<...>::
- Tag the kernel and initrd with a name, if not defined this
- option defaults to genkernel.
+*--initramfs-filename*=<...>::
+Set initramfs filename which will be used when initramfs will be installed
+into *BOOTDIR* (implies *--install* option). Please see
+*--kernel-filename* option for available placeholders and restrictions.
++
+By default, initramfs filename will be set to 'initramfs-genkernel-%%ARCH%%-%%KV%%'.
+
+*--initramfs-symlink-name*=<...>::
+Set initramfs symlink name which will be used when initramfs will be
+installed into *BOOTDIR* (implies *--install* option) and *--symlink*
+option is given. Please see *--kernel-filename* option for available
+placeholders and restrictions.
++
+By default, initramfs symlink name will be set to 'initramfs'.
+
+NOTE: Initramfs filename and initramfs symlink name must be different.
*--minkernpackage*=<file>::
Archive file created using tar containing kernel and initramfs.
@@ -445,11 +462,58 @@ NOTE: No modules outside of the initramfs will be included!
Archive file created using tar containing kernel binary, content of
'/lib/modules' and the kernel config after the callbacks have run.
+*--kernel-filename*=<...>::
+Set kernel filename which will be used when kernel will be installed
+into *BOOTDIR* (implies *--install* option). The following placeholders
+are available:
++
+[horizontal]
+*%%ARCH%%*:::
+Will be replaced with genkernel arch value, for example 'x86_64'.
+*%%KV%%*:::
+Will be replaced with kernel version, for example '5.2.3-gentoo'.
+
++
+Kernel filename is only allowed to contain characters like 'a-z' or 'A-Z',
+'0-9', '_', '.' and '-'.
++
+By default, kernel name will be set to 'kernel-genkernel-%%ARCH%%-%%KV%%'.
+
+NOTE: When setting a custom kernel name make sure that your bootloader and
+tools like *kexec* when used are recognizing your custom kernel name.
+
*--*[*no-*]*kernel-sources*::
This option is only valid if kerncache is defined If there is a
valid kerncache no checks will be made against a kernel source
tree.
+*--kernel-symlink-name*=<...>::
+Set kernel symlink name which will be used when kernel will be installed
+into *BOOTDIR* (implies *--install* option) and *--symlink* option is
+given. Please see *--kernel-filename* option for available placeholders
+and restrictions.
++
+By default, kernel symlink name will be set to 'kernel'.
+
+NOTE: Kernel filename and kernel symlink name must be different.
+
+*--systemmap-filename*=<...>::
+Set System.map filename which will be used when kernel will be installed
+into *BOOTDIR* (implies *--install* option). Please see
+*--kernel-filename* option for available placeholders and restrictions.
++
+By default, System.map filename will be set to 'System.map-genkernel-%%ARCH%%-%%KV%%'.
+
+*--systemmap-symlink-name*=<...>::
+Set System.map symlink name which will be used when kernel will be
+installed into *BOOTDIR* (implies *--install* option) and *--symlink*
+option is given. Please see *--kernel-filename* option for available
+placeholders and restrictions.
++
+By default, System.map symlink name will be set to 'System.map'.
+
+NOTE: System.map filename and System.map symlink name must be different.
+
*--initramfs-overlay*=<dir>::
Directory structure to include in the initramfs, only available
on >=2.6 kernels.
diff --git a/gen_bootloader.sh b/gen_bootloader.sh
index b215cd8..5202047 100755
--- a/gen_bootloader.sh
+++ b/gen_bootloader.sh
@@ -102,12 +102,12 @@ set_bootloader_grub() {
# Add grub configuration to grub.conf
echo "# Genkernel generated entry, see GRUB documentation for details" >> ${GRUB_CONF}
echo "title=Gentoo Linux ($KV)" >> ${GRUB_CONF}
- printf "%b\n" "\tkernel /kernel-${KNAME}-${ARCH}-${KV} root=${GRUB_ROOTFS}" >> ${GRUB_CONF}
+ printf "%b\n" "\tkernel /${GK_FILENAME_KERNEL} root=${GRUB_ROOTFS}" >> ${GRUB_CONF}
if isTrue "${BUILD_RAMDISK}"
then
if [ "${PAT}" -gt '4' ]
then
- printf "%b\n" "\tinitrd /initramfs-${KNAME}-${ARCH}-${KV}" >> ${GRUB_CONF}
+ printf "%b\n" "\tinitrd /${GK_FILENAME_INITRAMFS}" >> ${GRUB_CONF}
fi
fi
echo >> ${GRUB_CONF}
@@ -129,14 +129,14 @@ set_bootloader_grub() {
}
set_bootloader_grub_duplicate_default_replace_kernel_initrd() {
- sed -r -e "/^[[:space:]]*kernel/s/kernel-[[:alnum:][:punct:]]+/kernel-${KNAME}-${ARCH}-${KV}/" - |
- sed -r -e "/^[[:space:]]*initrd/s/init(rd|ramfs)-[[:alnum:][:punct:]]+/init\1-${KNAME}-${ARCH}-${KV}/"
+ sed -r -e "/^[[:space:]]*kernel/s/kernel-[[:alnum:][:punct:]]+/${GK_FILENAME_KERNEL}/" - |
+ sed -r -e "/^[[:space:]]*initrd/s/init(rd|ramfs)-[[:alnum:][:punct:]]+/${GK_FILENAME_INITRAMFS}/"
}
set_bootloader_grub_check_for_existing_entry() {
local GRUB_CONF=$1
- if grep -q "^[[:space:]]*kernel[[:space:]=]*.*/kernel-${KNAME}-${ARCH}-${KV}\([[:space:]]\|$\)" "${GRUB_CONF}" &&
- grep -q "^[[:space:]]*initrd[[:space:]=]*.*/initramfs-${KNAME}-${ARCH}-${KV}\([[:space:]]\|$\)" "${GRUB_CONF}"
+ if grep -q "^[[:space:]]*kernel[[:space:]=]*.*/${GK_FILENAME_KERNEL}\([[:space:]]\|$\)" "${GRUB_CONF}" &&
+ grep -q "^[[:space:]]*initrd[[:space:]=]*.*/${GK_FILENAME_INITRAMFS}\([[:space:]]\|$\)" "${GRUB_CONF}"
then
return 0
fi
diff --git a/gen_cmdline.sh b/gen_cmdline.sh
index 5d62a64..6fbf309 100755
--- a/gen_cmdline.sh
+++ b/gen_cmdline.sh
@@ -182,8 +182,10 @@ longusage() {
echo " --postclear Clear all tmp files and caches after genkernel has run"
echo " --no-postclear Do not clean up after genkernel has run"
echo " Output Settings"
- echo " --kernname=<...> Tag the kernel and initramfs with a name; If not defined"
- echo " the option defaults to 'genkernel'"
+ echo " --kernel-filename=<...>"
+ echo " Set kernel filename"
+ echo " --kernel-symlink-name=<...>"
+ echo " Set kernel symlink name"
echo " --minkernpackage=<archive>"
echo " Archive file created using tar containing kernel and"
echo " initramfs"
@@ -196,9 +198,13 @@ longusage() {
echo " --no-kernel-sources This option is only valid if kerncache is"
echo " defined. If there is a valid kerncache no checks"
echo " will be made against a kernel source tree"
+ echo " --initramfs-filename=<...>"
+ echo " Set initramfs filename"
echo " --initramfs-overlay=<dir>"
echo " Directory structure to include in the initramfs,"
echo " only available on 2.6 kernels"
+ echo " --initramfs-symlink-name=<...>"
+ echo " Set initramfs symlink name"
echo " --firmware Enable copying of firmware into initramfs"
echo " --firmware-dir=<dir>"
echo " Specify directory to copy firmware from (defaults"
@@ -229,6 +235,10 @@ longusage() {
echo " Strip debug symbols from none, all, installed kernel (obsolete) or"
echo " modules (default)"
echo " --no-strip Don't strip installed kernel or modules, alias for --strip=none"
+ echo " --systemmap-filename=<...>"
+ echo " Set System.map filename"
+ echo " --systemmap-symlink-name=<...>"
+ echo " Set System.map symlink name"
echo
echo "For a detailed list of supported initramfs options and flags; issue:"
echo " man 8 genkernel"
@@ -670,9 +680,13 @@ parse_cmdline() {
CMD_KERNCACHE="${*#*=}"
print_info 3 "KERNCACHE: ${CMD_KERNCACHE}"
;;
- --kernname=*)
- CMD_KERNNAME="${*#*=}"
- print_info 3 "KERNNAME: ${CMD_KERNNAME}"
+ --kernel-filename=*)
+ CMD_KERNEL_FILENAME="${*#*=}"
+ print_info 3 "CMD_KERNEL_FILENAME: ${CMD_KERNEL_FILENAME}"
+ ;;
+ --kernel-symlink-name=*)
+ CMD_KERNEL_SYMLINK_NAME="${*#*=}"
+ print_info 3 "CMD_KERNEL_SYMLINK_NAME: ${CMD_KERNEL_SYMLINK_NAME}"
;;
--symlink|--no-symlink)
CMD_SYMLINK=$(parse_optbool "$*")
@@ -682,10 +696,26 @@ parse_cmdline() {
CMD_KERNEL_SOURCES=$(parse_optbool "$*")
print_info 3 "CMD_KERNEL_SOURCES: ${CMD_KERNEL_SOURCES}"
;;
+ --initramfs-filename=*)
+ CMD_INITRAMFS_FILENAME="${*#*=}"
+ print_info 3 "CMD_INITRAMFS_FILENAME: ${CMD_INITRAMFS_FILENAME}"
+ ;;
--initramfs-overlay=*)
CMD_INITRAMFS_OVERLAY="${*#*=}"
print_info 3 "CMD_INITRAMFS_OVERLAY: ${CMD_INITRAMFS_OVERLAY}"
;;
+ --initramfs-symlink-name=*)
+ CMD_INITRAMFS_SYMLINK_NAME="${*#*=}"
+ print_info 3 "CMD_INITRAMFS_SYMLINK_NAME: ${CMD_INITRAMFS_SYMLINK_NAME}"
+ ;;
+ --systemmap-filename=*)
+ CMD_SYSTEMMAP_FILENAME="${*#*=}"
+ print_info 3 "CMD_SYSTEMMAP_FILENAME: ${CMD_SYSTEMMAP_FILENAME}"
+ ;;
+ --systemmap-symlink-name=*)
+ CMD_SYSTEMMAP_SYMLINK_NAME="${*#*=}"
+ print_info 3 "CMD_SYSTEMMAP_SYMLINK_NAME: ${CMD_SYSTEMMAP_SYMLINK_NAME}"
+ ;;
--linuxrc=*)
CMD_LINUXRC="${*#*=}"
print_info 3 "CMD_LINUXRC: ${CMD_LINUXRC}"
diff --git a/gen_compile.sh b/gen_compile.sh
index b3a8382..dd2e7d7 100755
--- a/gen_compile.sh
+++ b/gen_compile.sh
@@ -303,38 +303,38 @@ compile_kernel() {
# if source != outputdir, we need this:
tmp_kernel_binary="${KERNEL_OUTPUTDIR}"/"${tmp_kernel_binary}"
tmp_kernel_binary2="${KERNEL_OUTPUTDIR}"/"${tmp_kernel_binary2}"
- systemmap="${KERNEL_OUTPUTDIR}"/System.map
+ local tmp_systemmap="${KERNEL_OUTPUTDIR}"/System.map
if isTrue "${CMD_INSTALL}"
then
copy_image_with_preserve \
- "kernel" \
+ "${GK_FILENAME_KERNEL_SYMLINK}" \
"${tmp_kernel_binary}" \
- "kernel-${KNAME}-${ARCH}-${KV}"
+ "${GK_FILENAME_KERNEL}"
copy_image_with_preserve \
- "System.map" \
- "${systemmap}" \
- "System.map-${KNAME}-${ARCH}-${KV}"
+ "${GK_FILENAME_SYSTEMMAP_SYMLINK}" \
+ "${tmp_systemmap}" \
+ "${GK_FILENAME_SYSTEMMAP}"
if isTrue "${GENZIMAGE}"
then
copy_image_with_preserve \
"kernelz" \
"${tmp_kernel_binary2}" \
- "kernelz-${KV}"
+ "${GK_FILENAME_KERNELZ}"
fi
else
- cp "${tmp_kernel_binary}" "${TMPDIR}/kernel-${KNAME}-${ARCH}-${KV}" \
- || gen_die "Could not copy the kernel binary to '${TMPDIR}'!"
+ cp "${tmp_kernel_binary}" "${TMPDIR}/${GK_FILENAME_TEMP_KERNEL}" \
+ || gen_die "Could not copy kernel binary '${tmp_kernel_binary}' to '${TMPDIR}'!"
- cp "${systemmap}" "${TMPDIR}/System.map-${KNAME}-${ARCH}-${KV}" \
- || gen_die "Could not copy System.map to '${TMPDIR}'!"
+ cp "${tmp_systemmap}" "${TMPDIR}/${GK_FILENAME_TEMP_SYSTEMMAP}" \
+ || gen_die "Could not copy System.map '${tmp_systemmap}' to '${TMPDIR}'!"
if isTrue "${GENZIMAGE}"
then
- cp "${tmp_kernel_binary2}" "${TMPDIR}/kernelz-${KV}" \
- || gen_die "Could not copy the kernelz binary to '${TMPDIR}'!"
+ cp "${tmp_kernel_binary2}" "${TMPDIR}/${GK_FILENAME_TEMP_KERNELZ}" \
+ || gen_die "Could not copy kernelz binary '${tmp_kernel_binary2}' to '${TMPDIR}'!"
fi
fi
}
diff --git a/gen_configkernel.sh b/gen_configkernel.sh
index 9a33717..124852e 100755
--- a/gen_configkernel.sh
+++ b/gen_configkernel.sh
@@ -27,7 +27,7 @@ determine_kernel_config_file() {
then
print_info 1 "Default configuration was forced. Will ignore any user kernel configuration!"
else
- kconfig_candidates=( "/etc/kernels/kernel-config-${ARCH}-${KV}" ${kconfig_candidates[@]} )
+ kconfig_candidates=( "/etc/kernels/${GK_FILENAME_CONFIG}" ${kconfig_candidates[@]} )
fi
local f
diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index 3674cf0..2689f86 100755
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -83,6 +83,168 @@ determine_KV() {
fi
}
+determine_output_filenames() {
+ print_info 5 '' 1 0
+
+ GK_FILENAME_CONFIG="kernel-config-${ARCH}-${KV}"
+ GK_FILENAME_KERNELZ="kernelz-${KV}"
+ GK_FILENAME_TEMP_CONFIG="config-${ARCH}-${KV}"
+ GK_FILENAME_TEMP_INITRAMFS="initramfs-${ARCH}-${KV}"
+ GK_FILENAME_TEMP_KERNEL="kernel-${ARCH}-${KV}"
+ GK_FILENAME_TEMP_KERNELZ="kernelz-${ARCH}-${KV}"
+ GK_FILENAME_TEMP_SYSTEMMAP="System.map-${ARCH}-${KV}"
+
+ isTrue "${CMD_INSTALL}" || return
+
+ # Do we have values?
+ if [ -z "${KERNEL_FILENAME}" ]
+ then
+ gen_die "--kernel-filename must be set to a non-empty value!"
+ elif [ -z "${KERNEL_SYMLINK_NAME}" ]
+ then
+ gen_die "--kernel-symlink-name must be set to a non-empty value!"
+ elif [ -z "${SYSTEMMAP_FILENAME}" ]
+ then
+ gen_die "--systemmap-filename must be set to a non-empty value!"
+ elif [ -z "${SYSTEMMAP_SYMLINK_NAME}" ]
+ then
+ gen_die "--systemmap-symlink-name must be set to a non-empty value!"
+ elif [ -z "${INITRAMFS_FILENAME}" ]
+ then
+ gen_die "--initramfs-filename must be set to a non-empty value!"
+ elif [ -z "${INITRAMFS_FILENAME}" ]
+ then
+ gen_die "--initramfs-filename must be set to a non-empty value!"
+ fi
+
+ # Kernel
+ GK_FILENAME_KERNEL=$(arch_replace "${KERNEL_FILENAME}")
+ GK_FILENAME_KERNEL=$(kv_replace "${GK_FILENAME_KERNEL}")
+
+ if [ -z "${GK_FILENAME_KERNEL}" ]
+ then
+ gen_die "Internal error: Variable 'GK_FILENAME_KERNEL' is empty!"
+ else
+ print_info 5 "GK_FILENAME_KERNEL set to '${GK_FILENAME_KERNEL}' (was: '${KERNEL_FILENAME}')"
+ fi
+
+ # Kernel symlink
+ GK_FILENAME_KERNEL_SYMLINK=$(arch_replace "${KERNEL_SYMLINK_NAME}")
+ GK_FILENAME_KERNEL_SYMLINK=$(kv_replace "${GK_FILENAME_KERNEL_SYMLINK}")
+
+ if [ -z "${GK_FILENAME_KERNEL_SYMLINK}" ]
+ then
+ gen_die "Internal error: Variable 'GK_FILENAME_KERNEL_SYMLINK' is empty!"
+ else
+ print_info 5 "GK_FILENAME_KERNEL_SYMLINK set to '${GK_FILENAME_KERNEL_SYMLINK}' (was: '${KERNEL_SYMLINK_NAME}')"
+ fi
+
+ if [[ "${GK_FILENAME_KERNEL}" == "${GK_FILENAME_KERNEL_SYMLINK}" ]]
+ then
+ gen_die "--kernel-filename cannot be identical with --kernel-symlink-name!"
+ fi
+
+ # System.map
+ GK_FILENAME_SYSTEMMAP=$(arch_replace "${SYSTEMMAP_FILENAME}")
+ GK_FILENAME_SYSTEMMAP=$(kv_replace "${GK_FILENAME_SYSTEMMAP}")
+
+ if [ -z "${GK_FILENAME_SYSTEMMAP}" ]
+ then
+ gen_die "Internal error: Variable 'GK_FILENAME_SYSTEMMAP' is empty!"
+ else
+ print_info 5 "GK_FILENAME_SYSTEMMAP set to '${GK_FILENAME_SYSTEMMAP}' (was: '${SYSTEMMAP_FILENAME}')"
+ fi
+
+ # System.map symlink
+ GK_FILENAME_SYSTEMMAP_SYMLINK=$(arch_replace "${SYSTEMMAP_SYMLINK_NAME}")
+ GK_FILENAME_SYSTEMMAP_SYMLINK=$(kv_replace "${GK_FILENAME_SYSTEMMAP_SYMLINK}")
+
+ if [ -z "${GK_FILENAME_SYSTEMMAP_SYMLINK}" ]
+ then
+ gen_die "Internal error: Variable 'GK_FILENAME_SYSTEMMAP_SYMLINK' is empty!"
+ else
+ print_info 5 "GK_FILENAME_SYSTEMMAP_SYMLINK set to '${GK_FILENAME_SYSTEMMAP_SYMLINK}' (was: '${SYSTEMMAP_SYMLINK_NAME}')"
+ fi
+
+ if [[ "${GK_FILENAME_SYSTEMMAP}" == "${GK_FILENAME_SYSTEMMAP_SYMLINK}" ]]
+ then
+ gen_die "--systemmap-filename cannot be identical with --systemmap-symlink-name!"
+ fi
+
+ # Initramfs
+ GK_FILENAME_INITRAMFS=$(arch_replace "${INITRAMFS_FILENAME}")
+ GK_FILENAME_INITRAMFS=$(kv_replace "${GK_FILENAME_INITRAMFS}")
+
+ if [ -z "${GK_FILENAME_INITRAMFS}" ]
+ then
+ gen_die "Internal error: Variable 'GK_FILENAME_INITRAMFS' is empty!"
+ else
+ print_info 5 "GK_FILENAME_INITRAMFS set to '${GK_FILENAME_INITRAMFS}' (was: '${INITRAMFS_FILENAME}')"
+ fi
+
+ # Initramfs symlink
+ GK_FILENAME_INITRAMFS_SYMLINK=$(arch_replace "${INITRAMFS_SYMLINK_NAME}")
+ GK_FILENAME_INITRAMFS_SYMLINK=$(kv_replace "${GK_FILENAME_INITRAMFS_SYMLINK}")
+
+ if [ -z "${GK_FILENAME_INITRAMFS_SYMLINK}" ]
+ then
+ gen_die "Internal error: Variable 'GK_FILENAME_INITRAMFS_SYMLINK' is empty!"
+ else
+ print_info 5 "GK_FILENAME_INITRAMFS_SYMLINK set to '${GK_FILENAME_INITRAMFS_SYMLINK}' (was: '${INITRAMFS_SYMLINK_NAME}')"
+ fi
+
+ if [[ "${GK_FILENAME_INITRAMFS}" == "${GK_FILENAME_INITRAMFS_SYMLINK}" ]]
+ then
+ gen_die "--initramfs-filename cannot be identical with --initramfs-symlink-name!"
+ fi
+
+ # Make sure we have unique filenames
+ if [[ "${GK_FILENAME_KERNEL}" == "${GK_FILENAME_INITRAMFS}" ]]
+ then
+ gen_die "--kernel-filename cannot be identical with --initramfs-filename!"
+ elif [[ "${GK_FILENAME_KERNEL}" == "${GK_FILENAME_SYSTEMMAP}" ]]
+ then
+ gen_die "--kernel-filename cannot be identical with --systemmap-filename!"
+ elif [[ "${GK_FILENAME_INITRAMFS}" == "${GK_FILENAME_SYSTEMMAP}" ]]
+ then
+ gen_die "--initramfs-filename cannot be identical with --systemmap-filename!"
+ fi
+
+ if [[ "${GK_FILENAME_KERNEL_SYMLINK}" == "${GK_FILENAME_INITRAMFS_SYMLINK}" ]]
+ then
+ gen_die "--kernel-symlink-name cannot be identical with --initramfs-symlink-name!"
+ elif [[ "${GK_FILENAME_KERNEL_SYMLINK}" == "${GK_FILENAME_SYSTEMMAP_SYMLINK}" ]]
+ then
+ gen_die "--kernel-symlink-name cannot be identical with --systemmap-symlink-name!"
+ elif [[ "${GK_FILENAME_INITRAMFS_SYMLINK}" == "${GK_FILENAME_SYSTEMMAP_SYMLINK}" ]]
+ then
+ gen_die "--initramfs-symlink-name cannot be identical with --systemmap-symlink-name!"
+ fi
+
+ local -a filename_vars
+ filename_vars+=( 'GK_FILENAME_INITRAMFS;--initramfs-filename' )
+ filename_vars+=( 'GK_FILENAME_INITRAMFS_SYMLINK;--initramfs-symlink-name' )
+ filename_vars+=( 'GK_FILENAME_KERNEL;--kernel-filename' )
+ filename_vars+=( 'GK_FILENAME_KERNEL_SYMLINK;--kernel-symlink-name' )
+ filename_vars+=( 'GK_FILENAME_SYSTEMMAP;--systemmap-filename' )
+ filename_vars+=( 'GK_FILENAME_SYSTEMMAP_SYMLINK;--systemmap-symlink-name' )
+
+ local valid_filename_pattern='^[a-zA-Z0-9_.-]{1,}$'
+ local filename_combo filename_varname filename_option
+
+ for filename_combo in "${filename_vars[@]}"
+ do
+ filename_combo=( ${filename_combo//;/ } )
+ filename_varname=${filename_combo[0]}
+ filename_option=${filename_combo[1]}
+
+ if [[ ! "${!filename_varname}" =~ ${valid_filename_pattern} ]]
+ then
+ gen_die "${filename_varname} value '${!filename_varname}' does not match regex '${valid_filename_pattern}'. Check ${filename_option} option!"
+ fi
+ done
+}
+
determine_real_args() {
# Unset known variables which will interfere with _tc-getPROG().
local tc_var tc_varname_build tc_vars=$(get_tc_vars)
@@ -101,7 +263,12 @@ determine_real_args() {
set_config_with_override STRING LOGFILE CMD_LOGFILE "/var/log/genkernel.conf"
set_config_with_override STRING KERNEL_DIR CMD_KERNEL_DIR "${DEFAULT_KERNEL_SOURCE}"
set_config_with_override BOOL KERNEL_SOURCES CMD_KERNEL_SOURCES "yes"
- set_config_with_override STRING KNAME CMD_KERNNAME "genkernel"
+ set_config_with_override STRING INITRAMFS_FILENAME CMD_INITRAMFS_FILENAME "${DEFAULT_INITRAMFS_FILENAME}"
+ set_config_with_override STRING INITRAMFS_SYMLINK_NAME CMD_INITRAMFS_SYMLINK_NAME "${DEFAULT_INITRAMFS_SYMLINK_NAME}"
+ set_config_with_override STRING KERNEL_FILENAME CMD_KERNEL_FILENAME "${DEFAULT_KERNEL_FILENAME}"
+ set_config_with_override STRING KERNEL_SYMLINK_NAME CMD_KERNEL_SYMLINK_NAME "${DEFAULT_KERNEL_SYMLINK_NAME}"
+ set_config_with_override STRING SYSTEMMAP_FILENAME CMD_SYSTEMMAP_FILENAME "${DEFAULT_SYSTEMMAP_FILENAME}"
+ set_config_with_override STRING SYSTEMMAP_SYMLINK_NAME CMD_SYSTEMMAP_SYMLINK_NAME "${DEFAULT_SYSTEMMAP_SYMLINK_NAME}"
set_config_with_override STRING CHECK_FREE_DISK_SPACE_BOOTDIR CMD_CHECK_FREE_DISK_SPACE_BOOTDIR
set_config_with_override STRING CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR CMD_CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR
diff --git a/gen_funcs.sh b/gen_funcs.sh
index e0b679a..a1fe98a 100755
--- a/gen_funcs.sh
+++ b/gen_funcs.sh
@@ -298,6 +298,13 @@ cache_replace() {
var_replace "CACHE" "${GK_V_CACHEDIR}" "${1}"
}
+kv_replace() {
+ [[ ${#} -ne 1 ]] \
+ && gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes exactly one argument (${#} given)!"
+
+ var_replace "KV" "${KV}" "${1}"
+}
+
gen_die() {
set +x
diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index 9c07c54..fb269b8 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -1536,7 +1536,7 @@ create_initramfs() {
print_info 1 "initramfs: >> Initializing ..."
# Create empty cpio
- CPIO_ARCHIVE="${TMPDIR}/initramfs-${KNAME}-${ARCH}-${KV}"
+ CPIO_ARCHIVE="${TMPDIR}/${GK_FILENAME_TEMP_INITRAMFS}"
append_data 'devices' # WARNING, must be first!
append_data 'base_layout'
append_data 'auxilary' "${BUSYBOX}"
@@ -1826,8 +1826,8 @@ create_initramfs() {
[[ -z ${mkimage_cmd} ]] && gen_die "mkimage is not available. Please install package 'dev-embedded/u-boot-tools'."
local mkimage_args="-A ${ARCH} -O linux -T ramdisk -C ${compression:-none} -a 0x00000000 -e 0x00000000"
print_info 1 "$(get_indent 1)>> Wrapping initramfs using mkimage ..."
- print_info 2 "$(get_indent 1)${mkimage_cmd} ${mkimage_args} -n initramfs-${KNAME}-${ARCH}-${KV} -d ${CPIO_ARCHIVE} ${CPIO_ARCHIVE}.uboot"
- ${mkimage_cmd} ${mkimage_args} -n "initramfs-${KNAME}-${ARCH}-${KV}" -d "${CPIO_ARCHIVE}" "${CPIO_ARCHIVE}.uboot" >> ${LOGFILE} 2>&1 || gen_die "Wrapping initramfs using mkimage failed"
+ print_info 2 "$(get_indent 1)${mkimage_cmd} ${mkimage_args} -n ${GK_FILENAME_TEMP_INITRAMFS} -d ${CPIO_ARCHIVE} ${CPIO_ARCHIVE}.uboot"
+ ${mkimage_cmd} ${mkimage_args} -n "${GK_FILENAME_TEMP_INITRAMFS}" -d "${CPIO_ARCHIVE}" "${CPIO_ARCHIVE}.uboot" >> ${LOGFILE} 2>&1 || gen_die "Wrapping initramfs using mkimage failed"
mv -f "${CPIO_ARCHIVE}.uboot" "${CPIO_ARCHIVE}" || gen_die "Rename failed"
fi
fi
@@ -1837,9 +1837,9 @@ create_initramfs() {
if ! isTrue "${INTEGRATED_INITRAMFS}"
then
copy_image_with_preserve \
- "initramfs" \
+ "${GK_FILENAME_INITRAMFS_SYMLINK}" \
"${CPIO_ARCHIVE}" \
- "initramfs-${KNAME}-${ARCH}-${KV}"
+ "${GK_FILENAME_INITRAMFS}"
fi
fi
}
diff --git a/gen_package.sh b/gen_package.sh
index 0240b80..aad52de 100755
--- a/gen_package.sh
+++ b/gen_package.sh
@@ -7,31 +7,37 @@ gen_minkernpackage() {
mkdir "${TEMP}/minkernpackage" || gen_die "Failed to create '${TEMP}/minkernpackage'!"
if [ -n "${KERNCACHE}" ]
then
- "${TAR_COMMAND}" -x -C "${TEMP}"/minkernpackage -f "${KERNCACHE}" kernel-${ARCH}-${KV} \
- || gen_die "Failed to extract 'kernel-${ARCH}-${KV}' from '${KERNCACHE}' to '${TEMP}/minkernpackage'!"
+ "${TAR_COMMAND}" -x -C "${TEMP}"/minkernpackage -f "${KERNCACHE}" "${GK_FILENAME_TEMP_KERNEL}" \
+ || gen_die "Failed to extract '${GK_FILENAME_TEMP_KERNEL}' from '${KERNCACHE}' to '${TEMP}/minkernpackage'!"
- mv "${TEMP}"/minkernpackage/{kernel-${ARCH}-${KV},kernel-${KNAME}-${ARCH}-${KV}} \
- || gen_die "Failed to rename '${TEMP}/minkernpackage/kernel-${ARCH}-${KV}' to 'kernel-${KNAME}-${ARCH}-${KV}'!"
-
- "${TAR_COMMAND}" -x -C "${TEMP}"/minkernpackage -f "${KERNCACHE}" System.map-${ARCH}-${KV} \
- || gen_die "Failed to extract 'System.map-${ARCH}-${KV}' from '${KERNCACHE}' to '${TEMP}/minkernpackage'!"
+ if [[ "${GK_FILENAME_TEMP_KERNEL}" != "${GK_FILENAME_KERNEL}" ]]
+ then
+ mv "${TEMP}"/minkernpackage/{${GK_FILENAME_TEMP_KERNEL},${GK_FILENAME_KERNEL}} \
+ || gen_die "Failed to rename '${TEMP}/minkernpackage/${GK_FILENAME_TEMP_KERNEL}' to '${GK_FILENAME_KERNEL}'!"
+ fi
- mv "${TEMP}"/minkernpackage/{System.map-${ARCH}-${KV},System.map-${KNAME}-${ARCH}-${KV}} \
- || gen_die "Failed to rename '${TEMP}/minkernpackage/System.map-${ARCH}-${KV}' to 'System.map-${KNAME}-${ARCH}-${KV}'!"
+ "${TAR_COMMAND}" -x -C "${TEMP}"/minkernpackage -f "${KERNCACHE}" "${GK_FILENAME_TEMP_SYSTEMMAP}" \
+ || gen_die "Failed to extract '${GK_FILENAME_TEMP_SYSTEMMAP}' from '${KERNCACHE}' to '${TEMP}/minkernpackage'!"
- "${TAR_COMMAND}" -x -C "${TEMP}"/minkernpackage -f "${KERNCACHE}" config-${ARCH}-${KV} \
- || gen_die "Failed to extract 'config-${ARCH}-${KV}' from '${KERNCACHE}' to '${TEMP}/minkernpackage'!"
+ if [[ "${GK_FILENAME_TEMP_SYSTEMMAP}" != "${GK_FILENAME_SYSTEMMAP}" ]]
+ then
+ mv "${TEMP}"/minkernpackage/{${GK_FILENAME_TEMP_SYSTEMMAP},${GK_FILENAME_SYSTEMMAP}} \
+ || gen_die "Failed to rename '${TEMP}/minkernpackage/${GK_FILENAME_TEMP_SYSTEMMAP}' to '${GK_FILENAME_SYSTEMMAP}'!"
+ fi
- mv "${TEMP}"/minkernpackage/{config-${ARCH}-${KV},config-${KNAME}-${ARCH}-${KV}} \
- || gen_die "Failed to rename '${TEMP}/minkernpackage/config-${ARCH}-${KV}' to 'config-${KNAME}-${ARCH}-${KV}'!"
+ "${TAR_COMMAND}" -x -C "${TEMP}"/minkernpackage -f "${KERNCACHE}" "${GK_FILENAME_TEMP_CONFIG}" \
+ || gen_die "Failed to extract '${GK_FILENAME_TEMP_CONFIG}' from '${KERNCACHE}' to '${TEMP}/minkernpackage'!"
if isTrue "${GENZIMAGE}"
then
- "${TAR_COMMAND}" -x -C "${TEMP}"/minkernpackage -f "${KERNCACHE}" kernelz-${ARCH}-${KV} \
- || gen_die "Failed to extract 'kernelz-${ARCH}-${KV}' from '${KERNCACHE}' to '${TEMP}/minkernpackage'!"
+ "${TAR_COMMAND}" -x -C "${TEMP}"/minkernpackage -f "${KERNCACHE}" "${GK_FILENAME_TEMP_KERNELZ}" \
+ || gen_die "Failed to extract '${GK_FILENAME_TEMP_KERNELZ}' from '${KERNCACHE}' to '${TEMP}/minkernpackage'!"
- mv "${TEMP}"/minkernpackage/{kernelz-${ARCH}-${KV},kernelz-${KNAME}-${ARCH}-${KV}} \
- || gen_die "Failed to rename '${TEMP}/minkernpackage/kernelz-${ARCH}-${KV}' to 'kernelz-${KNAME}-${ARCH}-${KV}'!"
+ if [[ "${GK_FILENAME_TEMP_KERNELZ}" != "${GK_FILENAME_KERNELZ}" ]]
+ then
+ mv "${TEMP}"/minkernpackage/{${GK_FILENAME_TEMP_KERNELZ},${GK_FILENAME_KERNELZ}} \
+ || gen_die "Failed to rename '${TEMP}/minkernpackage/${GK_FILENAME_TEMP_KERNELZ}' to '${GK_FILENAME_KERNELZ}'!"
+ fi
fi
else
local tmp_kernel_binary=$(find_kernel_binary ${KERNEL_BINARY})
@@ -42,13 +48,13 @@ gen_minkernpackage() {
cd "${KERNEL_OUTPUTDIR}" || gen_die "Failed to chdir to '${KERNEL_OUTPUTDIR}'!"
- cp "${tmp_kernel_binary}" "${TEMP}/minkernpackage/kernel-${KNAME}-${ARCH}-${KV}" \
+ cp "${tmp_kernel_binary}" "${TEMP}/minkernpackage/${GK_FILENAME_TEMP_KERNEL}" \
|| gen_die "Could not copy the kernel binary '${tmp_kernel_binary}' for the min kernel package!"
- cp "System.map" "${TEMP}/minkernpackage/System.map-${KNAME}-${ARCH}-${KV}" \
+ cp "System.map" "${TEMP}/minkernpackage/${GK_FILENAME_TEMP_SYSTEMMAP}" \
|| gen_die "Could not copy '${KERNEL_OUTPUTDIR}/System.map' for the min kernel package!"
- cp ".config" "${TEMP}/minkernpackage/config-${KNAME}-${ARCH}-${KV}" \
+ cp ".config" "${TEMP}/minkernpackage/${GK_FILENAME_TEMP_CONFIG}" \
|| gen_die "Could not copy the kernel config '${KERNEL_OUTPUTDIR}/.config' for the min kernel package!"
if isTrue "${GENZIMAGE}"
@@ -59,7 +65,7 @@ gen_minkernpackage() {
gen_die "Failed to locate kernel binary '${KERNEL_BINARY_2}'!"
fi
- cp "${tmp_kernel_binary2}" "${TEMP}/minkernpackage/kernelz-${KNAME}-${ARCH}-${KV}" \
+ cp "${tmp_kernel_binary2}" "${TEMP}/minkernpackage/${GK_FILENAME_TEMP_KERNEL}" \
|| gen_die "Could not copy the kernelz binary '${tmp_kernel_binary2}' for the min kernel package!"
fi
fi
@@ -68,8 +74,8 @@ gen_minkernpackage() {
then
if isTrue "${BUILD_RAMDISK}"
then
- cp "${TMPDIR}/initramfs-${KV}" "${TEMP}/minkernpackage/initramfs-${KNAME}-${ARCH}-${KV}" \
- || gen_die "Could not copy the initramfs '${TMPDIR}/initramfs-${KV}' for the min kernel package!"
+ cp "${TMPDIR}/${GK_FILENAME_TEMP_INITRAMFS}" "${TEMP}/minkernpackage/${GK_FILENAME_TEMP_INITRAMFS}" \
+ || gen_die "Could not copy the initramfs '${TMPDIR}/${GK_FILENAME_TEMP_INITRAMFS}' for the min kernel package!"
fi
fi
@@ -117,23 +123,23 @@ gen_kerncache() {
cd "${KERNEL_OUTPUTDIR}" || gen_die "Failed to chdir to '${KERNEL_OUTPUTDIR}'!"
- cp -aL "${tmp_kernel_binary}" "${TEMP}/kerncache/kernel-${ARCH}-${KV}" \
+ cp -aL "${tmp_kernel_binary}" "${TEMP}/kerncache/${GK_FILENAME_TEMP_KERNEL}" \
|| gen_die "Could not copy the kernel binary '${tmp_kernel_binary}' for the kernel package!"
- cp -aL "${KERNEL_OUTPUTDIR}/.config" "${TEMP}/kerncache/config-${ARCH}-${KV}" \
+ cp -aL "${KERNEL_OUTPUTDIR}/.config" "${TEMP}/kerncache/${GK_FILENAME_TEMP_CONFIG}" \
|| gen_die "Could not copy the kernel config '${KERNEL_OUTPUTDIR}/.config' for the kernel package!"
if isTrue "$(is_gzipped "${KERNEL_CONFIG}")"
then
# Support --kernel-config=/proc/config.gz, mainly
- zcat "${KERNEL_CONFIG}" > "${TEMP}/kerncache/config-${ARCH}-${KV}.orig" \
+ zcat "${KERNEL_CONFIG}" > "${TEMP}/kerncache/${GK_FILENAME_TEMP_CONFIG}.orig" \
|| gen_die "Could not copy the kernel config '${KERNEL_CONFIG}' for the kernel package!"
else
- cp -aL "${KERNEL_CONFIG}" "${TEMP}/kerncache/config-${ARCH}-${KV}.orig" \
+ cp -aL "${KERNEL_CONFIG}" "${TEMP}/kerncache/${GK_FILENAME_TEMP_CONFIG}.orig" \
|| gen_die "Could not copy the kernel config '${KERNEL_CONFIG}' for the kernel package!"
fi
- cp -aL "${KERNEL_OUTPUTDIR}/System.map" "${TEMP}/kerncache/System.map-${ARCH}-${KV}" \
+ cp -aL "${KERNEL_OUTPUTDIR}/System.map" "${TEMP}/kerncache/${GK_FILENAME_TEMP_SYSTEMMAP}" \
|| gen_die "Could not copy the System.map '${KERNEL_OUTPUTDIR}/System.map' for the kernel package!"
if isTrue "${GENZIMAGE}"
@@ -144,7 +150,7 @@ gen_kerncache() {
gen_die "Failed locate kernelz binary '${KERNEL_BINARY_2}'!"
fi
- cp -aL "${tmp_kernel_binary2}" "${TEMP}/kerncache/kernelz-${ARCH}-${KV}" \
+ cp -aL "${tmp_kernel_binary2}" "${TEMP}/kerncache/${GK_FILENAME_TEMP_KERNELZ}" \
|| gen_die "Could not copy the kernelz '${tmp_kernel_binary2}' for the kernel package!"
fi
@@ -179,22 +185,22 @@ gen_kerncache_extract_kernel() {
|| gen_die "Failed to extract '${KERNCACHE}' to '${TEMP}'!"
copy_image_with_preserve \
- "kernel" \
- "${TEMP}/kernel-${ARCH}-${KV}" \
- "kernel-${KNAME}-${ARCH}-${KV}"
+ "${GK_FILENAME_KERNEL_SYMLINK}" \
+ "${TEMP}/${GK_FILENAME_TEMP_KERNEL}" \
+ "${GK_FILENAME_KERNEL}"
if isTrue "${GENZIMAGE}"
then
copy_image_with_preserve \
"kernelz" \
- "${TEMP}/kernelz-${ARCH}-${KV}" \
- "kernelz-${KNAME}-${ARCH}-${KV}"
+ "${TEMP}/${GK_FILENAME_TEMP_KERNELZ}" \
+ "${GK_FILENAME_KERNELZ}"
fi
copy_image_with_preserve \
- "System.map" \
- "${TEMP}/System.map-${ARCH}-${KV}" \
- "System.map-${KNAME}-${ARCH}-${KV}"
+ "${GK_FILENAME_SYSTEMMAP_SYMLINK}" \
+ "${TEMP}/${GK_FILENAME_TEMP_SYSTEMMAP}" \
+ "${GK_FILENAME_SYSTEMMAP}"
}
gen_kerncache_extract_modules() {
@@ -217,11 +223,11 @@ gen_kerncache_extract_config() {
mkdir -p /etc/kernels || gen_die "Failed to create '/etc/kernels'!"
fi
- "${TAR_COMMAND}" -xf "${KERNCACHE}" -C /etc/kernels config-${ARCH}-${KV} \
- || gen_die "Failed to extract kerncache config 'config-${ARCH}-${KV}' from '${KERNCACHE}' to '/etc/kernels'!"
+ "${TAR_COMMAND}" -xf "${KERNCACHE}" -C /etc/kernels "${GK_FILENAME_TEMP_CONFIG}" \
+ || gen_die "Failed to extract kerncache config '${GK_FILENAME_TEMP_CONFIG}' from '${KERNCACHE}' to '/etc/kernels'!"
- mv /etc/kernels/config-${ARCH}-${KV} /etc/kernels/kernel-config-${ARCH}-${KV} \
- || gen_die "Failed to rename kernelcache config '/etc/kernels/config-${ARCH}-${KV}' to '/etc/kernels/kernel-config-${ARCH}-${KV}'!"
+ mv /etc/kernels/${GK_FILENAME_TEMP_CONFIG} /etc/kernels/${GK_FILENAME_CONFIG} \
+ || gen_die "Failed to rename kernelcache config '/etc/kernels/${GK_FILENAME_TEMP_CONFIG}' to '/etc/kernels/${GK_FILENAME_CONFIG}'!"
}
gen_kerncache_is_valid() {
@@ -237,20 +243,20 @@ gen_kerncache_is_valid() {
BUILD_KERNEL="no"
# Can make this more secure ....
- if [ -e "${TEMP}/config-${ARCH}-${KV}" -a -e "${TEMP}/kernel-${ARCH}-${KV}" ]
+ if [ -e "${TEMP}/${GK_FILENAME_TEMP_CONFIG}" -a -e "${TEMP}/${GK_FILENAME_TEMP_KERNEL}" ]
then
print_info 1 '' 1 0
print_info 1 'Valid kerncache found; No sources will be used ...'
KERNCACHE_IS_VALID="yes"
fi
else
- if [ -e "${TEMP}/config-${ARCH}-${KV}" -a -e "${KERNEL_CONFIG}" ]
+ if [ -e "${TEMP}/${GK_FILENAME_TEMP_CONFIG}" -a -e "${KERNEL_CONFIG}" ]
then
- if [ -e "${TEMP}/config-${ARCH}-${KV}.orig" ]
+ if [ -e "${TEMP}/${GK_FILENAME_TEMP_CONFIG}.orig" ]
then
- local test1=$(grep -v "^#" "${TEMP}/config-${ARCH}-${KV}.orig" | md5sum | cut -d " " -f 1)
+ local test1=$(grep -v "^#" "${TEMP}/${GK_FILENAME_TEMP_CONFIG}.orig" | md5sum | cut -d " " -f 1)
else
- local test1=$(grep -v "^#" "${TEMP}/config-${ARCH}-${KV}" | md5sum | cut -d " " -f 1)
+ local test1=$(grep -v "^#" "${TEMP}/${GK_FILENAME_TEMP_CONFIG}" | md5sum | cut -d " " -f 1)
fi
if isTrue "$(is_gzipped "${KERNEL_CONFIG}")"
diff --git a/genkernel b/genkernel
index da3d2d8..3c125c9 100755
--- a/genkernel
+++ b/genkernel
@@ -174,6 +174,8 @@ determine_KV
determine_kernel_arch
+determine_output_filenames
+
determine_kernel_config_file
setup_cache_dir
@@ -219,6 +221,8 @@ then
determine_KV
if [ -f "${TEMP}/.old_kv" ]
then
+ determine_output_filenames
+
old_KV=$(cat "${TEMP}/.old_kv")
print_info 1 "$(get_indent 1)>> Kernel version has changed (probably due to config change) since genkernel start:"
print_info 1 "$(get_indent 1)>> We are now building Linux kernel ${BOLD}${KV}${NORMAL} for ${BOLD}${ARCH}${NORMAL} ..."
@@ -237,9 +241,9 @@ then
if isTrue "${SAVE_CONFIG}"
then
- print_info 1 "$(get_indent 1)>> Saving config of successful build to '/etc/kernels/kernel-config-${ARCH}-${KV}' ..."
+ print_info 1 "$(get_indent 1)>> Saving config of successful build to '/etc/kernels/${GK_FILENAME_CONFIG}' ..."
[ ! -e '/etc/kernels' ] && mkdir -p /etc/kernels
- cp "${KERNEL_OUTPUTDIR}/.config" "/etc/kernels/kernel-config-${ARCH}-${KV}" || \
+ cp "${KERNEL_OUTPUTDIR}/.config" "/etc/kernels/${GK_FILENAME_CONFIG}" || \
print_warning 1 "Unable to copy the kernel configuration file; Ignoring non-fatal error ..."
# Just a warning because ordinary users are not allowed to write in /etc
fi
@@ -373,16 +377,16 @@ then
esac
else
print_info 1 ''
- print_info 1 "You will find the kernel image in '${TMPDIR}/kernel-${KNAME}-${ARCH}-${KV}'."
+ print_info 1 "You will find the kernel image in '${TMPDIR}/${GK_FILENAME_TEMP_KERNEL}'."
if isTrue "${GENZIMAGE}"
then
- print_info 1 "You will find the kernelz binary in '${TMPDIR}/kernelz-${KV}'."
+ print_info 1 "You will find the kernelz binary in '${TMPDIR}/${GK_FILENAME_TEMP_KERNELZ}'."
fi
if isTrue "${BUILD_RAMDISK}"
then
- print_info 1 "You will find the initramfs in '${TMPDIR}/initramfs-${KNAME}-${ARCH}-${KV}'."
+ print_info 1 "You will find the initramfs in '${TMPDIR}/${GK_FILENAME_TEMP_INITRAMFS}'."
fi
fi
@@ -396,26 +400,27 @@ then
if isTrue "${show_warning_initramfs_is_required}" && isTrue "${BUILD_RAMDISK}"
then
- INITRAMFS_INSTALLED_IN="${TMPDIR}"
- isTrue "${CMD_INSTALL}" && INITRAMFS_INSTALLED_IN="${BOOTDIR}"
+ INITRAMFS_FILE="${TMPDIR}/${GK_FILENAME_TEMP_INITRAMFS}"
+ isTrue "${CMD_INSTALL}" && INITRAMFS_FILE="${BOOTDIR}/${GK_FILENAME_INITRAMFS}"
print_warning 1 '' 1 0
print_warning 1 "If you require Genkernel's hardware detection features, you ${BOLD}MUST${NORMAL}"
- print_warning 1 "tell your bootloader to use the provided initramfs file (${INITRAMFS_INSTALLED_IN}/initramfs-${KNAME}-${ARCH}-${KV})."
+ print_warning 1 "tell your bootloader to use the provided initramfs file '${INITRAMFS_FILE}'."
+ unset INITRAMFS_FILE
fi
unset show_warning_initramfs_is_required
fi
if isTrue "${BUILD_RAMDISK}"
then
- if ! isTrue "${BUILD_KERNEL}" && ! isTrue "${CMD_INSTALL}"
- then
- print_info 1 ''
- print_info 1 "You will find the initramfs in '${TMPDIR}/initramfs-${KNAME}-${ARCH}-${KV}'."
- elif ! isTrue "${BUILD_KERNEL}" && isTrue "${CMD_INSTALL}"
+ if ! isTrue "${BUILD_KERNEL}"
then
+ INITRAMFS_FILE="${TMPDIR}/${GK_FILENAME_TEMP_INITRAMFS}"
+ isTrue "${CMD_INSTALL}" && INITRAMFS_FILE="${BOOTDIR}/${GK_FILENAME_INITRAMFS}"
+
print_info 1 ''
- print_info 1 "You will find the initramfs in '${BOOTDIR}/initramfs-${KNAME}-${ARCH}-${KV}'."
+ print_info 1 "You will find the initramfs in '${INITRAMFS_FILE}'."
+ unset INITRAMFS_FILE
fi
print_warning 1 '' 1 0
diff --git a/genkernel.conf b/genkernel.conf
index 0c1a2e7..23e015b 100644
--- a/genkernel.conf
+++ b/genkernel.conf
@@ -172,7 +172,7 @@ NOCOLOR="false"
# Run the specified command in the current environment after the kernel and
# modules have been compiled, useful to rebuild external kernel module
# (see MODULEREBUILD above) or installing additional
-# files (use 'copy_image_with_preserve dtb path/to/dtb dtb ${KNAME}-${ARCH}-${KV}')
+# files (use 'copy_image_with_preserve dtb path/to/dtb dtb <kernelname>')
#CMD_CALLBACK=""
@@ -279,10 +279,13 @@ DEFAULT_KERNEL_SOURCE="/usr/src/linux"
# =========MISC KERNEL CONFIGURATION============
#
-# Tag the kernel and initramfs with a name:
-# If not defined the option defaults to
-# 'genkernel'
-#KNAME="genkernel"
+# Set kernel filename which will be used when kernel will be installed
+# into BOOTDIR. See man page to learn more about available placeholders.
+#KERNEL_FILENAME="kernel-genkernel-%%ARCH%%-%%KV%%"
+
+# Set kernel symlink name which will be used when kernel will be installed
+# into BOOTDIR and SYMLINK option is enabled
+#KERNEL_SYMLINK_NAME="kernel"
# This option will set kernel option CONFIG_LOCALVERSION.
# Use special value "UNSET" to unset already set CONFIG_LOCALVERSION.
@@ -312,6 +315,15 @@ DEFAULT_KERNEL_SOURCE="/usr/src/linux"
# =========MISC INITRAMFS CONFIGURATION============
#
+# Set initramfs filename which will be used when initramfs will be
+# installed into BOOTDIR. See man page to learn more about available
+# placeholders.
+#INITRAMFS_FILENAME="initramfs-genkernel-%%ARCH%%-%%KV%%"
+
+# Set initramfs symlink name which will be used when initramfs will be
+# installed into BOOTDIR and SYMLINK option is enabled
+#INITRAMFS_SYMLINK_NAME="initramfs"
+
# Copy all compiled kernel modules to the initramfs
#ALLRAMDISKMODULES="no"