Add --kernel-outputdir to save files outside the source tree.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
cleanup-cruft
Łukasz Stelmach 13 years ago committed by Robin H. Johnson
parent 63b9e57491
commit 79d7fa1948

@ -5,6 +5,12 @@
# Distributed under the GPL v2 # Distributed under the GPL v2
# $Id$ # $Id$
13 Oct 2012; Łukasz Stelmach <stlman@poczta.fm> gen_cmdline.sh,
gen_compile.sh, gen_configkernel.sh, gen_determineargs.sh, gen_funcs.sh,
genkernel:
Bug #435210 support external kernel output location, to allow pristine
source.
13 Oct 2012; Robin H. Johnson <robbat2@gentoo.org> gen_compile.sh: 13 Oct 2012; Robin H. Johnson <robbat2@gentoo.org> gen_compile.sh:
Bug #397947: Run depmod on new modules to avoid need to run at every boot on Bug #397947: Run depmod on new modules to avoid need to run at every boot on
unionfs systems, or systemd that never runs it. unionfs systems, or systemd that never runs it.

@ -63,6 +63,7 @@ longusage() {
echo " --kernel-make=<makeprg> GNU Make to use for kernel" echo " --kernel-make=<makeprg> GNU Make to use for kernel"
echo " --kernel-target=<t> Override default make target (bzImage)" echo " --kernel-target=<t> Override default make target (bzImage)"
echo " --kernel-binary=<path> Override default kernel binary path (arch/foo/boot/bar)" echo " --kernel-binary=<path> Override default kernel binary path (arch/foo/boot/bar)"
echo " --kernel-outputdir=<path> Save output files outside the source tree."
echo " --utils-cc=<compiler> Compiler to use for utilities" echo " --utils-cc=<compiler> Compiler to use for utilities"
echo " --utils-as=<assembler> Assembler to use for utils" echo " --utils-as=<assembler> Assembler to use for utils"
@ -214,6 +215,10 @@ parse_cmdline() {
CMD_KERNEL_CROSS_COMPILE=$(echo ${CMD_KERNEL_CROSS_COMPILE}|sed -e 's/.*[^-]$/&-/g') CMD_KERNEL_CROSS_COMPILE=$(echo ${CMD_KERNEL_CROSS_COMPILE}|sed -e 's/.*[^-]$/&-/g')
print_info 2 "CMD_KERNEL_CROSS_COMPILE: ${CMD_KERNEL_CROSS_COMPILE}" print_info 2 "CMD_KERNEL_CROSS_COMPILE: ${CMD_KERNEL_CROSS_COMPILE}"
;; ;;
--kernel-outputdir=*)
CMD_KERNEL_OUTPUTDIR=`parse_opt "$*"`
print_info 2 "CMD_KERNEL_OUTPUTDIR: ${CMD_KERNEL_OUTPUTDIR}"
;;
--utils-cc=*) --utils-cc=*)
CMD_UTILS_CC=`parse_opt "$*"` CMD_UTILS_CC=`parse_opt "$*"`
print_info 2 "CMD_UTILS_CC: ${CMD_UTILS_CC}" print_info 2 "CMD_UTILS_CC: ${CMD_UTILS_CC}"

@ -25,6 +25,10 @@ compile_kernel_args() {
then then
ARGS="${ARGS} ARCH=\"${KERNEL_ARCH}\"" ARGS="${ARGS} ARCH=\"${KERNEL_ARCH}\""
fi fi
if [ -n "${KERNEL_OUTPUTDIR}" ]
then
ARGS="${ARGS} O=\"${KERNEL_OUTPUTDIR}\""
fi
fi fi
echo -n "${ARGS}" echo -n "${ARGS}"
} }
@ -318,7 +322,7 @@ compile_kernel() {
compile_generic "${KERNEL_MAKE_DIRECTIVE_2}" kernel compile_generic "${KERNEL_MAKE_DIRECTIVE_2}" kernel
fi fi
local firmware_in_kernel_line=`fgrep CONFIG_FIRMWARE_IN_KERNEL "${KERNEL_DIR}"/.config` local firmware_in_kernel_line=`fgrep CONFIG_FIRMWARE_IN_KERNEL "${KERNEL_OUTPUTDIR}"/.config`
if [ -n "${firmware_in_kernel_line}" -a "${firmware_in_kernel_line}" != CONFIG_FIRMWARE_IN_KERNEL=y ] if [ -n "${firmware_in_kernel_line}" -a "${firmware_in_kernel_line}" != CONFIG_FIRMWARE_IN_KERNEL=y ]
then then
print_info 1 " >> Installing firmware ('make firmware_install') due to CONFIG_FIRMWARE_IN_KERNEL != y..." print_info 1 " >> Installing firmware ('make firmware_install') due to CONFIG_FIRMWARE_IN_KERNEL != y..."

@ -32,14 +32,14 @@ config_kernel() {
cd "${KERNEL_DIR}" || gen_die 'Could not switch to the kernel directory!' cd "${KERNEL_DIR}" || gen_die 'Could not switch to the kernel directory!'
# Backup current kernel .config # Backup current kernel .config
if isTrue "${MRPROPER}" || [ ! -f "${KERNEL_DIR}/.config" ] if isTrue "${MRPROPER}" || [ ! -f "${KERNEL_OUTPUTDIR}/.config" ]
then then
print_info 1 "kernel: Using config from ${KERNEL_CONFIG}" print_info 1 "kernel: Using config from ${KERNEL_CONFIG}"
if [ -f "${KERNEL_DIR}/.config" ] if [ -f "${KERNEL_OUTPUTDIR}/.config" ]
then then
NOW=`date +--%Y-%m-%d--%H-%M-%S` NOW=`date +--%Y-%m-%d--%H-%M-%S`
cp "${KERNEL_DIR}/.config" "${KERNEL_DIR}/.config${NOW}.bak" \ cp "${KERNEL_OUTPUTDIR}/.config" "${KERNEL_OUTPUTDIR}/.config${NOW}.bak" \
|| gen_die "Could not backup kernel config (${KERNEL_DIR}/.config)" || gen_die "Could not backup kernel config (${KERNEL_OUTPUTDIR}/.config)"
print_info 1 " Previous config backed up to .config${NOW}.bak" print_info 1 " Previous config backed up to .config${NOW}.bak"
fi fi
fi fi
@ -54,14 +54,14 @@ config_kernel() {
# If we're not cleaning a la mrproper, then we don't want to try to overwrite the configs # If we're not cleaning a la mrproper, then we don't want to try to overwrite the configs
# or we might remove configurations someone is trying to test. # or we might remove configurations someone is trying to test.
if isTrue "${MRPROPER}" || [ ! -f "${KERNEL_DIR}/.config" ] if isTrue "${MRPROPER}" || [ ! -f "${KERNEL_OUTPUTDIR}/.config" ]
then then
local message='Could not copy configuration file!' local message='Could not copy configuration file!'
if [[ "$(file --brief --mime-type "${KERNEL_CONFIG}")" == application/x-gzip ]]; then if [[ "$(file --brief --mime-type "${KERNEL_CONFIG}")" == application/x-gzip ]]; then
# Support --kernel-config=/proc/config.gz, mainly # Support --kernel-config=/proc/config.gz, mainly
zcat "${KERNEL_CONFIG}" > "${KERNEL_DIR}/.config" || gen_die "${message}" zcat "${KERNEL_CONFIG}" > "${KERNEL_OUTPUTDIR}/.config" || gen_die "${message}"
else else
cp "${KERNEL_CONFIG}" "${KERNEL_DIR}/.config" || gen_die "${message}" cp "${KERNEL_CONFIG}" "${KERNEL_OUTPUTDIR}/.config" || gen_die "${message}"
fi fi
fi fi
@ -106,21 +106,21 @@ config_kernel() {
then then
# Make sure Ext2 support is on... # Make sure Ext2 support is on...
sed -e 's/#\? \?CONFIG_EXT2_FS[ =].*/CONFIG_EXT2_FS=y/g' \ sed -e 's/#\? \?CONFIG_EXT2_FS[ =].*/CONFIG_EXT2_FS=y/g' \
-i ${KERNEL_DIR}/.config -i ${KERNEL_OUTPUTDIR}/.config
fi fi
# Make sure lvm modules are on if --lvm # Make sure lvm modules are on if --lvm
if isTrue ${CMD_LVM} if isTrue ${CMD_LVM}
then then
sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_BLK_DEV_DM is.*/CONFIG_BLK_DEV_DM=m/g' sed -i ${KERNEL_OUTPUTDIR}/.config -e 's/#\? \?CONFIG_BLK_DEV_DM is.*/CONFIG_BLK_DEV_DM=m/g'
sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_DM_SNAPSHOT is.*/CONFIG_DM_SNAPSHOT=m/g' sed -i ${KERNEL_OUTPUTDIR}/.config -e 's/#\? \?CONFIG_DM_SNAPSHOT is.*/CONFIG_DM_SNAPSHOT=m/g'
sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_DM_MIRROR is.*/CONFIG_DM_MIRROR=m/g' sed -i ${KERNEL_OUTPUTDIR}/.config -e 's/#\? \?CONFIG_DM_MIRROR is.*/CONFIG_DM_MIRROR=m/g'
fi fi
# Make sure dmraid modules are on if --dmraid # Make sure dmraid modules are on if --dmraid
if isTrue ${CMD_DMRAID} if isTrue ${CMD_DMRAID}
then then
sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_BLK_DEV_DM is.*/CONFIG_BLK_DEV_DM=m/g' sed -i ${KERNEL_OUTPUTDIR}/.config -e 's/#\? \?CONFIG_BLK_DEV_DM is.*/CONFIG_BLK_DEV_DM=m/g'
fi fi
# Make sure iSCSI modules are enabled in the kernel, if --iscsi # Make sure iSCSI modules are enabled in the kernel, if --iscsi
@ -128,15 +128,15 @@ config_kernel() {
# CONFIG_ISCSI_TCP # CONFIG_ISCSI_TCP
if isTrue ${CMD_ISCSI} if isTrue ${CMD_ISCSI}
then then
sed -i ${KERNEL_DIR}/.config -e 's/\# CONFIG_ISCSI_TCP is not set/CONFIG_ISCSI_TCP=m/g' sed -i ${KERNEL_OUTPUTDIR}/.config -e 's/\# CONFIG_ISCSI_TCP is not set/CONFIG_ISCSI_TCP=m/g'
sed -i ${KERNEL_DIR}/.config -e 's/\# CONFIG_SCSI_ISCSI_ATTRS is not set/CONFIG_SCSI_ISCSI_ATTRS=m/g' sed -i ${KERNEL_OUTPUTDIR}/.config -e 's/\# CONFIG_SCSI_ISCSI_ATTRS is not set/CONFIG_SCSI_ISCSI_ATTRS=m/g'
sed -i ${KERNEL_DIR}/.config -e 's/CONFIG_ISCSI_TCP=y/CONFIG_ISCSI_TCP=m/g' sed -i ${KERNEL_OUTPUTDIR}/.config -e 's/CONFIG_ISCSI_TCP=y/CONFIG_ISCSI_TCP=m/g'
sed -i ${KERNEL_DIR}/.config -e 's/CONFIG_SCSI_ISCSI_ATTRS=y/CONFIG_SCSI_ISCSI_ATTRS=m/g' sed -i ${KERNEL_OUTPUTDIR}/.config -e 's/CONFIG_SCSI_ISCSI_ATTRS=y/CONFIG_SCSI_ISCSI_ATTRS=m/g'
fi fi
if isTrue ${SPLASH} if isTrue ${SPLASH}
then then
sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_FB_SPLASH is.*/CONFIG_FB_SPLASH=y/g' sed -i ${KERNEL_OUTPUTDIR}/.config -e 's/#\? \?CONFIG_FB_SPLASH is.*/CONFIG_FB_SPLASH=y/g'
fi fi
} }

@ -90,6 +90,7 @@ determine_real_args() {
set_config_with_override STRING KERNEL_CROSS_COMPILE CMD_KERNEL_CROSS_COMPILE set_config_with_override STRING KERNEL_CROSS_COMPILE CMD_KERNEL_CROSS_COMPILE
set_config_with_override STRING UTILS_CROSS_COMPILE CMD_UTILS_CROSS_COMPILE set_config_with_override STRING UTILS_CROSS_COMPILE CMD_UTILS_CROSS_COMPILE
set_config_with_override STRING BOOTDIR CMD_BOOTDIR "/boot" set_config_with_override STRING BOOTDIR CMD_BOOTDIR "/boot"
set_config_with_override STRING KERNEL_OUTPUTDIR CMD_KERNEL_OUTPUTDIR "${DEFAULT_KERNEL_SOURCE}"
set_config_with_override STRING MODPROBEDIR CMD_MODPROBEDIR "/etc/modprobe.d" set_config_with_override STRING MODPROBEDIR CMD_MODPROBEDIR "/etc/modprobe.d"
set_config_with_override BOOL SPLASH CMD_SPLASH set_config_with_override BOOL SPLASH CMD_SPLASH

@ -298,6 +298,7 @@ copy_image_with_preserve() {
# Old product might be a different version. If so, we need to read # Old product might be a different version. If so, we need to read
# the symlink to see what it's name is, if there are symlinks. # the symlink to see what it's name is, if there are symlinks.
cd ${KERNEL_OUTPUTDIR}
if [ "${SYMLINK}" = '1' ] if [ "${SYMLINK}" = '1' ]
then then
print_info 4 "automatically managing symlinks and old images." 1 0 print_info 4 "automatically managing symlinks and old images." 1 0
@ -508,7 +509,7 @@ find_kernel_binary() {
local kernel_binary=$* local kernel_binary=$*
local curdir=$(pwd) local curdir=$(pwd)
cd "${KERNEL_DIR}" cd "${KERNEL_OUTPUTDIR}"
for i in ${kernel_binary} for i in ${kernel_binary}
do do
if [ -e "${i}" ] if [ -e "${i}" ]

@ -236,7 +236,9 @@ then
then then
print_info 1 "Copying config for successful build to /etc/kernels/kernel-config-${ARCH}-${KV}" print_info 1 "Copying config for successful build to /etc/kernels/kernel-config-${ARCH}-${KV}"
[ ! -e '/etc/kernels' ] && mkdir -p /etc/kernels [ ! -e '/etc/kernels' ] && mkdir -p /etc/kernels
cp "${KERNEL_DIR}/.config" "/etc/kernels/kernel-config-${ARCH}-${KV}" cp "${KERNEL_OUTPUTDIR}/.config" "/etc/kernels/kernel-config-${ARCH}-${KV}" || \
print_warning "Unable to copy the kernel configuration file."
# Just a warning because ordinary users are not allowed to write in /etc
fi fi
fi fi

Loading…
Cancel
Save