Skip to content

Commit

Permalink
Added --rebuild-external-modules option, minor fixes.
Browse files Browse the repository at this point in the history
Made emerge @modules-rebuild issue warning on error, rather than dying.
Fixed handling of additional kernel command line options.
  • Loading branch information
sakaki- committed Oct 19, 2014
1 parent 520ca68 commit 3958d0d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
31 changes: 19 additions & 12 deletions buildkernel
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ shopt -s nullglob
# ********************** variables *********************
PROGNAME="$(basename "${0}")"
CONFFILE="/etc/${PROGNAME}.conf"
VERSION="1.0.6"
VERSION="1.0.7"
DEFAULTEFIBOOTFILE="bootx64.efi"
EFIBOOTFILE="${DEFAULTEFIBOOTFILE}"
NEWVERSION="$(basename $(realpath "/usr/src/linux"))"
Expand Down Expand Up @@ -60,7 +60,7 @@ CMDLINE_DOLVM_FLAG="dolvm"
SECUREBOOTKEY="/etc/efikeys/db.key"
SECUREBOOTCERT="/etc/efikeys/db.crt"
SIGNEDSUFFIX=".signed"
ADDITIONAL_KERNEL_CMDS=""
ADDITIONALKERNELCMDS=""
CMDLINE_ROOTFSTYPE="ext4"
CMDLINE_REAL_ROOT="/dev/mapper/vg1-root"
CMDLINE_REAL_RESUME="/dev/mapper/vg1-swap"
Expand Down Expand Up @@ -147,6 +147,7 @@ declare -i ARG_ASK=0 ARG_CLEAN=0 ARG_COPYFROMSTAGING=0 ARG_HELP=0
declare -i ARG_STAGEONLY=0 ARG_UNMOUNTATEND=0 ARG_VERBOSE=0 ARG_VERSION=0
declare -i ARG_POSTCLEAR=0 ARG_MENUCONFIG=0 ARG_SNAPSHOTBACKUP=0
declare -i ARG_EASYSETUP=0 ARG_IS_NEW_KERNEL_AVAILABLE=0
declare -i ARG_REBUILD_EXTERNAL_MODULES=0

# ***************** various functions ******************
cleanup_and_exit_with_code() {
Expand Down Expand Up @@ -340,8 +341,8 @@ setup_final_variables() {
if [ -n "${PLYMOUTHTHEME}" ]; then
KERNEL_CMD_LINE+=" quiet splash"
fi
if [ -n "${ADDITIONAL_KERNEL_CMDS}" ]; then
KERNEL_CMD_LINE+=" ${ADDITIONAL_KERNEL_CMDS}"
if [ -n "${ADDITIONALKERNELCMDS}" ]; then
KERNEL_CMD_LINE+=" ${ADDITIONALKERNELCMDS}"
fi
}
check_if_booted_under_efi() {
Expand Down Expand Up @@ -1482,13 +1483,16 @@ kernel_build_pass_1() {
make firmware_install
}
rebuild_external_modules_if_necessary() {
show "Creating any necessary external modules (e.g., VirtualBox)..."
if ! emerge ${VERBOSITYFLAG} @module-rebuild; then
if MAKEOPTS="${MAKEOPTS-} -j1" emerge --resume; then
warning "emerge @module-rebuild completed successfully, but only by restricting"
warning "build parallelism"
else
die "Failed to complete emerge @module-rebuild due to error"
if ((ARG_REBUILD_EXTERNAL_MODULES==1)); then
show "Creating any necessary external modules (e.g., VirtualBox)..."
if ! emerge ${VERBOSITYFLAG} @module-rebuild; then
if MAKEOPTS="${MAKEOPTS-} -j1" emerge --resume; then
warning "emerge @module-rebuild completed successfully, but only by restricting"
warning "build parallelism"
else
warning "Failed to complete emerge @module-rebuild due to error"
warning "Continuing..."
fi
fi
fi
}
Expand Down Expand Up @@ -1765,6 +1769,8 @@ Options:
to system partition
-u, --unmount-at-end umount the EFI system partition on successful exit
-v, --verbose display more information, where possible
-x, --rebuild-external-modules
rebuild external modules if present
-V, --version display the version number of ${PROGNAME} and exit
EOF
}
Expand Down Expand Up @@ -1824,7 +1830,7 @@ process_command_line_options() {
declare -i RC
set +e
# error trapping off, as we want to handle errors
TEMP="$(getopt -o abcefhimpsuvV --long ask,snapshot-backup,clean,easy-setup,copy-from-staging,help,is-new-kernel-available,menuconfig,postclear,stage-only,verbose,unmount-at-end,version -n "${PROGNAME}" -- "${@}")"
TEMP="$(getopt -o abcefhimpsuvxV --long ask,snapshot-backup,clean,easy-setup,copy-from-staging,help,is-new-kernel-available,menuconfig,postclear,stage-only,verbose,unmount-at-end,rebuild-external-modules,version -n "${PROGNAME}" -- "${@}")"
RC="${?}"
set -e
if ((RC!=0)); then
Expand All @@ -1847,6 +1853,7 @@ process_command_line_options() {
-s|--stage-only) ARG_STAGEONLY=1 ; shift ;;
-u|--unmount-at-end) ARG_UNMOUNTATEND=1 ; shift ;;
-v|--verbose) ARG_VERBOSE=1 ; shift ;;
-x|--rebuild-external-modules) ARG_REBUILD_EXTERNAL_MODULES=1 ; shift ;;
-V|--version) ARG_VERSION=1 ; shift ;;
--) shift ; break ;;
*) die "Internal error!" ;;
Expand Down
14 changes: 11 additions & 3 deletions buildkernel.8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH BUILDKERNEL 8 "Version 1.0.6: October 2014"
.TH BUILDKERNEL 8 "Version 1.0.7: October 2014"
.SH NAME
buildkernel \- build secure boot kernel, save to EFI system partition
.SH SYNOPSIS
Expand Down Expand Up @@ -55,11 +55,11 @@ calls your user hook function \fBuser_conform_config_file\fR if you have defined
.IP \(bu 2
allows you to modify the resulting configuration using the standard \fBmake menuconfig\fR tool (you can force this to happen, even in non-interactive mode, with \fB--menuconfig\fR, and you will be asked whether you wish to do so in interactive mode (set by \fB--ask\fR)); if you choose not to run \fBmake menuconfig\fR, \fBmake olddefconfig\fR will be run instead (which silently sanitizes/upgrades the conformed \fB.config\fR);
.IP \(bu 2
cleans the kernel tree (you can force this with \fB--clean\fR, and you will be asked whether you wish to do so in interactive mode (set by \fB--ask\fR));
cleans the kernel tree (if you specify \fB--clean\fR; you will be asked whether you wish to do so in interactive mode (set by \fB--ask\fR));
.IP \(bu 2
builds the kernel, and its modules, with the specified configuration; in this first pass, an empty initramfs is used (since it must be incorporated in the kernel, to be protected by UEFI secure boot, but we don't have everything necessary to include in it, yet!);
.IP \(bu 2
builds any external modules (such as those required for VirtualBox), using \fBemerge @module-rebuild\fR;
builds any external modules (such as those required for VirtualBox), using \fBemerge @module-rebuild\fR, if you so specify (using the option \fB--rebuild-external-modules\fR);
.IP \(bu 2
creates a first cut of the initramfs using \fBgenkernel\fR(8) (see below for more details); this will contain \fBgenkernel\fR(8)'s \fBinit\fR(8) script, compiled modules, any necessary firmware (if you haven't deblobbed), and a minimal set of binaries; it does \fInot\fR at this point contain a static copy of \fBgpg\fR;
.IP \(bu 2
Expand Down Expand Up @@ -165,6 +165,14 @@ b) in interactive mode, ask you whether or not you wish to unmount.
.BR \-v ", " \-\-verbose
Provides more verbose output from invoked tools, where possible.
.TP
.BR \-x ", " \-\-rebuild\-external\-modules
Specifies that external modules (such as those required by VirtualBox) should
be rebuilt (using \fBemerge @module-rebuild\fR)
at the appropriate stage in the process (see \fBALGORITHM DETAIL\fR, above).
However, note that if you are upgrading a kernel,
it is best to defer this step until rebooted into
the new kernel (for example, by running \fBgenup\fR(8), post-reboot).
.TP
.BR \-V ", " \-\-version
Displays the version number of \fBbuildkernel\fR, and exits.
.SH IMPORTANT CONFIGURATION VARIABLES
Expand Down
2 changes: 1 addition & 1 deletion buildkernel.conf.5
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH BUILDKERNEL 5 "Version 1.0.6: October 2014"
.TH BUILDKERNEL 5 "Version 1.0.7: October 2014"
.SH NAME
buildkernel.conf \- a configuration file for \fBbuildkernel\fR(8)
.SH SYNOPSIS
Expand Down

0 comments on commit 3958d0d

Please sign in to comment.