From 6ea20790b7571394a425040aa601e6cf7296d0dc Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Mon, 10 Mar 2008 00:38:49 +0000 Subject: [PATCH] Add support for --firmware and --firmware-dir options to include firmware in the initramfs git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@612 67a159dc-881f-0410-a524-ba9dfbe2cb84 --- ChangeLog | 5 +++++ gen_cmdline.sh | 14 ++++++++++++++ gen_determineargs.sh | 2 ++ gen_initramfs.sh | 22 ++++++++++++++++++++++ genkernel.conf | 3 +++ 5 files changed, 46 insertions(+) diff --git a/ChangeLog b/ChangeLog index c5cde12..928101d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ # Copyright 2006-2008 Gentoo Foundation; Distributed under the GPL v2 # $Header: $ + 10 Mar 2008; Andrew Gaffney gen_cmdline.sh, + gen_determineargs.sh, gen_initramfs.sh, genkernel.conf: + Add support for --firmware and --firmware-dir options to include firmware in + the initramfs + 09 Mar 2008; Andrew Gaffney generic/linuxrc: Apply patch from Vince C to mount sysfs prior to loading modules, so that the mdev firmware loading can actually work diff --git a/gen_cmdline.sh b/gen_cmdline.sh index 4408900..b556127 100755 --- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -117,6 +117,11 @@ longusage() { echo " --initramfs-overlay=" echo " Directory structure to include in the initramfs," echo " only available on 2.6 kernels" + echo " --firmware" + echo " Enable copying of firmware into initramfs" + echo " --firmware-dir=" + echo " Specify directory to copy firmware from (defaults" + echo " to /lib/firmware)" } usage() { @@ -476,6 +481,15 @@ parse_cmdline() { CMD_LUKS=1 print_info 2 "CMD_LUKS: ${CMD_LUKS}" ;; + --firmware) + CMD_FIRMWARE=1 + print_info 2 "CMD_FIRMWARE: ${CMD_FIRMWARE}" + ;; + --firmware-dir=*) + CMD_FIRMWARE_DIR=`parse_opt "$*"` + CMD_FIRMWARE=1 + print_info 2 "CMD_FIRMWARE_DIR: ${CMD_FIRMWARE_DIR}" + ;; all) BUILD_KERNEL=1 BUILD_MODULES=1 diff --git a/gen_determineargs.sh b/gen_determineargs.sh index f025389..6a7b872 100644 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -114,6 +114,8 @@ determine_real_args() { set_config_with_override 1 DISKLABEL CMD_DISKLABEL set_config_with_override 1 LUKS CMD_LUKS set_config_with_override 1 MDADM CMD_MDADM + set_config_with_override 1 FIRMWARE CMD_FIRMWARE + set_config_with_override 2 FIRMWARE_DIR CMD_FIRMWARE_DIR "/lib/firmware" BOOTDIR=`arch_replace "${BOOTDIR}"` BOOTDIR=${BOOTDIR%/} # Remove any trailing slash diff --git a/gen_initramfs.sh b/gen_initramfs.sh index a9ee20f..b5a15bd 100644 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -251,6 +251,23 @@ append_overlay(){ cd ${INITRAMFS_OVERLAY} find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" } + +append_firmware() { + if [ ! -d "${FIRMWARE_DIR}" ] + then + gen_die "specified firmware directory (${FIRMWARE_DIR}) does not exist" + fi + if [ -d "${TEMP}/initramfs-firmware-temp" ] + then + rm -r "${TEMP}/initramfs-firmware-temp/" + fi + mkdir -p "${TEMP}/initramfs-firmware-temp/lib/firmware" + cp -a "${FIRMWARE_DIR}/*" ${TEMP}/initramfs-firmware-temp/lib/firmware/ + find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \ + || gen_die "appending firmware to cpio" + rm -r "${TEMP}/initramfs-firmware-temp/" +} + print_list() { local x @@ -449,6 +466,11 @@ create_initramfs() { append_data 'blkid' "${DISKLABEL}" append_data 'splash' "${SPLASH}" + if isTrue "${FIRMWARE}" && [ -n "${FIRMWARE_DIR}" ] + then + append_data 'firmware' + fi + # This should always be appended last if [ "${INITRAMFS_OVERLAY}" != '' ] then diff --git a/genkernel.conf b/genkernel.conf index 8ab0ac7..305e8e6 100755 --- a/genkernel.conf +++ b/genkernel.conf @@ -69,6 +69,9 @@ USECOLOR="yes" # Copy /etc/mdadm.conf to initramfs. # MDADM="no" +# Enable copying of firmware into initramfs +# FIRMWARE="no" +# FIRMWARE_DIR="/lib/firmware" # =========Low Level Compile Settings========= # -- 2.26.2