genkernel: migrate ALL the code to 4-spaces tabs

\t must die!
master
Fabio Erculiani 12 years ago
parent ebc7806e16
commit ce1e10241b

@ -1,39 +0,0 @@
# $Id$
DEPENDENCIES:
- GCC and binutils
- GNU Bash
- PaX Utilities
USAGE:
See http://www.gentoo.org/doc/en/genkernel.xml or
issue ``genkernel --help''.
PORTING:
To port to other arches:
# cd /usr/share/genkernel
# cp -Rp x86 ${myarch}
# mkdir /usr/share/genkernel/pkg/${myarch}
Modify what is needed in the /usr/share/genkernel/${myarch}
directory, as well making a generic kernel-config.
IMPORTANT KERNEL NOTES:
- You MUST have /dev/pts turned on.
- To boot genkernel properly, the kernel config must have
Initial RAM disk support.
BOOTING A KERNEL WITH INITRD:
GRUB:
root= needs to point to your root partition
vga= should be the resolution you want your screen. 0x317 is
1024x768 - 16bpp and you'll get a pretty splash if
configured properly
GRUB EXAMPLE ENTRY:
title=2.6.0 [ Genkernel ]
root (hd0,0)
kernel (hd0,0)/boot/kernel-2.6.0-gentoo root=/dev/hda3 vga=0x317
initrd (hd0,0)/boot/initrd-2.6.0-gentoo

File diff suppressed because it is too large Load Diff

@ -7,10 +7,10 @@
exec >${CONSOLE} <${CONSOLE} 2>&1 exec >${CONSOLE} <${CONSOLE} 2>&1
if [ "$$" != "1" ]; then if [ "$$" != "1" ]; then
echo "/linuxrc has to be run as the init process as the one" echo "/linuxrc has to be run as the init process as the one"
echo "with a PID of 1. Try adding init=/linuxrc to the" echo "with a PID of 1. Try adding init=/linuxrc to the"
echo "kernel command line or running "exec /linuxrc"." echo "kernel command line or running "exec /linuxrc"."
exit 1 exit 1
fi fi
mount -t proc -o noexec,nosuid,nodev proc /proc >/dev/null 2>&1 mount -t proc -o noexec,nosuid,nodev proc /proc >/dev/null 2>&1
@ -21,7 +21,7 @@ mount -t tmpfs none /dev/shm 2>&1
/bin/busybox --install -s /bin/busybox --install -s
if [ "$0" = "/init" ]; then if [ "$0" = "/init" ]; then
rm -f /linuxrc rm -f /linuxrc
fi fi
CMDLINE=$(cat /proc/cmdline) CMDLINE=$(cat /proc/cmdline)
@ -36,207 +36,207 @@ QUIET=""
mkdir -p /etc/cmdline /etc/modprobe.d mkdir -p /etc/cmdline /etc/modprobe.d
for x in ${CMDLINE}; do for x in ${CMDLINE}; do
case "${x}" in case "${x}" in
real_root=*) real_root=*)
REAL_ROOT=${x#*=} REAL_ROOT=${x#*=}
;; ;;
root=*) root=*)
FAKE_ROOT=${x#*=} FAKE_ROOT=${x#*=}
;; ;;
subdir=*) subdir=*)
SUBDIR=${x#*=} SUBDIR=${x#*=}
;; ;;
real_init=*) real_init=*)
REAL_INIT=${x#*=} REAL_INIT=${x#*=}
;; ;;
init=*) init=*)
FAKE_INIT=${x#*=} FAKE_INIT=${x#*=}
;; ;;
init_opts=*) init_opts=*)
INIT_OPTS=${x#*=} INIT_OPTS=${x#*=}
;; ;;
cdroot) cdroot)
CDROOT=1 CDROOT=1
;; ;;
cdroot=*) cdroot=*)
CDROOT=1 CDROOT=1
CDROOT_DEV=${x#*=} CDROOT_DEV=${x#*=}
;; ;;
cdroot_type=*) cdroot_type=*)
CDROOT_TYPE=${x#*=} CDROOT_TYPE=${x#*=}
;; ;;
cdroot_marker=*) cdroot_marker=*)
CDROOT_MARKER=${x#*=} CDROOT_MARKER=${x#*=}
;; ;;
loop=*) loop=*)
LOOP=${x#*=} LOOP=${x#*=}
;; ;;
looptype=*) looptype=*)
LOOPTYPE=${x#*=} LOOPTYPE=${x#*=}
;; ;;
isoboot=*) isoboot=*)
ISOBOOT=${x#*=} ISOBOOT=${x#*=}
;; ;;
domdev) domdev)
USE_MDEV=1 USE_MDEV=1
;; ;;
dolvm) dolvm)
USE_LVM_NORMAL=1 USE_LVM_NORMAL=1
;; ;;
domdadm) domdadm)
USE_MDADM=1 USE_MDADM=1
;; ;;
dodmraid) dodmraid)
USE_DMRAID_NORMAL=1 USE_DMRAID_NORMAL=1
;; ;;
dodmraid=*) dodmraid=*)
DMRAID_OPTS=${x#*=} DMRAID_OPTS=${x#*=}
USE_DMRAID_NORMAL=1 USE_DMRAID_NORMAL=1
;; ;;
domultipath) domultipath)
good_msg "Booting with multipath activated." good_msg "Booting with multipath activated."
USE_MULTIPATH_NORMAL=1 USE_MULTIPATH_NORMAL=1
;; ;;
dozfs*) dozfs*)
USE_ZFS=1 USE_ZFS=1
if [ "${x#*=}" = "force" ]; then if [ "${x#*=}" = "force" ]; then
ZPOOL_FORCE=-f ZPOOL_FORCE=-f
fi fi
;; ;;
quiet) quiet)
QUIET=1 QUIET=1
;; ;;
debug) debug)
DEBUG="yes" DEBUG="yes"
;; ;;
scandelay=*) scandelay=*)
SDELAY=${x#*=} SDELAY=${x#*=}
;; ;;
scandelay) scandelay)
SDELAY=3 SDELAY=3
;; ;;
doload=*) doload=*)
MDOLIST=${x#*=} MDOLIST=${x#*=}
MDOLIST=$(echo ${MDOLIST} | sed -e "s/,/ /g") MDOLIST=$(echo ${MDOLIST} | sed -e "s/,/ /g")
;; ;;
nodetect) nodetect)
NODETECT=1 NODETECT=1
;; ;;
noload=*) noload=*)
MLIST=${x#*=} MLIST=${x#*=}
MLIST="$(echo ${MLIST} | sed -e "s/,/ /g")" MLIST="$(echo ${MLIST} | sed -e "s/,/ /g")"
export MLIST export MLIST
;; ;;
CONSOLE=*|console=*) CONSOLE=*|console=*)
CONSOLE=${x#*=} CONSOLE=${x#*=}
CONSOLE=$(basename ${CONSOLE}) CONSOLE=$(basename ${CONSOLE})
;; ;;
splash) splash)
PLYMOUTH=1 PLYMOUTH=1
;; ;;
splash=*) splash=*)
FBSPLASH=1 FBSPLASH=1
;; ;;
lvmraid=*) lvmraid=*)
RAID_DEVICES="${x#*=}" RAID_DEVICES="${x#*=}"
RAID_DEVICES="$(echo ${RAID_DEVICES} | sed -e "s/,/ /g")" RAID_DEVICES="$(echo ${RAID_DEVICES} | sed -e "s/,/ /g")"
USE_LVM_NORMAL=1 USE_LVM_NORMAL=1
;; ;;
part=*) part=*)
MDPART=${x#*=} MDPART=${x#*=}
;; ;;
part|partitionable) part|partitionable)
MDPART=1 MDPART=1
;; ;;
ip=*) ip=*)
IP=${x#*=} IP=${x#*=}
;; ;;
nfsroot=*) nfsroot=*)
NFSROOT=${x#*=} NFSROOT=${x#*=}
;; ;;
iscsi_initiatorname=*) iscsi_initiatorname=*)
ISCSI_INITIATORNAME=${x#*=} ISCSI_INITIATORNAME=${x#*=}
;; ;;
iscsi_target=*) iscsi_target=*)
ISCSI_TARGET=${x#*=} ISCSI_TARGET=${x#*=}
;; ;;
iscsi_tgpt=*) iscsi_tgpt=*)
ISCSI_TGPT=${x#*=} ISCSI_TGPT=${x#*=}
;; ;;
iscsi_address=*) iscsi_address=*)
ISCSI_ADDRESS=${x#*=} ISCSI_ADDRESS=${x#*=}
;; ;;
iscsi_port=*) iscsi_port=*)
ISCSI_PORT=${x#*=} ISCSI_PORT=${x#*=}
;; ;;
iscsi_username=*) iscsi_username=*)
ISCSI_USERNAME=${x#*=} ISCSI_USERNAME=${x#*=}
;; ;;
iscsi_password=*) iscsi_password=*)
ISCSI_PASSWORD=${x#*=} ISCSI_PASSWORD=${x#*=}
;; ;;
iscsi_username_in=*) iscsi_username_in=*)
ISCSI_USERNAME_IN=${x#*=} ISCSI_USERNAME_IN=${x#*=}
;; ;;
iscsi_password_in=*) iscsi_password_in=*)
ISCSI_PASSWORD_IN=${x#*=} ISCSI_PASSWORD_IN=${x#*=}
;; ;;
iscsi_debug=*) iscsi_debug=*)
ISCSI_DEBUG=${x#*=} ISCSI_DEBUG=${x#*=}
;; ;;
iscsi_noibft) iscsi_noibft)
ISCSI_NOIBFT=1 ISCSI_NOIBFT=1
;; ;;
crypt_root=*) crypt_root=*)
CRYPT_ROOT=${x#*=} CRYPT_ROOT=${x#*=}
;; ;;
crypt_swap=*) crypt_swap=*)
CRYPT_SWAP=${x#*=} CRYPT_SWAP=${x#*=}
;; ;;
root_key=*) root_key=*)
CRYPT_ROOT_KEY=${x#*=} CRYPT_ROOT_KEY=${x#*=}
;; ;;
root_keydev=*) root_keydev=*)
CRYPT_ROOT_KEYDEV=${x#*=} CRYPT_ROOT_KEYDEV=${x#*=}
;; ;;
root_trim=*) root_trim=*)
CRYPT_ROOT_TRIM=${x#*=} CRYPT_ROOT_TRIM=${x#*=}
;; ;;
swap_key=*) swap_key=*)
CRYPT_SWAP_KEY=${x#*=} CRYPT_SWAP_KEY=${x#*=}
;; ;;
swap_keydev=*) swap_keydev=*)
CRYPT_SWAP_KEYDEV=${x#*=} CRYPT_SWAP_KEYDEV=${x#*=}
;; ;;
real_resume=*|resume=*) real_resume=*|resume=*)
REAL_RESUME=${x#*=} REAL_RESUME=${x#*=}
;; ;;
noresume) noresume)
NORESUME=1 NORESUME=1
;; ;;
crypt_silent) crypt_silent)
CRYPT_SILENT=1 CRYPT_SILENT=1
;; ;;
real_rootflags=*) real_rootflags=*)
REAL_ROOTFLAGS=${x#*=} REAL_ROOTFLAGS=${x#*=}
;; ;;
rootflags=*) rootflags=*)
FAKE_ROOTFLAGS=${x#*=} FAKE_ROOTFLAGS=${x#*=}
;; ;;
rootfstype=*) rootfstype=*)
ROOTFSTYPE=${x#*=} ROOTFSTYPE=${x#*=}
;; ;;
keymap=*) keymap=*)
keymap=${x#*=} keymap=${x#*=}
;; ;;
aufs) aufs)
USE_AUFS=1 USE_AUFS=1
;; ;;
esac esac
done done
quiet_kmsg quiet_kmsg
@ -305,8 +305,8 @@ splashcmd hasroot "${NEW_ROOT}"
cdupdate cdupdate
if [ "${SUBDIR}" != "" ] && [ -e "${CHROOT}/${SUBDIR}" ]; then if [ "${SUBDIR}" != "" ] && [ -e "${CHROOT}/${SUBDIR}" ]; then
good_msg "Entering ${SUBDIR} to boot" good_msg "Entering ${SUBDIR} to boot"
CHROOT="${CHROOT}/${SUBDIR}" CHROOT="${CHROOT}/${SUBDIR}"
fi fi
verbose_kmsg verbose_kmsg
@ -323,7 +323,7 @@ move_mounts_to_chroot
rundebugshell "before entering switch_root" rundebugshell "before entering switch_root"
exec /sbin/switch_root -c "/dev/console" "${CHROOT}" \ exec /sbin/switch_root -c "/dev/console" "${CHROOT}" \
"${REAL_INIT}" "${INIT_OPTS}" "${REAL_INIT}" "${INIT_OPTS}"
# If we get here, something bad has happened # If we get here, something bad has happened
splashcmd verbose splashcmd verbose

@ -3,35 +3,35 @@
[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1 [ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
case ${1} in case ${1} in
renew|bound) renew|bound)
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet" [ -n "$subnet" ] && NETMASK="netmask $subnet"
[ -n "$rootpath" ] && echo "$rootpath" > /rootpath [ -n "$rootpath" ] && echo "$rootpath" > /rootpath
[ -n "$hostname" ] && hostname ${hostname} [ -n "$hostname" ] && hostname ${hostname}
busybox ifconfig $interface $ip $BROADCAST $NETMASK busybox ifconfig $interface $ip $BROADCAST $NETMASK
if [ -n "${router}" ] if [ -n "${router}" ]
then then
while route del default gw 0.0.0.0 dev $interface; do while route del default gw 0.0.0.0 dev $interface; do
: :
done done
for i in ${router} for i in ${router}
do do
busybox route add default gw ${i} busybox route add default gw ${i}
done done
fi fi
[ -n "$domain" ] && echo "domain ${domain}" >> /etc/resolv.conf [ -n "$domain" ] && echo "domain ${domain}" >> /etc/resolv.conf
if [ -n "${dns}" ] if [ -n "${dns}" ]
then then
for i in ${dns} for i in ${dns}
do do
echo "nameserver ${i}" >> /etc/resolv.conf echo "nameserver ${i}" >> /etc/resolv.conf
done done
fi fi
;; ;;
deconfig) deconfig)
busybox ifconfig $interface 0.0.0.0 busybox ifconfig $interface 0.0.0.0
;; ;;
esac esac

@ -154,8 +154,8 @@ KERNEL COMPILATION
kernel and modules have been compiled. kernel and modules have been compiled.
*--*[*no-*]*static*:: *--*[*no-*]*static*::
Builds, or does not build a monolithic kernel without any modules on any Builds, or does not build a monolithic kernel without any modules on any
initial ramdisks. initial ramdisks.
KERNEL LOCATIONS KERNEL LOCATIONS
@ -256,8 +256,8 @@ INITIALIZATION
the system. the system.
*--*[*no-*]*lvm*:: *--*[*no-*]*lvm*::
Adds or skips in LVM support from static binaries if they exist on the Adds or skips in LVM support from static binaries if they exist on the
system, or compile static LVM binaries if static ones do not exist. system, or compile static LVM binaries if static ones do not exist.
*--*[*no-*]*mdadm*:: *--*[*no-*]*mdadm*::
Includes or excludes mdadm/mdmon support. Includes or excludes mdadm/mdmon support.
@ -296,15 +296,15 @@ INITIALIZATION
Specifies a user created busybox config. Specifies a user created busybox config.
*--genzimage*:: *--genzimage*::
Make and install kernelz image from 'arch/powerpc/boot/zImage.initrd'. Make and install kernelz image from 'arch/powerpc/boot/zImage.initrd'.
*--*[*no-*]*luks*:: *--*[*no-*]*luks*::
Includes or excludes Luks support from static binaries if they exist on Includes or excludes Luks support from static binaries if they exist on
the system. the system.
*--*[*no-*]*gpg*:: *--*[*no-*]*gpg*::
Includes or excludes support for GnuPG 1.x, the portable standalone branch Includes or excludes support for GnuPG 1.x, the portable standalone branch
of GnuPG. A key can be made from of GnuPG. A key can be made from
`gpg --symmetric -o /path/to/LUKS-key.gpg /path/to/LUKS-key` . `gpg --symmetric -o /path/to/LUKS-key.gpg /path/to/LUKS-key` .
After that, re-point the *root_key* argument to the new .gpg file. After that, re-point the *root_key* argument to the new .gpg file.
@ -331,7 +331,7 @@ INTERNALS
Sets genkernel's temporary working directory to <dir>. Sets genkernel's temporary working directory to <dir>.
*--*[*no-*]*postclear*:: *--*[*no-*]*postclear*::
Clears or skips clearing all tmp files and caches after genkernel has run. Clears or skips clearing all tmp files and caches after genkernel has run.
OUTPUT SETTINGS OUTPUT SETTINGS
@ -372,16 +372,16 @@ OUTPUT SETTINGS
For multiple files, separate the filenames with a comma. For multiple files, separate the filenames with a comma.
*--*[*no-*]*integrated-initramfs*:: *--*[*no-*]*integrated-initramfs*::
Builds or does not build the generated initramfs into the kernel instead Builds or does not build the generated initramfs into the kernel instead
of keeping it as a separate file. of keeping it as a separate file.
*--*[*no-*]*compress-initramfs*, *--*[*no-*]*compress-initrd*:: *--*[*no-*]*compress-initramfs*, *--*[*no-*]*compress-initrd*::
Compresses or does not compress the generated initramfs. Compresses or does not compress the generated initramfs.
*--compress-initramfs-type*=<arg>:: *--compress-initramfs-type*=<arg>::
Compression type for initramfs (best, xz, lzma, bzip2, gzip, lzop). Compression type for initramfs (best, xz, lzma, bzip2, gzip, lzop).
"Best" causes selection of the best available algorithm that is selected "Best" causes selection of the best available algorithm that is selected
in your kernel configuration. in your kernel configuration.
RAMDISK OPTIONS RAMDISK OPTIONS
@ -526,8 +526,8 @@ which the ramdisk scripts would recognize.
*part*[=<0,1>]:: *part*[=<0,1>]::
*partitionable*:: *partitionable*::
Enable/Disable partitionable RAIDs (metadata 0.x) during auto-run. Enable/Disable partitionable RAIDs (metadata 0.x) during auto-run.
Standalone *part* and *partitionable* keywords for kernel compatability. Standalone *part* and *partitionable* keywords for kernel compatability.
*iscsi_initiatorname*=<...>:: *iscsi_initiatorname*=<...>::
*iscsi_target*=<...>:: *iscsi_target*=<...>::

@ -2,93 +2,93 @@
# $Id$ # $Id$
get_official_arch() { get_official_arch() {
if [ "${CMD_ARCHOVERRIDE}" != '' ] if [ "${CMD_ARCHOVERRIDE}" != '' ]
then then
ARCH=${CMD_ARCHOVERRIDE} ARCH=${CMD_ARCHOVERRIDE}
else else
if [ "${ARCH_OVERRIDE}" != '' ] if [ "${ARCH_OVERRIDE}" != '' ]
then then
ARCH=${ARCH_OVERRIDE} ARCH=${ARCH_OVERRIDE}
else else
ARCH=`uname -m` ARCH=`uname -m`
case "${ARCH}" in case "${ARCH}" in
i?86) i?86)
ARCH="x86" ARCH="x86"
;; ;;
mips|mips64) mips|mips64)
ARCH="mips" ARCH="mips"
;; ;;
arm*) arm*)
ARCH=arm ARCH=arm
;; ;;
*) *)
;; ;;
esac esac
fi fi
fi fi
if [ "${CMD_UTILS_ARCH}" != '' ] if [ "${CMD_UTILS_ARCH}" != '' ]
then then
UTILS_ARCH=${CMD_UTILS_ARCH} UTILS_ARCH=${CMD_UTILS_ARCH}
else else
if [ "${UTILS_ARCH}" != '' ] if [ "${UTILS_ARCH}" != '' ]
then then
UTILS_ARCH=${UTILS_ARCH} UTILS_ARCH=${UTILS_ARCH}
fi fi
fi fi
# sparc64 klibc is b0rked, so we force to 32 # sparc64 klibc is b0rked, so we force to 32
if [ "${ARCH}" = 'sparc64' ] if [ "${ARCH}" = 'sparc64' ]
then then
UTILS_ARCH='sparc' UTILS_ARCH='sparc'
fi fi
ARCH_CONFIG="${GK_SHARE}/arch/${ARCH}/config.sh" ARCH_CONFIG="${GK_SHARE}/arch/${ARCH}/config.sh"
[ -f "${ARCH_CONFIG}" ] || gen_die "${ARCH} not yet supported by genkernel. Please add the arch-specific config file, ${ARCH_CONFIG}" [ -f "${ARCH_CONFIG}" ] || gen_die "${ARCH} not yet supported by genkernel. Please add the arch-specific config file, ${ARCH_CONFIG}"
} }
set_kernel_arch() { set_kernel_arch() {
KERNEL_ARCH=${ARCH} KERNEL_ARCH=${ARCH}
case ${ARCH} in case ${ARCH} in
ppc|ppc64) ppc|ppc64)
if [ "${VER}" -ge "3" ] if [ "${VER}" -ge "3" ]
then then
KERNEL_ARCH=powerpc KERNEL_ARCH=powerpc
elif [ "${VER}" -eq "2" -a "${PAT}" -ge "6" ] elif [ "${VER}" -eq "2" -a "${PAT}" -ge "6" ]
then then
if [ "${PAT}" -eq "6" -a "${SUB}" -ge "16" ] || [ "${PAT}" -gt "6" ] if [ "${PAT}" -eq "6" -a "${SUB}" -ge "16" ] || [ "${PAT}" -gt "6" ]
then then
KERNEL_ARCH=powerpc KERNEL_ARCH=powerpc
fi fi
fi fi
;; ;;
x86) x86)
if [ "${VER}" -ge "3" ] if [ "${VER}" -ge "3" ]
then then
KERNEL_ARCH=x86 KERNEL_ARCH=x86
elif [ "${VER}" -eq "2" -a "${PAT}" -ge "6" ] || [ "${VER}" -gt "2" ] elif [ "${VER}" -eq "2" -a "${PAT}" -ge "6" ] || [ "${VER}" -gt "2" ]
then then
if [ "${PAT}" -eq "6" -a "${SUB}" -ge "24" ] || [ "${PAT}" -gt "6" ] if [ "${PAT}" -eq "6" -a "${SUB}" -ge "24" ] || [ "${PAT}" -gt "6" ]
then then
KERNEL_ARCH=x86 KERNEL_ARCH=x86
else else
KERNEL_ARCH=i386 KERNEL_ARCH=i386
fi fi
fi fi
;; ;;
x86_64) x86_64)
if [ "${VER}" -ge "3" ] if [ "${VER}" -ge "3" ]
then then
KERNEL_ARCH=x86 KERNEL_ARCH=x86
elif [ "${VER}" -eq "2" -a "${PAT}" -ge "6" ] || [ "${VER}" -gt "2" ] elif [ "${VER}" -eq "2" -a "${PAT}" -ge "6" ] || [ "${VER}" -gt "2" ]
then then
if [ "${PAT}" -eq "6" -a "${SUB}" -ge "24" ] || [ "${PAT}" -gt "6" ] if [ "${PAT}" -eq "6" -a "${SUB}" -ge "24" ] || [ "${PAT}" -gt "6" ]
then then
KERNEL_ARCH=x86 KERNEL_ARCH=x86
fi fi
fi fi
;; ;;
esac esac
export KERNEL_ARCH export KERNEL_ARCH
print_info 2 "KERNEL_ARCH=${KERNEL_ARCH}" print_info 2 "KERNEL_ARCH=${KERNEL_ARCH}"
} }

@ -1,177 +1,177 @@
# $Id$ # $Id$
set_bootloader() { set_bootloader() {
case "${BOOTLOADER}" in case "${BOOTLOADER}" in
grub) grub)
set_bootloader_grub set_bootloader_grub
;; ;;
grub2) grub2)
set_bootloader_grub2 set_bootloader_grub2
;; ;;
*) *)
print_warning "Bootloader ${BOOTLOADER} is not currently supported" print_warning "Bootloader ${BOOTLOADER} is not currently supported"
;; ;;
esac esac
} }
set_bootloader_read_fstab() { set_bootloader_read_fstab() {
local ROOTFS=$(awk 'BEGIN{RS="((#[^\n]*)?\n)"}( $2 == "/" ) { print $1; exit }' /etc/fstab) local ROOTFS=$(awk 'BEGIN{RS="((#[^\n]*)?\n)"}( $2 == "/" ) { print $1; exit }' /etc/fstab)
local BOOTFS=$(awk 'BEGIN{RS="((#[^\n]*)?\n)"}( $2 == "'${BOOTDIR}'") { print $1; exit }' /etc/fstab) local BOOTFS=$(awk 'BEGIN{RS="((#[^\n]*)?\n)"}( $2 == "'${BOOTDIR}'") { print $1; exit }' /etc/fstab)
# If ${BOOTDIR} is not defined in /etc/fstab, it must be the same as / # If ${BOOTDIR} is not defined in /etc/fstab, it must be the same as /
[ -z "${BOOTFS}" ] && BOOTFS=${ROOTFS} [ -z "${BOOTFS}" ] && BOOTFS=${ROOTFS}
echo "${ROOTFS} ${BOOTFS}" echo "${ROOTFS} ${BOOTFS}"
} }
set_bootloader_grub_read_device_map() { set_bootloader_grub_read_device_map() {
# Read GRUB device map # Read GRUB device map
[ ! -d ${TEMP} ] && mkdir ${TEMP} [ ! -d ${TEMP} ] && mkdir ${TEMP}
echo "quit" | grub --batch --device-map=${TEMP}/grub.map &>/dev/null echo "quit" | grub --batch --device-map=${TEMP}/grub.map &>/dev/null
echo "${TEMP}/grub.map" echo "${TEMP}/grub.map"
} }
set_bootloader_grub2() { set_bootloader_grub2() {
local GRUB_CONF local GRUB_CONF
for candidate in \ for candidate in \
"${BOOTDIR}/grub2/grub.cfg" \ "${BOOTDIR}/grub2/grub.cfg" \
"${BOOTDIR}/grub/grub.cfg" \ "${BOOTDIR}/grub/grub.cfg" \
; do ; do
if [[ -e "${candidate}" ]]; then if [[ -e "${candidate}" ]]; then
GRUB_CONF=${candidate} GRUB_CONF=${candidate}
break break
fi fi
done done
if [[ -z "${GRUB_CONF}" ]]; then if [[ -z "${GRUB_CONF}" ]]; then
print_error 1 "Error! Grub2 configuration file does not exist, please ensure grub2 is correctly setup first." print_error 1 "Error! Grub2 configuration file does not exist, please ensure grub2 is correctly setup first."
return 0 return 0
fi fi
print_info 1 "You can customize Grub2 parameters in /etc/default/grub." print_info 1 "You can customize Grub2 parameters in /etc/default/grub."
print_info 1 "Running grub2-mkconfig to create ${GRUB_CONF}..." print_info 1 "Running grub2-mkconfig to create ${GRUB_CONF}..."
grub2-mkconfig -o "${GRUB_CONF}" grub2-mkconfig -o "${GRUB_CONF}"
[ "${BUILD_RAMDISK}" -ne 0 ] && sed -i 's/ro single/ro debug/' "${GRUB_CONF}" [ "${BUILD_RAMDISK}" -ne 0 ] && sed -i 's/ro single/ro debug/' "${GRUB_CONF}"
} }
set_bootloader_grub() { set_bootloader_grub() {
local GRUB_CONF="${BOOTDIR}/grub/grub.conf" local GRUB_CONF="${BOOTDIR}/grub/grub.conf"
print_info 1 "Adding kernel to ${GRUB_CONF}..." print_info 1 "Adding kernel to ${GRUB_CONF}..."
if [ ! -e ${GRUB_CONF} ] if [ ! -e ${GRUB_CONF} ]
then then
local GRUB_BOOTFS local GRUB_BOOTFS
if [ -n "${BOOTFS}" ] if [ -n "${BOOTFS}" ]
then then
GRUB_BOOTFS=$BOOTFS GRUB_BOOTFS=$BOOTFS
else else
GRUB_BOOTFS=$(set_bootloader_read_fstab | cut -d' ' -f2) GRUB_BOOTFS=$(set_bootloader_read_fstab | cut -d' ' -f2)
fi fi
# Get the GRUB mapping for our device # Get the GRUB mapping for our device
local GRUB_BOOT_DISK1=$(echo ${GRUB_BOOTFS} | sed -e 's#\(/dev/.\+\)[[:digit:]]\+#\1#') local GRUB_BOOT_DISK1=$(echo ${GRUB_BOOTFS} | sed -e 's#\(/dev/.\+\)[[:digit:]]\+#\1#')
local GRUB_BOOT_DISK=$(awk '{if ($2 == "'${GRUB_BOOT_DISK1}'") {gsub(/(\(|\))/, "", $1); print $1;}}' ${TEMP}/grub.map) local GRUB_BOOT_DISK=$(awk '{if ($2 == "'${GRUB_BOOT_DISK1}'") {gsub(/(\(|\))/, "", $1); print $1;}}' ${TEMP}/grub.map)
local GRUB_BOOT_PARTITION=$(($(echo ${GRUB_BOOTFS} | sed -e 's#/dev/.\+\([[:digit:]]?*\)#\1#') - 1)) local GRUB_BOOT_PARTITION=$(($(echo ${GRUB_BOOTFS} | sed -e 's#/dev/.\+\([[:digit:]]?*\)#\1#') - 1))
if [ -n "${GRUB_BOOT_DISK}" -a -n "${GRUB_BOOT_PARTITION}" ] if [ -n "${GRUB_BOOT_DISK}" -a -n "${GRUB_BOOT_PARTITION}" ]
then then
# Create grub configuration directory and file if it doesn't exist. # Create grub configuration directory and file if it doesn't exist.
[ ! -d `dirname ${GRUB_CONF}` ] && mkdir -p `dirname ${GRUB_CONF}` [ ! -d `dirname ${GRUB_CONF}` ] && mkdir -p `dirname ${GRUB_CONF}`
touch ${GRUB_CONF} touch ${GRUB_CONF}
echo 'default 0' >> ${GRUB_CONF} echo 'default 0' >> ${GRUB_CONF}
echo 'timeout 5' >> ${GRUB_CONF} echo 'timeout 5' >> ${GRUB_CONF}
echo "root (${GRUB_BOOT_DISK},${GRUB_BOOT_PARTITION})" >> ${GRUB_CONF} echo "root (${GRUB_BOOT_DISK},${GRUB_BOOT_PARTITION})" >> ${GRUB_CONF}
echo >> ${GRUB_CONF} echo >> ${GRUB_CONF}
# Add grub configuration to grub.conf # Add grub configuration to grub.conf
echo "# Genkernel generated entry, see GRUB documentation for details" >> ${GRUB_CONF} echo "# Genkernel generated entry, see GRUB documentation for details" >> ${GRUB_CONF}
echo "title=Gentoo Linux ($KV)" >> ${GRUB_CONF} echo "title=Gentoo Linux ($KV)" >> ${GRUB_CONF}
echo -e "\tkernel /kernel-${KNAME}-${ARCH}-${KV} root=${GRUB_ROOTFS}" >> ${GRUB_CONF} echo -e "\tkernel /kernel-${KNAME}-${ARCH}-${KV} root=${GRUB_ROOTFS}" >> ${GRUB_CONF}
if [ "${BUILD_INITRD}" = '1' ] if [ "${BUILD_INITRD}" = '1' ]
then then
if [ "${PAT}" -gt '4' ] if [ "${PAT}" -gt '4' ]
then then
echo -e "\tinitrd /initramfs-${KNAME}-${ARCH}-${KV}" >> ${GRUB_CONF} echo -e "\tinitrd /initramfs-${KNAME}-${ARCH}-${KV}" >> ${GRUB_CONF}
fi fi
fi fi
echo >> ${GRUB_CONF} echo >> ${GRUB_CONF}
else else
print_error 1 "Error! ${BOOTDIR}/grub/grub.conf does not exist and the correct settings can not be automatically detected." print_error 1 "Error! ${BOOTDIR}/grub/grub.conf does not exist and the correct settings can not be automatically detected."
print_error 1 "Please manually create your ${BOOTDIR}/grub/grub.conf file." print_error 1 "Please manually create your ${BOOTDIR}/grub/grub.conf file."
fi fi
else else
# The grub.conf already exists, so let's try to duplicate the default entry # The grub.conf already exists, so let's try to duplicate the default entry
if set_bootloader_grub_check_for_existing_entry "${GRUB_CONF}"; then if set_bootloader_grub_check_for_existing_entry "${GRUB_CONF}"; then
print_warning 1 "An entry was already found for a kernel/initramfs with this name...skipping update" print_warning 1 "An entry was already found for a kernel/initramfs with this name...skipping update"
return 0 return 0
fi fi
set_bootloader_grub_duplicate_default "${GRUB_CONF}" set_bootloader_grub_duplicate_default "${GRUB_CONF}"
fi fi
} }
set_bootloader_grub_duplicate_default_replace_kernel_initrd() { set_bootloader_grub_duplicate_default_replace_kernel_initrd() {
sed -r -e "/^[[:space:]]*kernel/s/kernel-[[:alnum:][:punct:]]+/kernel-${KNAME}-${ARCH}-${KV}/" - | sed -r -e "/^[[:space:]]*kernel/s/kernel-[[:alnum:][:punct:]]+/kernel-${KNAME}-${ARCH}-${KV}/" - |
sed -r -e "/^[[:space:]]*initrd/s/init(rd|ramfs)-[[:alnum:][:punct:]]+/init\1-${KNAME}-${ARCH}-${KV}/" sed -r -e "/^[[:space:]]*initrd/s/init(rd|ramfs)-[[:alnum:][:punct:]]+/init\1-${KNAME}-${ARCH}-${KV}/"
} }
set_bootloader_grub_check_for_existing_entry() { set_bootloader_grub_check_for_existing_entry() {
local GRUB_CONF=$1 local GRUB_CONF=$1
if grep -q "^[[:space:]]*kernel[[:space:]=]*.*/kernel-${KNAME}-${ARCH}-${KV}\([[:space:]]\|$\)" "${GRUB_CONF}" && if grep -q "^[[:space:]]*kernel[[:space:]=]*.*/kernel-${KNAME}-${ARCH}-${KV}\([[:space:]]\|$\)" "${GRUB_CONF}" &&
grep -q "^[[:space:]]*initrd[[:space:]=]*.*/initramfs-${KNAME}-${ARCH}-${KV}\([[:space:]]\|$\)" "${GRUB_CONF}" grep -q "^[[:space:]]*initrd[[:space:]=]*.*/initramfs-${KNAME}-${ARCH}-${KV}\([[:space:]]\|$\)" "${GRUB_CONF}"
then then
return 0 return 0
fi fi
return 1 return 1
} }
set_bootloader_grub_duplicate_default() { set_bootloader_grub_duplicate_default() {
local GRUB_CONF=$1 local GRUB_CONF=$1
local GRUB_CONF_TMP="${GRUB_CONF}.tmp" local GRUB_CONF_TMP="${GRUB_CONF}.tmp"
line_count=$(wc -l < "${GRUB_CONF}") line_count=$(wc -l < "${GRUB_CONF}")
line_nums="$(grep -n "^title" "${GRUB_CONF}" | cut -d: -f1)" line_nums="$(grep -n "^title" "${GRUB_CONF}" | cut -d: -f1)"
if [ -z "${line_nums}" ]; then if [ -z "${line_nums}" ]; then
print_error 1 "No current 'title' entries found in your grub.conf...skipping update" print_error 1 "No current 'title' entries found in your grub.conf...skipping update"
return 0 return 0
fi fi
line_nums="${line_nums} $((${line_count}+1))" line_nums="${line_nums} $((${line_count}+1))"
# Find default entry # Find default entry
default=$(sed -rn '/^[[:space:]]*default[[:space:]=]/s/^.*default[[:space:]=]+([[:alnum:]]+).*$/\1/p' "${GRUB_CONF}") default=$(sed -rn '/^[[:space:]]*default[[:space:]=]/s/^.*default[[:space:]=]+([[:alnum:]]+).*$/\1/p' "${GRUB_CONF}")
if [ -z "${default}" ]; then if [ -z "${default}" ]; then
print_warning 1 "No default entry found...assuming 0" print_warning 1 "No default entry found...assuming 0"
default=0 default=0
fi fi
if ! echo ${default} | grep -q '^[0-9]\+$'; then if ! echo ${default} | grep -q '^[0-9]\+$'; then
print_error 1 "We don't support non-numeric (such as 'saved') default values...skipping update" print_error 1 "We don't support non-numeric (such as 'saved') default values...skipping update"
return 0 return 0
fi fi
# Grub defaults are 0 based, cut is 1 based # Grub defaults are 0 based, cut is 1 based
# Figure out where the default entry lives # Figure out where the default entry lives
startstop=$(echo ${line_nums} | cut -d" " -f$((${default}+1))-$((${default}+2))) startstop=$(echo ${line_nums} | cut -d" " -f$((${default}+1))-$((${default}+2)))
startline=$(echo ${startstop} | cut -d" " -f1) startline=$(echo ${startstop} | cut -d" " -f1)
stopline=$(echo ${startstop} | cut -d" " -f2) stopline=$(echo ${startstop} | cut -d" " -f2)
# Write out the bits before the default entry # Write out the bits before the default entry
sed -n 1,$((${startline}-1))p "${GRUB_CONF}" > "${GRUB_CONF_TMP}" sed -n 1,$((${startline}-1))p "${GRUB_CONF}" > "${GRUB_CONF_TMP}"
# Put in our title # Put in our title
echo "title=Gentoo Linux (${KV})" >> "${GRUB_CONF_TMP}" echo "title=Gentoo Linux (${KV})" >> "${GRUB_CONF_TMP}"
# Pass the default entry (minus the title) through to the replacement function and pipe the output to GRUB_CONF_TMP # Pass the default entry (minus the title) through to the replacement function and pipe the output to GRUB_CONF_TMP
sed -n $((${startline}+1)),$((${stopline}-1))p "${GRUB_CONF}" | set_bootloader_grub_duplicate_default_replace_kernel_initrd >> "${GRUB_CONF_TMP}" sed -n $((${startline}+1)),$((${stopline}-1))p "${GRUB_CONF}" | set_bootloader_grub_duplicate_default_replace_kernel_initrd >> "${GRUB_CONF_TMP}"
# Finish off with everything including the previous default entry # Finish off with everything including the previous default entry
sed -n ${startline},${line_count}p "${GRUB_CONF}" >> "${GRUB_CONF_TMP}" sed -n ${startline},${line_count}p "${GRUB_CONF}" >> "${GRUB_CONF_TMP}"
cp "${GRUB_CONF}" "${GRUB_CONF}.bak" cp "${GRUB_CONF}" "${GRUB_CONF}.bak"
cp "${GRUB_CONF_TMP}" "${GRUB_CONF}" cp "${GRUB_CONF_TMP}" "${GRUB_CONF}"
rm "${GRUB_CONF_TMP}" rm "${GRUB_CONF_TMP}"
} }

File diff suppressed because it is too large Load Diff

@ -2,403 +2,403 @@
# $Id$ # $Id$
compile_kernel_args() { compile_kernel_args() {
local ARGS local ARGS
ARGS='' ARGS=''
if [ "${KERNEL_CC}" != '' ] if [ "${KERNEL_CC}" != '' ]
then then
ARGS="CC=\"${KERNEL_CC}\"" ARGS="CC=\"${KERNEL_CC}\""
fi fi
if [ "${KERNEL_LD}" != '' ] if [ "${KERNEL_LD}" != '' ]
then then
ARGS="${ARGS} LD=\"${KERNEL_LD}\"" ARGS="${ARGS} LD=\"${KERNEL_LD}\""
fi fi
if [ "${KERNEL_AS}" != '' ] if [ "${KERNEL_AS}" != '' ]
then then
ARGS="${ARGS} AS=\"${KERNEL_AS}\"" ARGS="${ARGS} AS=\"${KERNEL_AS}\""
fi fi
if [ -n "${KERNEL_ARCH}" ] if [ -n "${KERNEL_ARCH}" ]
then then
ARGS="${ARGS} ARCH=\"${KERNEL_ARCH}\"" ARGS="${ARGS} ARCH=\"${KERNEL_ARCH}\""
fi fi
if [ -n "${KERNEL_OUTPUTDIR}" -a "${KERNEL_OUTPUTDIR}" != "${KERNEL_DIR}" ] if [ -n "${KERNEL_OUTPUTDIR}" -a "${KERNEL_OUTPUTDIR}" != "${KERNEL_DIR}" ]
then then
ARGS="${ARGS} O=\"${KERNEL_OUTPUTDIR}\"" ARGS="${ARGS} O=\"${KERNEL_OUTPUTDIR}\""
fi fi
echo -n "${ARGS}" echo -n "${ARGS}"
} }
compile_utils_args() compile_utils_args()
{ {
local ARGS local ARGS
ARGS='' ARGS=''
if [ "${UTILS_ARCH}" != '' ] if [ "${UTILS_ARCH}" != '' ]
then then
ARGS="ARCH=\"${UTILS_ARCH}\"" ARGS="ARCH=\"${UTILS_ARCH}\""
fi fi
if [ "${UTILS_CC}" != '' ] if [ "${UTILS_CC}" != '' ]
then then
ARGS="CC=\"${UTILS_CC}\"" ARGS="CC=\"${UTILS_CC}\""
fi fi
if [ "${UTILS_LD}" != '' ] if [ "${UTILS_LD}" != '' ]
then then
ARGS="${ARGS} LD=\"${UTILS_LD}\"" ARGS="${ARGS} LD=\"${UTILS_LD}\""
fi fi
if [ "${UTILS_AS}" != '' ] if [ "${UTILS_AS}" != '' ]
then then
ARGS="${ARGS} AS=\"${UTILS_AS}\"" ARGS="${ARGS} AS=\"${UTILS_AS}\""
fi fi
echo -n "${ARGS}" echo -n "${ARGS}"
} }
export_utils_args() export_utils_args()
{ {
save_args save_args
if [ "${UTILS_ARCH}" != '' ] if [ "${UTILS_ARCH}" != '' ]
then then
export ARCH="${UTILS_ARCH}" export ARCH="${UTILS_ARCH}"
fi fi
if [ "${UTILS_CC}" != '' ] if [ "${UTILS_CC}" != '' ]
then then
export CC="${UTILS_CC}" export CC="${UTILS_CC}"
fi fi
if [ "${UTILS_LD}" != '' ] if [ "${UTILS_LD}" != '' ]
then then
export LD="${UTILS_LD}" export LD="${UTILS_LD}"
fi fi
if [ "${UTILS_AS}" != '' ] if [ "${UTILS_AS}" != '' ]
then then
export AS="${UTILS_AS}" export AS="${UTILS_AS}"
fi fi
} }
unset_utils_args() unset_utils_args()
{ {
if [ "${UTILS_ARCH}" != '' ] if [ "${UTILS_ARCH}" != '' ]
then then
unset ARCH unset ARCH
fi fi
if [ "${UTILS_CC}" != '' ] if [ "${UTILS_CC}" != '' ]
then then
unset CC unset CC
fi fi
if [ "${UTILS_LD}" != '' ] if [ "${UTILS_LD}" != '' ]
then then
unset LD unset LD
fi fi
if [ "${UTILS_AS}" != '' ] if [ "${UTILS_AS}" != '' ]
then then
unset AS unset AS
fi fi
reset_args reset_args
} }
export_kernel_args() export_kernel_args()
{ {
if [ "${KERNEL_CC}" != '' ] if [ "${KERNEL_CC}" != '' ]
then then
export CC="${KERNEL_CC}" export CC="${KERNEL_CC}"
fi fi
if [ "${KERNEL_LD}" != '' ] if [ "${KERNEL_LD}" != '' ]
then then
export LD="${KERNEL_LD}" export LD="${KERNEL_LD}"
fi fi
if [ "${KERNEL_AS}" != '' ] if [ "${KERNEL_AS}" != '' ]
then then
export AS="${KERNEL_AS}" export AS="${KERNEL_AS}"
fi fi
} }
unset_kernel_args() unset_kernel_args()
{ {
if [ "${KERNEL_CC}" != '' ] if [ "${KERNEL_CC}" != '' ]
then then
unset CC unset CC
fi fi
if [ "${KERNEL_LD}" != '' ] if [ "${KERNEL_LD}" != '' ]
then then
unset LD unset LD
fi fi
if [ "${KERNEL_AS}" != '' ] if [ "${KERNEL_AS}" != '' ]
then then
unset AS unset AS
fi fi
} }
save_args() save_args()
{ {
if [ "${ARCH}" != '' ] if [ "${ARCH}" != '' ]
then then
export ORIG_ARCH="${ARCH}" export ORIG_ARCH="${ARCH}"
fi fi
if [ "${CC}" != '' ] if [ "${CC}" != '' ]
then then
export ORIG_CC="${CC}" export ORIG_CC="${CC}"
fi fi
if [ "${LD}" != '' ] if [ "${LD}" != '' ]
then then
export ORIG_LD="${LD}" export ORIG_LD="${LD}"
fi fi
if [ "${AS}" != '' ] if [ "${AS}" != '' ]
then then
export ORIG_AS="${AS}" export ORIG_AS="${AS}"
fi fi
} }
reset_args() reset_args()
{ {
if [ "${ORIG_ARCH}" != '' ] if [ "${ORIG_ARCH}" != '' ]
then then
export ARCH="${ORIG_ARCH}" export ARCH="${ORIG_ARCH}"
unset ORIG_ARCH unset ORIG_ARCH
fi fi
if [ "${ORIG_CC}" != '' ] if [ "${ORIG_CC}" != '' ]
then then
export CC="${ORIG_CC}" export CC="${ORIG_CC}"
unset ORIG_CC unset ORIG_CC
fi fi
if [ "${ORIG_LD}" != '' ] if [ "${ORIG_LD}" != '' ]
then then
export LD="${ORIG_LD}" export LD="${ORIG_LD}"
unset ORIG_LD unset ORIG_LD
fi fi
if [ "${ORIG_AS}" != '' ] if [ "${ORIG_AS}" != '' ]
then then
export AS="${ORIG_AS}" export AS="${ORIG_AS}"
unset ORIG_AS unset ORIG_AS
fi fi
} }
apply_patches() { apply_patches() {
util=$1 util=$1
version=$2 version=$2
if [ -d "${GK_SHARE}/patches/${util}/${version}" ] if [ -d "${GK_SHARE}/patches/${util}/${version}" ]
then then
print_info 1 "${util}: >> Applying patches..." print_info 1 "${util}: >> Applying patches..."
for i in ${GK_SHARE}/patches/${util}/${version}/*{diff,patch} for i in ${GK_SHARE}/patches/${util}/${version}/*{diff,patch}
do do
[ -f "${i}" ] || continue [ -f "${i}" ] || continue
patch_success=0 patch_success=0
for j in `seq 0 5` for j in `seq 0 5`
do do
patch -p${j} --backup-if-mismatch -f < "${i}" >/dev/null patch -p${j} --backup-if-mismatch -f < "${i}" >/dev/null
if [ $? = 0 ] if [ $? = 0 ]
then then
patch_success=1 patch_success=1
break break
fi fi
done done
if [ ${patch_success} -eq 1 ] if [ ${patch_success} -eq 1 ]
then then
print_info 1 " - `basename ${i}`" print_info 1 " - `basename ${i}`"
else else
gen_die "could not apply patch ${i} for ${util}-${version}" gen_die "could not apply patch ${i} for ${util}-${version}"
fi fi
done done
fi fi
} }
compile_generic() { compile_generic() {
local RET local RET
[ "$#" -lt '2' ] && [ "$#" -lt '2' ] &&
gen_die 'compile_generic(): improper usage!' gen_die 'compile_generic(): improper usage!'
local target=${1} local target=${1}
local argstype=${2} local argstype=${2}
case "${argstype}" in case "${argstype}" in
kernel|kernelruntask) kernel|kernelruntask)
export_kernel_args export_kernel_args
MAKE=${KERNEL_MAKE} MAKE=${KERNEL_MAKE}
;; ;;
utils) utils)
export_utils_args export_utils_args
MAKE=${UTILS_MAKE} MAKE=${UTILS_MAKE}
;; ;;
esac esac
case "${argstype}" in case "${argstype}" in
kernel|kernelruntask) ARGS="`compile_kernel_args`" ;; kernel|kernelruntask) ARGS="`compile_kernel_args`" ;;
utils) ARGS="`compile_utils_args`" ;; utils) ARGS="`compile_utils_args`" ;;
*) ARGS="" ;; *) ARGS="" ;;
esac esac
shift 2 shift 2
# the eval usage is needed in the next set of code # the eval usage is needed in the next set of code
# as ARGS can contain spaces and quotes, eg: # as ARGS can contain spaces and quotes, eg:
# ARGS='CC="ccache gcc"' # ARGS='CC="ccache gcc"'
if [ "${argstype}" == 'kernelruntask' ] if [ "${argstype}" == 'kernelruntask' ]
then then
# Silent operation, forced -j1 # Silent operation, forced -j1
print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} -j1 ${ARGS} ${target} $*" 1 0 1 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} -j1 ${ARGS} ${target} $*" 1 0 1
eval ${MAKE} -s ${MAKEOPTS} -j1 "${ARGS}" ${target} $* eval ${MAKE} -s ${MAKEOPTS} -j1 "${ARGS}" ${target} $*
RET=$? RET=$?
elif [ "${LOGLEVEL}" -gt "1" ] elif [ "${LOGLEVEL}" -gt "1" ]
then then
# Output to stdout and logfile # Output to stdout and logfile
print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $*" 1 0 1 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $*" 1 0 1
eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* 2>&1 | tee -a ${LOGFILE} eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* 2>&1 | tee -a ${LOGFILE}
RET=${PIPESTATUS[0]} RET=${PIPESTATUS[0]}
else else
# Output to logfile only # Output to logfile only
print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${1} $*" 1 0 1 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${1} $*" 1 0 1
eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* >> ${LOGFILE} 2>&1 eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* >> ${LOGFILE} 2>&1
RET=$? RET=$?
fi fi
[ ${RET} -ne 0 ] && [ ${RET} -ne 0 ] &&
gen_die "Failed to compile the \"${target}\" target..." gen_die "Failed to compile the \"${target}\" target..."
unset MAKE unset MAKE
unset ARGS unset ARGS
case "${argstype}" in case "${argstype}" in
kernel) unset_kernel_args ;; kernel) unset_kernel_args ;;
utils) unset_utils_args ;; utils) unset_utils_args ;;
esac esac
} }
compile_modules() { compile_modules() {
print_info 1 " >> Compiling ${KV} modules..." print_info 1 " >> Compiling ${KV} modules..."
cd ${KERNEL_DIR} cd ${KERNEL_DIR}
compile_generic modules kernel compile_generic modules kernel
export UNAME_MACHINE="${ARCH}" export UNAME_MACHINE="${ARCH}"
[ "${INSTALL_MOD_PATH}" != '' ] && export INSTALL_MOD_PATH [ "${INSTALL_MOD_PATH}" != '' ] && export INSTALL_MOD_PATH
MAKEOPTS="${MAKEOPTS} -j1" compile_generic "modules_install" kernel MAKEOPTS="${MAKEOPTS} -j1" compile_generic "modules_install" kernel
print_info 1 " >> Generating module dependency data..." print_info 1 " >> Generating module dependency data..."
if [ "${INSTALL_MOD_PATH}" != '' ] if [ "${INSTALL_MOD_PATH}" != '' ]
then then
depmod -a -e -F "${KERNEL_OUTPUTDIR}"/System.map -b "${INSTALL_MOD_PATH}" ${KV} depmod -a -e -F "${KERNEL_OUTPUTDIR}"/System.map -b "${INSTALL_MOD_PATH}" ${KV}
else else
depmod -a -e -F "${KERNEL_OUTPUTDIR}"/System.map ${KV} depmod -a -e -F "${KERNEL_OUTPUTDIR}"/System.map ${KV}
fi fi
unset UNAME_MACHINE unset UNAME_MACHINE
} }
compile_kernel() { compile_kernel() {
[ "${KERNEL_MAKE}" = '' ] && [ "${KERNEL_MAKE}" = '' ] &&
gen_die "KERNEL_MAKE undefined - I don't know how to compile a kernel for this arch!" gen_die "KERNEL_MAKE undefined - I don't know how to compile a kernel for this arch!"
cd ${KERNEL_DIR} cd ${KERNEL_DIR}
local kernel_make_directive="${KERNEL_MAKE_DIRECTIVE}" local kernel_make_directive="${KERNEL_MAKE_DIRECTIVE}"
if [ "${KERNEL_MAKE_DIRECTIVE_OVERRIDE}" != "${DEFAULT_KERNEL_MAKE_DIRECTIVE_OVERRIDE}" ]; then if [ "${KERNEL_MAKE_DIRECTIVE_OVERRIDE}" != "${DEFAULT_KERNEL_MAKE_DIRECTIVE_OVERRIDE}" ]; then
kernel_make_directive="${KERNEL_MAKE_DIRECTIVE_OVERRIDE}" kernel_make_directive="${KERNEL_MAKE_DIRECTIVE_OVERRIDE}"
fi fi
print_info 1 " >> Compiling ${KV} ${kernel_make_directive/_install/ [ install ]/}..." print_info 1 " >> Compiling ${KV} ${kernel_make_directive/_install/ [ install ]/}..."
compile_generic "${kernel_make_directive}" kernel compile_generic "${kernel_make_directive}" kernel
if [ "${KERNEL_MAKE_DIRECTIVE_2}" != '' ] if [ "${KERNEL_MAKE_DIRECTIVE_2}" != '' ]
then then
print_info 1 " >> Starting supplimental compile of ${KV}: ${KERNEL_MAKE_DIRECTIVE_2}..." print_info 1 " >> Starting supplimental compile of ${KV}: ${KERNEL_MAKE_DIRECTIVE_2}..."
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_OUTPUTDIR}"/.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..."
MAKEOPTS="${MAKEOPTS} -j1" compile_generic "firmware_install" kernel MAKEOPTS="${MAKEOPTS} -j1" compile_generic "firmware_install" kernel
else else
print_info 1 " >> Not installing firmware as it's included in the kernel already (CONFIG_FIRMWARE_IN_KERNEL=y)..." print_info 1 " >> Not installing firmware as it's included in the kernel already (CONFIG_FIRMWARE_IN_KERNEL=y)..."
fi fi
local tmp_kernel_binary=$(find_kernel_binary ${KERNEL_BINARY_OVERRIDE:-${KERNEL_BINARY}}) local tmp_kernel_binary=$(find_kernel_binary ${KERNEL_BINARY_OVERRIDE:-${KERNEL_BINARY}})
local tmp_kernel_binary2=$(find_kernel_binary ${KERNEL_BINARY_2}) local tmp_kernel_binary2=$(find_kernel_binary ${KERNEL_BINARY_2})
if [ -z "${tmp_kernel_binary}" ] if [ -z "${tmp_kernel_binary}" ]
then then
gen_die "Cannot locate kernel binary" gen_die "Cannot locate kernel binary"
fi fi
if isTrue "${CMD_INSTALL}" if isTrue "${CMD_INSTALL}"
then then
copy_image_with_preserve "kernel" \ copy_image_with_preserve "kernel" \
"${tmp_kernel_binary}" \ "${tmp_kernel_binary}" \
"kernel-${KNAME}-${ARCH}-${KV}" "kernel-${KNAME}-${ARCH}-${KV}"
copy_image_with_preserve "System.map" \ copy_image_with_preserve "System.map" \
"System.map" \ "System.map" \
"System.map-${KNAME}-${ARCH}-${KV}" "System.map-${KNAME}-${ARCH}-${KV}"
if isTrue "${GENZIMAGE}" if isTrue "${GENZIMAGE}"
then then
copy_image_with_preserve "kernelz" \ copy_image_with_preserve "kernelz" \
"${tmp_kernel_binary2}" \ "${tmp_kernel_binary2}" \
"kernelz-${KV}" "kernelz-${KV}"
fi fi
else else
cp "${tmp_kernel_binary}" "${TMPDIR}/kernel-${KNAME}-${ARCH}-${KV}" || cp "${tmp_kernel_binary}" "${TMPDIR}/kernel-${KNAME}-${ARCH}-${KV}" ||
gen_die "Could not copy the kernel binary to ${TMPDIR}!" gen_die "Could not copy the kernel binary to ${TMPDIR}!"
cp "System.map" "${TMPDIR}/System.map-${KNAME}-${ARCH}-${KV}" || cp "System.map" "${TMPDIR}/System.map-${KNAME}-${ARCH}-${KV}" ||
gen_die "Could not copy System.map to ${TMPDIR}!" gen_die "Could not copy System.map to ${TMPDIR}!"
if isTrue "${GENZIMAGE}" if isTrue "${GENZIMAGE}"
then then
cp "${tmp_kernel_binary2}" "${TMPDIR}/kernelz-${KV}" || cp "${tmp_kernel_binary2}" "${TMPDIR}/kernelz-${KV}" ||
gen_die "Could not copy the kernelz binary to ${TMPDIR}!" gen_die "Could not copy the kernelz binary to ${TMPDIR}!"
fi fi
fi fi
} }
compile_busybox() { compile_busybox() {
[ -f "${BUSYBOX_SRCTAR}" ] || [ -f "${BUSYBOX_SRCTAR}" ] ||
gen_die "Could not find busybox source tarball: ${BUSYBOX_SRCTAR}!" gen_die "Could not find busybox source tarball: ${BUSYBOX_SRCTAR}!"
if [ -n "${BUSYBOX_CONFIG}" ] if [ -n "${BUSYBOX_CONFIG}" ]
then then
[ -f "${BUSYBOX_CONFIG}" ] || [ -f "${BUSYBOX_CONFIG}" ] ||
gen_die "Could not find busybox config file: ${BUSYBOX_CONFIG}" gen_die "Could not find busybox config file: ${BUSYBOX_CONFIG}"
elif isTrue "${NETBOOT}" && [ -f "$(arch_replace "${GK_SHARE}/arch/%%ARCH%%/netboot-busy-config")" ] elif isTrue "${NETBOOT}" && [ -f "$(arch_replace "${GK_SHARE}/arch/%%ARCH%%/netboot-busy-config")" ]
then then
BUSYBOX_CONFIG="$(arch_replace "${GK_SHARE}/arch/%%ARCH%%/netboot-busy-config")" BUSYBOX_CONFIG="$(arch_replace "${GK_SHARE}/arch/%%ARCH%%/netboot-busy-config")"
elif isTrue "${NETBOOT}" && [ -f "${GK_SHARE}/netboot/busy-config" ] elif isTrue "${NETBOOT}" && [ -f "${GK_SHARE}/netboot/busy-config" ]
then then
BUSYBOX_CONFIG="${GK_SHARE}/netboot/busy-config" BUSYBOX_CONFIG="${GK_SHARE}/netboot/busy-config"
elif [ -f "$(arch_replace "${GK_SHARE}/arch/%%ARCH%%/busy-config")" ] elif [ -f "$(arch_replace "${GK_SHARE}/arch/%%ARCH%%/busy-config")" ]
then then
BUSYBOX_CONFIG="$(arch_replace "${GK_SHARE}/arch/%%ARCH%%/busy-config")" BUSYBOX_CONFIG="$(arch_replace "${GK_SHARE}/arch/%%ARCH%%/busy-config")"
elif [ -f "${GK_SHARE}/defaults/busy-config" ] elif [ -f "${GK_SHARE}/defaults/busy-config" ]
then then
BUSYBOX_CONFIG="${GK_SHARE}/defaults/busy-config" BUSYBOX_CONFIG="${GK_SHARE}/defaults/busy-config"
else else
gen_die "Could not find a busybox config file" gen_die "Could not find a busybox config file"
fi fi
# Delete cache if stored config's MD5 does not match one to be used # Delete cache if stored config's MD5 does not match one to be used
if [ -f "${BUSYBOX_BINCACHE}" ] if [ -f "${BUSYBOX_BINCACHE}" ]
then then
oldconfig_md5=$(tar -xjf "${BUSYBOX_BINCACHE}" -O .config.gk_orig 2>/dev/null | md5sum) oldconfig_md5=$(tar -xjf "${BUSYBOX_BINCACHE}" -O .config.gk_orig 2>/dev/null | md5sum)
newconfig_md5=$(md5sum < "${BUSYBOX_CONFIG}") newconfig_md5=$(md5sum < "${BUSYBOX_CONFIG}")
if [ "${oldconfig_md5}" != "${newconfig_md5}" ] if [ "${oldconfig_md5}" != "${newconfig_md5}" ]
then then
print_info 1 "busybox: >> Removing stale cache..." print_info 1 "busybox: >> Removing stale cache..."
rm -rf "${BUSYBOX_BINCACHE}" rm -rf "${BUSYBOX_BINCACHE}"
else else
print_info 1 "busybox: >> Using cache" print_info 1 "busybox: >> Using cache"
fi fi
fi fi
if [ ! -f "${BUSYBOX_BINCACHE}" ] if [ ! -f "${BUSYBOX_BINCACHE}" ]
then then
cd "${TEMP}" cd "${TEMP}"
rm -rf "${BUSYBOX_DIR}" > /dev/null rm -rf "${BUSYBOX_DIR}" > /dev/null
/bin/tar -jxpf ${BUSYBOX_SRCTAR} || /bin/tar -jxpf ${BUSYBOX_SRCTAR} ||
gen_die 'Could not extract busybox source tarball!' gen_die 'Could not extract busybox source tarball!'
[ -d "${BUSYBOX_DIR}" ] || [ -d "${BUSYBOX_DIR}" ] ||
gen_die "Busybox directory ${BUSYBOX_DIR} is invalid!" gen_die "Busybox directory ${BUSYBOX_DIR} is invalid!"
cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config" cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config"
cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config.gk_orig" cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config.gk_orig"
cd "${BUSYBOX_DIR}" cd "${BUSYBOX_DIR}"
apply_patches busybox ${BUSYBOX_VER} apply_patches busybox ${BUSYBOX_VER}
print_info 1 'busybox: >> Configuring...' print_info 1 'busybox: >> Configuring...'
yes '' 2>/dev/null | compile_generic oldconfig utils yes '' 2>/dev/null | compile_generic oldconfig utils
print_info 1 'busybox: >> Compiling...' print_info 1 'busybox: >> Compiling...'
compile_generic all utils compile_generic all utils
print_info 1 'busybox: >> Copying to cache...' print_info 1 'busybox: >> Copying to cache...'
[ -f "${TEMP}/${BUSYBOX_DIR}/busybox" ] || [ -f "${TEMP}/${BUSYBOX_DIR}/busybox" ] ||
gen_die 'Busybox executable does not exist!' gen_die 'Busybox executable does not exist!'
strip "${TEMP}/${BUSYBOX_DIR}/busybox" || strip "${TEMP}/${BUSYBOX_DIR}/busybox" ||
gen_die 'Could not strip busybox binary!' gen_die 'Could not strip busybox binary!'
tar -cj -C "${TEMP}/${BUSYBOX_DIR}" -f "${BUSYBOX_BINCACHE}" busybox .config .config.gk_orig || tar -cj -C "${TEMP}/${BUSYBOX_DIR}" -f "${BUSYBOX_BINCACHE}" busybox .config .config.gk_orig ||
gen_die 'Could not create the busybox bincache!' gen_die 'Could not create the busybox bincache!'
cd "${TEMP}" cd "${TEMP}"
rm -rf "${BUSYBOX_DIR}" > /dev/null rm -rf "${BUSYBOX_DIR}" > /dev/null
fi fi
} }

@ -3,106 +3,106 @@
# Fills variable KERNEL_CONFIG # Fills variable KERNEL_CONFIG
determine_config_file() { determine_config_file() {
if [ "${CMD_KERNEL_CONFIG}" != "" ] if [ "${CMD_KERNEL_CONFIG}" != "" ]
then then
KERNEL_CONFIG="${CMD_KERNEL_CONFIG}" KERNEL_CONFIG="${CMD_KERNEL_CONFIG}"
elif [ -f "/etc/kernels/kernel-config-${ARCH}-${KV}" ] elif [ -f "/etc/kernels/kernel-config-${ARCH}-${KV}" ]
then then
KERNEL_CONFIG="/etc/kernels/kernel-config-${ARCH}-${KV}" KERNEL_CONFIG="/etc/kernels/kernel-config-${ARCH}-${KV}"
elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}" ] elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}" ]
then then
KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}" KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}"
elif [ "${DEFAULT_KERNEL_CONFIG}" != "" -a -f "${DEFAULT_KERNEL_CONFIG}" ] elif [ "${DEFAULT_KERNEL_CONFIG}" != "" -a -f "${DEFAULT_KERNEL_CONFIG}" ]
then then
KERNEL_CONFIG="${DEFAULT_KERNEL_CONFIG}" KERNEL_CONFIG="${DEFAULT_KERNEL_CONFIG}"
elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}" ] elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}" ]
then then
KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}" KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}"
elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config" ] elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config" ]
then then
KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config" KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config"
else else
gen_die 'Error: No kernel .config specified, or file not found!' gen_die 'Error: No kernel .config specified, or file not found!'
fi fi
KERNEL_CONFIG="$(readlink -f "${KERNEL_CONFIG}")" KERNEL_CONFIG="$(readlink -f "${KERNEL_CONFIG}")"
} }
config_kernel() { config_kernel() {
determine_config_file determine_config_file
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_OUTPUTDIR}/.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_OUTPUTDIR}/.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_OUTPUTDIR}/.config" "${KERNEL_OUTPUTDIR}/.config${NOW}.bak" \ cp "${KERNEL_OUTPUTDIR}/.config" "${KERNEL_OUTPUTDIR}/.config${NOW}.bak" \
|| gen_die "Could not backup kernel config (${KERNEL_OUTPUTDIR}/.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
if isTrue ${MRPROPER} if isTrue ${MRPROPER}
then then
print_info 1 'kernel: >> Running mrproper...' print_info 1 'kernel: >> Running mrproper...'
compile_generic mrproper kernel compile_generic mrproper kernel
else else
print_info 1 "kernel: --mrproper is disabled; not running 'make mrproper'." print_info 1 "kernel: --mrproper is disabled; not running 'make mrproper'."
fi fi
# 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_OUTPUTDIR}/.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_OUTPUTDIR}/.config" || gen_die "${message}" zcat "${KERNEL_CONFIG}" > "${KERNEL_OUTPUTDIR}/.config" || gen_die "${message}"
else else
cp "${KERNEL_CONFIG}" "${KERNEL_OUTPUTDIR}/.config" || gen_die "${message}" cp "${KERNEL_CONFIG}" "${KERNEL_OUTPUTDIR}/.config" || gen_die "${message}"
fi fi
fi fi
if isTrue "${OLDCONFIG}" if isTrue "${OLDCONFIG}"
then then
print_info 1 ' >> Running oldconfig...' print_info 1 ' >> Running oldconfig...'
yes '' 2>/dev/null | compile_generic oldconfig kernel 2>/dev/null yes '' 2>/dev/null | compile_generic oldconfig kernel 2>/dev/null
else else
print_info 1 "kernel: --oldconfig is disabled; not running 'make oldconfig'." print_info 1 "kernel: --oldconfig is disabled; not running 'make oldconfig'."
fi fi
if isTrue "${CLEAN}" if isTrue "${CLEAN}"
then then
print_info 1 'kernel: >> Cleaning...' print_info 1 'kernel: >> Cleaning...'
compile_generic clean kernel compile_generic clean kernel
else else
print_info 1 "kernel: --clean is disabled; not running 'make clean'." print_info 1 "kernel: --clean is disabled; not running 'make clean'."
fi fi
if isTrue ${MENUCONFIG} if isTrue ${MENUCONFIG}
then then
print_info 1 'kernel: >> Invoking menuconfig...' print_info 1 'kernel: >> Invoking menuconfig...'
compile_generic menuconfig kernelruntask compile_generic menuconfig kernelruntask
[ "$?" ] || gen_die 'Error: menuconfig failed!' [ "$?" ] || gen_die 'Error: menuconfig failed!'
elif isTrue ${NCONFIG} elif isTrue ${NCONFIG}
then then
print_info 1 'kernel: >> Invoking nconfig...' print_info 1 'kernel: >> Invoking nconfig...'
compile_generic nconfig kernelruntask compile_generic nconfig kernelruntask
[ "$?" ] || gen_die 'Error: nconfig failed!' [ "$?" ] || gen_die 'Error: nconfig failed!'
elif isTrue ${CMD_GCONFIG} elif isTrue ${CMD_GCONFIG}
then then
print_info 1 'kernel: >> Invoking gconfig...' print_info 1 'kernel: >> Invoking gconfig...'
compile_generic gconfig kernel compile_generic gconfig kernel
[ "$?" ] || gen_die 'Error: gconfig failed!' [ "$?" ] || gen_die 'Error: gconfig failed!'
CMD_XCONFIG=0 CMD_XCONFIG=0
fi fi
if isTrue ${CMD_XCONFIG} if isTrue ${CMD_XCONFIG}
then then
print_info 1 'kernel: >> Invoking xconfig...' print_info 1 'kernel: >> Invoking xconfig...'
compile_generic xconfig kernel compile_generic xconfig kernel
[ "$?" ] || gen_die 'Error: xconfig failed!' [ "$?" ] || gen_die 'Error: xconfig failed!'
fi fi
} }

@ -2,216 +2,216 @@
# $Id$ # $Id$
get_KV() { get_KV() {
if [ "${KERNEL_SOURCES}" = '0' -a -e "${KERNCACHE}" ] if [ "${KERNEL_SOURCES}" = '0' -a -e "${KERNCACHE}" ]
then then
/bin/tar -xj -C ${TEMP} -f ${KERNCACHE} kerncache.config /bin/tar -xj -C ${TEMP} -f ${KERNCACHE} kerncache.config
if [ -e ${TEMP}/kerncache.config ] if [ -e ${TEMP}/kerncache.config ]
then then
VER=`grep ^VERSION\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'` VER=`grep ^VERSION\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
PAT=`grep ^PATCHLEVEL\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'` PAT=`grep ^PATCHLEVEL\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
SUB=`grep ^SUBLEVEL\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'` SUB=`grep ^SUBLEVEL\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
EXV=`grep ^EXTRAVERSION\ \= ${TEMP}/kerncache.config | sed -e "s/EXTRAVERSION =//" -e "s/ //g"` EXV=`grep ^EXTRAVERSION\ \= ${TEMP}/kerncache.config | sed -e "s/EXTRAVERSION =//" -e "s/ //g"`
LOV=`grep ^CONFIG_LOCALVERSION\= ${TEMP}/kerncache.config | sed -e "s/CONFIG_LOCALVERSION=\"\(.*\)\"/\1/"` LOV=`grep ^CONFIG_LOCALVERSION\= ${TEMP}/kerncache.config | sed -e "s/CONFIG_LOCALVERSION=\"\(.*\)\"/\1/"`
KV=${VER}.${PAT}.${SUB}${EXV}${LOV} KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
else else
gen_die "Could not find kerncache.config in the kernel cache! Exiting." gen_die "Could not find kerncache.config in the kernel cache! Exiting."
fi fi
else else
# Configure the kernel # Configure the kernel
# If BUILD_KERNEL=0 then assume --no-clean, menuconfig is cleared # If BUILD_KERNEL=0 then assume --no-clean, menuconfig is cleared
if [ ! -f "${KERNEL_DIR}"/Makefile ] if [ ! -f "${KERNEL_DIR}"/Makefile ]
then then
gen_die "Kernel Makefile (${KERNEL_DIR}/Makefile) missing. Maybe re-install the kernel sources." gen_die "Kernel Makefile (${KERNEL_DIR}/Makefile) missing. Maybe re-install the kernel sources."
fi fi
VER=`grep ^VERSION\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'` VER=`grep ^VERSION\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'`
PAT=`grep ^PATCHLEVEL\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'` PAT=`grep ^PATCHLEVEL\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'`
SUB=`grep ^SUBLEVEL\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'` SUB=`grep ^SUBLEVEL\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'`
EXV=`grep ^EXTRAVERSION\ \= ${KERNEL_DIR}/Makefile | sed -e "s/EXTRAVERSION =//" -e "s/ //g" -e 's/\$([a-z]*)//gi'` EXV=`grep ^EXTRAVERSION\ \= ${KERNEL_DIR}/Makefile | sed -e "s/EXTRAVERSION =//" -e "s/ //g" -e 's/\$([a-z]*)//gi'`
if [ -z "${SUB}" ] if [ -z "${SUB}" ]
then then
# Handle O= build directories # Handle O= build directories
KERNEL_SOURCE_DIR=`grep ^MAKEARGS\ \:\= ${KERNEL_DIR}/Makefile | awk '{ print $4 };'` KERNEL_SOURCE_DIR=`grep ^MAKEARGS\ \:\= ${KERNEL_DIR}/Makefile | awk '{ print $4 };'`
[ -z "${KERNEL_SOURCE_DIR}" ] && gen_die "Deriving \${KERNEL_SOURCE_DIR} failed" [ -z "${KERNEL_SOURCE_DIR}" ] && gen_die "Deriving \${KERNEL_SOURCE_DIR} failed"
SUB=`grep ^SUBLEVEL\ \= ${KERNEL_SOURCE_DIR}/Makefile | awk '{ print $3 };'` SUB=`grep ^SUBLEVEL\ \= ${KERNEL_SOURCE_DIR}/Makefile | awk '{ print $3 };'`
EXV=`grep ^EXTRAVERSION\ \= ${KERNEL_SOURCE_DIR}/Makefile | sed -e "s/EXTRAVERSION =//" -e "s/ //g" -e 's/\$([a-z]*)//gi'` EXV=`grep ^EXTRAVERSION\ \= ${KERNEL_SOURCE_DIR}/Makefile | sed -e "s/EXTRAVERSION =//" -e "s/ //g" -e 's/\$([a-z]*)//gi'`
fi fi
cd ${KERNEL_DIR} cd ${KERNEL_DIR}
#compile_generic prepare kernel > /dev/null 2>&1 #compile_generic prepare kernel > /dev/null 2>&1
cd - > /dev/null 2>&1 cd - > /dev/null 2>&1
[ -f "${KERNEL_DIR}/include/linux/version.h" ] && \ [ -f "${KERNEL_DIR}/include/linux/version.h" ] && \
VERSION_SOURCE="${KERNEL_DIR}/include/linux/version.h" VERSION_SOURCE="${KERNEL_DIR}/include/linux/version.h"
[ -f "${KERNEL_DIR}/include/linux/utsrelease.h" ] && \ [ -f "${KERNEL_DIR}/include/linux/utsrelease.h" ] && \
VERSION_SOURCE="${KERNEL_DIR}/include/linux/utsrelease.h" VERSION_SOURCE="${KERNEL_DIR}/include/linux/utsrelease.h"
# Handle new-style releases where version.h doesn't have UTS_RELEASE # Handle new-style releases where version.h doesn't have UTS_RELEASE
if [ -f ${KERNEL_DIR}/include/config/kernel.release ] if [ -f ${KERNEL_DIR}/include/config/kernel.release ]
then then
UTS_RELEASE=`cat ${KERNEL_DIR}/include/config/kernel.release` UTS_RELEASE=`cat ${KERNEL_DIR}/include/config/kernel.release`
LOV=`echo ${UTS_RELEASE}|sed -e "s/${VER}.${PAT}.${SUB}${EXV}//"` LOV=`echo ${UTS_RELEASE}|sed -e "s/${VER}.${PAT}.${SUB}${EXV}//"`
KV=${VER}.${PAT}.${SUB}${EXV}${LOV} KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
elif [ -n "${VERSION_SOURCE}" ] elif [ -n "${VERSION_SOURCE}" ]
then then
UTS_RELEASE=`grep UTS_RELEASE ${VERSION_SOURCE} | sed -e 's/#define UTS_RELEASE "\(.*\)"/\1/'` UTS_RELEASE=`grep UTS_RELEASE ${VERSION_SOURCE} | sed -e 's/#define UTS_RELEASE "\(.*\)"/\1/'`
LOV=`echo ${UTS_RELEASE}|sed -e "s/${VER}.${PAT}.${SUB}${EXV}//"` LOV=`echo ${UTS_RELEASE}|sed -e "s/${VER}.${PAT}.${SUB}${EXV}//"`
KV=${VER}.${PAT}.${SUB}${EXV}${LOV} KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
else else
determine_config_file determine_config_file
LCV=`grep ^CONFIG_LOCALVERSION= "${KERNEL_CONFIG}" | sed -r -e "s/.*=\"(.*)\"/\1/"` LCV=`grep ^CONFIG_LOCALVERSION= "${KERNEL_CONFIG}" | sed -r -e "s/.*=\"(.*)\"/\1/"`
KV=${VER}.${PAT}.${SUB}${EXV}${LCV} KV=${VER}.${PAT}.${SUB}${EXV}${LCV}
fi fi
fi fi
} }
determine_real_args() { determine_real_args() {
print_info 4 "Resolving config file, command line, and arch default settings." print_info 4 "Resolving config file, command line, and arch default settings."
# Dest / Config File Command Line Arch Default # Dest / Config File Command Line Arch Default
# ------------------ ------------ ------------ # ------------------ ------------ ------------
set_config_with_override STRING LOGFILE CMD_LOGFILE set_config_with_override STRING LOGFILE CMD_LOGFILE
set_config_with_override STRING KERNEL_DIR CMD_KERNEL_DIR "${DEFAULT_KERNEL_SOURCE}" set_config_with_override STRING KERNEL_DIR CMD_KERNEL_DIR "${DEFAULT_KERNEL_SOURCE}"
set_config_with_override BOOL KERNEL_SOURCES CMD_KERNEL_SOURCES "yes" set_config_with_override BOOL KERNEL_SOURCES CMD_KERNEL_SOURCES "yes"
set_config_with_override STRING KNAME CMD_KERNNAME "genkernel" set_config_with_override STRING KNAME CMD_KERNNAME "genkernel"
set_config_with_override STRING COMPRESS_INITRD CMD_COMPRESS_INITRD "$DEFAULT_COMPRESS_INITRD" set_config_with_override STRING COMPRESS_INITRD CMD_COMPRESS_INITRD "$DEFAULT_COMPRESS_INITRD"
set_config_with_override STRING COMPRESS_INITRD_TYPE CMD_COMPRESS_INITRD_TYPE "$DEFAULT_COMPRESS_INITRD_TYPE" set_config_with_override STRING COMPRESS_INITRD_TYPE CMD_COMPRESS_INITRD_TYPE "$DEFAULT_COMPRESS_INITRD_TYPE"
set_config_with_override STRING MAKEOPTS CMD_MAKEOPTS "$DEFAULT_MAKEOPTS" set_config_with_override STRING MAKEOPTS CMD_MAKEOPTS "$DEFAULT_MAKEOPTS"
set_config_with_override STRING KERNEL_MAKE CMD_KERNEL_MAKE "$DEFAULT_KERNEL_MAKE" set_config_with_override STRING KERNEL_MAKE CMD_KERNEL_MAKE "$DEFAULT_KERNEL_MAKE"
set_config_with_override STRING UTILS_MAKE CMD_UTILS_MAKE "$DEFAULT_UTILS_MAKE" set_config_with_override STRING UTILS_MAKE CMD_UTILS_MAKE "$DEFAULT_UTILS_MAKE"
set_config_with_override STRING KERNEL_CC CMD_KERNEL_CC "$DEFAULT_KERNEL_CC" set_config_with_override STRING KERNEL_CC CMD_KERNEL_CC "$DEFAULT_KERNEL_CC"
set_config_with_override STRING KERNEL_LD CMD_KERNEL_LD "$DEFAULT_KERNEL_LD" 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 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_CC CMD_UTILS_CC "$DEFAULT_UTILS_CC"
set_config_with_override STRING UTILS_LD CMD_UTILS_LD "$DEFAULT_UTILS_LD" 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" set_config_with_override STRING UTILS_AS CMD_UTILS_AS "$DEFAULT_UTILS_AS"
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 "${KERNEL_DIR}" set_config_with_override STRING KERNEL_OUTPUTDIR CMD_KERNEL_OUTPUTDIR "${KERNEL_DIR}"
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
set_config_with_override BOOL PLYMOUTH CMD_PLYMOUTH set_config_with_override BOOL PLYMOUTH CMD_PLYMOUTH
set_config_with_override BOOL POSTCLEAR CMD_POSTCLEAR set_config_with_override BOOL POSTCLEAR CMD_POSTCLEAR
set_config_with_override BOOL MRPROPER CMD_MRPROPER set_config_with_override BOOL MRPROPER CMD_MRPROPER
set_config_with_override BOOL MENUCONFIG CMD_MENUCONFIG set_config_with_override BOOL MENUCONFIG CMD_MENUCONFIG
set_config_with_override BOOL NCONFIG CMD_NCONFIG set_config_with_override BOOL NCONFIG CMD_NCONFIG
set_config_with_override BOOL CLEAN CMD_CLEAN set_config_with_override BOOL CLEAN CMD_CLEAN
set_config_with_override STRING MINKERNPACKAGE CMD_MINKERNPACKAGE set_config_with_override STRING MINKERNPACKAGE CMD_MINKERNPACKAGE
set_config_with_override STRING MODULESPACKAGE CMD_MODULESPACKAGE set_config_with_override STRING MODULESPACKAGE CMD_MODULESPACKAGE
set_config_with_override STRING KERNCACHE CMD_KERNCACHE set_config_with_override STRING KERNCACHE CMD_KERNCACHE
set_config_with_override BOOL RAMDISKMODULES CMD_RAMDISKMODULES "yes" set_config_with_override BOOL RAMDISKMODULES CMD_RAMDISKMODULES "yes"
set_config_with_override BOOL ALLRAMDISKMODULES CMD_ALLRAMDISKMODULES set_config_with_override BOOL ALLRAMDISKMODULES CMD_ALLRAMDISKMODULES
set_config_with_override STRING INITRAMFS_OVERLAY CMD_INITRAMFS_OVERLAY set_config_with_override STRING INITRAMFS_OVERLAY CMD_INITRAMFS_OVERLAY
set_config_with_override BOOL MOUNTBOOT CMD_MOUNTBOOT set_config_with_override BOOL MOUNTBOOT CMD_MOUNTBOOT
set_config_with_override BOOL BUILD_STATIC CMD_STATIC set_config_with_override BOOL BUILD_STATIC CMD_STATIC
set_config_with_override BOOL SAVE_CONFIG CMD_SAVE_CONFIG set_config_with_override BOOL SAVE_CONFIG CMD_SAVE_CONFIG
set_config_with_override BOOL SYMLINK CMD_SYMLINK set_config_with_override BOOL SYMLINK CMD_SYMLINK
set_config_with_override STRING INSTALL_MOD_PATH CMD_INSTALL_MOD_PATH set_config_with_override STRING INSTALL_MOD_PATH CMD_INSTALL_MOD_PATH
set_config_with_override BOOL OLDCONFIG CMD_OLDCONFIG set_config_with_override BOOL OLDCONFIG CMD_OLDCONFIG
set_config_with_override BOOL UDEV CMD_UDEV set_config_with_override BOOL UDEV CMD_UDEV
set_config_with_override BOOL LVM CMD_LVM set_config_with_override BOOL LVM CMD_LVM
set_config_with_override BOOL DMRAID CMD_DMRAID set_config_with_override BOOL DMRAID CMD_DMRAID
set_config_with_override BOOL ISCSI CMD_ISCSI set_config_with_override BOOL ISCSI CMD_ISCSI
set_config_with_override BOOL BUSYBOX CMD_BUSYBOX "yes" set_config_with_override BOOL BUSYBOX CMD_BUSYBOX "yes"
set_config_with_override BOOL NETBOOT CMD_NETBOOT set_config_with_override BOOL NETBOOT CMD_NETBOOT
set_config_with_override STRING REAL_ROOT CMD_REAL_ROOT set_config_with_override STRING REAL_ROOT CMD_REAL_ROOT
set_config_with_override BOOL LUKS CMD_LUKS set_config_with_override BOOL LUKS CMD_LUKS
set_config_with_override BOOL GPG CMD_GPG set_config_with_override BOOL GPG CMD_GPG
set_config_with_override BOOL MDADM CMD_MDADM set_config_with_override BOOL MDADM CMD_MDADM
set_config_with_override STRING MDADM_CONFIG CMD_MDADM_CONFIG set_config_with_override STRING MDADM_CONFIG CMD_MDADM_CONFIG
set_config_with_override BOOL E2FSPROGS CMD_E2FSPROGS "no" set_config_with_override BOOL E2FSPROGS CMD_E2FSPROGS "no"
set_config_with_override BOOL ZFS CMD_ZFS set_config_with_override BOOL ZFS CMD_ZFS
set_config_with_override BOOL BTRFS CMD_BTRFS set_config_with_override BOOL BTRFS CMD_BTRFS
set_config_with_override BOOL VIRTIO CMD_VIRTIO "no" set_config_with_override BOOL VIRTIO CMD_VIRTIO "no"
set_config_with_override BOOL MULTIPATH CMD_MULTIPATH set_config_with_override BOOL MULTIPATH CMD_MULTIPATH
set_config_with_override BOOL FIRMWARE CMD_FIRMWARE set_config_with_override BOOL FIRMWARE CMD_FIRMWARE
set_config_with_override STRING FIRMWARE_DIR CMD_FIRMWARE_DIR "/lib/firmware" set_config_with_override STRING FIRMWARE_DIR CMD_FIRMWARE_DIR "/lib/firmware"
set_config_with_override STRING FIRMWARE_FILES CMD_FIRMWARE_FILES set_config_with_override STRING FIRMWARE_FILES CMD_FIRMWARE_FILES
set_config_with_override BOOL INTEGRATED_INITRAMFS CMD_INTEGRATED_INITRAMFS set_config_with_override BOOL INTEGRATED_INITRAMFS CMD_INTEGRATED_INITRAMFS
set_config_with_override BOOL GENZIMAGE CMD_GENZIMAGE set_config_with_override BOOL GENZIMAGE CMD_GENZIMAGE
set_config_with_override BOOL KEYMAP CMD_KEYMAP "yes" set_config_with_override BOOL KEYMAP CMD_KEYMAP "yes"
set_config_with_override BOOL DOKEYMAPAUTO CMD_DOKEYMAPAUTO set_config_with_override BOOL DOKEYMAPAUTO CMD_DOKEYMAPAUTO
set_config_with_override STRING BUSYBOX_CONFIG CMD_BUSYBOX_CONFIG set_config_with_override STRING BUSYBOX_CONFIG CMD_BUSYBOX_CONFIG
set_config_with_override BOOL INSTALL CMD_INSTALL "yes" set_config_with_override BOOL INSTALL CMD_INSTALL "yes"
BOOTDIR=`arch_replace "${BOOTDIR}"` BOOTDIR=`arch_replace "${BOOTDIR}"`
BOOTDIR=${BOOTDIR%/} # Remove any trailing slash BOOTDIR=${BOOTDIR%/} # Remove any trailing slash
MODPROBEDIR=${MODPROBEDIR%/} # Remove any trailing slash MODPROBEDIR=${MODPROBEDIR%/} # Remove any trailing slash
CACHE_DIR=`arch_replace "${CACHE_DIR}"` CACHE_DIR=`arch_replace "${CACHE_DIR}"`
BUSYBOX_BINCACHE=`cache_replace "${BUSYBOX_BINCACHE}"` BUSYBOX_BINCACHE=`cache_replace "${BUSYBOX_BINCACHE}"`
DEFAULT_KERNEL_CONFIG=`arch_replace "${DEFAULT_KERNEL_CONFIG}"` DEFAULT_KERNEL_CONFIG=`arch_replace "${DEFAULT_KERNEL_CONFIG}"`
BUSYBOX_CONFIG=`arch_replace "${BUSYBOX_CONFIG}"` BUSYBOX_CONFIG=`arch_replace "${BUSYBOX_CONFIG}"`
BUSYBOX_BINCACHE=`arch_replace "${BUSYBOX_BINCACHE}"` BUSYBOX_BINCACHE=`arch_replace "${BUSYBOX_BINCACHE}"`
if [ -n "${CMD_BOOTLOADER}" ] if [ -n "${CMD_BOOTLOADER}" ]
then then
BOOTLOADER="${CMD_BOOTLOADER}" BOOTLOADER="${CMD_BOOTLOADER}"
if [ "${CMD_BOOTLOADER}" != "${CMD_BOOTLOADER/:/}" ] if [ "${CMD_BOOTLOADER}" != "${CMD_BOOTLOADER/:/}" ]
then then
BOOTFS=`echo "${CMD_BOOTLOADER}" | cut -f2- -d:` BOOTFS=`echo "${CMD_BOOTLOADER}" | cut -f2- -d:`
BOOTLOADER=`echo "${CMD_BOOTLOADER}" | cut -f1 -d:` BOOTLOADER=`echo "${CMD_BOOTLOADER}" | cut -f1 -d:`
fi fi
fi fi
if [ "${KERNEL_SOURCES}" != "0" ] if [ "${KERNEL_SOURCES}" != "0" ]
then then
if [ ! -d ${KERNEL_DIR} ] if [ ! -d ${KERNEL_DIR} ]
then then
gen_die "kernel source directory \"${KERNEL_DIR}\" was not found!" gen_die "kernel source directory \"${KERNEL_DIR}\" was not found!"
fi fi
fi fi
if [ -z "${KERNCACHE}" ] if [ -z "${KERNCACHE}" ]
then then
if [ "${KERNEL_DIR}" = '' -a "${KERNEL_SOURCES}" != "0" ] if [ "${KERNEL_DIR}" = '' -a "${KERNEL_SOURCES}" != "0" ]
then then
gen_die 'No kernel source directory!' gen_die 'No kernel source directory!'
fi fi
if [ ! -e "${KERNEL_DIR}" -a "${KERNEL_SOURCES}" != "0" ] if [ ! -e "${KERNEL_DIR}" -a "${KERNEL_SOURCES}" != "0" ]
then then
gen_die 'No kernel source directory!' gen_die 'No kernel source directory!'
fi fi
else else
if [ "${KERNEL_DIR}" = '' ] if [ "${KERNEL_DIR}" = '' ]
then then
gen_die 'Kernel Cache specified but no kernel tree to verify against!' gen_die 'Kernel Cache specified but no kernel tree to verify against!'
fi fi
fi fi
# Special case: If --no-clean is specified on the command line, # Special case: If --no-clean is specified on the command line,
# imply --no-mrproper. # imply --no-mrproper.
if [ "${CMD_CLEAN}" != '' ] if [ "${CMD_CLEAN}" != '' ]
then then
if ! isTrue ${CLEAN} if ! isTrue ${CLEAN}
then then
MRPROPER=0 MRPROPER=0
fi fi
fi fi
if [ -n "${MINKERNPACKAGE}" ] if [ -n "${MINKERNPACKAGE}" ]
then then
mkdir -p `dirname ${MINKERNPACKAGE}` mkdir -p `dirname ${MINKERNPACKAGE}`
fi fi
if [ -n "${MODULESPACKAGE}" ] if [ -n "${MODULESPACKAGE}" ]
then then
mkdir -p `dirname ${MODULESPACKAGE}` mkdir -p `dirname ${MODULESPACKAGE}`
fi fi
if [ -n "${KERNCACHE}" ] if [ -n "${KERNCACHE}" ]
then then
mkdir -p `dirname ${KERNCACHE}` mkdir -p `dirname ${KERNCACHE}`
fi fi
if ! isTrue "${BUILD_RAMDISK}" if ! isTrue "${BUILD_RAMDISK}"
then then
INTEGRATED_INITRAMFS=0 INTEGRATED_INITRAMFS=0
fi fi
get_KV get_KV
} }

@ -2,169 +2,169 @@
# $Id$ # $Id$
isTrue() { isTrue() {
case "$1" in case "$1" in
[Tt][Rr][Uu][Ee]) [Tt][Rr][Uu][Ee])
return 0 return 0
;; ;;
[Tt]) [Tt])
return 0 return 0
;; ;;
[Yy][Ee][Ss]) [Yy][Ee][Ss])
return 0 return 0
;; ;;
[Yy]) [Yy])
return 0 return 0
;; ;;
1) 1)
return 0 return 0
;; ;;
esac esac
return 1 return 1
} }
setColorVars() { setColorVars() {
if isTrue ${USECOLOR} if isTrue ${USECOLOR}
then then
GOOD=$'\e[32;01m' GOOD=$'\e[32;01m'
WARN=$'\e[33;01m' WARN=$'\e[33;01m'
BAD=$'\e[31;01m' BAD=$'\e[31;01m'
NORMAL=$'\e[0m' NORMAL=$'\e[0m'
BOLD=$'\e[0;01m' BOLD=$'\e[0;01m'
UNDER=$'\e[4m' UNDER=$'\e[4m'
else else
GOOD='' GOOD=''
WARN='' WARN=''
BAD='' BAD=''
NORMAL='' NORMAL=''
BOLD='' BOLD=''
UNDER='' UNDER=''
fi fi
} }
setColorVars setColorVars
dump_debugcache() { dump_debugcache() {
TODEBUGCACHE=0 TODEBUGCACHE=0
echo "${DEBUGCACHE}" >> ${LOGFILE} echo "${DEBUGCACHE}" >> ${LOGFILE}
} }
# print_info(loglevel, print [, newline [, prefixline [, forcefile ] ] ]) # print_info(loglevel, print [, newline [, prefixline [, forcefile ] ] ])
print_info() { print_info() {
local NEWLINE=1 local NEWLINE=1
local FORCEFILE=0 local FORCEFILE=0
local PREFIXLINE=1 local PREFIXLINE=1
local SCRPRINT=0 local SCRPRINT=0
local STR='' local STR=''
# NOT ENOUGH ARGS # NOT ENOUGH ARGS
if [ "$#" -lt '2' ] ; then return 1; fi if [ "$#" -lt '2' ] ; then return 1; fi
# IF 3 OR MORE ARGS, CHECK IF WE WANT A NEWLINE AFTER PRINT # IF 3 OR MORE ARGS, CHECK IF WE WANT A NEWLINE AFTER PRINT
if [ "$#" -gt '2' ] if [ "$#" -gt '2' ]
then then
if isTrue "$3" if isTrue "$3"
then then
NEWLINE='1'; NEWLINE='1';
else else
NEWLINE='0'; NEWLINE='0';
fi fi
fi fi
# IF 4 OR MORE ARGS, CHECK IF WE WANT TO PREFIX WITH A * # IF 4 OR MORE ARGS, CHECK IF WE WANT TO PREFIX WITH A *
if [ "$#" -gt '3' ] if [ "$#" -gt '3' ]
then then
if isTrue "$4" if isTrue "$4"
then then
PREFIXLINE='1' PREFIXLINE='1'
else else
PREFIXLINE='0' PREFIXLINE='0'
fi fi
fi fi
# IF 5 OR MORE ARGS, CHECK IF WE WANT TO FORCE OUTPUT TO DEBUG # IF 5 OR MORE ARGS, CHECK IF WE WANT TO FORCE OUTPUT TO DEBUG
# FILE EVEN IF IT DOESN'T MEET THE MINIMUM DEBUG REQS # FILE EVEN IF IT DOESN'T MEET THE MINIMUM DEBUG REQS
if [ "$#" -gt '4' ] if [ "$#" -gt '4' ]
then then
if isTrue "$5" if isTrue "$5"
then then
FORCEFILE='1' FORCEFILE='1'
else else
FORCEFILE='0' FORCEFILE='0'
fi fi
fi fi
# PRINT TO SCREEN ONLY IF PASSED LOGLEVEL IS HIGHER THAN # PRINT TO SCREEN ONLY IF PASSED LOGLEVEL IS HIGHER THAN
# OR EQUAL TO SET DEBUG LEVEL # OR EQUAL TO SET DEBUG LEVEL
if [ "$1" -lt "${LOGLEVEL}" -o "$1" = "${LOGLEVEL}" ] if [ "$1" -lt "${LOGLEVEL}" -o "$1" = "${LOGLEVEL}" ]
then then
SCRPRINT='1' SCRPRINT='1'
fi fi
# RETURN IF NOT OUTPUTTING ANYWHERE # RETURN IF NOT OUTPUTTING ANYWHERE
if [ "${SCRPRINT}" != '1' -a "${FORCEFILE}" != '1' ] if [ "${SCRPRINT}" != '1' -a "${FORCEFILE}" != '1' ]
then then
return 0 return 0
fi fi
# STRUCTURE DATA TO BE OUTPUT TO SCREEN, AND OUTPUT IT # STRUCTURE DATA TO BE OUTPUT TO SCREEN, AND OUTPUT IT
if [ "${SCRPRINT}" = '1' ] if [ "${SCRPRINT}" = '1' ]
then then
if [ "${PREFIXLINE}" = '1' ] if [ "${PREFIXLINE}" = '1' ]
then then
STR="${GOOD}*${NORMAL} ${2}" STR="${GOOD}*${NORMAL} ${2}"
else else
STR="${2}" STR="${2}"
fi fi
if [ "${NEWLINE}" = '0' ] if [ "${NEWLINE}" = '0' ]
then then
echo -ne "${STR}" echo -ne "${STR}"
else else
echo "${STR}" echo "${STR}"
fi fi
fi fi
# STRUCTURE DATA TO BE OUTPUT TO FILE, AND OUTPUT IT # STRUCTURE DATA TO BE OUTPUT TO FILE, AND OUTPUT IT
if [ "${SCRPRINT}" = '1' -o "${FORCEFILE}" = '1' ] if [ "${SCRPRINT}" = '1' -o "${FORCEFILE}" = '1' ]
then then
STRR=${2//${WARN}/} STRR=${2//${WARN}/}
STRR=${STRR//${BAD}/} STRR=${STRR//${BAD}/}
STRR=${STRR//${BOLD}/} STRR=${STRR//${BOLD}/}
STRR=${STRR//${NORMAL}/} STRR=${STRR//${NORMAL}/}
if [ "${PREFIXLINE}" = '1' ] if [ "${PREFIXLINE}" = '1' ]
then then
STR="* ${STRR}" STR="* ${STRR}"
else else
STR="${STRR}" STR="${STRR}"
fi fi
if [ "${NEWLINE}" = '0' ] if [ "${NEWLINE}" = '0' ]
then then
if [ "${TODEBUGCACHE}" = '1' ]; then if [ "${TODEBUGCACHE}" = '1' ]; then
DEBUGCACHE="${DEBUGCACHE}${STR}" DEBUGCACHE="${DEBUGCACHE}${STR}"
else else
echo -ne "${STR}" >> ${LOGFILE} echo -ne "${STR}" >> ${LOGFILE}
fi fi
else else
if [ "${TODEBUGCACHE}" = '1' ]; then if [ "${TODEBUGCACHE}" = '1' ]; then
DEBUGCACHE="${DEBUGCACHE}${STR}"$'\n' DEBUGCACHE="${DEBUGCACHE}${STR}"$'\n'
else else
echo "${STR}" >> ${LOGFILE} echo "${STR}" >> ${LOGFILE}
fi fi
fi fi
fi fi
return 0 return 0
} }
print_error() print_error()
{ {
GOOD=${BAD} print_info "$@" GOOD=${BAD} print_info "$@"
} }
print_warning() print_warning()
{ {
GOOD=${WARN} print_info "$@" GOOD=${WARN} print_info "$@"
} }
# var_replace(var_name, var_value, string) # var_replace(var_name, var_value, string)
@ -193,50 +193,50 @@ cache_replace() {
clear_log() { clear_log() {
if [ -f "${LOGFILE}" ] if [ -f "${LOGFILE}" ]
then then
(echo > "${LOGFILE}") 2>/dev/null || small_die "Genkernel: Could not write to ${LOGFILE}." (echo > "${LOGFILE}") 2>/dev/null || small_die "Genkernel: Could not write to ${LOGFILE}."
fi fi
} }
gen_die() { gen_die() {
dump_debugcache dump_debugcache
if [ "$#" -gt '0' ] if [ "$#" -gt '0' ]
then then
print_error 1 "ERROR: ${1}" print_error 1 "ERROR: ${1}"
fi fi
print_error 1 '' print_error 1 ''
print_error 1 "-- Grepping log... --" print_error 1 "-- Grepping log... --"
print_error 1 '' print_error 1 ''
if isTrue ${USECOLOR} if isTrue ${USECOLOR}
then then
GREP_COLOR='1' grep -B5 -E --colour=always "([Ww][Aa][Rr][Nn][Ii][Nn][Gg]|[Ee][Rr][Rr][Oo][Rr][ :,!]|[Ff][Aa][Ii][Ll][Ee]?[Dd]?)" ${LOGFILE} \ GREP_COLOR='1' grep -B5 -E --colour=always "([Ww][Aa][Rr][Nn][Ii][Nn][Gg]|[Ee][Rr][Rr][Oo][Rr][ :,!]|[Ff][Aa][Ii][Ll][Ee]?[Dd]?)" ${LOGFILE} \
| sed -s "s|^\(*\)\?|${BAD}*${NORMAL}|" | sed -s "s|^\(*\)\?|${BAD}*${NORMAL}|"
else else
grep -B5 -E "([Ww][Aa][Rr][Nn][Ii][Nn][Gg]|[Ee][Rr][Rr][Oo][Rr][ :,!]|[Ff][Aa][Ii][Ll][Ee]?[Dd]?)" ${LOGFILE} grep -B5 -E "([Ww][Aa][Rr][Nn][Ii][Nn][Gg]|[Ee][Rr][Rr][Oo][Rr][ :,!]|[Ff][Aa][Ii][Ll][Ee]?[Dd]?)" ${LOGFILE}
fi fi
print_error 1 '' print_error 1 ''
print_error 1 "-- End log... --" print_error 1 "-- End log... --"
print_error 1 '' print_error 1 ''
print_error 1 "Please consult ${LOGFILE} for more information and any" print_error 1 "Please consult ${LOGFILE} for more information and any"
print_error 1 "errors that were reported above." print_error 1 "errors that were reported above."
print_error 1 '' print_error 1 ''
print_error 1 "Report any genkernel bugs to bugs.gentoo.org and" print_error 1 "Report any genkernel bugs to bugs.gentoo.org and"
print_error 1 "assign your bug to genkernel@gentoo.org. Please include" print_error 1 "assign your bug to genkernel@gentoo.org. Please include"
print_error 1 "as much information as you can in your bug report; attaching" print_error 1 "as much information as you can in your bug report; attaching"
print_error 1 "${LOGFILE} so that your issue can be dealt with effectively." print_error 1 "${LOGFILE} so that your issue can be dealt with effectively."
print_error 1 '' print_error 1 ''
print_error 1 'Please do *not* report compilation failures as genkernel bugs!' print_error 1 'Please do *not* report compilation failures as genkernel bugs!'
print_error 1 '' print_error 1 ''
# Cleanup temp dirs and caches if requested # Cleanup temp dirs and caches if requested
cleanup cleanup
exit 1 exit 1
} }
isBootRO() isBootRO()
{ {
return $(awk '( $2 == "'${BOOTDIR}'" && $4 ~ /(^|,)ro(,|$)/){ I=1; exit }END{print !I }' /proc/mounts); return $(awk '( $2 == "'${BOOTDIR}'" && $4 ~ /(^|,)ro(,|$)/){ I=1; exit }END{print !I }' /proc/mounts);
} }
setup_cache_dir() setup_cache_dir()
@ -246,12 +246,12 @@ setup_cache_dir()
if [ "${CLEAR_CACHE_DIR}" == 'yes' ] if [ "${CLEAR_CACHE_DIR}" == 'yes' ]
then then
print_info 1 "Clearing cache dir contents from ${CACHE_DIR}" print_info 1 "Clearing cache dir contents from ${CACHE_DIR}"
while read i while read i
do do
print_info 1 " >> removing ${i}" print_info 1 " >> removing ${i}"
rm "${i}" rm "${i}"
done < <(find "${CACHE_DIR}" -maxdepth 1 -type f -name '*.tar.*' -o -name '*.bz2') done < <(find "${CACHE_DIR}" -maxdepth 1 -type f -name '*.tar.*' -o -name '*.bz2')
fi fi
} }
@ -260,13 +260,13 @@ clear_tmpdir()
{ {
if isTrue ${CMD_INSTALL} if isTrue ${CMD_INSTALL}
then then
TMPDIR_CONTENTS=`ls ${TMPDIR}` TMPDIR_CONTENTS=`ls ${TMPDIR}`
print_info 1 "Removing tmp dir contents" print_info 1 "Removing tmp dir contents"
for i in ${TMPDIR_CONTENTS} for i in ${TMPDIR_CONTENTS}
do do
print_info 1 " >> removing ${i}" print_info 1 " >> removing ${i}"
rm ${TMPDIR}/${i} rm ${TMPDIR}/${i}
done done
fi fi
} }
@ -285,127 +285,127 @@ fi
# - JRG # - JRG
# #
copy_image_with_preserve() { copy_image_with_preserve() {
local symlinkName=$1 local symlinkName=$1
local newSrceImage=$2 local newSrceImage=$2
local fullDestName=$3 local fullDestName=$3
local currDestImage local currDestImage
local prevDestImage local prevDestImage
local currDestImageExists=0 local currDestImageExists=0
local prevDestImageExists=0 local prevDestImageExists=0
print_info 4 "Copying new ${symlinkName} image, " 0 print_info 4 "Copying new ${symlinkName} image, " 0
# 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} 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
if [ -e "${BOOTDIR}/${symlinkName}" ] if [ -e "${BOOTDIR}/${symlinkName}" ]
then then
# JRG: Do I need a special case here for when the standard symlink # JRG: Do I need a special case here for when the standard symlink
# name is, in fact, not a symlink? # name is, in fact, not a symlink?
currDestImage=`readlink --no-newline ${BOOTDIR}/${symlinkName}` currDestImage=`readlink --no-newline ${BOOTDIR}/${symlinkName}`
print_info 5 " Current ${symlinkName} symlink exists:" print_info 5 " Current ${symlinkName} symlink exists:"
print_info 5 " ${currDestImage}" print_info 5 " ${currDestImage}"
else else
currDestImage="${fullDestName}" currDestImage="${fullDestName}"
print_info 5 " Current ${symlinkName} symlink did not exist." print_info 5 " Current ${symlinkName} symlink did not exist."
print_info 5 " Defaulted to: ${currDestImage}" print_info 5 " Defaulted to: ${currDestImage}"
fi fi
if [ -e "${BOOTDIR}/${currDestImage}" ] if [ -e "${BOOTDIR}/${currDestImage}" ]
then then
currDestImageExists=1 currDestImageExists=1
print_info 5 " Actual image file exists." print_info 5 " Actual image file exists."
fi fi
if [ -e "${BOOTDIR}/${symlinkName}.old" ] if [ -e "${BOOTDIR}/${symlinkName}.old" ]
then then
# JRG: Do I need a special case here for when the standard symlink # JRG: Do I need a special case here for when the standard symlink
# name is, in fact, not a symlink? # name is, in fact, not a symlink?
prevDestImage=`readlink --no-newline ${BOOTDIR}/${symlinkName}.old` prevDestImage=`readlink --no-newline ${BOOTDIR}/${symlinkName}.old`
print_info 5 " Old ${symlinkName} symlink exists:" print_info 5 " Old ${symlinkName} symlink exists:"
print_info 5 " ${prevDestImage}" print_info 5 " ${prevDestImage}"
else else
prevDestImage="${fullDestName}.old" prevDestImage="${fullDestName}.old"
print_info 5 " Old ${symlinkName} symlink did not exist." print_info 5 " Old ${symlinkName} symlink did not exist."
print_info 5 " Defaulted to: ${prevDestImage}" print_info 5 " Defaulted to: ${prevDestImage}"
fi fi
if [ -e "${BOOTDIR}/${prevDestImage}" ] if [ -e "${BOOTDIR}/${prevDestImage}" ]
then then
prevDestImageExists=1 prevDestImageExists=1
print_info 5 " Actual old image file exists." print_info 5 " Actual old image file exists."
fi fi
else else
print_info 4 "symlinks not being handled by genkernel." 1 0 print_info 4 "symlinks not being handled by genkernel." 1 0
currDestImage="${fullDestName}" currDestImage="${fullDestName}"
prevDestImage="${fullDestName}.old" prevDestImage="${fullDestName}.old"
fi fi
# When symlinks are not being managed by genkernel, old symlinks might # When symlinks are not being managed by genkernel, old symlinks might
# still be useful. Leave 'em alone unless managed. # still be useful. Leave 'em alone unless managed.
if [ "${SYMLINK}" = '1' ] if [ "${SYMLINK}" = '1' ]
then then
print_info 5 " Deleting old symlinks, if any." print_info 5 " Deleting old symlinks, if any."
rm -f "${BOOTDIR}/${symlinkName}" rm -f "${BOOTDIR}/${symlinkName}"
rm -f "${BOOTDIR}/${symlinkName}.old" rm -f "${BOOTDIR}/${symlinkName}.old"
fi fi
# We only erase the .old image when it is the exact same version as the # We only erase the .old image when it is the exact same version as the
# current and new images. Different version .old (and current) images are # current and new images. Different version .old (and current) images are
# left behind. This is consistent with how "make install" of the manual # left behind. This is consistent with how "make install" of the manual
# kernel build works. # kernel build works.
if [ "${currDestImage}" == "${fullDestName}" ] if [ "${currDestImage}" == "${fullDestName}" ]
then then
# #
# Case for new and currrent of the same base version. # Case for new and currrent of the same base version.
# #
print_info 5 " Same base version. May have to delete old image to make room." print_info 5 " Same base version. May have to delete old image to make room."
if [ "${currDestImageExists}" = '1' ] if [ "${currDestImageExists}" = '1' ]
then then
if [ -e "${BOOTDIR}/${currDestImage}.old" ] if [ -e "${BOOTDIR}/${currDestImage}.old" ]
then then
print_info 5 " Deleting old identical version ${symlinkName}." print_info 5 " Deleting old identical version ${symlinkName}."
rm -f "${BOOTDIR}/${currDestImage}.old" rm -f "${BOOTDIR}/${currDestImage}.old"
fi fi
print_info 5 " Moving ${BOOTDIR}/${currDestImage}" print_info 5 " Moving ${BOOTDIR}/${currDestImage}"
print_info 5 " to ${BOOTDIR}/${currDestImage}.old" print_info 5 " to ${BOOTDIR}/${currDestImage}.old"
mv "${BOOTDIR}/${currDestImage}" "${BOOTDIR}/${currDestImage}.old" || mv "${BOOTDIR}/${currDestImage}" "${BOOTDIR}/${currDestImage}.old" ||
gen_die "Could not rename the old ${symlinkName} image!" gen_die "Could not rename the old ${symlinkName} image!"
prevDestImage="${currDestImage}.old" prevDestImage="${currDestImage}.old"
prevDestImageExists=1 prevDestImageExists=1
fi fi
else else
# #
# Case for new / current not of the same base version. # Case for new / current not of the same base version.
# #
print_info 5 " Different base version. Do not delete old images." print_info 5 " Different base version. Do not delete old images."
prevDestImage="${currDestImage}" prevDestImage="${currDestImage}"
currDestImage="${fullDestName}" currDestImage="${fullDestName}"
fi fi
print_info 5 " Copying ${symlinkName}: ${newSrceImage}" print_info 5 " Copying ${symlinkName}: ${newSrceImage}"
print_info 5 " to ${BOOTDIR}/${currDestImage}" print_info 5 " to ${BOOTDIR}/${currDestImage}"
cp "${newSrceImage}" "${BOOTDIR}/${currDestImage}" || cp "${newSrceImage}" "${BOOTDIR}/${currDestImage}" ||
gen_die "Could not copy the ${symlinkName} image to ${BOOTDIR}!" gen_die "Could not copy the ${symlinkName} image to ${BOOTDIR}!"
if [ "${SYMLINK}" = '1' ] if [ "${SYMLINK}" = '1' ]
then then
print_info 5 " Make new symlink(s) (from ${BOOTDIR}):" print_info 5 " Make new symlink(s) (from ${BOOTDIR}):"
print_info 5 " ${symlinkName} -> ${currDestImage}" print_info 5 " ${symlinkName} -> ${currDestImage}"
pushd ${BOOTDIR} >/dev/null pushd ${BOOTDIR} >/dev/null
ln -s "${currDestImage}" "${symlinkName}" || ln -s "${currDestImage}" "${symlinkName}" ||
gen_die "Could not create the ${symlinkName} symlink!" gen_die "Could not create the ${symlinkName} symlink!"
if [ "${prevDestImageExists}" = '1' ] if [ "${prevDestImageExists}" = '1' ]
then then
print_info 5 " ${symlinkName}.old -> ${prevDestImage}" print_info 5 " ${symlinkName}.old -> ${prevDestImage}"
ln -s "${prevDestImage}" "${symlinkName}.old" || ln -s "${prevDestImage}" "${symlinkName}.old" ||
gen_die "Could not create the ${symlinkName}.old symlink!" gen_die "Could not create the ${symlinkName}.old symlink!"
fi fi
popd >/dev/null popd >/dev/null
fi fi
} }
# #
@ -436,92 +436,92 @@ copy_image_with_preserve() {
# - JRG # - JRG
# #
set_config_with_override() { set_config_with_override() {
local VarType=$1 local VarType=$1
local CfgVar=$2 local CfgVar=$2
local OverrideVar=$3 local OverrideVar=$3
local Default=$4 local Default=$4
local Result local Result
# #
# Syntax check the function arguments. # Syntax check the function arguments.
# #
case "$VarType" in case "$VarType" in
BOOL|STRING) BOOL|STRING)
;; ;;
*) *)
gen_die "Illegal variable type \"$VarType\" passed to set_config_with_override()." gen_die "Illegal variable type \"$VarType\" passed to set_config_with_override()."
;; ;;
esac esac
if [ -n "${!OverrideVar}" ] if [ -n "${!OverrideVar}" ]
then then
Result=${!OverrideVar} Result=${!OverrideVar}
if [ -n "${!CfgVar}" ] if [ -n "${!CfgVar}" ]
then then
print_info 5 " $CfgVar overridden on command line to \"$Result\"." print_info 5 " $CfgVar overridden on command line to \"$Result\"."
else else
print_info 5 " $CfgVar set on command line to \"$Result\"." print_info 5 " $CfgVar set on command line to \"$Result\"."
fi fi
else else
if [ -n "${!CfgVar}" ] if [ -n "${!CfgVar}" ]
then then
Result=${!CfgVar} Result=${!CfgVar}
# we need to set the CMD_* according to configfile... # we need to set the CMD_* according to configfile...
eval ${OverrideVar}=\"${Result}\" eval ${OverrideVar}=\"${Result}\"
print_info 5 " $CfgVar set in config file to \"${Result}\"." print_info 5 " $CfgVar set in config file to \"${Result}\"."
else else
if [ -n "$Default" ] if [ -n "$Default" ]
then then
Result=${Default} Result=${Default}
# set OverrideVar to Result, otherwise CMD_* may not be initialized... # set OverrideVar to Result, otherwise CMD_* may not be initialized...
eval ${OverrideVar}=\"${Result}\" eval ${OverrideVar}=\"${Result}\"
print_info 5 " $CfgVar defaulted to \"${Result}\"." print_info 5 " $CfgVar defaulted to \"${Result}\"."
else else
print_info 5 " $CfgVar not set." print_info 5 " $CfgVar not set."
fi fi
fi fi
fi fi
if [ "${VarType}" = BOOL ] if [ "${VarType}" = BOOL ]
then then
if isTrue "${Result}" if isTrue "${Result}"
then then
Result=1 Result=1
else else
Result=0 Result=0
fi fi
fi fi
eval ${CfgVar}=\"${Result}\" eval ${CfgVar}=\"${Result}\"
} }
check_distfiles() { check_distfiles() {
for i in $BUSYBOX_SRCTAR $MULTIPATH_SRCTAR $ISCSI_SRCTAR $GPG_SRCTAR for i in $BUSYBOX_SRCTAR $MULTIPATH_SRCTAR $ISCSI_SRCTAR $GPG_SRCTAR
do do
if [ ! -f "${i}" ] if [ ! -f "${i}" ]
then then
small_die "Could not find source tarball ${i}. Please refetch." small_die "Could not find source tarball ${i}. Please refetch."
fi fi
done done
} }
find_kernel_binary() { find_kernel_binary() {
local kernel_binary=$* local kernel_binary=$*
local curdir=$(pwd) local curdir=$(pwd)
cd "${KERNEL_OUTPUTDIR}" cd "${KERNEL_OUTPUTDIR}"
for i in ${kernel_binary} for i in ${kernel_binary}
do do
if [ -e "${i}" ] if [ -e "${i}" ]
then then
tmp_kernel_binary=$i tmp_kernel_binary=$i
break break
fi fi
done done
# if [ -z "${tmp_kernel_binary}" ] # if [ -z "${tmp_kernel_binary}" ]
# then # then
# gen_die "Cannot locate kernel binary!" # gen_die "Cannot locate kernel binary!"
# fi # fi
cd "${curdir}" cd "${curdir}"
echo "${tmp_kernel_binary}" echo "${tmp_kernel_binary}"
} }

File diff suppressed because it is too large Load Diff

@ -3,17 +3,17 @@
modules_kext() modules_kext()
{ {
KEXT=".ko" KEXT=".ko"
echo ${KEXT} echo ${KEXT}
} }
modules_dep_list() modules_dep_list()
{ {
KEXT=$(modules_kext) KEXT=$(modules_kext)
if [ -f ${INSTALL_MOD_PATH}/lib/modules/${KV}/modules.dep ] if [ -f ${INSTALL_MOD_PATH}/lib/modules/${KV}/modules.dep ]
then then
cat ${INSTALL_MOD_PATH}/lib/modules/${KV}/modules.dep | grep ${1}${KEXT}\: | cut -d\: -f2 cat ${INSTALL_MOD_PATH}/lib/modules/${KV}/modules.dep | grep ${1}${KEXT}\: | cut -d\: -f2
fi fi
} }
# Pass module deps list # Pass module deps list
@ -34,42 +34,42 @@ strip_mod_paths()
gen_deps() gen_deps()
{ {
local modlist local modlist
local deps local deps
for x in ${*} for x in ${*}
do do
echo ${x} >> ${TEMP}/moddeps echo ${x} >> ${TEMP}/moddeps
modlist=`modules_dep_list ${x}` modlist=`modules_dep_list ${x}`
if [ "${modlist}" != "" -a "${modlist}" != " " ] if [ "${modlist}" != "" -a "${modlist}" != " " ]
then then
deps=`strip_mod_paths ${modlist}` deps=`strip_mod_paths ${modlist}`
else else
deps="" deps=""
fi fi
for y in ${deps} for y in ${deps}
do do
echo ${y} >> ${TEMP}/moddeps echo ${y} >> ${TEMP}/moddeps
done done
done done
} }
gen_dep_list() gen_dep_list()
{ {
if [ "${ALLRAMDISKMODULES}" = "1" ]; then if [ "${ALLRAMDISKMODULES}" = "1" ]; then
strip_mod_paths $(find "${INSTALL_MOD_PATH}/lib/modules/${KV}" -name "*$(modules_kext)") | sort strip_mod_paths $(find "${INSTALL_MOD_PATH}/lib/modules/${KV}" -name "*$(modules_kext)") | sort
else else
local group_modules local group_modules
rm -f ${TEMP}/moddeps > /dev/null rm -f ${TEMP}/moddeps > /dev/null
for group_modules in ${!MODULES_*}; do for group_modules in ${!MODULES_*}; do
gen_deps ${!group_modules} gen_deps ${!group_modules}
done done
# Only list each module once # Only list each module once
if [ -f ${TEMP}/moddeps ] if [ -f ${TEMP}/moddeps ]
then then
cat ${TEMP}/moddeps | sort | uniq cat ${TEMP}/moddeps | sort | uniq
fi fi
fi fi
} }

@ -2,210 +2,210 @@
# $Id$ # $Id$
gen_minkernpackage() { gen_minkernpackage() {
print_info 1 'Creating minimal kernel package' print_info 1 'Creating minimal kernel package'
rm -rf "${TEMP}/minkernpackage" > /dev/null 2>&1 rm -rf "${TEMP}/minkernpackage" > /dev/null 2>&1
mkdir "${TEMP}/minkernpackage" || gen_die 'Could not make a directory for the kernel package!' mkdir "${TEMP}/minkernpackage" || gen_die 'Could not make a directory for the kernel package!'
if [ "${KERNCACHE}" != "" ] if [ "${KERNCACHE}" != "" ]
then then
/bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} kernel-${ARCH}-${KV} /bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} kernel-${ARCH}-${KV}
/bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} config-${ARCH}-${KV} /bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} config-${ARCH}-${KV}
if isTrue "${GENZIMAGE}" if isTrue "${GENZIMAGE}"
then then
/bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} kernelz-${ARCH}-${KV} /bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} kernelz-${ARCH}-${KV}
fi fi
else else
local tmp_kernel_binary=$(find_kernel_binary ${KERNEL_BINARY}) local tmp_kernel_binary=$(find_kernel_binary ${KERNEL_BINARY})
local tmp_kernel_binary2=$(find_kernel_binary ${KERNEL_BINARY_2}) local tmp_kernel_binary2=$(find_kernel_binary ${KERNEL_BINARY_2})
if [ -z "${tmp_kernel_binary}" ] if [ -z "${tmp_kernel_binary}" ]
then then
gen_die "Cannot locate kernel binary" gen_die "Cannot locate kernel binary"
fi fi
cd "${KERNEL_OUTPUTDIR}" cd "${KERNEL_OUTPUTDIR}"
cp "${tmp_kernel_binary}" "${TEMP}/minkernpackage/kernel-${KV}" || gen_die 'Could not the copy kernel for the min kernel package!' cp "${tmp_kernel_binary}" "${TEMP}/minkernpackage/kernel-${KV}" || gen_die 'Could not the copy kernel for the min kernel package!'
cp ".config" "${TEMP}/minkernpackage/config-${ARCH}-${KV}" || gen_die 'Could not the copy kernel config for the min kernel package!' cp ".config" "${TEMP}/minkernpackage/config-${ARCH}-${KV}" || gen_die 'Could not the copy kernel config for the min kernel package!'
if isTrue "${GENZIMAGE}" if isTrue "${GENZIMAGE}"
then then
cp "${tmp_kernel_binary2}" "${TEMP}/minkernpackage/kernelz-${KV}" || gen_die "Could not copy the kernelz for the min kernel package" cp "${tmp_kernel_binary2}" "${TEMP}/minkernpackage/kernelz-${KV}" || gen_die "Could not copy the kernelz for the min kernel package"
fi fi
fi fi
if ! isTrue "${INTEGRATED_INITRAMFS}" if ! isTrue "${INTEGRATED_INITRAMFS}"
then then
[ "${BUILD_RAMDISK}" != '0' ] && { cp "${TMPDIR}/initramfs-${KV}" "${TEMP}/minkernpackage/initramfs-${ARCH}-${KV}" || gen_die 'Could not copy the initramfs for the kernel package!'; } [ "${BUILD_RAMDISK}" != '0' ] && { cp "${TMPDIR}/initramfs-${KV}" "${TEMP}/minkernpackage/initramfs-${ARCH}-${KV}" || gen_die 'Could not copy the initramfs for the kernel package!'; }
fi fi
if [ "${KERNCACHE}" != "" ] if [ "${KERNCACHE}" != "" ]
then then
/bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} System.map-${ARCH}-${KV} /bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} System.map-${ARCH}-${KV}
else else
cp "${KERNEL_OUTPUTDIR}/System.map" "${TEMP}/minkernpackage/System.map-${ARCH}-${KV}" || gen_die 'Could not copy System.map for the kernel package!'; cp "${KERNEL_OUTPUTDIR}/System.map" "${TEMP}/minkernpackage/System.map-${ARCH}-${KV}" || gen_die 'Could not copy System.map for the kernel package!';
fi fi
cd "${TEMP}/minkernpackage" cd "${TEMP}/minkernpackage"
/bin/tar -jcpf ${MINKERNPACKAGE} * || gen_die 'Could not compress the kernel package!' /bin/tar -jcpf ${MINKERNPACKAGE} * || gen_die 'Could not compress the kernel package!'
cd "${TEMP}" && rm -rf "${TEMP}/minkernpackage" > /dev/null 2>&1 cd "${TEMP}" && rm -rf "${TEMP}/minkernpackage" > /dev/null 2>&1
} }
gen_modulespackage() { gen_modulespackage() {
print_info 1 'Creating modules package' print_info 1 'Creating modules package'
rm -rf "${TEMP}/modulespackage" > /dev/null 2>&1 rm -rf "${TEMP}/modulespackage" > /dev/null 2>&1
mkdir "${TEMP}/modulespackage" || gen_die 'Could not make a directory for the kernel package!' mkdir "${TEMP}/modulespackage" || gen_die 'Could not make a directory for the kernel package!'
if [ -d ${INSTALL_MOD_PATH}/lib/modules/${KV} ] if [ -d ${INSTALL_MOD_PATH}/lib/modules/${KV} ]
then then
mkdir -p ${TEMP}/modulespackage/lib/modules mkdir -p ${TEMP}/modulespackage/lib/modules
cp -r "${INSTALL_MOD_PATH}/lib/modules/${KV}" "${TEMP}/modulespackage/lib/modules" cp -r "${INSTALL_MOD_PATH}/lib/modules/${KV}" "${TEMP}/modulespackage/lib/modules"
cd "${TEMP}/modulespackage" cd "${TEMP}/modulespackage"
/bin/tar -jcpf ${MODULESPACKAGE} * || gen_die 'Could not compress the modules package!' /bin/tar -jcpf ${MODULESPACKAGE} * || gen_die 'Could not compress the modules package!'
else else
print_info 1 "Could not create a modules package ${INSTALL_MOD_PATH}/lib/modules/${KV} was not found" print_info 1 "Could not create a modules package ${INSTALL_MOD_PATH}/lib/modules/${KV} was not found"
fi fi
cd "${TEMP}" && rm -rf "${TEMP}/modulespackage" > /dev/null 2>&1 cd "${TEMP}" && rm -rf "${TEMP}/modulespackage" > /dev/null 2>&1
} }
gen_kerncache() gen_kerncache()
{ {
print_info 1 'Creating kernel cache' print_info 1 'Creating kernel cache'
rm -rf "${TEMP}/kerncache" > /dev/null 2>&1 rm -rf "${TEMP}/kerncache" > /dev/null 2>&1
mkdir "${TEMP}/kerncache" || gen_die 'Could not make a directory for the kernel cache!' mkdir "${TEMP}/kerncache" || gen_die 'Could not make a directory for the kernel cache!'
local tmp_kernel_binary=$(find_kernel_binary ${KERNEL_BINARY}) local tmp_kernel_binary=$(find_kernel_binary ${KERNEL_BINARY})
local tmp_kernel_binary2=$(find_kernel_binary ${KERNEL_BINARY_2}) local tmp_kernel_binary2=$(find_kernel_binary ${KERNEL_BINARY_2})
if [ -z "${tmp_kernel_binary}" ] if [ -z "${tmp_kernel_binary}" ]
then then
gen_die "Cannot locate kernel binary" gen_die "Cannot locate kernel binary"
fi fi
cd "${KERNEL_OUTPUTDIR}" cd "${KERNEL_OUTPUTDIR}"
cp "${tmp_kernel_binary}" "${TEMP}/kerncache/kernel-${ARCH}-${KV}" || gen_die 'Could not the copy kernel for the kernel package!' cp "${tmp_kernel_binary}" "${TEMP}/kerncache/kernel-${ARCH}-${KV}" || gen_die 'Could not the copy kernel for the kernel package!'
cp "${KERNEL_OUTPUTDIR}/.config" "${TEMP}/kerncache/config-${ARCH}-${KV}" cp "${KERNEL_OUTPUTDIR}/.config" "${TEMP}/kerncache/config-${ARCH}-${KV}"
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}" > "${TEMP}/kerncache/config-${ARCH}-${KV}.orig" zcat "${KERNEL_CONFIG}" > "${TEMP}/kerncache/config-${ARCH}-${KV}.orig"
else else
cp "${KERNEL_CONFIG}" "${TEMP}/kerncache/config-${ARCH}-${KV}.orig" cp "${KERNEL_CONFIG}" "${TEMP}/kerncache/config-${ARCH}-${KV}.orig"
fi fi
cp "${KERNEL_OUTPUTDIR}/System.map" "${TEMP}/kerncache/System.map-${ARCH}-${KV}" cp "${KERNEL_OUTPUTDIR}/System.map" "${TEMP}/kerncache/System.map-${ARCH}-${KV}"
if isTrue "${GENZIMAGE}" if isTrue "${GENZIMAGE}"
then then
cp "${tmp_kernel_binary2}" "${TEMP}/kerncache/kernelz-${ARCH}-${KV}" || gen_die "Could not copy the kernelz for the kernel package" cp "${tmp_kernel_binary2}" "${TEMP}/kerncache/kernelz-${ARCH}-${KV}" || gen_die "Could not copy the kernelz for the kernel package"
fi fi
echo "VERSION = ${VER}" > "${TEMP}/kerncache/kerncache.config" echo "VERSION = ${VER}" > "${TEMP}/kerncache/kerncache.config"
echo "PATCHLEVEL = ${PAT}" >> "${TEMP}/kerncache/kerncache.config" echo "PATCHLEVEL = ${PAT}" >> "${TEMP}/kerncache/kerncache.config"
echo "SUBLEVEL = ${SUB}" >> "${TEMP}/kerncache/kerncache.config" echo "SUBLEVEL = ${SUB}" >> "${TEMP}/kerncache/kerncache.config"
echo "EXTRAVERSION = ${EXV}" >> "${TEMP}/kerncache/kerncache.config" echo "EXTRAVERSION = ${EXV}" >> "${TEMP}/kerncache/kerncache.config"
mkdir -p "${TEMP}/kerncache/lib/modules/" mkdir -p "${TEMP}/kerncache/lib/modules/"
if [ -d ${INSTALL_MOD_PATH}/lib/modules/${KV} ] if [ -d ${INSTALL_MOD_PATH}/lib/modules/${KV} ]
then then
cp -r "${INSTALL_MOD_PATH}/lib/modules/${KV}" "${TEMP}/kerncache/lib/modules" cp -r "${INSTALL_MOD_PATH}/lib/modules/${KV}" "${TEMP}/kerncache/lib/modules"
fi fi
cd "${TEMP}/kerncache" cd "${TEMP}/kerncache"
/bin/tar -jcpf ${KERNCACHE} * || gen_die 'Could not compress the kernel package!' /bin/tar -jcpf ${KERNCACHE} * || gen_die 'Could not compress the kernel package!'
cd "${TEMP}" && rm -rf "${TEMP}/kerncache" > /dev/null 2>&1 cd "${TEMP}" && rm -rf "${TEMP}/kerncache" > /dev/null 2>&1
} }
gen_kerncache_extract_kernel() gen_kerncache_extract_kernel()
{ {
/bin/tar -f ${KERNCACHE} -C ${TEMP} -xj /bin/tar -f ${KERNCACHE} -C ${TEMP} -xj
copy_image_with_preserve "kernel" \ copy_image_with_preserve "kernel" \
"${TEMP}/kernel-${ARCH}-${KV}" \ "${TEMP}/kernel-${ARCH}-${KV}" \
"kernel-${KNAME}-${ARCH}-${KV}" "kernel-${KNAME}-${ARCH}-${KV}"
if isTrue "${GENZIMAGE}" if isTrue "${GENZIMAGE}"
then then
copy_image_with_preserve "kernelz" \ copy_image_with_preserve "kernelz" \
"${TEMP}/kernelz-${ARCH}-${KV}" \ "${TEMP}/kernelz-${ARCH}-${KV}" \
"kernelz-${KNAME}-${ARCH}-${KV}" "kernelz-${KNAME}-${ARCH}-${KV}"
fi fi
copy_image_with_preserve "System.map" \ copy_image_with_preserve "System.map" \
"${TEMP}/System.map-${ARCH}-${KV}" \ "${TEMP}/System.map-${ARCH}-${KV}" \
"System.map-${KNAME}-${ARCH}-${KV}" "System.map-${KNAME}-${ARCH}-${KV}"
} }
gen_kerncache_extract_modules() gen_kerncache_extract_modules()
{ {
if [ -e "${KERNCACHE}" ] if [ -e "${KERNCACHE}" ]
then then
print_info 1 'Extracting kerncache kernel modules' print_info 1 'Extracting kerncache kernel modules'
if [ "${INSTALL_MOD_PATH}" != '' ] if [ "${INSTALL_MOD_PATH}" != '' ]
then then
/bin/tar -xjf ${KERNCACHE} -C ${INSTALL_MOD_PATH} lib /bin/tar -xjf ${KERNCACHE} -C ${INSTALL_MOD_PATH} lib
else else
/bin/tar -xjf ${KERNCACHE} -C / lib /bin/tar -xjf ${KERNCACHE} -C / lib
fi fi
fi fi
} }
gen_kerncache_extract_config() gen_kerncache_extract_config()
{ {
if [ -e "${KERNCACHE}" ] if [ -e "${KERNCACHE}" ]
then then
print_info 1 'Extracting kerncache config to /etc/kernels' print_info 1 'Extracting kerncache config to /etc/kernels'
mkdir -p /etc/kernels mkdir -p /etc/kernels
/bin/tar -xjf ${KERNCACHE} -C /etc/kernels config-${ARCH}-${KV} /bin/tar -xjf ${KERNCACHE} -C /etc/kernels config-${ARCH}-${KV}
mv /etc/kernels/config-${ARCH}-${KV} /etc/kernels/kernel-config-${ARCH}-${KV} mv /etc/kernels/config-${ARCH}-${KV} /etc/kernels/kernel-config-${ARCH}-${KV}
fi fi
} }
gen_kerncache_is_valid() gen_kerncache_is_valid()
{ {
KERNCACHE_IS_VALID=0 KERNCACHE_IS_VALID=0
if [ "${NO_KERNEL_SOURCES}" = '1' ] if [ "${NO_KERNEL_SOURCES}" = '1' ]
then then
BUILD_KERNEL=0 BUILD_KERNEL=0
# Can make this more secure .... # Can make this more secure ....
/bin/tar -xj -f ${KERNCACHE} -C ${TEMP} /bin/tar -xj -f ${KERNCACHE} -C ${TEMP}
if [ -e ${TEMP}/config-${ARCH}-${KV} -a -e ${TEMP}/kernel-${ARCH}-${KV} ] if [ -e ${TEMP}/config-${ARCH}-${KV} -a -e ${TEMP}/kernel-${ARCH}-${KV} ]
then then
print_info 1 'Valid kernel cache found; no sources will be used' print_info 1 'Valid kernel cache found; no sources will be used'
KERNCACHE_IS_VALID=1 KERNCACHE_IS_VALID=1
fi fi
else else
if [ -e "${KERNCACHE}" ] if [ -e "${KERNCACHE}" ]
then then
KERNEL_CONFIG="/${KERNEL_OUTPUTDIR}/.config" KERNEL_CONFIG="/${KERNEL_OUTPUTDIR}/.config"
if [ "${CMD_KERNEL_CONFIG}" != '' ] if [ "${CMD_KERNEL_CONFIG}" != '' ]
then then
KERNEL_CONFIG="${CMD_KERNEL_CONFIG}" KERNEL_CONFIG="${CMD_KERNEL_CONFIG}"
fi fi
/bin/tar -xj -f ${KERNCACHE} -C ${TEMP} /bin/tar -xj -f ${KERNCACHE} -C ${TEMP}
if [ -e ${TEMP}/config-${ARCH}-${KV} -a -e ${KERNEL_CONFIG} ] if [ -e ${TEMP}/config-${ARCH}-${KV} -a -e ${KERNEL_CONFIG} ]
then then
if [ -e ${TEMP}/config-${ARCH}-${KV}.orig ] if [ -e ${TEMP}/config-${ARCH}-${KV}.orig ]
then then
test1=$(grep -v "^#" ${TEMP}/config-${ARCH}-${KV}.orig | md5sum | cut -d " " -f 1) test1=$(grep -v "^#" ${TEMP}/config-${ARCH}-${KV}.orig | md5sum | cut -d " " -f 1)
else else
test1=$(grep -v "^#" ${TEMP}/config-${ARCH}-${KV} | md5sum | cut -d " " -f 1) test1=$(grep -v "^#" ${TEMP}/config-${ARCH}-${KV} | md5sum | cut -d " " -f 1)
fi fi
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
local CONFGREP=zgrep local CONFGREP=zgrep
else else
local CONFGREP=grep local CONFGREP=grep
fi fi
test2=$("${CONFGREP}" -v "^#" ${KERNEL_CONFIG} | md5sum | cut -d " " -f 1) test2=$("${CONFGREP}" -v "^#" ${KERNEL_CONFIG} | md5sum | cut -d " " -f 1)
if [ "${test1}" == "${test2}" ] if [ "${test1}" == "${test2}" ]
then then
echo echo
print_info 1 "No kernel configuration change, skipping kernel build..." print_info 1 "No kernel configuration change, skipping kernel build..."
echo echo
KERNCACHE_IS_VALID=1 KERNCACHE_IS_VALID=1
fi fi
fi fi
fi fi
fi fi
export KERNCACHE_IS_VALID export KERNCACHE_IS_VALID
return 1 return 1
} }

@ -16,11 +16,11 @@ small_die() {
} }
parse_opt() { parse_opt() {
case "$1" in case "$1" in
*\=*) *\=*)
echo "$1" | cut -f2- -d= echo "$1" | cut -f2- -d=
;; ;;
esac esac
} }
# We don't know where our config is, so we check for it, and default to using # We don't know where our config is, so we check for it, and default to using
@ -28,8 +28,8 @@ parse_opt() {
# NOTE: We are look for --config=... in a way that doesn't modify $@ since we access that again, later # NOTE: We are look for --config=... in a way that doesn't modify $@ since we access that again, later
for (( i=1; i<=$# ; i=i+1 )); do for (( i=1; i<=$# ; i=i+1 )); do
eval arg="\$$i" eval arg="\$$i"
[[ "${arg}" = --config=* ]] && CMD_GK_CONFIG=`parse_opt "${arg}"` [[ "${arg}" = --config=* ]] && CMD_GK_CONFIG=`parse_opt "${arg}"`
done done
# Pull in our configuration # Pull in our configuration
@ -52,27 +52,27 @@ source ${GK_SHARE}/gen_bootloader.sh || gen_die "Could not read ${GK_SHARE}/gen_
TEMP=${TMPDIR}/$RANDOM.$RANDOM.$RANDOM.$$ TEMP=${TMPDIR}/$RANDOM.$RANDOM.$RANDOM.$$
trap_cleanup(){ trap_cleanup(){
# Call exit code of 1 for failure # Call exit code of 1 for failure
cleanup cleanup
exit 1 exit 1
} }
cleanup(){ cleanup(){
if [ -n "$TEMP" -a -d "$TEMP" ]; then if [ -n "$TEMP" -a -d "$TEMP" ]; then
rm -rf "$TEMP" rm -rf "$TEMP"
fi fi
if isTrue ${POSTCLEAR} if isTrue ${POSTCLEAR}
then then
echo echo
print_info 1 'RUNNING FINAL CACHE/TMP CLEANUP' print_info 1 'RUNNING FINAL CACHE/TMP CLEANUP'
print_info 1 "CACHE_DIR: ${CACHE_DIR}" print_info 1 "CACHE_DIR: ${CACHE_DIR}"
CLEAR_CACHE_DIR='yes' CLEAR_CACHE_DIR='yes'
setup_cache_dir setup_cache_dir
echo echo
print_info 1 "TMPDIR: ${TMPDIR}" print_info 1 "TMPDIR: ${TMPDIR}"
clear_tmpdir clear_tmpdir
fi fi
} }
trap trap_cleanup SIGHUP SIGQUIT SIGINT SIGTERM SIGKILL trap trap_cleanup SIGHUP SIGQUIT SIGINT SIGTERM SIGKILL
@ -84,15 +84,15 @@ BUILD_MODULES=0
Options=$* # Save for later Options=$* # Save for later
while [ $# -gt 0 ] while [ $# -gt 0 ]
do do
Option=$1; shift Option=$1; shift
parse_cmdline $Option parse_cmdline $Option
done done
# Check if no action is specified... # Check if no action is specified...
if [ "${BUILD_KERNEL}" = '0' -a "${BUILD_RAMDISK}" = '0' ] if [ "${BUILD_KERNEL}" = '0' -a "${BUILD_RAMDISK}" = '0' ]
then then
usage usage
exit 1 exit 1
fi fi
clear_log clear_log
@ -114,10 +114,10 @@ echo
# Merge modules_load from config # Merge modules_load from config
for group_modules in ${!AMODULES_*}; do for group_modules in ${!AMODULES_*}; do
group="$(echo $group_modules | cut -d_ -f2)" group="$(echo $group_modules | cut -d_ -f2)"
eval cmodules="\$$group_modules" eval cmodules="\$$group_modules"
eval MODULES_${group}=\"\${MODULES_${group}} ${cmodules}\" eval MODULES_${group}=\"\${MODULES_${group}} ${cmodules}\"
print_info 1 "<config> Merged AMODULES_${group}:'${cmodules}' into MODULES_${group}" print_info 1 "<config> Merged AMODULES_${group}:'${cmodules}' into MODULES_${group}"
done done
@ -143,65 +143,65 @@ print_info 1 ".. with config file ${KERNEL_CONFIG}"
# Check BOOTDIR is mounted # Check BOOTDIR is mounted
if ! isTrue ${CMD_INSTALL} if ! isTrue ${CMD_INSTALL}
then then
isTrue ${MOUNTBOOT} && print_info 2 'Skipping automatic mount of boot' isTrue ${MOUNTBOOT} && print_info 2 'Skipping automatic mount of boot'
else else
[[ -d ${BOOTDIR} ]] || gen_die "${BOOTDIR} is not a directory" [[ -d ${BOOTDIR} ]] || gen_die "${BOOTDIR} is not a directory"
if ! egrep -q "[[:space:]]${BOOTDIR}[[:space:]]" /proc/mounts if ! egrep -q "[[:space:]]${BOOTDIR}[[:space:]]" /proc/mounts
then then
if egrep -q "^[^#].+[[:space:]]${BOOTDIR}[[:space:]]" /etc/fstab if egrep -q "^[^#].+[[:space:]]${BOOTDIR}[[:space:]]" /etc/fstab
then then
if isTrue ${MOUNTBOOT} if isTrue ${MOUNTBOOT}
then then
if ! mount ${BOOTDIR} if ! mount ${BOOTDIR}
then then
print_warning 1 "${BOLD}WARNING${NORMAL}: Failed to mount ${BOOTDIR}!" print_warning 1 "${BOLD}WARNING${NORMAL}: Failed to mount ${BOOTDIR}!"
echo echo
else else
print_info 1 "mount: ${BOOTDIR} mounted successfully!" print_info 1 "mount: ${BOOTDIR} mounted successfully!"
fi fi
else else
print_warning 1 "${BOLD}WARNING${NORMAL}: No mounted ${BOOTDIR} partition detected!" print_warning 1 "${BOLD}WARNING${NORMAL}: No mounted ${BOOTDIR} partition detected!"
print_warning 1 " Run ``mount ${BOOTDIR}`` to mount it!" print_warning 1 " Run ``mount ${BOOTDIR}`` to mount it!"
echo echo
fi fi
fi fi
elif isBootRO elif isBootRO
then then
if isTrue ${MOUNTBOOT} if isTrue ${MOUNTBOOT}
then then
if ! mount -o remount,rw ${BOOTDIR} if ! mount -o remount,rw ${BOOTDIR}
then then
print_warning 1 "${BOLD}WARNING${NORMAL}: Failed to remount ${BOOTDIR} RW!" print_warning 1 "${BOLD}WARNING${NORMAL}: Failed to remount ${BOOTDIR} RW!"
echo echo
else else
print_info 1 "mount: ${BOOTDIR} remounted read/write successfully!" print_info 1 "mount: ${BOOTDIR} remounted read/write successfully!"
BOOTRW=1 BOOTRW=1
fi fi
fi fi
fi fi
fi fi
## Check whether another Genkernel is running ## Check whether another Genkernel is running
#GENPIDS="`ps -C genkernel --no-headers -o pid | wc -l`" #GENPIDS="`ps -C genkernel --no-headers -o pid | wc -l`"
#if [ "${GENPIDS}" -gt '3' ] #if [ "${GENPIDS}" -gt '3' ]
#then #then
# [ "${GENPIDS}" -gt '4' ] && EX='s' # [ "${GENPIDS}" -gt '4' ] && EX='s'
# print_warning 1 "${BOLD}WARNING${NORMAL}: Another Genkernel instance is running under" # print_warning 1 "${BOLD}WARNING${NORMAL}: Another Genkernel instance is running under"
# print_warning 1 " process ID${EX} " 0 # print_warning 1 " process ID${EX} " 0
# GENPIDS=`ps -C genkernel --no-headers -o pid` # GENPIDS=`ps -C genkernel --no-headers -o pid`
# echo -n "${GENPIDS}" | sed -e "s/$$//; s/ /, /g" # echo -n "${GENPIDS}" | sed -e "s/$$//; s/ /, /g"
# echo 'halting...' # echo 'halting...'
# echo # echo
# print_warning 1 'Running multiple genkernels on the same source tree will cause data loss!' # print_warning 1 'Running multiple genkernels on the same source tree will cause data loss!'
# print_info 1 "Press ^C to halt; ^D to continue [ ${BOLD}if${NORMAL} you know what you're doing! ]" # print_info 1 "Press ^C to halt; ^D to continue [ ${BOLD}if${NORMAL} you know what you're doing! ]"
# echo # echo
# CTEMP="${TEMP}" # CTEMP="${TEMP}"
# TEMP=${TMPDIR-/tmp} # TEMP=${TMPDIR-/tmp}
# TEMP=${TEMP}/genkernel.$RANDOM.$RANDOM.$RANDOM.$$ # TEMP=${TEMP}/genkernel.$RANDOM.$RANDOM.$RANDOM.$$
# print_info 1 'thread: Running multiple genkernels may cause problems!' # print_info 1 'thread: Running multiple genkernels may cause problems!'
# print_info 1 "thread: Temporary files reallocated to ${TEMP}..." # print_info 1 "thread: Temporary files reallocated to ${TEMP}..."
# echo # echo
#fi #fi
KERNCACHE_IS_VALID=0 KERNCACHE_IS_VALID=0
@ -212,101 +212,101 @@ fi
if [ ${BUILD_KERNEL} = '1' -a "${KERNCACHE_IS_VALID}" = '0' ] if [ ${BUILD_KERNEL} = '1' -a "${KERNCACHE_IS_VALID}" = '0' ]
then then
# Configure kernel # Configure kernel
config_kernel config_kernel
# Make prepare # Make prepare
if [ "${ARCH_HAVENOPREPARE}" = '' ] if [ "${ARCH_HAVENOPREPARE}" = '' ]
then then
compile_generic prepare kernel compile_generic prepare kernel
fi fi
# KV may have changed due to the configuration # KV may have changed due to the configuration
get_KV get_KV
compile_kernel compile_kernel
# Compile modules # Compile modules
if [ "${BUILD_MODULES}" = '1' -a "${BUILD_STATIC}" = '0' ] if [ "${BUILD_MODULES}" = '1' -a "${BUILD_STATIC}" = '0' ]
then then
compile_modules compile_modules
fi fi
if [ "${SAVE_CONFIG}" = '1' ] if [ "${SAVE_CONFIG}" = '1' ]
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_OUTPUTDIR}/.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." print_warning "Unable to copy the kernel configuration file."
# Just a warning because ordinary users are not allowed to write in /etc # Just a warning because ordinary users are not allowed to write in /etc
fi fi
fi fi
if isTrue "${CMD_INSTALL}" if isTrue "${CMD_INSTALL}"
then then
if [ "${KERNCACHE}" != "" -a "${KERNCACHE_IS_VALID}" != "0" ] if [ "${KERNCACHE}" != "" -a "${KERNCACHE_IS_VALID}" != "0" ]
then then
gen_kerncache_extract_kernel gen_kerncache_extract_kernel
fi fi
fi fi
if [ "${KERNCACHE}" != "" -a "${KERNCACHE_IS_VALID}" != "0" ] if [ "${KERNCACHE}" != "" -a "${KERNCACHE_IS_VALID}" != "0" ]
then then
[ "${BUILD_STATIC}" = '0' ] && gen_kerncache_extract_modules [ "${BUILD_STATIC}" = '0' ] && gen_kerncache_extract_modules
gen_kerncache_extract_config gen_kerncache_extract_config
fi fi
# Run callback # Run callback
if [ "${CMD_CALLBACK}" != "" ] if [ "${CMD_CALLBACK}" != "" ]
then then
print_info 1 "" 1 0 print_info 1 "" 1 0
print_info 1 "Preparing to run callback: \"${CMD_CALLBACK}\"" 0 print_info 1 "Preparing to run callback: \"${CMD_CALLBACK}\"" 0
CALLBACK_ESCAPE=0 CALLBACK_ESCAPE=0
CALLBACK_COUNT=0 CALLBACK_COUNT=0
trap "CALLBACK_ESCAPE=1" TERM KILL INT QUIT ABRT trap "CALLBACK_ESCAPE=1" TERM KILL INT QUIT ABRT
while [[ "${CALLBACK_ESCAPE}" = '0' && ${CALLBACK_COUNT} -lt 5 ]] while [[ "${CALLBACK_ESCAPE}" = '0' && ${CALLBACK_COUNT} -lt 5 ]]
do do
sleep 1; echo -n '.'; sleep 1; echo -n '.';
let CALLBACK_COUNT=${CALLBACK_COUNT}+1 let CALLBACK_COUNT=${CALLBACK_COUNT}+1
done done
if [ "${CALLBACK_ESCAPE}" = '0' ] if [ "${CALLBACK_ESCAPE}" = '0' ]
then then
echo echo
echo echo
eval ${CMD_CALLBACK} | tee -a ${LOGFILE} eval ${CMD_CALLBACK} | tee -a ${LOGFILE}
CMD_STATUS="${PIPESTATUS[0]}" CMD_STATUS="${PIPESTATUS[0]}"
echo echo
print_info 1 "<<< Callback exit status: ${CMD_STATUS}" print_info 1 "<<< Callback exit status: ${CMD_STATUS}"
[ "${CMD_STATUS}" != '0' ] && gen_die '--callback failed!' [ "${CMD_STATUS}" != '0' ] && gen_die '--callback failed!'
else else
echo echo
print_info 1 ">>> Callback cancelled..." print_info 1 ">>> Callback cancelled..."
fi fi
trap - TERM KILL INT QUIT ABRT trap - TERM KILL INT QUIT ABRT
print_info 1 "" 1 0 print_info 1 "" 1 0
fi fi
if [ "${BUILD_RAMDISK}" = '1' ] if [ "${BUILD_RAMDISK}" = '1' ]
then then
if [ "${BUSYBOX}" = '1' ] if [ "${BUSYBOX}" = '1' ]
then then
# Compile Busybox # Compile Busybox
compile_busybox compile_busybox
fi fi
# Compile initramfs # Compile initramfs
create_initramfs create_initramfs
else else
print_info 1 'initrd: Not building since only the kernel was requested...' print_info 1 'initrd: Not building since only the kernel was requested...'
fi fi
if isTrue "${INTEGRATED_INITRAMFS}" #|| [ "${BUILD_KERNEL}" = '1' -a "${KERNCACHE_IS_VALID}" == "0" ] if isTrue "${INTEGRATED_INITRAMFS}" #|| [ "${BUILD_KERNEL}" = '1' -a "${KERNCACHE_IS_VALID}" == "0" ]
then then
# We build the kernel a second time to include the initramfs # We build the kernel a second time to include the initramfs
compile_kernel compile_kernel
fi fi
[ "${KERNCACHE}" != "" ] && gen_kerncache [ "${KERNCACHE}" != "" ] && gen_kerncache
@ -318,58 +318,58 @@ fi
if [ "${BUILD_KERNEL}" = '1' ] if [ "${BUILD_KERNEL}" = '1' ]
then then
if isTrue "${CMD_INSTALL}" if isTrue "${CMD_INSTALL}"
then then
set_bootloader set_bootloader
fi fi
print_info 1 '' print_info 1 ''
print_info 1 "Kernel compiled successfully!" print_info 1 "Kernel compiled successfully!"
print_info 1 '' print_info 1 ''
print_info 1 'Required Kernel Parameters:' print_info 1 'Required Kernel Parameters:'
print_info 1 ' root=/dev/$ROOT' print_info 1 ' root=/dev/$ROOT'
if [ "${BUILD_RAMDISK}" = '0' ] if [ "${BUILD_RAMDISK}" = '0' ]
then then
print_info 1 ' [ And "vga=0x317 splash=verbose" if you use a framebuffer ]' print_info 1 ' [ And "vga=0x317 splash=verbose" if you use a framebuffer ]'
print_info 1 '' print_info 1 ''
print_info 1 ' Where $ROOT is the device node for your root partition as the' print_info 1 ' Where $ROOT is the device node for your root partition as the'
print_info 1 ' one specified in /etc/fstab' print_info 1 ' one specified in /etc/fstab'
else else
print_info 1 '' print_info 1 ''
print_info 1 ' Where $ROOT is the device node for your root partition as the' print_info 1 ' Where $ROOT is the device node for your root partition as the'
print_info 1 ' one specified in /etc/fstab' print_info 1 ' one specified in /etc/fstab'
print_info 1 '' print_info 1 ''
print_info 1 "If you require Genkernel's hardware detection features; you MUST" print_info 1 "If you require Genkernel's hardware detection features; you MUST"
print_info 1 'tell your bootloader to use the provided INITRAMFS file.' print_info 1 'tell your bootloader to use the provided INITRAMFS file.'
fi fi
fi fi
if [ "${BUILD_RAMDISK}" = '1' ] if [ "${BUILD_RAMDISK}" = '1' ]
then then
echo echo
print_warning 1 'WARNING... WARNING... WARNING...' print_warning 1 'WARNING... WARNING... WARNING...'
print_warning 1 'Additional kernel cmdline arguments that *may* be required to boot properly...' print_warning 1 'Additional kernel cmdline arguments that *may* be required to boot properly...'
[ "${SPLASH}" = '1' ] && print_warning 1 "add \"vga=791 splash=silent,theme:${SPLASH_THEME} console=tty1 quiet\" if you use a splash framebuffer ]" [ "${SPLASH}" = '1' ] && print_warning 1 "add \"vga=791 splash=silent,theme:${SPLASH_THEME} console=tty1 quiet\" if you use a splash framebuffer ]"
[ "${LVM}" = '1' ] && print_warning 1 'add "dolvm" for lvm support' [ "${LVM}" = '1' ] && print_warning 1 'add "dolvm" for lvm support'
[ "${DMRAID}" = '1' ] && print_warning 1 'add "dodmraid" for dmraid support' [ "${DMRAID}" = '1' ] && print_warning 1 'add "dodmraid" for dmraid support'
[ "${MDADM}" = '1' ] && print_warning 1 'add "domdadm" for RAID support' [ "${MDADM}" = '1' ] && print_warning 1 'add "domdadm" for RAID support'
[ "${DMRAID}" = '1' ] && print_warning 1 ' or "dodmraid=<additional options>"' [ "${DMRAID}" = '1' ] && print_warning 1 ' or "dodmraid=<additional options>"'
[ "${ZFS}" = '1' ] && print_warning 1 'add "dozfs" for ZFS volume management support' [ "${ZFS}" = '1' ] && print_warning 1 'add "dozfs" for ZFS volume management support'
[ "${ZFS}" = '1' ] && print_warning 1 ' and either "root=ZFS" to use bootfs autodetection or "root=ZFS=<dataset>" to force booting from a specific dataset' [ "${ZFS}" = '1' ] && print_warning 1 ' and either "root=ZFS" to use bootfs autodetection or "root=ZFS=<dataset>" to force booting from a specific dataset'
[ "${ISCSI}" = '1' ] && print_warning 1 'add at least "iscsi_initiatorname=<initiator name> iscsi_target=<target name> and iscsi_address=<target ip>" for iscsi support' [ "${ISCSI}" = '1' ] && print_warning 1 'add at least "iscsi_initiatorname=<initiator name> iscsi_target=<target name> and iscsi_address=<target ip>" for iscsi support'
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
CONFGREP=zgrep CONFGREP=zgrep
else else
CONFGREP=grep CONFGREP=grep
fi fi
if [ `${CONFGREP} 'CONFIG_EXT[0-9]_FS=' "${KERNEL_CONFIG}" | wc -l` -ge 2 ]; then if [ `${CONFGREP} 'CONFIG_EXT[0-9]_FS=' "${KERNEL_CONFIG}" | wc -l` -ge 2 ]; then
print_warning 1 'With support for several ext* filesystems available, it may be needed to' print_warning 1 'With support for several ext* filesystems available, it may be needed to'
print_warning 1 'add "rootfstype=ext3" or "rootfstype=ext4" to the list of boot parameters.' print_warning 1 'add "rootfstype=ext3" or "rootfstype=ext4" to the list of boot parameters.'
fi fi
unset CONFGREP unset CONFGREP
fi fi
[ "${BOOTRW}" != '' ] && mount -o remount,ro ${BOOTDIR} [ "${BOOTRW}" != '' ] && mount -o remount,ro ${BOOTDIR}

@ -13,7 +13,7 @@ _genkernel()
# extract initial list of params/actions from genkernel --help # extract initial list of params/actions from genkernel --help
genkernel_help=$(command genkernel --help) genkernel_help=$(command genkernel --help)
actions=( $(<<<"$genkernel_help" sed -n \ actions=( $(<<<"$genkernel_help" sed -n \
'/^Available Actions:/,/^$/s/^[[:space:]]\+\([^[:space:]]\+\).*/\1/p') ) '/^Available Actions:/,/^$/s/^[[:space:]]\+\([^[:space:]]\+\).*/\1/p') )
params=( $(<<<"$genkernel_help" egrep -oe '--[^[:space:]]{2,}') ) params=( $(<<<"$genkernel_help" egrep -oe '--[^[:space:]]{2,}') )
# attempt to complete the current parameter based on the list # attempt to complete the current parameter based on the list
@ -21,22 +21,22 @@ _genkernel()
# if we don't have a rhs to complete # if we don't have a rhs to complete
if [[ ${#COMPREPLY[@]} -gt 1 ]]; then if [[ ${#COMPREPLY[@]} -gt 1 ]]; then
return return
elif [[ ${#COMPREPLY[@]} -eq 0 && $cur != --*=* ]]; then elif [[ ${#COMPREPLY[@]} -eq 0 && $cur != --*=* ]]; then
return return
elif [[ ${#COMPREPLY[@]} -eq 1 && $COMPREPLY != --*= ]]; then elif [[ ${#COMPREPLY[@]} -eq 1 && $COMPREPLY != --*= ]]; then
# using nospace completion, add an explicit space # using nospace completion, add an explicit space
COMPREPLY="${COMPREPLY} " COMPREPLY="${COMPREPLY} "
return return
fi fi
# we have a unique lhs and need to complete the rhs # we have a unique lhs and need to complete the rhs
declare args lhs rhs declare args lhs rhs
if [[ ${#COMPREPLY[@]} -eq 1 ]]; then if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
lhs=$COMPREPLY lhs=$COMPREPLY
else else
lhs=${cur%%=*}= lhs=${cur%%=*}=
rhs=${cur#*=} rhs=${cur#*=}
fi fi
# genkernel's help gives clues as to what belongs on the rhs. # genkernel's help gives clues as to what belongs on the rhs.
@ -48,25 +48,25 @@ _genkernel()
# generate a list of completions for the argument; this replaces args with # generate a list of completions for the argument; this replaces args with
# an array of results # an array of results
args=( $(case $args in args=( $(case $args in
('<0-5>') compgen -W "$(echo {1..5})" -- "$rhs" ;; ('<0-5>') compgen -W "$(echo {1..5})" -- "$rhs" ;;
('<outfile>'|'<file>') compgen -A file -o plusdirs -- "$rhs" ;; ('<outfile>'|'<file>') compgen -A file -o plusdirs -- "$rhs" ;;
('<dir>') compgen -A directory -S / -- "$rhs" ;; ('<dir>') compgen -A directory -S / -- "$rhs" ;;
('<tbz2>') compgen -G '*.tbz2' -G '*.tar.bz2' -o plusdirs -- "$rhs" ;; ('<tbz2>') compgen -G '*.tbz2' -G '*.tar.bz2' -o plusdirs -- "$rhs" ;;
(*) compgen -o bashdefault -- "$rhs" ;; # punt (*) compgen -o bashdefault -- "$rhs" ;; # punt
esac) ) esac) )
# we're using nospace completion to prevent spaces after paths that aren't # we're using nospace completion to prevent spaces after paths that aren't
# "done" yet. So do some hacking to the args to add spaces after # "done" yet. So do some hacking to the args to add spaces after
# non-directories. # non-directories.
declare slash=/ declare slash=/
args=( "${args[@]/%/ }" ) # add space to all args=( "${args[@]/%/ }" ) # add space to all
args=( "${args[@]/%$slash /$slash}" ) # remove space from dirs args=( "${args[@]/%$slash /$slash}" ) # remove space from dirs
# recreate COMPREPLY # recreate COMPREPLY
if [[ $cur == "$lhs"* ]]; then if [[ $cur == "$lhs"* ]]; then
COMPREPLY=( "${args[@]}" ) COMPREPLY=( "${args[@]}" )
elif [[ ${#args[@]} -gt 0 ]]; then elif [[ ${#args[@]} -gt 0 ]]; then
COMPREPLY=( "${args[@]/#/$lhs}" ) COMPREPLY=( "${args[@]/#/$lhs}" )
fi fi
} }

@ -10,18 +10,18 @@ import os
NON_VARIABLES = ('UTF', 'USE', 'TCP', 'SMP', 'PXE', 'PPC', 'MAC', NON_VARIABLES = ('UTF', 'USE', 'TCP', 'SMP', 'PXE', 'PPC', 'MAC',
'GTK', 'GNU', 'CPU', 'DOS', 'NIC', 'NFS', 'ISO', 'TIMEOUT', 'GTK', 'GNU', 'CPU', 'DOS', 'NIC', 'NFS', 'ISO', 'TIMEOUT',
'TFTP', 'SYSTEM', 'SPARC', 'RAID', 'LABEL', 'PROMPT', 'KERNEL', 'TFTP', 'SYSTEM', 'SPARC', 'RAID', 'LABEL', 'PROMPT', 'KERNEL',
'GRP', 'DOCTYPE', 'DHCP', 'DEFAULT', 'ATARAID', 'APPEND') 'GRP', 'DOCTYPE', 'DHCP', 'DEFAULT', 'ATARAID', 'APPEND')
NON_CONFIG_VARIABLES = ('BUILD_KERNEL', 'BUILD_MODULES', 'BUILD_RAMDISK', NON_CONFIG_VARIABLES = ('BUILD_KERNEL', 'BUILD_MODULES', 'BUILD_RAMDISK',
'TERM_COLUMNS', 'TERM_LINES', 'SPLASH_RES', 'TEMP') 'TERM_COLUMNS', 'TERM_LINES', 'SPLASH_RES', 'TEMP')
EXTRA_VARIABLES = ['ARCH_OVERRIDE', 'BOOTLOADER', 'CLEAR_CACHE_DIR', 'DEFAULT_KERNEL_SOURCE', 'DISTDIR', 'GK_SHARE', 'BUSYBOX_APPLETS'] EXTRA_VARIABLES = ['ARCH_OVERRIDE', 'BOOTLOADER', 'CLEAR_CACHE_DIR', 'DEFAULT_KERNEL_SOURCE', 'DISTDIR', 'GK_SHARE', 'BUSYBOX_APPLETS']
for app in ('DEVICE_MAPPER', 'BUSYBOX', 'DMRAID', 'LVM', 'ISCSI', 'GPG', 'MDADM'): for app in ('DEVICE_MAPPER', 'BUSYBOX', 'DMRAID', 'LVM', 'ISCSI', 'GPG', 'MDADM'):
for prop in ('DIR', 'SRCTAR', 'VER'): for prop in ('DIR', 'SRCTAR', 'VER'):
EXTRA_VARIABLES.append('%s_%s' % (app, prop)) EXTRA_VARIABLES.append('%s_%s' % (app, prop))
EXTRA_VARIABLES = tuple(EXTRA_VARIABLES) EXTRA_VARIABLES = tuple(EXTRA_VARIABLES)
IGNORE_OPTIONS = ('help', 'version') IGNORE_OPTIONS = ('help', 'version')
@ -31,265 +31,265 @@ DEPRECATED_PARAMETERS = ('lvm2', 'gensplash', 'gensplash-res')
def exract_gen_cmdline_sh(): def exract_gen_cmdline_sh():
f = open('gen_cmdline.sh', 'r') f = open('gen_cmdline.sh', 'r')
gen_cmdline_sh = f.read() gen_cmdline_sh = f.read()
f.close() f.close()
usage_lines = list() usage_lines = list()
parsing_lines = list() parsing_lines = list()
dest = None dest = None
for line in gen_cmdline_sh.split('\n'): for line in gen_cmdline_sh.split('\n'):
if line in ('longusage() {', 'usage() {'): if line in ('longusage() {', 'usage() {'):
dest = usage_lines dest = usage_lines
elif line == 'parse_cmdline() {': elif line == 'parse_cmdline() {':
dest = parsing_lines dest = parsing_lines
if dest is not None: if dest is not None:
dest.append(line) dest.append(line)
if line == '}': if line == '}':
dest = None dest = None
del gen_cmdline_sh del gen_cmdline_sh
parsing_code = '\n'.join(parsing_lines) parsing_code = '\n'.join(parsing_lines)
del parsing_lines del parsing_lines
gen_cmdline_sh_parsing_long_params = set() gen_cmdline_sh_parsing_long_params = set()
for match in re.finditer('--([a-z][a-z0-9-]+)', parsing_code): for match in re.finditer('--([a-z][a-z0-9-]+)', parsing_code):
para_name = match.group(1) para_name = match.group(1)
if para_name in IGNORE_OPTIONS: if para_name in IGNORE_OPTIONS:
continue continue
if para_name in DEPRECATED_PARAMETERS: if para_name in DEPRECATED_PARAMETERS:
continue continue
gen_cmdline_sh_parsing_long_params.add(para_name) gen_cmdline_sh_parsing_long_params.add(para_name)
gen_cmdline_sh_variables = set() gen_cmdline_sh_variables = set()
for match in re.finditer('^\s*([A-Z_]+)=', parsing_code, re.MULTILINE): for match in re.finditer('^\s*([A-Z_]+)=', parsing_code, re.MULTILINE):
var_name = match.group(1) var_name = match.group(1)
if var_name.startswith('CMD_'): if var_name.startswith('CMD_'):
continue continue
if var_name in NON_CONFIG_VARIABLES: if var_name in NON_CONFIG_VARIABLES:
continue continue
gen_cmdline_sh_variables.add(var_name) gen_cmdline_sh_variables.add(var_name)
del parsing_code del parsing_code
gen_cmdline_sh_usage_long_params = set() gen_cmdline_sh_usage_long_params = set()
for match in re.finditer('--([a-z][a-z0-9-]+)', '\n'.join(usage_lines)): for match in re.finditer('--([a-z][a-z0-9-]+)', '\n'.join(usage_lines)):
para_name = match.group(1) para_name = match.group(1)
if para_name in IGNORE_OPTIONS: if para_name in IGNORE_OPTIONS:
continue continue
gen_cmdline_sh_usage_long_params.add(para_name) gen_cmdline_sh_usage_long_params.add(para_name)
del usage_lines del usage_lines
return gen_cmdline_sh_parsing_long_params, gen_cmdline_sh_usage_long_params, gen_cmdline_sh_variables return gen_cmdline_sh_parsing_long_params, gen_cmdline_sh_usage_long_params, gen_cmdline_sh_variables
def extract_genkernel_8_txt(): def extract_genkernel_8_txt():
f = open(os.path.join('doc', 'genkernel.8.txt'), 'r') f = open(os.path.join('doc', 'genkernel.8.txt'), 'r')
genkernel_8_txt = f.read() genkernel_8_txt = f.read()
f.close() f.close()
# Preprocess # Preprocess
genkernel_8_txt = genkernel_8_txt.replace('*[*no-*]*','[no-]') genkernel_8_txt = genkernel_8_txt.replace('*[*no-*]*','[no-]')
yes_no = re.compile('^\\[(no-)\\]([a-z0-9-]+)$') yes_no = re.compile('^\\[(no-)\\]([a-z0-9-]+)$')
genkernel_8_txt_long_params = set() genkernel_8_txt_long_params = set()
for match in re.finditer('--((?:[a-z]|\\[no-\\])[a-z0-9-]+)', genkernel_8_txt): for match in re.finditer('--((?:[a-z]|\\[no-\\])[a-z0-9-]+)', genkernel_8_txt):
para_name = match.group(1) para_name = match.group(1)
# Black list # Black list
if para_name == 'no-': if para_name == 'no-':
continue continue
if para_name in IGNORE_PARAMETERS: if para_name in IGNORE_PARAMETERS:
continue continue
m = yes_no.match(para_name) m = yes_no.match(para_name)
if m: if m:
p_yes = m.group(2) p_yes = m.group(2)
p_no = m.group(1) + m.group(2) p_no = m.group(1) + m.group(2)
genkernel_8_txt_long_params.add(p_yes) genkernel_8_txt_long_params.add(p_yes)
genkernel_8_txt_long_params.add(p_no) genkernel_8_txt_long_params.add(p_no)
else: else:
genkernel_8_txt_long_params.add(para_name) genkernel_8_txt_long_params.add(para_name)
del genkernel_8_txt del genkernel_8_txt
return genkernel_8_txt_long_params return genkernel_8_txt_long_params
def extract_genkernel_xml(genkernel_xml_path, variables_blacklist): def extract_genkernel_xml(genkernel_xml_path, variables_blacklist):
f = open(genkernel_xml_path, 'r') f = open(genkernel_xml_path, 'r')
genkernel_xml = f.read() genkernel_xml = f.read()
f.close() f.close()
# Preprocess # Preprocess
genkernel_xml = genkernel_xml.replace('<c>','').replace('</c>','').replace('<b>','').replace('</b>','') genkernel_xml = genkernel_xml.replace('<c>','').replace('</c>','').replace('<b>','').replace('</b>','')
yes_no = re.compile('^(no-)([a-z0-9-]+)$') yes_no = re.compile('^(no-)([a-z0-9-]+)$')
genkernel_xml_long_params = set() genkernel_xml_long_params = set()
for match in re.finditer('--([a-z][a-z0-9-]+)', genkernel_xml): for match in re.finditer('--([a-z][a-z0-9-]+)', genkernel_xml):
para_name = match.group(1) para_name = match.group(1)
if para_name in IGNORE_OPTIONS: if para_name in IGNORE_OPTIONS:
continue continue
# Fix doc error "--no install" # Fix doc error "--no install"
if para_name == 'no': if para_name == 'no':
para_name = 'no-install' para_name = 'no-install'
m = yes_no.match(para_name) m = yes_no.match(para_name)
if m and para_name != 'no-ramdisk-modules': if m and para_name != 'no-ramdisk-modules':
p_yes = m.group(2) p_yes = m.group(2)
p_no = m.group(1) + m.group(2) p_no = m.group(1) + m.group(2)
genkernel_xml_long_params.add(p_yes) genkernel_xml_long_params.add(p_yes)
genkernel_xml_long_params.add(p_no) genkernel_xml_long_params.add(p_no)
else: else:
genkernel_xml_long_params.add(para_name) genkernel_xml_long_params.add(para_name)
genkernel_xml_variables = set() genkernel_xml_variables = set()
for match in re.finditer('[A-Z_]{3,}', genkernel_xml): for match in re.finditer('[A-Z_]{3,}', genkernel_xml):
var_name = match.group(0) var_name = match.group(0)
if var_name in variables_blacklist: if var_name in variables_blacklist:
continue continue
genkernel_xml_variables.add(var_name) genkernel_xml_variables.add(var_name)
del genkernel_xml del genkernel_xml
return genkernel_xml_long_params, genkernel_xml_variables return genkernel_xml_long_params, genkernel_xml_variables
def extract_gen_determineargs_sh(): def extract_gen_determineargs_sh():
f = open('gen_determineargs.sh', 'r') f = open('gen_determineargs.sh', 'r')
gen_determineargs_sh = f.read() gen_determineargs_sh = f.read()
f.close() f.close()
gen_determineargs_sh_variables = set() gen_determineargs_sh_variables = set()
for match in re.finditer('set_config_with_override\s+(?:BOOL|STRING)\s+([A-Z_]+)', gen_determineargs_sh): for match in re.finditer('set_config_with_override\s+(?:BOOL|STRING)\s+([A-Z_]+)', gen_determineargs_sh):
var_name = match.group(1) var_name = match.group(1)
gen_determineargs_sh_variables.add(var_name) gen_determineargs_sh_variables.add(var_name)
for match in re.finditer('([A-Z_]+)=`(?:arch|cache)_replace "\\$\\{\\1\\}"`', gen_determineargs_sh): for match in re.finditer('([A-Z_]+)=`(?:arch|cache)_replace "\\$\\{\\1\\}"`', gen_determineargs_sh):
var_name = match.group(1) var_name = match.group(1)
gen_determineargs_sh_variables.add(var_name) gen_determineargs_sh_variables.add(var_name)
del gen_determineargs_sh del gen_determineargs_sh
return gen_determineargs_sh_variables return gen_determineargs_sh_variables
def extract_genkernel_conf(variables_blacklist): def extract_genkernel_conf(variables_blacklist):
f = open('genkernel.conf', 'r') f = open('genkernel.conf', 'r')
genkernel_conf = f.read() genkernel_conf = f.read()
f.close() f.close()
genkernel_conf_variables = set() genkernel_conf_variables = set()
for match in re.finditer('^#*\\s*([A-Z_]{3,})', genkernel_conf, re.MULTILINE): for match in re.finditer('^#*\\s*([A-Z_]{3,})', genkernel_conf, re.MULTILINE):
var_name = match.group(1) var_name = match.group(1)
if var_name in variables_blacklist: if var_name in variables_blacklist:
continue continue
genkernel_conf_variables.add(var_name) genkernel_conf_variables.add(var_name)
del genkernel_conf del genkernel_conf
return genkernel_conf_variables return genkernel_conf_variables
def print_set(s): def print_set(s):
if s: if s:
print('\n'.join(('- ' + e) for e in sorted(s))) print('\n'.join(('- ' + e) for e in sorted(s)))
else: else:
print(' NONE') print(' NONE')
print() print()
def usage(): def usage():
print('USAGE: %s GENTOO/xml/htdocs/doc/en/genkernel.xml' % os.path.basename(sys.argv[0])) print('USAGE: %s GENTOO/xml/htdocs/doc/en/genkernel.xml' % os.path.basename(sys.argv[0]))
def main(): def main():
if len(sys.argv) != 2: if len(sys.argv) != 2:
usage() usage()
sys.exit(1) sys.exit(1)
gen_cmdline_sh_parsing_long_params, gen_cmdline_sh_usage_long_params, gen_cmdline_sh_variables = exract_gen_cmdline_sh() gen_cmdline_sh_parsing_long_params, gen_cmdline_sh_usage_long_params, gen_cmdline_sh_variables = exract_gen_cmdline_sh()
genkernel_8_txt_long_params = extract_genkernel_8_txt() genkernel_8_txt_long_params = extract_genkernel_8_txt()
gen_determineargs_sh_variables = extract_gen_determineargs_sh() gen_determineargs_sh_variables = extract_gen_determineargs_sh()
variables_blacklist = set(NON_VARIABLES).difference(gen_determineargs_sh_variables) variables_blacklist = set(NON_VARIABLES).difference(gen_determineargs_sh_variables)
known_variales = set(EXTRA_VARIABLES).union(gen_determineargs_sh_variables).union(gen_cmdline_sh_variables) known_variales = set(EXTRA_VARIABLES).union(gen_determineargs_sh_variables).union(gen_cmdline_sh_variables)
genkernel_xml_long_params, genkernel_xml_variables = extract_genkernel_xml(sys.argv[1], variables_blacklist) genkernel_xml_long_params, genkernel_xml_variables = extract_genkernel_xml(sys.argv[1], variables_blacklist)
genkernel_conf_variables = extract_genkernel_conf(variables_blacklist) genkernel_conf_variables = extract_genkernel_conf(variables_blacklist)
# Status quo # Status quo
print('Options used by parser in *gen_cmdline.sh*:') print('Options used by parser in *gen_cmdline.sh*:')
print_set(gen_cmdline_sh_parsing_long_params) print_set(gen_cmdline_sh_parsing_long_params)
print('Options mentioned in usage of *gen_cmdline.sh*:') print('Options mentioned in usage of *gen_cmdline.sh*:')
print_set(gen_cmdline_sh_usage_long_params) print_set(gen_cmdline_sh_usage_long_params)
print('Options mentioned in *man page*:') print('Options mentioned in *man page*:')
print_set(genkernel_8_txt_long_params) print_set(genkernel_8_txt_long_params)
print('Options mentioned in *web page*:') print('Options mentioned in *web page*:')
print_set(genkernel_xml_long_params) print_set(genkernel_xml_long_params)
print('Variables set by *gen_cmdline.sh*:') print('Variables set by *gen_cmdline.sh*:')
print_set(gen_cmdline_sh_variables) print_set(gen_cmdline_sh_variables)
print('Variables read by *gen_determineargs.sh*:') print('Variables read by *gen_determineargs.sh*:')
print_set(gen_determineargs_sh_variables) print_set(gen_determineargs_sh_variables)
print('Variables mentioned in *web page*:') print('Variables mentioned in *web page*:')
print_set(genkernel_xml_variables) print_set(genkernel_xml_variables)
print('Variables used in *genkernel.conf*:') print('Variables used in *genkernel.conf*:')
print_set(genkernel_conf_variables) print_set(genkernel_conf_variables)
# Future work (due extensions) # Future work (due extensions)
print('Variables missing from *web page*:') print('Variables missing from *web page*:')
print_set(known_variales.difference(genkernel_xml_variables)) print_set(known_variales.difference(genkernel_xml_variables))
print('Options missing from *web page*:') print('Options missing from *web page*:')
print_set(gen_cmdline_sh_parsing_long_params.difference(genkernel_xml_long_params)) print_set(gen_cmdline_sh_parsing_long_params.difference(genkernel_xml_long_params))
print('Variables missing from *genkernel.conf*:') print('Variables missing from *genkernel.conf*:')
print_set(known_variales.difference(genkernel_conf_variables)) print_set(known_variales.difference(genkernel_conf_variables))
print('Options missing from the *man page*:') print('Options missing from the *man page*:')
print_set(gen_cmdline_sh_parsing_long_params.difference(genkernel_8_txt_long_params)) print_set(gen_cmdline_sh_parsing_long_params.difference(genkernel_8_txt_long_params))
print('Options missing from *--help*:') print('Options missing from *--help*:')
print_set(gen_cmdline_sh_parsing_long_params.difference(gen_cmdline_sh_usage_long_params)) print_set(gen_cmdline_sh_parsing_long_params.difference(gen_cmdline_sh_usage_long_params))
# Future work (due removal and updates) # Future work (due removal and updates)
print('Removed options still mentioned in the *man page*:') print('Removed options still mentioned in the *man page*:')
print_set(genkernel_8_txt_long_params.difference(gen_cmdline_sh_parsing_long_params)) print_set(genkernel_8_txt_long_params.difference(gen_cmdline_sh_parsing_long_params))
print('Removed options still mentioned in *--help*:') print('Removed options still mentioned in *--help*:')
print_set(gen_cmdline_sh_usage_long_params.difference(gen_cmdline_sh_parsing_long_params)) print_set(gen_cmdline_sh_usage_long_params.difference(gen_cmdline_sh_parsing_long_params))
print('Removed options still mentioned in *web page*:') print('Removed options still mentioned in *web page*:')
print_set(genkernel_xml_long_params.difference(gen_cmdline_sh_parsing_long_params)) print_set(genkernel_xml_long_params.difference(gen_cmdline_sh_parsing_long_params))
print('Removed variables still mentioned in *web page*:') print('Removed variables still mentioned in *web page*:')
print_set(genkernel_xml_variables.difference(known_variales)) print_set(genkernel_xml_variables.difference(known_variales))
print('Removed variables still mentioned in *genkernel.conf*:') print('Removed variables still mentioned in *genkernel.conf*:')
print_set(genkernel_conf_variables.difference(known_variales)) print_set(genkernel_conf_variables.difference(known_variales))
if __name__ == '__main__': if __name__ == '__main__':
main() main()

Loading…
Cancel
Save