Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable bootconfig support in genkernel #42

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions defaults/linuxrc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ run busybox --install -s
CMDLINE=$(cat /proc/cmdline 2>/dev/null)
for x in ${CMDLINE}
do
x=${x//\"/}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I realized there IS a problem here.
If there are arguments with significant double-quotes, e.g. due to embedded whitespace, this would break them.

They are probably also partially broken already, so now is a good time to fix them.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't thought about the embedded whitespace, so do you have any better solution for this? (my knowledge with bash is kind of limited)

case "${x}" in
real_root=*)
REAL_ROOT=${x#*=}
Expand Down
13 changes: 13 additions & 0 deletions gen_cmdline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ longusage() {
echo " --bootloader=(grub|grub2)"
echo " Add new kernel to GRUB (grub) or GRUB2 (grub2) bootloader"
echo " --no-bootloader Skip bootloader update"
echo " --bootconfig=(<file>|none)"
echo " Append a kernel bootconfig data to initramfs"
echo " --no-bootconfig No append the kernel bootconfig to initramfs"
echo " --linuxrc=<file> Specifies a user created linuxrc"
echo " --busybox-config=<file> Specifies a user created busybox config"
echo " --genzimage Make and install kernelz image (PowerPC)"
Expand Down Expand Up @@ -540,6 +543,16 @@ parse_cmdline() {
CMD_BOOTLOADER="no"
print_info 3 "CMD_BOOTLOADER: ${CMD_BOOTLOADER}"
;;
--bootconfig=*)
CMD_BOOTCONFIG="yes"
BOOTCONFIG_FILE="${*#*=}"
[ -z "${BOOTCONFIG_FILE}" ] && CMD_BOOTCONFIG="no"
print_info 3 "CMD_BOOTCONFIG: ${BOOTCONFIG_FILE}"
;;
--no-bootconfig)
CMD_BOOTCONFIG="no"
print_info 3 "CMD_BOOTCONFIG=${CMD_BOOTCONFIG}"
;;
--iscsi|--no-iscsi)
CMD_ISCSI=$(parse_optbool "$*")
print_info 3 "CMD_ISCSI: ${CMD_ISCSI}"
Expand Down
13 changes: 13 additions & 0 deletions gen_determineargs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ determine_real_args() {
set_config_with_override BOOL HYPERV CMD_HYPERV "no"
set_config_with_override STRING BOOTFONT CMD_BOOTFONT "none"
set_config_with_override STRING BOOTLOADER CMD_BOOTLOADER "no"
set_config_with_override BOOL BOOTCONFIG CMD_BOOTCONFIG "no"
set_config_with_override BOOL B2SUM CMD_B2SUM "no"
set_config_with_override BOOL BUSYBOX CMD_BUSYBOX "yes"
set_config_with_override STRING BUSYBOX_CONFIG CMD_BUSYBOX_CONFIG
Expand Down Expand Up @@ -770,6 +771,18 @@ determine_real_args() {
;;
esac

if isTrue "${BOOTCONFIG}"
then
BOOTCONFIG_FILE=$(expand_file "${BOOTCONFIG_FILE}")
if [ -z "${BOOTCONFIG_FILE}" ]
then
gen_die "--bootconfig value '${BOOTCONFIG_FILE}' failed to expand!"
elif [ ! -e "${BOOTCONFIG_FILE}" ]
then
gen_die "--bootconfig file '${BOOTCONFIG_FILE}' does not exist!"
fi
fi

if isTrue "${KERNEL_SOURCES}"
then
if [ ! -d "${KERNEL_DIR}" ]
Expand Down
10 changes: 10 additions & 0 deletions gen_initramfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2311,6 +2311,16 @@ create_initramfs() {
${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

if isTrue "${BOOTCONFIG}"
then
local bootconfig_cmd=$(type -p bootconfig)
[[ -z ${bootconfig_cmd} ]] && gen_die "bootconfig is not available. Please install package 'dev-util/bootconfig'."
local bootconfig_args="-a ${BOOTCONFIG_FILE}"
print_info 1 "$(get_indent 1)>> Appending bootconfig data ..."
print_info 2 "$(get_indent 1)${bootconfig_cmd} ${bootconfig_args} ${CPIO_ARCHIVE}"
${bootconfig_cmd} ${bootconfig_args} "${CPIO_ARCHIVE}" >> ${LOGFILE} 2>&1 || gen_die "Appending bootconfig data failed"
fi
fi

if isTrue "${CMD_INSTALL}"
Expand Down
3 changes: 3 additions & 0 deletions genkernel.conf
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ NOCOLOR="false"
# Add boot splash using splashutils
#SPLASH="no"

# Append a bootconfig to the initramfs
#BOOTCONFIG="no"

# Use this splash theme. If commented out - the "default" name theme is used.
# Also, SPLASH="yes" needs to be enabled for this one to work.
# This supersedes the "SPLASH_THEME" option in '/etc/conf.d/splash'.
Expand Down