[gentoo-commits] proj/genkernel:master commit in: doc/, defaults/

2021-03-14 Thread Thomas Deutschmann
commit: 90138e02119bae09efe78f6ece02c039ad132137
Author: Thomas Deutschmann  gentoo  org>
AuthorDate: Sun Mar 14 18:24:39 2021 +
Commit: Thomas Deutschmann  gentoo  org>
CommitDate: Sun Mar 14 19:39:48 2021 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=90138e02

linuxrc: Refactor switch_root error handling

Previous idea (commit 93bf318e5114233f3cacc4575ab2e58d60e785c7) never
worked: Exec will replace initramfs' init (PID 1) with specified command
so that any further line will never be reached. If that command will
fail now, init basically ended which will trigger a kernel panic:

  !! A fatal error has occured since /sbin/openrc-init did not
  !! boot correctly. Trying to open a shell ...
  + exec /bin/bash
  /init: exec: line 1366: /bin/bash: not found
  [   55.060649] Kernel panic - not syncing: Attempted to kill init! 
exitcode=0x7f00

The new error handling will keep init running in loop which will
allow user to fix every detected problem until we are confident that
switch_root call has a chance to succeed.

In case the user cannot fix the problem (maybe because of
gk.userinteraction.disabled), we will call the newly added
gk.emergency action (reboot, poweroff or halt).

Signed-off-by: Thomas Deutschmann  gentoo.org>

 defaults/initrd.defaults |  1 +
 defaults/linuxrc | 73 +---
 doc/genkernel.8.txt  |  8 +-
 3 files changed, 59 insertions(+), 23 deletions(-)

diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index b4e1e1d..18e1382 100644
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -71,6 +71,7 @@ VERIFY=0
 IP='dhcp'
 GK_BOOTFONT_DISABLED=0
 GK_DEBUGMODE_STATEFILE="/tmp/debug.enabled"
+GK_EMERGENCY_ACTION="halt -f"
 GK_HW_LOAD_ALL_MODULES=0
 GK_HW_USE_MODULES_LOAD=0
 GK_INIT_LOG='/run/initramfs/init.log'

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 8356aea..ebed7d8 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -289,6 +289,24 @@ do
fi
unset tmp_disabled
;;
+   gk.emergency=*)
+   tmp_action=${x#*=}
+   case "${tmp_action}" in
+   reboot)
+   GK_EMERGENCY_ACTION="reboot -f"
+   ;;
+   poweroff)
+   GK_EMERGENCY_ACTION="poweroff -f"
+   ;;
+   halt)
+   GK_EMERGENCY_ACTION="halt -f"
+   ;;
+   *)
+   warn_msg "'${x}' is an unsupported 
emergency action -- ignored!"
+   ;;
+   esac
+   unset tmp_action
+   ;;
gk.hw.load-all=*)
tmp_disabled=${x#*=}
if is_true "${tmp_disabled}"
@@ -1341,28 +1359,39 @@ fi
 
 # init_opts is set in the environment by the kernel when it parses the command 
line
 init=${REAL_INIT:-/sbin/init}
-if ! mountpoint "${CHROOT}" 1>/dev/null 2>&1
-then
-   bad_msg "${CHROOT} was not a mountpoint"
-elif chroot "${CHROOT}" test ! -x /${init#/}
-then
-   bad_msg "init=${init} does not exist in the rootfs!"
-elif [ $$ != 1 ]
-then
-   bad_msg "PID was not 1! switch_root would fail"
-else
-   good_msg "Switching to real root: switch_root ${CHROOT} ${init} 
${init_opts}"
-   exec switch_root "${CHROOT}" "${init}" ${init_opts}
-fi
 
-# If we get here, something bad has happened
-splash 'verbose'
+while true
+do
+   # switch_root can only be called from PID 1;
+   # So stay in loop as long as user is able
+   # to fix the problem.
 
-bad_msg "A fatal error has occured since ${init} did not"
-bad_msg "boot correctly. Trying to open a shell ..."
+   if  ! mountpoint "${CHROOT}" 1>/dev/null 2>&1
+   then
+   bad_msg "${CHROOT} is not a mountpoint; Was root device 
(${REAL_ROOT}) not mounted?"
+   elif ! chroot "${CHROOT}" test -x /${init#/} 1>/dev/null 2>&1
+   then
+   mounted_root_device=$(mountpoint -n /newroot 2>/dev/null | awk 
'{ print $1 }')
+   bad_msg "init (${init}) not found in mounted root device 
(${mounted_root_device})!"
+   else
+   break
+   fi
+
+   run_emergency_shell
+   if ! is_userinteraction_allowed
+   then
+   ${GK_EMERGENCY_ACTION} || exit 1
+   fi
+done
 
-exec /bin/bash
-exec /bin/sh
-exec /bin/ash
-exec /bin/dash
-exec sh
+good_msg "Switching to real root: switch_root ${CHROOT} ${init} ${init_opts}"
+exec switch_root "${CHROOT}" "${init}" ${init_opts}
+
+# If we reached here, something went very badly wrong in the initramfs.
+# However, spawning a rescue shell 

[gentoo-commits] proj/genkernel:master commit in: doc/, defaults/

2021-03-14 Thread Thomas Deutschmann
commit: 3fc2bfa183e05fe38bae40deb608bcb4e46ed065
Author: Thomas Deutschmann  gentoo  org>
AuthorDate: Sat Mar 13 18:36:22 2021 +
Commit: Thomas Deutschmann  gentoo  org>
CommitDate: Sun Mar 14 19:33:50 2021 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=3fc2bfa1

linuxrc: Mark kernel command-line argument lvmraid as deprecated

Not used anymore since we moved to (e)udev.

Signed-off-by: Thomas Deutschmann  gentoo.org>

 defaults/linuxrc| 3 +--
 doc/genkernel.8.txt | 4 
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 37a8dfa..28a504b 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -186,8 +186,7 @@ do
;;
# /dev/md
lvmraid=*)
-   RAID_DEVICES="${x#*=}"
-   RAID_DEVICES="$(echo ${RAID_DEVICES} | sed -e 's/,/ 
/g')"
+   warn_msg "'${x}' kernel command-line argument is 
deprecated; Use 'dolvm' instead!"
USE_LVM_NORMAL=1
;;
part=*)

diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index 74729be..d7afc07 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -780,10 +780,6 @@ when not set. This will allow remote user to provide 
answer through
 *dolvm*::
 Activate LVM volumes on bootup.
 
-*lvmraid*=<...>::
-Specify RAID devices to set up before the activation of LVM volumes.
-Implies option *dolvm*.
-
 *domdadm*::
 Scan for RAID arrays on bootup.
 



[gentoo-commits] proj/genkernel:master commit in: doc/, defaults/, /

2020-08-28 Thread Thomas Deutschmann
commit: 8c19b84644d3a0b7f70b101b9c83931280028eb7
Author: Thomas Deutschmann  gentoo  org>
AuthorDate: Fri Aug 28 13:16:36 2020 +
Commit: Thomas Deutschmann  gentoo  org>
CommitDate: Fri Aug 28 16:35:55 2020 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=8c19b846

defaults/linuxrc: Always preserve log

Now that we are using UDEV and have to preserve /run, we can also
use /run to always store log from initramfs.

This will make debugging easier because user don't have to explicit
enable logging (disabling is still possible).

Signed-off-by: Thomas Deutschmann  gentoo.org>

 defaults/initrd.defaults |  4 +--
 defaults/initrd.scripts  | 74 +---
 defaults/linuxrc | 39 -
 doc/genkernel.8.txt  | 13 +
 gen_initramfs.sh | 10 ++-
 5 files changed, 12 insertions(+), 128 deletions(-)

diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index e4c861b..e310f19 100644
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -74,9 +74,7 @@ GK_BOOTFONT_DISABLED=0
 GK_DEBUGMODE_STATEFILE="/tmp/debug.enabled"
 GK_HW_LOAD_ALL_MODULES=0
 GK_HW_USE_MODULES_LOAD=0
-GK_INIT_LOG='/tmp/init.log'
-GK_INIT_LOG_COPYTO=
-GK_INIT_LOG_COPYTO_DEFAULT='/genkernel-boot.log'
+GK_INIT_LOG='/run/initramfs/init.log'
 GK_INIT_LOG_DISABLED='/tmp/no-init.log'
 GK_INIT_LOG_PREFIX=
 GK_NET_DHCP_PIDFILE='/var/run/udhcpc.pid'

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index b579e4f..ee7ca2c 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -1177,78 +1177,6 @@ crypt_filter() {
fi
 }
 
-preserve_log() {
-   is_log_enabled || return
-   [ ! -s "${GK_INIT_LOG}" ] && return
-   [ -z "${GK_INIT_LOG_COPYTO}" ] && return
-
-   local have_errors=0
-
-   local logfile_target="${CHROOT}/${GK_INIT_LOG_COPYTO#/}"
-   if ! echo "${logfile_target}" | grep -qE '^.*/[A-Za-z0-9._-]+$'
-   then
-   # The test above will make sure that a filename was given
-   # so we can be sure that dirname() will always return a
-   # path.
-   warn_msg "gk.log.keep value '${GK_INIT_LOG_COPYTO}' is invalid; 
Will copy log to '${GK_INIT_LOG_COPYTO_DEFAULT}' instead ..."
-   logfile_target="${CHROOT}/${GK_INIT_LOG_COPYTO_DEFAULT#/}"
-   fi
-
-   local fail_msg="Failed to copy '${GK_INIT_LOG}' to '${logfile_target}'"
-   local logfile_target_dir="$(dirname "${logfile_target}")"
-
-   if [ -z "${logfile_target_dir}" ]
-   then
-   bad_msg "${fail_msg}: Failed to determine dirname of 
'${logfile_target}'!"
-   return 1
-   fi
-
-   log_msg "Determining mountpoint of '${logfile_target}' ..."
-
-   local logfile_mountpoint="${logfile_target_dir}"
-   while [ true ]
-   do
-   if run mountpoint "${logfile_mountpoint}" 1>/dev/null 2>&1
-   then
-   if run mount -o remount,rw "${logfile_mountpoint}" 
1>/dev/null 2>&1
-   then
-   break
-   else
-   bad_msg "${fail_msg}: 'mount -o remount,rw 
\"${logfile_mountpoint}\"' failed!"
-   return 1
-   fi
-   fi
-
-   logfile_mountpoint="$(dirname "${logfile_mountpoint}")"
-   if [ "${logfile_mountpoint}" = "/" ]
-   then
-   # Stop here
-   bad_msg "${fail_msg}: Failed to determine mountpoint 
for '${logfile_target}'!"
-   return 1
-   fi
-   done
-
-   if [ ! -d "${logfile_target_dir}" ]
-   then
-   if ! run mkdir -p "${logfile_target_dir}" 2>/dev/null
-   then
-   bad_msg "${fail_msg}: Failed to create 
'${logfile_target_dir}'!"
-   return 1
-   fi
-   fi
-
-   good_msg "gk.log.keep set; Copying '${GK_INIT_LOG}' to 
'${logfile_target}' ..."
-   if ! run cp -f "${GK_INIT_LOG}" "${logfile_target}" 2>/dev/null
-   then
-   bad_msg "${fail_msg}!"
-   fi
-
-   if ! run mount -o remount,ro "${logfile_mountpoint}" 1>/dev/null 2>&1
-   then
-   bad_msg "Failed to re-mount ${logfile_mountpoint} read-only!"
-   fi
-}
-
 process_initramfs_mounts() {
local fslist=
 
@@ -2388,7 +2316,7 @@ start_sshd() {
run touch /var/log/lastlog
 
good_msg "Starting dropbear sshd ..." ${QUIET}
-   run dropbear -p ${GK_SSHD_PORT} -R -P "${GK_SSHD_PIDFILE}" 
2>/var/log/dropbear.log
+   run dropbear -p ${GK_SSHD_PORT} -R -P "${GK_SSHD_PIDFILE}" 
2>/run/initramfs/dropbear.log
if [ $? -eq 0 ]
then
if [ "${GK_PROMPT_TIMEOUT}" = '0' ]

diff --git a/defaults/linuxrc b/defaults/linuxrc
index afb91d8..a4ed811 100644
--- 

[gentoo-commits] proj/genkernel:master commit in: /, doc/, defaults/

2020-07-16 Thread Thomas Deutschmann
commit: 944da1fc61bd64a47c2bc6415da5e5d5611b6ff5
Author: Thomas Deutschmann  gentoo  org>
AuthorDate: Tue Jul 14 14:17:30 2020 +
Commit: Thomas Deutschmann  gentoo  org>
CommitDate: Thu Jul 16 14:29:15 2020 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=944da1fc

gen_initramfs.sh: create_initramfs(): Move and unify validation of 
--compress-initramfs-type to determine_real_args()

This will allow us to error out early if required user space tool
needed to compress initramfs based on specified --compress-initramfs-type
is missing or selected type is invalid/unsupported.

Best/fastest list is based on results from [Link1][Link2][Link3].

Link1: 
https://events.static.linuxfound.org/sites/events/files/lcjpcojp13_klee.pdf
Link2: 
https://kernel.ubuntu.com/~cking/boot-speed-eoan-5.3/kernel-compression-method.txt
Link3: https://lwn.net/Articles/817134/
Signed-off-by: Thomas Deutschmann  gentoo.org>

 defaults/compression_methods.sh | 37 +
 doc/genkernel.8.txt | 10 +++--
 gen_cmdline.sh  |  3 +-
 gen_determineargs.sh| 91 +
 gen_funcs.sh| 24 +++
 gen_initramfs.sh| 67 +++---
 genkernel   |  1 +
 7 files changed, 168 insertions(+), 65 deletions(-)

diff --git a/defaults/compression_methods.sh b/defaults/compression_methods.sh
new file mode 100644
index 000..41ee9c4
--- /dev/null
+++ b/defaults/compression_methods.sh
@@ -0,0 +1,37 @@
+# NOTE:
+# - This file (compression_methods.sh) is sourced by genkernel.
+#   Rather than changing this very file, please override specific variables
+#   somewhere in /etc/genkernel.conf .
+#
+# - This file should not override previously defined variables, as their 
values may
+#   originate from user changes to /etc/genkernel.conf .
+
+GKICM_BZ2_KOPTNAME="BZIP2"
+GKICM_BZ2_CMD="bzip2 -z -f -9"
+GKICM_BZ2_EXT=".bz2"
+GKICM_BZ2_PKG="app-arch/bzip2"
+
+GKICM_GZ_KOPTNAME="GZIP"
+GKICM_GZ_CMD="gzip -f -9"
+GKICM_GZ_EXT=".gz"
+GKICM_GZ_PKG="app-arch/gzip"
+
+GKICM_LZO_KOPTNAME="LZO"
+GKICM_LZO_CMD="lzop -f -9"
+GKICM_LZO_EXT=".lzo"
+GKICM_LZO_PKG="app-arch/lzop"
+
+GKICM_LZ4_KOPTNAME="LZ4"
+GKICM_LZ4_CMD="lz4 -f -9 -l -q"
+GKICM_LZ4_EXT=".lz4"
+GKICM_LZ4_PKG="app-arch/lz4"
+
+GKICM_LZMA_KOPTNAME="LZMA"
+GKICM_LZMA_CMD="lzma -z -f -9"
+GKICM_LZMA_EXT=".lzma"
+GKICM_LZMA_PKG="app-arch/xz-utils"
+
+GKICM_XZ_KOPTNAME="XZ"
+GKICM_XZ_CMD="xz -e --check=none -z -f -9"
+GKICM_XZ_EXT=".xz"
+GKICM_XZ_PKG="app-arch/xz-utils"

diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index 494a29c..40c591e 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -598,9 +598,13 @@ NOTE: System.map filename and System.map symlink name must 
be different.
 Deprecated alias for *--*[*no-*]*compress-initramfs*.
 
 *--compress-initramfs-type*=::
-Compression type for initramfs (best, xz, lzma, bzip2, gzip, lzop, lz4).
-"Best" causes selection of the best available algorithm that is selected
-in your kernel configuration.
+Compression type for initramfs (best, bzip2, fastest, gzip, lz4, lzma, 
lza, xz).
++
+*best* will select the algorithm providing best compression
+from those selected in your kernel configuration.
++
+*fastest* will select the algorithm providing fastest decompression
+from those selected in your kernel configuration.
 
 *--strip*=::
 Strip debug symbols from none, all, installed kernel (obsolete) or

diff --git a/gen_cmdline.sh b/gen_cmdline.sh
index 9e59ed2..1daee5c 100755
--- a/gen_cmdline.sh
+++ b/gen_cmdline.sh
@@ -243,7 +243,8 @@ longusage() {
   echo "   --compress-initrd   Deprecated alias for 
--compress-initramfs"
   echo "   --no-compress-initrdDeprecated alias for 
--no-compress-initramfs"
   echo "   --compress-initramfs-type="
-  echo "   Compression type for initramfs (best, 
xz, lzma, bzip2, gzip, lzop, lz4)"
+  echo "   Compression type for initramfs (best, 
bzip2, fastest, gzip, lz4,"
+  echo "   lzma, lza, xz)"
   echo "   --strip=(all|kernel|modules|none)"
   echo "   Strip debug symbols from none, all, 
installed kernel (obsolete) or"
   echo "   modules (default)"

diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index 0cbba36..406d1d5 100755
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -619,6 +619,73 @@ determine_real_args() {
done
unset v pn pn_varname pkg_prefixes
 
+   declare -gA GKICM_LOOKUP_TABLE_CMD=()
+   declare -gA GKICM_LOOKUP_TABLE_EXT=()
+   declare -gA GKICM_LOOKUP_TABLE_PKG=()
+   local known_initramfs_compression_methods_by_compression=( 
$(get_initramfs_compression_method_by_compression) )
+   local known_initramfs_compression_methods_by_speed=( 

[gentoo-commits] proj/genkernel:master commit in: /, doc/, defaults/

2020-03-03 Thread Thomas Deutschmann
commit: 8768d9f1b9e8d166dbbd3428b221578c7504679c
Author: Thomas Deutschmann  gentoo  org>
AuthorDate: Tue Mar  3 00:38:31 2020 +
Commit: Thomas Deutschmann  gentoo  org>
CommitDate: Tue Mar  3 23:53:06 2020 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=8768d9f1

Make kernel config filename customizable

This commit will make kernel config filename used by --save-config
feature customizable like previous commit 769a07fd3e947 did for
initramfs and kernel image.

Signed-off-by: Thomas Deutschmann  gentoo.org>

 defaults/config.sh   |  1 +
 doc/genkernel.8.txt  |  6 ++
 gen_cmdline.sh   |  6 ++
 gen_configkernel.sh  |  2 +-
 gen_determineargs.sh | 19 +--
 5 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/defaults/config.sh b/defaults/config.sh
index fed5355..8c7cf7e 100644
--- a/defaults/config.sh
+++ b/defaults/config.sh
@@ -23,6 +23,7 @@ KERNEL_SUPPORT_MICROCODE=no
 #
 DEFAULT_INITRAMFS_FILENAME="initramfs-%%KV%%.img"
 DEFAULT_INITRAMFS_SYMLINK_NAME="initramfs"
+DEFAULT_KERNEL_CONFIG_FILENAME="kernel-config-%%KV%%"
 DEFAULT_KERNEL_FILENAME="vmlinuz-%%KV%%"
 DEFAULT_KERNEL_SYMLINK_NAME="kernel"
 DEFAULT_SYSTEMMAP_FILENAME="System.map-%%KV%%"

diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index e00e028..7cd65fe 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -506,6 +506,12 @@ 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-config-filename*=<...>::
+Set the kernel config filename used by *--save-config*. Please see
+*--kernel-filename* option for available placeholders and restrictions.
++
+By default, kernel config filename will be set to 'kernel-config-%%KV%%'.
+
 *--kernel-filename*=<...>::
 Set kernel filename which will be used when kernel will be installed
 into *BOOTDIR* (implies *--install* option). The following placeholders

diff --git a/gen_cmdline.sh b/gen_cmdline.sh
index aa54c29..a34a739 100755
--- a/gen_cmdline.sh
+++ b/gen_cmdline.sh
@@ -193,6 +193,8 @@ 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 "   --kernel-config-filename=<...>"
+  echo "   Set kernel config filename"
   echo "   --kernel-filename=<...>"
   echo "   Set kernel filename"
   echo "   --kernel-symlink-name=<...>"
@@ -701,6 +703,10 @@ parse_cmdline() {
CMD_KERNCACHE="${*#*=}"
print_info 3 "KERNCACHE: ${CMD_KERNCACHE}"
;;
+   --kernel-config-filename=*)
+   CMD_KERNEL_CONFIG_FILENAME="${*#*=}"
+   print_info 3 "CMD_KERNEL_CONFIG_FILENAME: 
${CMD_KERNEL_CONFIG_FILENAME}"
+   ;;
--kernel-filename=*)
CMD_KERNEL_FILENAME="${*#*=}"
print_info 3 "CMD_KERNEL_FILENAME: 
${CMD_KERNEL_FILENAME}"

diff --git a/gen_configkernel.sh b/gen_configkernel.sh
index 2f9a6a5..7804949 100755
--- a/gen_configkernel.sh
+++ b/gen_configkernel.sh
@@ -44,7 +44,7 @@ determine_kernel_config_file() {
else
local -a user_kconfig_candidates
 
-   # Always prefer kernel config based on actual $KV 
reading
+   # Always prefer kernel config based on set 
--kernel-config-filename
user_kconfig_candidates+=( 
"/etc/kernels/${GK_FILENAME_CONFIG}" )
 
if [ -n "${KERNEL_LOCALVERSION}" -a 
"${KERNEL_LOCALVERSION}" != "UNSET" ]

diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index 14ef757..6c5d01c 100755
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -87,7 +87,6 @@ determine_KV() {
 determine_output_filenames() {
print_info 5 '' 1 0
 
-   GK_FILENAME_CONFIG="kernel-config-${KV}"
GK_FILENAME_KERNELZ="kernelz-${KV}"
GK_FILENAME_TEMP_CONFIG="config-${ARCH}-${KV}"
GK_FILENAME_TEMP_INITRAMFS="initramfs-${ARCH}-${KV}"
@@ -96,7 +95,10 @@ determine_output_filenames() {
GK_FILENAME_TEMP_SYSTEMMAP="System.map-${ARCH}-${KV}"
 
# Do we have values?
-   if [ -z "${KERNEL_FILENAME}" ]
+   if [ -z "${KERNEL_CONFIG_FILENAME}" ]
+   then
+   gen_die "--kernel-config-filename must be set to a non-empty 
value!"
+   elif [ -z "${KERNEL_FILENAME}" ]
then
gen_die "--kernel-filename must be set to a non-empty value!"
elif [ -z "${KERNEL_SYMLINK_NAME}" ]
@@ -116,6 +118,17 @@ determine_output_filenames() {
gen_die "--initramfs-filename must be set to a non-empty value!"
fi
 
+   # Kernel 

[gentoo-commits] proj/genkernel:master commit in: doc/, defaults/

2020-01-29 Thread Thomas Deutschmann
commit: 93c4a548b0aa06c2b5fd40467b80e945e081be24
Author: Thomas Deutschmann  gentoo  org>
AuthorDate: Wed Jan 29 22:04:22 2020 +
Commit: Thomas Deutschmann  gentoo  org>
CommitDate: Wed Jan 29 22:12:36 2020 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=93c4a548

defaults/config.sh: Use --buildpkg=n and --usepkg=n in DEFAULT_MODULEREBUILD_CMD

While we call emerge with "--ignore-default-opts" since commit 
da5a5fa797a5fffa6c4d694cbfe2edc83bab4890
to avoid conflicting emerge options, we also need to ensure that
we don't clash with problematic emerge FEATURES like "getbinpkg".

Reported-by: Rick Farina  gentoo.org>
Signed-off-by: Thomas Deutschmann  gentoo.org>

 defaults/config.sh  | 2 +-
 doc/genkernel.8.txt | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/defaults/config.sh b/defaults/config.sh
index 694b3e9..fed5355 100644
--- a/defaults/config.sh
+++ b/defaults/config.sh
@@ -34,7 +34,7 @@ DEFAULT_COMPRESS_INITRD_TYPE=best
 PORTAGE_MAKEOPTS="$(portageq envvar MAKEOPTS)"
 DEFAULT_MAKEOPTS="${PORTAGE_MAKEOPTS:- -j2}"
 
-DEFAULT_MODULEREBUILD_CMD="emerge --ignore-default-opts --quiet-build=y 
@module-rebuild"
+DEFAULT_MODULEREBUILD_CMD="emerge --ignore-default-opts --buildpkg=n 
--usepkg=n --quiet-build=y @module-rebuild"
 
 DEFAULT_KERNEL_MAKE=make
 DEFAULT_UTILS_MAKE=make

diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index aebea03..6c7b9bd 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -196,7 +196,7 @@ specified.
 Copies or does not copy all kernel modules to the initrd.
 
 *--*[*no-*]*module-rebuild*::
-Runs, or does not run "emerge --ignore-default-opts --quiet-build=y 
@module-rebuild"
+Runs, or does not run "emerge --ignore-default-opts --buildpkg=n 
--usepkg=n --quiet-build=y @module-rebuild"
 to build out-of-tree modules when possible, i.e. when non-static
 kernel and modules will be build, installed, no custom
 'INSTALL_MOD_PATH' is set, '/var/lib/module-rebuild/moduledb' exists



[gentoo-commits] proj/genkernel:master commit in: doc/, defaults/

2020-01-13 Thread Thomas Deutschmann
commit: fe50a5857ded294fef0d6f28e50616b84f99e111
Author: Thomas Deutschmann  gentoo  org>
AuthorDate: Sun Jan 12 22:04:10 2020 +
Commit: Thomas Deutschmann  gentoo  org>
CommitDate: Sun Jan 12 22:09:32 2020 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=fe50a585

defaults/config.sh: Use --quiet-build=y in DEFAULT_MODULEREBUILD_CMD

--quiet-build=y instead of just --quiet will output error message in
case emerge failed. Because we catch output this will make genkernel.log
a single point of truth logfile without the need to consult any additional
logfile.

Signed-off-by: Thomas Deutschmann  gentoo.org>

 defaults/config.sh  | 2 +-
 doc/genkernel.8.txt | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/defaults/config.sh b/defaults/config.sh
index 678c0f9..694b3e9 100644
--- a/defaults/config.sh
+++ b/defaults/config.sh
@@ -34,7 +34,7 @@ DEFAULT_COMPRESS_INITRD_TYPE=best
 PORTAGE_MAKEOPTS="$(portageq envvar MAKEOPTS)"
 DEFAULT_MAKEOPTS="${PORTAGE_MAKEOPTS:- -j2}"
 
-DEFAULT_MODULEREBUILD_CMD="emerge --ignore-default-opts --quiet 
@module-rebuild"
+DEFAULT_MODULEREBUILD_CMD="emerge --ignore-default-opts --quiet-build=y 
@module-rebuild"
 
 DEFAULT_KERNEL_MAKE=make
 DEFAULT_UTILS_MAKE=make

diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index e9076a4..aebea03 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -196,7 +196,7 @@ specified.
 Copies or does not copy all kernel modules to the initrd.
 
 *--*[*no-*]*module-rebuild*::
-Runs, or does not run "emerge --ignore-default-opts --quiet 
@module-rebuild"
+Runs, or does not run "emerge --ignore-default-opts --quiet-build=y 
@module-rebuild"
 to build out-of-tree modules when possible, i.e. when non-static
 kernel and modules will be build, installed, no custom
 'INSTALL_MOD_PATH' is set, '/var/lib/module-rebuild/moduledb' exists



[gentoo-commits] proj/genkernel:master commit in: /, doc/, defaults/

2019-10-02 Thread Thomas Deutschmann
commit: 2ca8d5bb635d8f9db68d87e078f4ce4f410e9152
Author: Thomas Deutschmann  gentoo  org>
AuthorDate: Sun Sep 29 23:07:57 2019 +
Commit: Thomas Deutschmann  gentoo  org>
CommitDate: Sun Sep 29 23:07:57 2019 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=2ca8d5bb

Add --utils-cxx option

To compile thin-provisioning-tools, required for LVM thin provisioning
support which was added in commit 9dea735590ebfff278710148fa8743777a18c4bd,
we need a C++ compiler.

This option will allow user to specify custom C++ compiler (for example
when using ccache/distcc).

Signed-off-by: Thomas Deutschmann  gentoo.org>

 defaults/config.sh   | 1 +
 doc/genkernel.8.txt  | 5 -
 gen_cmdline.sh   | 7 ++-
 gen_determineargs.sh | 1 +
 gen_funcs.sh | 3 +++
 genkernel.conf   | 6 +-
 6 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/defaults/config.sh b/defaults/config.sh
index 9d15633..d9ea32c 100644
--- a/defaults/config.sh
+++ b/defaults/config.sh
@@ -43,5 +43,6 @@ DEFAULT_KERNEL_LD=ld
 
 DEFAULT_UTILS_CFLAGS="-Os -pipe -fomit-frame-pointer"
 DEFAULT_UTILS_CC=gcc
+DEFAULT_UTILS_CXX=g++
 DEFAULT_UTILS_AS=as
 DEFAULT_UTILS_LD=ld

diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index 82da1e1..3932e3d 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -269,7 +269,10 @@ LOW-LEVEL COMPILATION OPTIONS
 C compiler flags used to compile utilities.
 
 *--utils-cc*=::
-Compiler to use for utilities.
+C Compiler to use for utilities.
+
+*--utils-cxx*=::
+C++ Compiler to use for utilities.
 
 *--utils-ld*=::
 Linker to use for utilities.

diff --git a/gen_cmdline.sh b/gen_cmdline.sh
index 7e74182..d74c8f8 100755
--- a/gen_cmdline.sh
+++ b/gen_cmdline.sh
@@ -94,7 +94,8 @@ longusage() {
   echo "   --kernel-outputdir="
   echo "   Save output files outside the source 
tree"
   echo "   --utils-as=  Assembler to use for utils"
-  echo "   --utils-cc=   Compiler to use for utilities"
+  echo "   --utils-cc=   C Compiler to use for utilities"
+  echo "   --utils-cxx=  C++ Compiler to use for utilities"
   echo "   --utils-cflags= C compiler flags used to compile 
utilities"
   echo "   --utils-ld= Linker to use for utils"
   echo "   --utils-make= GNU Make to use for utils"
@@ -309,6 +310,10 @@ parse_cmdline() {
CMD_UTILS_CC="${*#*=}"
print_info 3 "CMD_UTILS_CC: ${CMD_UTILS_CC}"
;;
+   --utils-cxx=*)
+   CMD_UTILS_CXX="${*#*=}"
+   print_info 3 "CMD_UTILS_CXX: ${CMD_UTILS_CXX}"
+   ;;
--utils-cflags=*)
CMD_UTILS_CFLAGS="${*#*=}"
print_info 3 "CMD_UTILS_CFLAGS: ${CMD_UTILS_CFLAGS}"

diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index f3cfedf..28590d3 100755
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -285,6 +285,7 @@ determine_real_args() {
set_config_with_override STRING KERNEL_LD 
CMD_KERNEL_LD "$DEFAULT_KERNEL_LD"
set_config_with_override STRING KERNEL_AS 
CMD_KERNEL_AS "$DEFAULT_KERNEL_AS"
set_config_with_override STRING UTILS_CC  
CMD_UTILS_CC  "$DEFAULT_UTILS_CC"
+   set_config_with_override STRING UTILS_CXX 
CMD_UTILS_CXX "$DEFAULT_UTILS_CXX"
set_config_with_override STRING UTILS_LD  
CMD_UTILS_LD  "$DEFAULT_UTILS_LD"
set_config_with_override STRING UTILS_AS  
CMD_UTILS_AS  "$DEFAULT_UTILS_AS"
 

diff --git a/gen_funcs.sh b/gen_funcs.sh
index 23f6d30..1d4a91d 100755
--- a/gen_funcs.sh
+++ b/gen_funcs.sh
@@ -1061,6 +1061,9 @@ _tc-getPROG() {
CC)
[[ -n "${multilib_cflags}" ]] && prog+=( 
"${multilib_cflags}" )
;;
+   CXX)
+   [[ -n "${multilib_cflags}" ]] && prog+=( 
"${multilib_cflags}" )
+   ;;
LD)
[[ -n "${multilib_ldflags}" ]] &&  prog+=( 
"${multilib_ldflags}" )
;;

diff --git a/genkernel.conf b/genkernel.conf
index aa458fb..388502f 100644
--- a/genkernel.conf
+++ b/genkernel.conf
@@ -205,10 +205,14 @@ NOCOLOR="false"
 # option.
 #UTILS_MAKE="make"
 
-# Compiler to use for the utilities (e.g. distcc).  See also the --utils-cc
+# C Compiler to use for the utilities (e.g. distcc).  See also the --utils-cc
 # command line option.
 #UTILS_CC="gcc"
 
+# C++ Compiler to use for the utilities (e.g. distcc).  See 

[gentoo-commits] proj/genkernel:master commit in: doc/, defaults/, /

2019-07-29 Thread Thomas Deutschmann
commit: 769a07fd3e947ffb216ea94887d752a27ea212d9
Author: Thomas Deutschmann  gentoo  org>
AuthorDate: Sun Jul 28 14:33:25 2019 +
Commit: Thomas Deutschmann  gentoo  org>
CommitDate: Mon Jul 29 20:00:24 2019 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=769a07fd

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  gentoo.org>

 defaults/config.sh   |   7 +++
 doc/genkernel.8.txt  |  90 +++
 gen_bootloader.sh|  12 ++--
 gen_cmdline.sh   |  40 ++--
 gen_compile.sh   |  26 
 gen_configkernel.sh  |   2 +-
 gen_determineargs.sh | 169 ++-
 gen_funcs.sh |   7 +++
 gen_initramfs.sh |  10 +--
 gen_package.sh   |  98 +++--
 genkernel|  33 +-
 genkernel.conf   |  22 +--
 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*=::
 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.
 

[gentoo-commits] proj/genkernel:master commit in: /, doc/, defaults/

2019-07-29 Thread Thomas Deutschmann
commit: c452f3d690dc695a55aee63f0f2e4ab0cbb7b93a
Author: Thomas Deutschmann  gentoo  org>
AuthorDate: Sun Jul 28 20:56:30 2019 +
Commit: Thomas Deutschmann  gentoo  org>
CommitDate: Mon Jul 29 20:00:26 2019 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=c452f3d6

Change kernel and initramfs default filename in $BOOTDIR

This commit will change default kernel and initramfs filename:

  kernel-genkernel-%%ARCH%%-%%KV%%  -> vmlinuz-%%KV%%
  System.map-genkernel--%%ARCH%%-%%KV%% -> System.map-%%KV%%
  initramfs-genkernel-%%ARCH%%-%%KV%%   -> initramfs-%%KV%%.img

The new naming will be consistent with kernel's "make install" and
will allow to match files in /lib/modules with actual kernel.

In addition, $ARCH value was moved to kernel's LOCALVERSION. This will
ensure that this information is still present and when you do
cross-compilation, that /lib/modules content don't get mixed.

Bug: https://bugs.gentoo.org/390407
Signed-off-by: Thomas Deutschmann  gentoo.org>

 defaults/config.sh   |  6 +++---
 doc/genkernel.8.txt  | 21 -
 gen_configkernel.sh  |  2 +-
 gen_determineargs.sh | 11 +--
 genkernel| 10 ++
 genkernel.conf   |  6 +++---
 6 files changed, 42 insertions(+), 14 deletions(-)

diff --git a/defaults/config.sh b/defaults/config.sh
index 7232671..9d15633 100644
--- a/defaults/config.sh
+++ b/defaults/config.sh
@@ -21,11 +21,11 @@ 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_FILENAME="initramfs-%%KV%%.img"
 DEFAULT_INITRAMFS_SYMLINK_NAME="initramfs"
-DEFAULT_KERNEL_FILENAME="kernel-genkernel-%%ARCH%%-%%KV%%"
+DEFAULT_KERNEL_FILENAME="vmlinuz-%%KV%%"
 DEFAULT_KERNEL_SYMLINK_NAME="kernel"
-DEFAULT_SYSTEMMAP_FILENAME="System.map-%%ARCH%%-%%KV%%"
+DEFAULT_SYSTEMMAP_FILENAME="System.map-%%KV%%"
 DEFAULT_SYSTEMMAP_SYMLINK_NAME="System.map"
 
 DEFAULT_COMPRESS_INITRD=yes

diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index e94fa12..35762a2 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -125,8 +125,19 @@ KERNEL CONFIGURATION
 Adds, or skip adding VirtIO support to kernel configuration.
 
 *--kernel-localversion*=<...>::
-Set kernel option CONFIG_LOCALVERSION. Use special value "UNSET" to
-unset any already set LOCALVERSION.
+Set kernel option *LOCALVERSION*. Use special value *UNSET* to
+unset any already set *LOCALVERSION*. The following placeholders are
+available:
++
+[horizontal]
+*%%ARCH%%*:::
+Will be replaced with genkernel arch value, for example 'x86_64'.
+
++
+*LOCALVERSION* is only allowed to contain characters like 'a-z' or 'A-Z',
+'0-9', '_', '.' and '-'.
++
+By default, *LOCALVERSION* will be set to '-%%ARCH%%'.
 
 
 KERNEL COMPILATION
@@ -437,7 +448,7 @@ 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%%'.
+By default, initramfs filename will be set to 'initramfs-%%KV%%.img'.
 
 *--initramfs-symlink-name*=<...>::
 Set initramfs symlink name which will be used when initramfs will be
@@ -477,7 +488,7 @@ 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%%'.
+By default, kernel name will be set to 'vmlinuz-%%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.
@@ -502,7 +513,7 @@ 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%%'.
+By default, System.map filename will be set to 'System.map-%%KV%%'.
 
 *--systemmap-symlink-name*=<...>::
 Set System.map symlink name which will be used when kernel will be

diff --git a/gen_configkernel.sh b/gen_configkernel.sh
index 124852e..4cfd246 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/${GK_FILENAME_CONFIG}" ${kconfig_candidates[@]} )
+   kconfig_candidates=( 
"/etc/kernels/${GK_FILENAME_CONFIG}" "/etc/kernels/kernel-config-${ARCH}-${KV}" 
${kconfig_candidates[@]} )
fi
 
   

[gentoo-commits] proj/genkernel:master commit in: doc/, defaults/

2019-07-18 Thread Thomas Deutschmann
commit: b3889e9bf7d486f83db3c182844b1217ce75d472
Author: Thomas Deutschmann  gentoo  org>
AuthorDate: Thu Jul 18 20:08:23 2019 +
Commit: Thomas Deutschmann  gentoo  org>
CommitDate: Thu Jul 18 20:08:23 2019 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=b3889e9b

linuxrc: Load network modules only when needed

To avoid problems related to drivers requiring special firmware which
might be not available when loading the module because the user don't really
need that module but it was added based on genkernel's module_load file,
we will no longer load network modules on boot.

Instead we will only load network modules when needed, for example
when dosshd is set or NFS is used.

Signed-off-by: Thomas Deutschmann  gentoo.org>

 defaults/initrd.defaults |  5 +--
 defaults/initrd.scripts  | 83 +---
 doc/genkernel.8.txt  |  3 ++
 3 files changed, 78 insertions(+), 13 deletions(-)

diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index fbbd214..c617064 100644
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -80,6 +80,7 @@ GK_NET_ROUTES=
 GK_NET_TIMEOUT_DAD=10
 GK_NET_TIMEOUT_DECONFIGURATION=10
 GK_NET_TIMEOUT_DHCP=10
+GK_NET_TIMEOUT_INTERFACE=10
 GK_SHELL_LOCKFILE='/var/run/rescueshell.pid'
 GK_SSHD_LOCKFILE='/tmp/remote-rescueshell.lock'
 GK_SSHD_PIDFILE='/var/run/dropbear.pid'
@@ -119,8 +120,8 @@ DEFAULT_NFSOPTIONS="ro,nolock"
 # - modules
 HWOPTS_BLK='nvme pata sata scsi usb firewire waitscan'
 HWOPTS_OBSOLETE='pcmcia ataraid' # Obsolete stuff that might be useful on old 
hardware, do$X only.
-HWOPTS="keymap cache modules virtio hyperv ${HWOPTS_BLK} bcache lvm dmraid 
multipath mdadm zfs fs net iscsi crypto"
+HWOPTS="keymap cache modules virtio hyperv ${HWOPTS_BLK} bcache lvm dmraid 
multipath mdadm zfs fs iscsi crypto"
 
 # This is the set of default HWOPTS, in the order that they are loaded.
 # This is whitespace aligned with HWOPTS above.
-MY_HWOPTS="  modules virtio hyperv ${HWOPTS_BLK} bcache lvm dmraid 
  mdadm fs net   crypto"
+MY_HWOPTS="  modules virtio hyperv ${HWOPTS_BLK} bcache lvm dmraid 
  mdadm fs   crypto"

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index bc19fff..61ae534 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -1597,6 +1597,10 @@ iface_name() {
 }
 
 start_network() {
+   # Load network modules only when we need them to avoid possible
+   # firmware problems for people not using network that early
+   MY_HWOPTS=net load_modules
+
# At least gk.net.iface can only be processed after sysfs was
# mounted.
local x=
@@ -1620,17 +1624,21 @@ start_network() {
GK_NET_GW=${x#*=}
;;
gk.net.iface=*)
-   local tmp_iface=$(iface_name "${x#*=}")
-   if [ -z "${tmp_iface}" ]
-   then
-   warn_msg "Interface specified by '${x}' 
not found, falling back to genkernel defaults ..."
-   else
-   GK_NET_IFACE=${tmp_iface}
-   fi
+   GK_NET_IFACE=${x#*=}
;;
gk.net.routes=*)
GK_NET_ROUTES=${x#*=}
;;
+   gk.net.timeout.interface=*)
+   local tmp_interface_timeout=${x#*=}
+   if is_int "${tmp_interface_timeout}"
+   then
+   
GK_NET_TIMEOUT_INTERFACE=${tmp_interface_timeout}
+   else
+   warn_msg "'${x}' does not look like a 
valid number -- will keep using default value ${GK_NET_TIMEOUT_INTERFACE}!"
+   fi
+   unset tmp_interface_timeout
+   ;;
gk.net.timeout.dad=*)
local tmp_dad_timeout=${x#*=}
if is_int "${tmp_dad_timeout}"
@@ -1664,10 +1672,63 @@ start_network() {
esac
done
 
-   if [ ! -d "/sys/class/net/${GK_NET_IFACE}" ]
+   local interface_identifier=device
+   if echo "${GK_NET_IFACE}" | grep -qE ':|-'
then
-   warn_msg "Interface ${GK_NET_IFACE} not found; Will not try to 
start network ..."
-   return
+   interface_identifier=mac
+   good_msg_n "Waiting for interface with MAC address 
${GK_NET_IFACE} ..."
+   else
+   good_msg_n "Waiting for interface ${GK_NET_IFACE} ..."
+   fi
+
+   local tmp_interface=
+   local have_interface=0
+   local 

[gentoo-commits] proj/genkernel:master commit in: doc/, defaults/

2018-06-12 Thread Robin H. Johnson
commit: 5c5c32aa7261a29a3ac48035086bb59449d3804d
Author: Georgy Yakovlev  sysdump  net>
AuthorDate: Wed Jun  6 02:33:07 2018 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Wed Jun  6 06:02:35 2018 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=5c5c32aa

Add option to force importing zpool using cache

Add simple option to pass to kernel via loader.

dozfs=cache will use /etc/zfs/zpool.cache
avoiding 30+ second wait for udev in zpool import

Also it's possible to use both cache and force
at the same time:
dozfs=force,cache (order is not important) will
force import and use cache.

Closes: https://bugs.gentoo.org/627320
Signed-off-by: Georgy Yakovlev  sysdump.net>

 defaults/initrd.scripts |  6 +++---
 defaults/linuxrc| 19 +++
 doc/genkernel.8.txt |  6 +++---
 3 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 2fb0eb4..f8f9825 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -1181,7 +1181,7 @@ startVolumes() {
then
good_msg "Importing ZFS pools"
 
-   /sbin/zpool import -N -a ${ZPOOL_FORCE}
+   /sbin/zpool import -N -a ${ZPOOL_CACHE} ${ZPOOL_FORCE}
 
if [ "$?" = '0' ]
then
@@ -1199,12 +1199,12 @@ startVolumes() {
then
good_msg "LUKS detected. Reimporting 
${ZFS_POOL}"
/sbin/zpool export -f "${ZFS_POOL}"
-   /sbin/zpool import -N ${ZPOOL_FORCE} 
"${ZFS_POOL}"
+   /sbin/zpool import -N ${ZPOOL_CACHE} 
${ZPOOL_FORCE} "${ZFS_POOL}"
fi
else
good_msg "Importing ZFS pool ${ZFS_POOL}"
 
-   /sbin/zpool import -N ${ZPOOL_FORCE} 
"${ZFS_POOL}"
+   /sbin/zpool import -N ${ZPOOL_CACHE} 
${ZPOOL_FORCE} "${ZFS_POOL}"
 
if [ "$?" = '0' ]
then

diff --git a/defaults/linuxrc b/defaults/linuxrc
index d58ef06..81e7799 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -111,10 +111,21 @@ do
dozfs*)
USE_ZFS=1
 
-   if [ "${x#*=}" = 'force' ]
-   then
-   ZPOOL_FORCE=-f
-   fi
+   case "${x#*=}" in
+   *force*)
+   ZPOOL_FORCE=-f
+   ;;
+   esac
+
+   case "${x#*=}" in
+   *cache*)
+   if [ -s "/etc/zfs/zpool.cache" ]; then
+   ZPOOL_CACHE="-c 
/etc/zfs/zpool.cache"
+   else
+   bad_msg "zpool.cache not found 
or empty, zpool import will be slow"
+   fi
+   ;;
+   esac
;;
dobtrfs*)
USE_BTRFS=1

diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index 908212e..ca84816 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -522,9 +522,9 @@ recognized by the kernel itself.
 *domdadm*::
 Scan for RAID arrays on bootup
 
-*dozfs*[=force]::
-Scan for bootable ZFS pools on bootup. Optionally force import if
-necessary.
+*dozfs*[=cache,force]::
+Scan for bootable ZFS pools on bootup. Optionally use cachefile or force 
import if
+necessary or perform both actions.
 
 *dobtrfs*::
 Scan for attached Btrfs devices on bootup.



[gentoo-commits] proj/genkernel:master commit in: doc/, defaults/

2016-05-16 Thread Robin H. Johnson
commit: 67893b749b83fd716e55fa7c865f4c924454ee24
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Mon May 16 06:40:43 2016 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Mon May 16 06:49:04 2016 +
URL:https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=67893b74

defaults/linuxrc: bug #232733: implement rootwait.

Based on patch from John Klug  gmail.com>.

Signed-off-by: Robin H. Johnson  gentoo.org>

 defaults/initrd.defaults |  1 +
 defaults/linuxrc | 15 +++
 doc/genkernel.8.txt  |  5 +
 3 files changed, 21 insertions(+)

diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index a5eb3ba..b63ebd0 100755
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -60,6 +60,7 @@ REAL_ROOT=''
 CONSOLE='/dev/console'
 NEW_ROOT='/newroot'
 
no_umounts='/newroot|/mnt/aufs-dev|/mnt/aufs-rw-branch|/mnt/livecd|/mnt/cdrom|/.unions/memory|/.unions/memory/xino'
+ROOTDELAY=1
 CDROOT='0'
 CDROOT_DEV=''
 CDROOT_TYPE='auto'

diff --git a/defaults/linuxrc b/defaults/linuxrc
index ac8f215..72e1543 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -133,6 +133,12 @@ do
scandelay)
SDELAY=3
;;
+   rootdelay=*|rootwait=*)
+   ROOTDELAY=${x#*=}
+   ;;
+   rootdelay|rootwait)
+   ROOTDELAY=5
+   ;;
# Module no-loads
doload=*)
MDOLIST=${x#*=}
@@ -485,10 +491,14 @@ fi
 
 # Determine root device
 good_msg 'Determining root device ...'
+ROOTDELAY_100MSEC=1
+[ -n "${ROOTDELAY}" ] && ROOTDELAY_100MSEC=$(($ROOTDELAY * 10))
 while true
 do
while [ "${got_good_root}" != '1' ]
do
+   # Start of sleep loop waiting on root
+   while [ ${ROOTDELAY_100MSEC} -ge 0 -a "${got_good_root}" != '1' 
] ; do
case "${REAL_ROOT}" in
LABEL=*|UUID=*)
 
@@ -574,6 +584,11 @@ do
;;
esac
 
+   if [ "${got_good_root}" != '1' ] ; then
+ let ROOTDELAY_100MSEC=${ROOTDELAY_100MSEC}-1
+ usleep 100
+   fi
+   done  # End of sleep loop waiting on root
if [ "${REAL_ROOT}" = '' ]
then
# No REAL_ROOT determined/specified. Prompt user for 
root block device.

diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index ab534cd..bab1034 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -464,6 +464,11 @@ which the ramdisk & initramfs scripts would recognize.
 Pauses for 10 seconds before running devfsd if no argument is
 specified; otherwise pauses for the number of specified seconds.
 
+*rootdelay*[=<...>]::
+*rootwait*[=<...>]::
+   Pauses for up to 3 seconds (or specified number of seconds) while
+   waiting for root device to appear during initramfs root scanning.
+
 *ip*=<...>::
 Normally used to tell the kernel that it should start a network
 interface. If present, the initrd will try to mount a  livecd