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

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

@ -154,8 +154,8 @@ KERNEL COMPILATION
kernel and modules have been compiled.
*--*[*no-*]*static*::
Builds, or does not build a monolithic kernel without any modules on any
initial ramdisks.
Builds, or does not build a monolithic kernel without any modules on any
initial ramdisks.
KERNEL LOCATIONS
@ -256,8 +256,8 @@ INITIALIZATION
the system.
*--*[*no-*]*lvm*::
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.
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.
*--*[*no-*]*mdadm*::
Includes or excludes mdadm/mdmon support.
@ -296,15 +296,15 @@ INITIALIZATION
Specifies a user created busybox config.
*--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*::
Includes or excludes Luks support from static binaries if they exist on
the system.
Includes or excludes Luks support from static binaries if they exist on
the system.
*--*[*no-*]*gpg*::
Includes or excludes support for GnuPG 1.x, the portable standalone branch
of GnuPG. A key can be made from
Includes or excludes support for GnuPG 1.x, the portable standalone branch
of GnuPG. A key can be made from
`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.
@ -331,7 +331,7 @@ INTERNALS
Sets genkernel's temporary working directory to <dir>.
*--*[*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
@ -372,16 +372,16 @@ OUTPUT SETTINGS
For multiple files, separate the filenames with a comma.
*--*[*no-*]*integrated-initramfs*::
Builds or does not build the generated initramfs into the kernel instead
of keeping it as a separate file.
Builds or does not build the generated initramfs into the kernel instead
of keeping it as a separate file.
*--*[*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>::
Compression type for initramfs (best, xz, lzma, bzip2, gzip, lzop).
"Best" causes selection of the best available algorithm that is selected
in your kernel configuration.
Compression type for initramfs (best, xz, lzma, bzip2, gzip, lzop).
"Best" causes selection of the best available algorithm that is selected
in your kernel configuration.
RAMDISK OPTIONS
@ -526,8 +526,8 @@ which the ramdisk scripts would recognize.
*part*[=<0,1>]::
*partitionable*::
Enable/Disable partitionable RAIDs (metadata 0.x) during auto-run.
Standalone *part* and *partitionable* keywords for kernel compatability.
Enable/Disable partitionable RAIDs (metadata 0.x) during auto-run.
Standalone *part* and *partitionable* keywords for kernel compatability.
*iscsi_initiatorname*=<...>::
*iscsi_target*=<...>::

@ -2,93 +2,93 @@
# $Id$
get_official_arch() {
if [ "${CMD_ARCHOVERRIDE}" != '' ]
then
ARCH=${CMD_ARCHOVERRIDE}
else
if [ "${ARCH_OVERRIDE}" != '' ]
then
ARCH=${ARCH_OVERRIDE}
else
ARCH=`uname -m`
case "${ARCH}" in
i?86)
ARCH="x86"
;;
mips|mips64)
ARCH="mips"
;;
arm*)
ARCH=arm
;;
*)
;;
esac
fi
fi
if [ "${CMD_ARCHOVERRIDE}" != '' ]
then
ARCH=${CMD_ARCHOVERRIDE}
else
if [ "${ARCH_OVERRIDE}" != '' ]
then
ARCH=${ARCH_OVERRIDE}
else
ARCH=`uname -m`
case "${ARCH}" in
i?86)
ARCH="x86"
;;
mips|mips64)
ARCH="mips"
;;
arm*)
ARCH=arm
;;
*)
;;
esac
fi
fi
if [ "${CMD_UTILS_ARCH}" != '' ]
then
UTILS_ARCH=${CMD_UTILS_ARCH}
else
if [ "${UTILS_ARCH}" != '' ]
then
UTILS_ARCH=${UTILS_ARCH}
fi
fi
if [ "${CMD_UTILS_ARCH}" != '' ]
then
UTILS_ARCH=${CMD_UTILS_ARCH}
else
if [ "${UTILS_ARCH}" != '' ]
then
UTILS_ARCH=${UTILS_ARCH}
fi
fi
# sparc64 klibc is b0rked, so we force to 32
if [ "${ARCH}" = 'sparc64' ]
then
UTILS_ARCH='sparc'
fi
# sparc64 klibc is b0rked, so we force to 32
if [ "${ARCH}" = 'sparc64' ]
then
UTILS_ARCH='sparc'
fi
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}"
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}"
}
set_kernel_arch() {
KERNEL_ARCH=${ARCH}
case ${ARCH} in
ppc|ppc64)
if [ "${VER}" -ge "3" ]
then
KERNEL_ARCH=powerpc
elif [ "${VER}" -eq "2" -a "${PAT}" -ge "6" ]
then
if [ "${PAT}" -eq "6" -a "${SUB}" -ge "16" ] || [ "${PAT}" -gt "6" ]
then
KERNEL_ARCH=powerpc
fi
fi
;;
x86)
if [ "${VER}" -ge "3" ]
then
KERNEL_ARCH=x86
elif [ "${VER}" -eq "2" -a "${PAT}" -ge "6" ] || [ "${VER}" -gt "2" ]
then
if [ "${PAT}" -eq "6" -a "${SUB}" -ge "24" ] || [ "${PAT}" -gt "6" ]
then
KERNEL_ARCH=x86
else
KERNEL_ARCH=i386
fi
fi
;;
x86_64)
if [ "${VER}" -ge "3" ]
then
KERNEL_ARCH=x86
elif [ "${VER}" -eq "2" -a "${PAT}" -ge "6" ] || [ "${VER}" -gt "2" ]
then
if [ "${PAT}" -eq "6" -a "${SUB}" -ge "24" ] || [ "${PAT}" -gt "6" ]
then
KERNEL_ARCH=x86
fi
fi
;;
esac
export KERNEL_ARCH
print_info 2 "KERNEL_ARCH=${KERNEL_ARCH}"
KERNEL_ARCH=${ARCH}
case ${ARCH} in
ppc|ppc64)
if [ "${VER}" -ge "3" ]
then
KERNEL_ARCH=powerpc
elif [ "${VER}" -eq "2" -a "${PAT}" -ge "6" ]
then
if [ "${PAT}" -eq "6" -a "${SUB}" -ge "16" ] || [ "${PAT}" -gt "6" ]
then
KERNEL_ARCH=powerpc
fi
fi
;;
x86)
if [ "${VER}" -ge "3" ]
then
KERNEL_ARCH=x86
elif [ "${VER}" -eq "2" -a "${PAT}" -ge "6" ] || [ "${VER}" -gt "2" ]
then
if [ "${PAT}" -eq "6" -a "${SUB}" -ge "24" ] || [ "${PAT}" -gt "6" ]
then
KERNEL_ARCH=x86
else
KERNEL_ARCH=i386
fi
fi
;;
x86_64)
if [ "${VER}" -ge "3" ]
then
KERNEL_ARCH=x86
elif [ "${VER}" -eq "2" -a "${PAT}" -ge "6" ] || [ "${VER}" -gt "2" ]
then
if [ "${PAT}" -eq "6" -a "${SUB}" -ge "24" ] || [ "${PAT}" -gt "6" ]
then
KERNEL_ARCH=x86
fi
fi
;;
esac
export KERNEL_ARCH
print_info 2 "KERNEL_ARCH=${KERNEL_ARCH}"
}

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

File diff suppressed because it is too large Load Diff

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

@ -3,106 +3,106 @@
# Fills variable KERNEL_CONFIG
determine_config_file() {
if [ "${CMD_KERNEL_CONFIG}" != "" ]
then
KERNEL_CONFIG="${CMD_KERNEL_CONFIG}"
elif [ -f "/etc/kernels/kernel-config-${ARCH}-${KV}" ]
then
KERNEL_CONFIG="/etc/kernels/kernel-config-${ARCH}-${KV}"
elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}" ]
then
KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}"
elif [ "${DEFAULT_KERNEL_CONFIG}" != "" -a -f "${DEFAULT_KERNEL_CONFIG}" ]
then
KERNEL_CONFIG="${DEFAULT_KERNEL_CONFIG}"
elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}" ]
then
KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}"
elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config" ]
then
KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config"
else
gen_die 'Error: No kernel .config specified, or file not found!'
fi
if [ "${CMD_KERNEL_CONFIG}" != "" ]
then
KERNEL_CONFIG="${CMD_KERNEL_CONFIG}"
elif [ -f "/etc/kernels/kernel-config-${ARCH}-${KV}" ]
then
KERNEL_CONFIG="/etc/kernels/kernel-config-${ARCH}-${KV}"
elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}" ]
then
KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}"
elif [ "${DEFAULT_KERNEL_CONFIG}" != "" -a -f "${DEFAULT_KERNEL_CONFIG}" ]
then
KERNEL_CONFIG="${DEFAULT_KERNEL_CONFIG}"
elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}" ]
then
KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}"
elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config" ]
then
KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config"
else
gen_die 'Error: No kernel .config specified, or file not found!'
fi
KERNEL_CONFIG="$(readlink -f "${KERNEL_CONFIG}")"
}
config_kernel() {
determine_config_file
cd "${KERNEL_DIR}" || gen_die 'Could not switch to the kernel directory!'
determine_config_file
cd "${KERNEL_DIR}" || gen_die 'Could not switch to the kernel directory!'
# Backup current kernel .config
if isTrue "${MRPROPER}" || [ ! -f "${KERNEL_OUTPUTDIR}/.config" ]
then
print_info 1 "kernel: Using config from ${KERNEL_CONFIG}"
if [ -f "${KERNEL_OUTPUTDIR}/.config" ]
then
NOW=`date +--%Y-%m-%d--%H-%M-%S`
cp "${KERNEL_OUTPUTDIR}/.config" "${KERNEL_OUTPUTDIR}/.config${NOW}.bak" \
|| gen_die "Could not backup kernel config (${KERNEL_OUTPUTDIR}/.config)"
print_info 1 " Previous config backed up to .config${NOW}.bak"
fi
fi
# Backup current kernel .config
if isTrue "${MRPROPER}" || [ ! -f "${KERNEL_OUTPUTDIR}/.config" ]
then
print_info 1 "kernel: Using config from ${KERNEL_CONFIG}"
if [ -f "${KERNEL_OUTPUTDIR}/.config" ]
then
NOW=`date +--%Y-%m-%d--%H-%M-%S`
cp "${KERNEL_OUTPUTDIR}/.config" "${KERNEL_OUTPUTDIR}/.config${NOW}.bak" \
|| gen_die "Could not backup kernel config (${KERNEL_OUTPUTDIR}/.config)"
print_info 1 " Previous config backed up to .config${NOW}.bak"
fi
fi
if isTrue ${MRPROPER}
then
print_info 1 'kernel: >> Running mrproper...'
compile_generic mrproper kernel
else
print_info 1 "kernel: --mrproper is disabled; not running 'make mrproper'."
fi
if isTrue ${MRPROPER}
then
print_info 1 'kernel: >> Running mrproper...'
compile_generic mrproper kernel
else
print_info 1 "kernel: --mrproper is disabled; not running 'make mrproper'."
fi
# 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.
if isTrue "${MRPROPER}" || [ ! -f "${KERNEL_OUTPUTDIR}/.config" ]
then
local message='Could not copy configuration file!'
if [[ "$(file --brief --mime-type "${KERNEL_CONFIG}")" == application/x-gzip ]]; then
# Support --kernel-config=/proc/config.gz, mainly
zcat "${KERNEL_CONFIG}" > "${KERNEL_OUTPUTDIR}/.config" || gen_die "${message}"
else
cp "${KERNEL_CONFIG}" "${KERNEL_OUTPUTDIR}/.config" || gen_die "${message}"
fi
fi
# 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.
if isTrue "${MRPROPER}" || [ ! -f "${KERNEL_OUTPUTDIR}/.config" ]
then
local message='Could not copy configuration file!'
if [[ "$(file --brief --mime-type "${KERNEL_CONFIG}")" == application/x-gzip ]]; then
# Support --kernel-config=/proc/config.gz, mainly
zcat "${KERNEL_CONFIG}" > "${KERNEL_OUTPUTDIR}/.config" || gen_die "${message}"
else
cp "${KERNEL_CONFIG}" "${KERNEL_OUTPUTDIR}/.config" || gen_die "${message}"
fi
fi
if isTrue "${OLDCONFIG}"
then
print_info 1 ' >> Running oldconfig...'
yes '' 2>/dev/null | compile_generic oldconfig kernel 2>/dev/null
else
print_info 1 "kernel: --oldconfig is disabled; not running 'make oldconfig'."
fi
if isTrue "${CLEAN}"
then
print_info 1 'kernel: >> Cleaning...'
compile_generic clean kernel
else
print_info 1 "kernel: --clean is disabled; not running 'make clean'."
fi
if isTrue "${OLDCONFIG}"
then
print_info 1 ' >> Running oldconfig...'
yes '' 2>/dev/null | compile_generic oldconfig kernel 2>/dev/null
else
print_info 1 "kernel: --oldconfig is disabled; not running 'make oldconfig'."
fi
if isTrue "${CLEAN}"
then
print_info 1 'kernel: >> Cleaning...'
compile_generic clean kernel
else
print_info 1 "kernel: --clean is disabled; not running 'make clean'."
fi
if isTrue ${MENUCONFIG}
then
print_info 1 'kernel: >> Invoking menuconfig...'
compile_generic menuconfig kernelruntask
[ "$?" ] || gen_die 'Error: menuconfig failed!'
elif isTrue ${NCONFIG}
then
print_info 1 'kernel: >> Invoking nconfig...'
compile_generic nconfig kernelruntask
[ "$?" ] || gen_die 'Error: nconfig failed!'
elif isTrue ${CMD_GCONFIG}
then
print_info 1 'kernel: >> Invoking gconfig...'
compile_generic gconfig kernel
[ "$?" ] || gen_die 'Error: gconfig failed!'
if isTrue ${MENUCONFIG}
then
print_info 1 'kernel: >> Invoking menuconfig...'
compile_generic menuconfig kernelruntask
[ "$?" ] || gen_die 'Error: menuconfig failed!'
elif isTrue ${NCONFIG}
then
print_info 1 'kernel: >> Invoking nconfig...'
compile_generic nconfig kernelruntask
[ "$?" ] || gen_die 'Error: nconfig failed!'
elif isTrue ${CMD_GCONFIG}
then
print_info 1 'kernel: >> Invoking gconfig...'
compile_generic gconfig kernel
[ "$?" ] || gen_die 'Error: gconfig failed!'
CMD_XCONFIG=0
fi
CMD_XCONFIG=0
fi
if isTrue ${CMD_XCONFIG}
then
print_info 1 'kernel: >> Invoking xconfig...'
compile_generic xconfig kernel
[ "$?" ] || gen_die 'Error: xconfig failed!'
fi
if isTrue ${CMD_XCONFIG}
then
print_info 1 'kernel: >> Invoking xconfig...'
compile_generic xconfig kernel
[ "$?" ] || gen_die 'Error: xconfig failed!'
fi
}

@ -2,216 +2,216 @@
# $Id$
get_KV() {
if [ "${KERNEL_SOURCES}" = '0' -a -e "${KERNCACHE}" ]
then
/bin/tar -xj -C ${TEMP} -f ${KERNCACHE} kerncache.config
if [ -e ${TEMP}/kerncache.config ]
then
VER=`grep ^VERSION\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
PAT=`grep ^PATCHLEVEL\ \= ${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"`
LOV=`grep ^CONFIG_LOCALVERSION\= ${TEMP}/kerncache.config | sed -e "s/CONFIG_LOCALVERSION=\"\(.*\)\"/\1/"`
KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
else
gen_die "Could not find kerncache.config in the kernel cache! Exiting."
fi
else
# Configure the kernel
# If BUILD_KERNEL=0 then assume --no-clean, menuconfig is cleared
if [ ! -f "${KERNEL_DIR}"/Makefile ]
then
gen_die "Kernel Makefile (${KERNEL_DIR}/Makefile) missing. Maybe re-install the kernel sources."
fi
VER=`grep ^VERSION\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'`
PAT=`grep ^PATCHLEVEL\ \= ${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'`
if [ -z "${SUB}" ]
then
# Handle O= build directories
KERNEL_SOURCE_DIR=`grep ^MAKEARGS\ \:\= ${KERNEL_DIR}/Makefile | awk '{ print $4 };'`
[ -z "${KERNEL_SOURCE_DIR}" ] && gen_die "Deriving \${KERNEL_SOURCE_DIR} failed"
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'`
fi
cd ${KERNEL_DIR}
#compile_generic prepare kernel > /dev/null 2>&1
cd - > /dev/null 2>&1
[ -f "${KERNEL_DIR}/include/linux/version.h" ] && \
VERSION_SOURCE="${KERNEL_DIR}/include/linux/version.h"
[ -f "${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
if [ -f ${KERNEL_DIR}/include/config/kernel.release ]
then
UTS_RELEASE=`cat ${KERNEL_DIR}/include/config/kernel.release`
LOV=`echo ${UTS_RELEASE}|sed -e "s/${VER}.${PAT}.${SUB}${EXV}//"`
KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
elif [ -n "${VERSION_SOURCE}" ]
then
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}//"`
KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
else
determine_config_file
LCV=`grep ^CONFIG_LOCALVERSION= "${KERNEL_CONFIG}" | sed -r -e "s/.*=\"(.*)\"/\1/"`
KV=${VER}.${PAT}.${SUB}${EXV}${LCV}
fi
fi
if [ "${KERNEL_SOURCES}" = '0' -a -e "${KERNCACHE}" ]
then
/bin/tar -xj -C ${TEMP} -f ${KERNCACHE} kerncache.config
if [ -e ${TEMP}/kerncache.config ]
then
VER=`grep ^VERSION\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
PAT=`grep ^PATCHLEVEL\ \= ${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"`
LOV=`grep ^CONFIG_LOCALVERSION\= ${TEMP}/kerncache.config | sed -e "s/CONFIG_LOCALVERSION=\"\(.*\)\"/\1/"`
KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
else
gen_die "Could not find kerncache.config in the kernel cache! Exiting."
fi
else
# Configure the kernel
# If BUILD_KERNEL=0 then assume --no-clean, menuconfig is cleared
if [ ! -f "${KERNEL_DIR}"/Makefile ]
then
gen_die "Kernel Makefile (${KERNEL_DIR}/Makefile) missing. Maybe re-install the kernel sources."
fi
VER=`grep ^VERSION\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'`
PAT=`grep ^PATCHLEVEL\ \= ${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'`
if [ -z "${SUB}" ]
then
# Handle O= build directories
KERNEL_SOURCE_DIR=`grep ^MAKEARGS\ \:\= ${KERNEL_DIR}/Makefile | awk '{ print $4 };'`
[ -z "${KERNEL_SOURCE_DIR}" ] && gen_die "Deriving \${KERNEL_SOURCE_DIR} failed"
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'`
fi
cd ${KERNEL_DIR}
#compile_generic prepare kernel > /dev/null 2>&1
cd - > /dev/null 2>&1
[ -f "${KERNEL_DIR}/include/linux/version.h" ] && \
VERSION_SOURCE="${KERNEL_DIR}/include/linux/version.h"
[ -f "${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
if [ -f ${KERNEL_DIR}/include/config/kernel.release ]
then
UTS_RELEASE=`cat ${KERNEL_DIR}/include/config/kernel.release`
LOV=`echo ${UTS_RELEASE}|sed -e "s/${VER}.${PAT}.${SUB}${EXV}//"`
KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
elif [ -n "${VERSION_SOURCE}" ]
then
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}//"`
KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
else
determine_config_file
LCV=`grep ^CONFIG_LOCALVERSION= "${KERNEL_CONFIG}" | sed -r -e "s/.*=\"(.*)\"/\1/"`
KV=${VER}.${PAT}.${SUB}${EXV}${LCV}
fi
fi
}
determine_real_args() {
print_info 4 "Resolving config file, command line, and arch default settings."
# Dest / Config File Command Line Arch Default
# ------------------ ------------ ------------
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 BOOL KERNEL_SOURCES CMD_KERNEL_SOURCES "yes"
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_TYPE CMD_COMPRESS_INITRD_TYPE "$DEFAULT_COMPRESS_INITRD_TYPE"
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 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_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 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_AS CMD_UTILS_AS "$DEFAULT_UTILS_AS"
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 MODPROBEDIR CMD_MODPROBEDIR "/etc/modprobe.d"
set_config_with_override BOOL SPLASH CMD_SPLASH
set_config_with_override BOOL PLYMOUTH CMD_PLYMOUTH
set_config_with_override BOOL POSTCLEAR CMD_POSTCLEAR
set_config_with_override BOOL MRPROPER CMD_MRPROPER
set_config_with_override BOOL MENUCONFIG CMD_MENUCONFIG
set_config_with_override BOOL NCONFIG CMD_NCONFIG
set_config_with_override BOOL CLEAN CMD_CLEAN
set_config_with_override STRING MINKERNPACKAGE CMD_MINKERNPACKAGE
set_config_with_override STRING MODULESPACKAGE CMD_MODULESPACKAGE
set_config_with_override STRING KERNCACHE CMD_KERNCACHE
set_config_with_override BOOL RAMDISKMODULES CMD_RAMDISKMODULES "yes"
set_config_with_override BOOL ALLRAMDISKMODULES CMD_ALLRAMDISKMODULES
set_config_with_override STRING INITRAMFS_OVERLAY CMD_INITRAMFS_OVERLAY
set_config_with_override BOOL MOUNTBOOT CMD_MOUNTBOOT
set_config_with_override BOOL BUILD_STATIC CMD_STATIC
set_config_with_override BOOL SAVE_CONFIG CMD_SAVE_CONFIG
set_config_with_override BOOL SYMLINK CMD_SYMLINK
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 UDEV CMD_UDEV
set_config_with_override BOOL LVM CMD_LVM
set_config_with_override BOOL DMRAID CMD_DMRAID
set_config_with_override BOOL ISCSI CMD_ISCSI
set_config_with_override BOOL BUSYBOX CMD_BUSYBOX "yes"
set_config_with_override BOOL NETBOOT CMD_NETBOOT
set_config_with_override STRING REAL_ROOT CMD_REAL_ROOT
set_config_with_override BOOL LUKS CMD_LUKS
set_config_with_override BOOL GPG CMD_GPG
set_config_with_override BOOL MDADM CMD_MDADM
set_config_with_override STRING MDADM_CONFIG CMD_MDADM_CONFIG
set_config_with_override BOOL E2FSPROGS CMD_E2FSPROGS "no"
set_config_with_override BOOL ZFS CMD_ZFS
set_config_with_override BOOL BTRFS CMD_BTRFS
set_config_with_override BOOL VIRTIO CMD_VIRTIO "no"
set_config_with_override BOOL MULTIPATH CMD_MULTIPATH
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_FILES CMD_FIRMWARE_FILES
set_config_with_override BOOL INTEGRATED_INITRAMFS CMD_INTEGRATED_INITRAMFS
set_config_with_override BOOL GENZIMAGE CMD_GENZIMAGE
set_config_with_override BOOL KEYMAP CMD_KEYMAP "yes"
set_config_with_override BOOL DOKEYMAPAUTO CMD_DOKEYMAPAUTO
set_config_with_override STRING BUSYBOX_CONFIG CMD_BUSYBOX_CONFIG
set_config_with_override BOOL INSTALL CMD_INSTALL "yes"
BOOTDIR=`arch_replace "${BOOTDIR}"`
BOOTDIR=${BOOTDIR%/} # Remove any trailing slash
MODPROBEDIR=${MODPROBEDIR%/} # Remove any trailing slash
CACHE_DIR=`arch_replace "${CACHE_DIR}"`
BUSYBOX_BINCACHE=`cache_replace "${BUSYBOX_BINCACHE}"`
DEFAULT_KERNEL_CONFIG=`arch_replace "${DEFAULT_KERNEL_CONFIG}"`
BUSYBOX_CONFIG=`arch_replace "${BUSYBOX_CONFIG}"`
BUSYBOX_BINCACHE=`arch_replace "${BUSYBOX_BINCACHE}"`
if [ -n "${CMD_BOOTLOADER}" ]
then
BOOTLOADER="${CMD_BOOTLOADER}"
if [ "${CMD_BOOTLOADER}" != "${CMD_BOOTLOADER/:/}" ]
then
BOOTFS=`echo "${CMD_BOOTLOADER}" | cut -f2- -d:`
BOOTLOADER=`echo "${CMD_BOOTLOADER}" | cut -f1 -d:`
fi
fi
if [ "${KERNEL_SOURCES}" != "0" ]
then
if [ ! -d ${KERNEL_DIR} ]
then
gen_die "kernel source directory \"${KERNEL_DIR}\" was not found!"
fi
fi
if [ -z "${KERNCACHE}" ]
then
if [ "${KERNEL_DIR}" = '' -a "${KERNEL_SOURCES}" != "0" ]
then
gen_die 'No kernel source directory!'
fi
if [ ! -e "${KERNEL_DIR}" -a "${KERNEL_SOURCES}" != "0" ]
then
gen_die 'No kernel source directory!'
fi
else
if [ "${KERNEL_DIR}" = '' ]
then
gen_die 'Kernel Cache specified but no kernel tree to verify against!'
fi
fi
# Special case: If --no-clean is specified on the command line,
# imply --no-mrproper.
if [ "${CMD_CLEAN}" != '' ]
then
if ! isTrue ${CLEAN}
then
MRPROPER=0
fi
fi
if [ -n "${MINKERNPACKAGE}" ]
then
mkdir -p `dirname ${MINKERNPACKAGE}`
fi
if [ -n "${MODULESPACKAGE}" ]
then
mkdir -p `dirname ${MODULESPACKAGE}`
fi
if [ -n "${KERNCACHE}" ]
then
mkdir -p `dirname ${KERNCACHE}`
fi
if ! isTrue "${BUILD_RAMDISK}"
then
INTEGRATED_INITRAMFS=0
fi
get_KV
print_info 4 "Resolving config file, command line, and arch default settings."
# Dest / Config File Command Line Arch Default
# ------------------ ------------ ------------
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 BOOL KERNEL_SOURCES CMD_KERNEL_SOURCES "yes"
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_TYPE CMD_COMPRESS_INITRD_TYPE "$DEFAULT_COMPRESS_INITRD_TYPE"
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 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_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 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_AS CMD_UTILS_AS "$DEFAULT_UTILS_AS"
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 MODPROBEDIR CMD_MODPROBEDIR "/etc/modprobe.d"
set_config_with_override BOOL SPLASH CMD_SPLASH
set_config_with_override BOOL PLYMOUTH CMD_PLYMOUTH
set_config_with_override BOOL POSTCLEAR CMD_POSTCLEAR
set_config_with_override BOOL MRPROPER CMD_MRPROPER
set_config_with_override BOOL MENUCONFIG CMD_MENUCONFIG
set_config_with_override BOOL NCONFIG CMD_NCONFIG
set_config_with_override BOOL CLEAN CMD_CLEAN
set_config_with_override STRING MINKERNPACKAGE CMD_MINKERNPACKAGE
set_config_with_override STRING MODULESPACKAGE CMD_MODULESPACKAGE
set_config_with_override STRING KERNCACHE CMD_KERNCACHE
set_config_with_override BOOL RAMDISKMODULES CMD_RAMDISKMODULES "yes"
set_config_with_override BOOL ALLRAMDISKMODULES CMD_ALLRAMDISKMODULES
set_config_with_override STRING INITRAMFS_OVERLAY CMD_INITRAMFS_OVERLAY
set_config_with_override BOOL MOUNTBOOT CMD_MOUNTBOOT
set_config_with_override BOOL BUILD_STATIC CMD_STATIC
set_config_with_override BOOL SAVE_CONFIG CMD_SAVE_CONFIG
set_config_with_override BOOL SYMLINK CMD_SYMLINK
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 UDEV CMD_UDEV
set_config_with_override BOOL LVM CMD_LVM
set_config_with_override BOOL DMRAID CMD_DMRAID
set_config_with_override BOOL ISCSI CMD_ISCSI
set_config_with_override BOOL BUSYBOX CMD_BUSYBOX "yes"
set_config_with_override BOOL NETBOOT CMD_NETBOOT
set_config_with_override STRING REAL_ROOT CMD_REAL_ROOT
set_config_with_override BOOL LUKS CMD_LUKS
set_config_with_override BOOL GPG CMD_GPG
set_config_with_override BOOL MDADM CMD_MDADM
set_config_with_override STRING MDADM_CONFIG CMD_MDADM_CONFIG
set_config_with_override BOOL E2FSPROGS CMD_E2FSPROGS "no"
set_config_with_override BOOL ZFS CMD_ZFS
set_config_with_override BOOL BTRFS CMD_BTRFS
set_config_with_override BOOL VIRTIO CMD_VIRTIO "no"
set_config_with_override BOOL MULTIPATH CMD_MULTIPATH
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_FILES CMD_FIRMWARE_FILES
set_config_with_override BOOL INTEGRATED_INITRAMFS CMD_INTEGRATED_INITRAMFS
set_config_with_override BOOL GENZIMAGE CMD_GENZIMAGE
set_config_with_override BOOL KEYMAP CMD_KEYMAP "yes"
set_config_with_override BOOL DOKEYMAPAUTO CMD_DOKEYMAPAUTO
set_config_with_override STRING BUSYBOX_CONFIG CMD_BUSYBOX_CONFIG
set_config_with_override BOOL INSTALL CMD_INSTALL "yes"
BOOTDIR=`arch_replace "${BOOTDIR}"`
BOOTDIR=${BOOTDIR%/} # Remove any trailing slash
MODPROBEDIR=${MODPROBEDIR%/} # Remove any trailing slash
CACHE_DIR=`arch_replace "${CACHE_DIR}"`
BUSYBOX_BINCACHE=`cache_replace "${BUSYBOX_BINCACHE}"`
DEFAULT_KERNEL_CONFIG=`arch_replace "${DEFAULT_KERNEL_CONFIG}"`
BUSYBOX_CONFIG=`arch_replace "${BUSYBOX_CONFIG}"`
BUSYBOX_BINCACHE=`arch_replace "${BUSYBOX_BINCACHE}"`
if [ -n "${CMD_BOOTLOADER}" ]
then
BOOTLOADER="${CMD_BOOTLOADER}"
if [ "${CMD_BOOTLOADER}" != "${CMD_BOOTLOADER/:/}" ]
then
BOOTFS=`echo "${CMD_BOOTLOADER}" | cut -f2- -d:`
BOOTLOADER=`echo "${CMD_BOOTLOADER}" | cut -f1 -d:`
fi
fi
if [ "${KERNEL_SOURCES}" != "0" ]
then
if [ ! -d ${KERNEL_DIR} ]
then
gen_die "kernel source directory \"${KERNEL_DIR}\" was not found!"
fi
fi
if [ -z "${KERNCACHE}" ]
then
if [ "${KERNEL_DIR}" = '' -a "${KERNEL_SOURCES}" != "0" ]
then
gen_die 'No kernel source directory!'
fi
if [ ! -e "${KERNEL_DIR}" -a "${KERNEL_SOURCES}" != "0" ]
then
gen_die 'No kernel source directory!'
fi
else
if [ "${KERNEL_DIR}" = '' ]
then
gen_die 'Kernel Cache specified but no kernel tree to verify against!'
fi
fi
# Special case: If --no-clean is specified on the command line,
# imply --no-mrproper.
if [ "${CMD_CLEAN}" != '' ]
then
if ! isTrue ${CLEAN}
then
MRPROPER=0
fi
fi
if [ -n "${MINKERNPACKAGE}" ]
then
mkdir -p `dirname ${MINKERNPACKAGE}`
fi
if [ -n "${MODULESPACKAGE}" ]
then
mkdir -p `dirname ${MODULESPACKAGE}`
fi
if [ -n "${KERNCACHE}" ]
then
mkdir -p `dirname ${KERNCACHE}`
fi
if ! isTrue "${BUILD_RAMDISK}"
then
INTEGRATED_INITRAMFS=0
fi
get_KV
}

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

File diff suppressed because it is too large Load Diff

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

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

@ -16,11 +16,11 @@ small_die() {
}
parse_opt() {
case "$1" in
*\=*)
echo "$1" | cut -f2- -d=
;;
esac
case "$1" in
*\=*)
echo "$1" | cut -f2- -d=
;;
esac
}
# 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
for (( i=1; i<=$# ; i=i+1 )); do
eval arg="\$$i"
[[ "${arg}" = --config=* ]] && CMD_GK_CONFIG=`parse_opt "${arg}"`
eval arg="\$$i"
[[ "${arg}" = --config=* ]] && CMD_GK_CONFIG=`parse_opt "${arg}"`
done
# 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.$$
trap_cleanup(){
# Call exit code of 1 for failure
cleanup
exit 1
# Call exit code of 1 for failure
cleanup
exit 1
}
cleanup(){
if [ -n "$TEMP" -a -d "$TEMP" ]; then
rm -rf "$TEMP"
rm -rf "$TEMP"
fi
if isTrue ${POSTCLEAR}
then
echo
print_info 1 'RUNNING FINAL CACHE/TMP CLEANUP'
print_info 1 "CACHE_DIR: ${CACHE_DIR}"
CLEAR_CACHE_DIR='yes'
setup_cache_dir
echo
print_info 1 "TMPDIR: ${TMPDIR}"
clear_tmpdir
fi
echo
print_info 1 'RUNNING FINAL CACHE/TMP CLEANUP'
print_info 1 "CACHE_DIR: ${CACHE_DIR}"
CLEAR_CACHE_DIR='yes'
setup_cache_dir
echo
print_info 1 "TMPDIR: ${TMPDIR}"
clear_tmpdir
fi
}
trap trap_cleanup SIGHUP SIGQUIT SIGINT SIGTERM SIGKILL
@ -84,15 +84,15 @@ BUILD_MODULES=0
Options=$* # Save for later
while [ $# -gt 0 ]
do
Option=$1; shift
parse_cmdline $Option
Option=$1; shift
parse_cmdline $Option
done
# Check if no action is specified...
if [ "${BUILD_KERNEL}" = '0' -a "${BUILD_RAMDISK}" = '0' ]
then
usage
exit 1
usage
exit 1
fi
clear_log
@ -114,10 +114,10 @@ echo
# Merge modules_load from config
for group_modules in ${!AMODULES_*}; do
group="$(echo $group_modules | cut -d_ -f2)"
eval cmodules="\$$group_modules"
eval MODULES_${group}=\"\${MODULES_${group}} ${cmodules}\"
print_info 1 "<config> Merged AMODULES_${group}:'${cmodules}' into MODULES_${group}"
group="$(echo $group_modules | cut -d_ -f2)"
eval cmodules="\$$group_modules"
eval MODULES_${group}=\"\${MODULES_${group}} ${cmodules}\"
print_info 1 "<config> Merged AMODULES_${group}:'${cmodules}' into MODULES_${group}"
done
@ -143,65 +143,65 @@ print_info 1 ".. with config file ${KERNEL_CONFIG}"
# Check BOOTDIR is mounted
if ! isTrue ${CMD_INSTALL}
then
isTrue ${MOUNTBOOT} && print_info 2 'Skipping automatic mount of boot'
isTrue ${MOUNTBOOT} && print_info 2 'Skipping automatic mount of boot'
else
[[ -d ${BOOTDIR} ]] || gen_die "${BOOTDIR} is not a directory"
if ! egrep -q "[[:space:]]${BOOTDIR}[[:space:]]" /proc/mounts
then
if egrep -q "^[^#].+[[:space:]]${BOOTDIR}[[:space:]]" /etc/fstab
then
if isTrue ${MOUNTBOOT}
then
if ! mount ${BOOTDIR}
then
print_warning 1 "${BOLD}WARNING${NORMAL}: Failed to mount ${BOOTDIR}!"
echo
else
print_info 1 "mount: ${BOOTDIR} mounted successfully!"
fi
else
print_warning 1 "${BOLD}WARNING${NORMAL}: No mounted ${BOOTDIR} partition detected!"
print_warning 1 " Run ``mount ${BOOTDIR}`` to mount it!"
echo
fi
fi
elif isBootRO
then
if isTrue ${MOUNTBOOT}
then
if ! mount -o remount,rw ${BOOTDIR}
then
print_warning 1 "${BOLD}WARNING${NORMAL}: Failed to remount ${BOOTDIR} RW!"
echo
else
print_info 1 "mount: ${BOOTDIR} remounted read/write successfully!"
BOOTRW=1
fi
fi
fi
[[ -d ${BOOTDIR} ]] || gen_die "${BOOTDIR} is not a directory"
if ! egrep -q "[[:space:]]${BOOTDIR}[[:space:]]" /proc/mounts
then
if egrep -q "^[^#].+[[:space:]]${BOOTDIR}[[:space:]]" /etc/fstab
then
if isTrue ${MOUNTBOOT}
then
if ! mount ${BOOTDIR}
then
print_warning 1 "${BOLD}WARNING${NORMAL}: Failed to mount ${BOOTDIR}!"
echo
else
print_info 1 "mount: ${BOOTDIR} mounted successfully!"
fi
else
print_warning 1 "${BOLD}WARNING${NORMAL}: No mounted ${BOOTDIR} partition detected!"
print_warning 1 " Run ``mount ${BOOTDIR}`` to mount it!"
echo
fi
fi
elif isBootRO
then
if isTrue ${MOUNTBOOT}
then
if ! mount -o remount,rw ${BOOTDIR}
then
print_warning 1 "${BOLD}WARNING${NORMAL}: Failed to remount ${BOOTDIR} RW!"
echo
else
print_info 1 "mount: ${BOOTDIR} remounted read/write successfully!"
BOOTRW=1
fi
fi
fi
fi
## Check whether another Genkernel is running
#GENPIDS="`ps -C genkernel --no-headers -o pid | wc -l`"
#if [ "${GENPIDS}" -gt '3' ]
#then
# [ "${GENPIDS}" -gt '4' ] && EX='s'
# print_warning 1 "${BOLD}WARNING${NORMAL}: Another Genkernel instance is running under"
# print_warning 1 " process ID${EX} " 0
# GENPIDS=`ps -C genkernel --no-headers -o pid`
# echo -n "${GENPIDS}" | sed -e "s/$$//; s/ /, /g"
# echo 'halting...'
# echo
# 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! ]"
# echo
# CTEMP="${TEMP}"
# TEMP=${TMPDIR-/tmp}
# TEMP=${TEMP}/genkernel.$RANDOM.$RANDOM.$RANDOM.$$
# print_info 1 'thread: Running multiple genkernels may cause problems!'
# print_info 1 "thread: Temporary files reallocated to ${TEMP}..."
# echo
# [ "${GENPIDS}" -gt '4' ] && EX='s'
# print_warning 1 "${BOLD}WARNING${NORMAL}: Another Genkernel instance is running under"
# print_warning 1 " process ID${EX} " 0
# GENPIDS=`ps -C genkernel --no-headers -o pid`
# echo -n "${GENPIDS}" | sed -e "s/$$//; s/ /, /g"
# echo 'halting...'
# echo
# 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! ]"
# echo
# CTEMP="${TEMP}"
# TEMP=${TMPDIR-/tmp}
# TEMP=${TEMP}/genkernel.$RANDOM.$RANDOM.$RANDOM.$$
# print_info 1 'thread: Running multiple genkernels may cause problems!'
# print_info 1 "thread: Temporary files reallocated to ${TEMP}..."
# echo
#fi
KERNCACHE_IS_VALID=0
@ -212,101 +212,101 @@ fi
if [ ${BUILD_KERNEL} = '1' -a "${KERNCACHE_IS_VALID}" = '0' ]
then
# Configure kernel
config_kernel
# Make prepare
if [ "${ARCH_HAVENOPREPARE}" = '' ]
then
compile_generic prepare kernel
fi
# KV may have changed due to the configuration
get_KV
compile_kernel
# Compile modules
if [ "${BUILD_MODULES}" = '1' -a "${BUILD_STATIC}" = '0' ]
then
compile_modules
fi
if [ "${SAVE_CONFIG}" = '1' ]
then
print_info 1 "Copying config for successful build to /etc/kernels/kernel-config-${ARCH}-${KV}"
[ ! -e '/etc/kernels' ] && mkdir -p /etc/kernels
cp "${KERNEL_OUTPUTDIR}/.config" "/etc/kernels/kernel-config-${ARCH}-${KV}" || \
print_warning "Unable to copy the kernel configuration file."
# Just a warning because ordinary users are not allowed to write in /etc
fi
# Configure kernel
config_kernel
# Make prepare
if [ "${ARCH_HAVENOPREPARE}" = '' ]
then
compile_generic prepare kernel
fi
# KV may have changed due to the configuration
get_KV
compile_kernel
# Compile modules
if [ "${BUILD_MODULES}" = '1' -a "${BUILD_STATIC}" = '0' ]
then
compile_modules
fi
if [ "${SAVE_CONFIG}" = '1' ]
then
print_info 1 "Copying config for successful build to /etc/kernels/kernel-config-${ARCH}-${KV}"
[ ! -e '/etc/kernels' ] && mkdir -p /etc/kernels
cp "${KERNEL_OUTPUTDIR}/.config" "/etc/kernels/kernel-config-${ARCH}-${KV}" || \
print_warning "Unable to copy the kernel configuration file."
# Just a warning because ordinary users are not allowed to write in /etc
fi
fi
if isTrue "${CMD_INSTALL}"
then
if [ "${KERNCACHE}" != "" -a "${KERNCACHE_IS_VALID}" != "0" ]
then
gen_kerncache_extract_kernel
fi
if [ "${KERNCACHE}" != "" -a "${KERNCACHE_IS_VALID}" != "0" ]
then
gen_kerncache_extract_kernel
fi
fi
if [ "${KERNCACHE}" != "" -a "${KERNCACHE_IS_VALID}" != "0" ]
then
[ "${BUILD_STATIC}" = '0' ] && gen_kerncache_extract_modules
gen_kerncache_extract_config
[ "${BUILD_STATIC}" = '0' ] && gen_kerncache_extract_modules
gen_kerncache_extract_config
fi
# Run callback
if [ "${CMD_CALLBACK}" != "" ]
then
print_info 1 "" 1 0
print_info 1 "Preparing to run callback: \"${CMD_CALLBACK}\"" 0
CALLBACK_ESCAPE=0
CALLBACK_COUNT=0
trap "CALLBACK_ESCAPE=1" TERM KILL INT QUIT ABRT
while [[ "${CALLBACK_ESCAPE}" = '0' && ${CALLBACK_COUNT} -lt 5 ]]
do
sleep 1; echo -n '.';
let CALLBACK_COUNT=${CALLBACK_COUNT}+1
done
if [ "${CALLBACK_ESCAPE}" = '0' ]
then
echo
echo
eval ${CMD_CALLBACK} | tee -a ${LOGFILE}
CMD_STATUS="${PIPESTATUS[0]}"
echo
print_info 1 "<<< Callback exit status: ${CMD_STATUS}"
[ "${CMD_STATUS}" != '0' ] && gen_die '--callback failed!'
else
echo
print_info 1 ">>> Callback cancelled..."
fi
trap - TERM KILL INT QUIT ABRT
print_info 1 "" 1 0
print_info 1 "" 1 0
print_info 1 "Preparing to run callback: \"${CMD_CALLBACK}\"" 0
CALLBACK_ESCAPE=0
CALLBACK_COUNT=0
trap "CALLBACK_ESCAPE=1" TERM KILL INT QUIT ABRT
while [[ "${CALLBACK_ESCAPE}" = '0' && ${CALLBACK_COUNT} -lt 5 ]]
do
sleep 1; echo -n '.';
let CALLBACK_COUNT=${CALLBACK_COUNT}+1
done
if [ "${CALLBACK_ESCAPE}" = '0' ]
then
echo
echo
eval ${CMD_CALLBACK} | tee -a ${LOGFILE}
CMD_STATUS="${PIPESTATUS[0]}"
echo
print_info 1 "<<< Callback exit status: ${CMD_STATUS}"
[ "${CMD_STATUS}" != '0' ] && gen_die '--callback failed!'
else
echo
print_info 1 ">>> Callback cancelled..."
fi
trap - TERM KILL INT QUIT ABRT
print_info 1 "" 1 0
fi
if [ "${BUILD_RAMDISK}" = '1' ]
then
if [ "${BUSYBOX}" = '1' ]
then
# Compile Busybox
compile_busybox
fi
# Compile initramfs
create_initramfs
if [ "${BUSYBOX}" = '1' ]
then
# Compile Busybox
compile_busybox
fi
# Compile initramfs
create_initramfs
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
if isTrue "${INTEGRATED_INITRAMFS}" #|| [ "${BUILD_KERNEL}" = '1' -a "${KERNCACHE_IS_VALID}" == "0" ]
then
# We build the kernel a second time to include the initramfs
compile_kernel
# We build the kernel a second time to include the initramfs
compile_kernel
fi
[ "${KERNCACHE}" != "" ] && gen_kerncache
@ -318,58 +318,58 @@ fi
if [ "${BUILD_KERNEL}" = '1' ]
then
if isTrue "${CMD_INSTALL}"
then
set_bootloader
fi
print_info 1 ''
print_info 1 "Kernel compiled successfully!"
print_info 1 ''
print_info 1 'Required Kernel Parameters:'
print_info 1 ' root=/dev/$ROOT'
if [ "${BUILD_RAMDISK}" = '0' ]
then
print_info 1 ' [ And "vga=0x317 splash=verbose" if you use a framebuffer ]'
print_info 1 ''
print_info 1 ' Where $ROOT is the device node for your root partition as the'
print_info 1 ' one specified in /etc/fstab'
else
print_info 1 ''
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 ''
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.'
fi
if isTrue "${CMD_INSTALL}"
then
set_bootloader
fi
print_info 1 ''
print_info 1 "Kernel compiled successfully!"
print_info 1 ''
print_info 1 'Required Kernel Parameters:'
print_info 1 ' root=/dev/$ROOT'
if [ "${BUILD_RAMDISK}" = '0' ]
then
print_info 1 ' [ And "vga=0x317 splash=verbose" if you use a framebuffer ]'
print_info 1 ''
print_info 1 ' Where $ROOT is the device node for your root partition as the'
print_info 1 ' one specified in /etc/fstab'
else
print_info 1 ''
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 ''
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.'
fi
fi
if [ "${BUILD_RAMDISK}" = '1' ]
then
echo
print_warning 1 'WARNING... WARNING... WARNING...'
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 ]"
[ "${LVM}" = '1' ] && print_warning 1 'add "dolvm" for lvm support'
[ "${DMRAID}" = '1' ] && print_warning 1 'add "dodmraid" for dmraid support'
[ "${MDADM}" = '1' ] && print_warning 1 'add "domdadm" for RAID support'
[ "${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 ' 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'
if [[ "$(file --brief --mime-type "${KERNEL_CONFIG}")" == application/x-gzip ]]; then
# Support --kernel-config=/proc/config.gz, mainly
CONFGREP=zgrep
else
CONFGREP=grep
fi
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 'add "rootfstype=ext3" or "rootfstype=ext4" to the list of boot parameters.'
fi
unset CONFGREP
echo
print_warning 1 'WARNING... WARNING... WARNING...'
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 ]"
[ "${LVM}" = '1' ] && print_warning 1 'add "dolvm" for lvm support'
[ "${DMRAID}" = '1' ] && print_warning 1 'add "dodmraid" for dmraid support'
[ "${MDADM}" = '1' ] && print_warning 1 'add "domdadm" for RAID support'
[ "${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 ' 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'
if [[ "$(file --brief --mime-type "${KERNEL_CONFIG}")" == application/x-gzip ]]; then
# Support --kernel-config=/proc/config.gz, mainly
CONFGREP=zgrep
else
CONFGREP=grep
fi
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 'add "rootfstype=ext3" or "rootfstype=ext4" to the list of boot parameters.'
fi
unset CONFGREP
fi
[ "${BOOTRW}" != '' ] && mount -o remount,ro ${BOOTDIR}

@ -13,7 +13,7 @@ _genkernel()
# extract initial list of params/actions from genkernel --help
genkernel_help=$(command genkernel --help)
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,}') )
# 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 [[ ${#COMPREPLY[@]} -gt 1 ]]; then
return
return
elif [[ ${#COMPREPLY[@]} -eq 0 && $cur != --*=* ]]; then
return
return
elif [[ ${#COMPREPLY[@]} -eq 1 && $COMPREPLY != --*= ]]; then
# using nospace completion, add an explicit space
COMPREPLY="${COMPREPLY} "
return
# using nospace completion, add an explicit space
COMPREPLY="${COMPREPLY} "
return
fi
# we have a unique lhs and need to complete the rhs
declare args lhs rhs
if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
lhs=$COMPREPLY
lhs=$COMPREPLY
else
lhs=${cur%%=*}=
rhs=${cur#*=}
lhs=${cur%%=*}=
rhs=${cur#*=}
fi
# 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
# an array of results
args=( $(case $args in
('<0-5>') compgen -W "$(echo {1..5})" -- "$rhs" ;;
('<outfile>'|'<file>') compgen -A file -o plusdirs -- "$rhs" ;;
('<dir>') compgen -A directory -S / -- "$rhs" ;;
('<tbz2>') compgen -G '*.tbz2' -G '*.tar.bz2' -o plusdirs -- "$rhs" ;;
(*) compgen -o bashdefault -- "$rhs" ;; # punt
('<0-5>') compgen -W "$(echo {1..5})" -- "$rhs" ;;
('<outfile>'|'<file>') compgen -A file -o plusdirs -- "$rhs" ;;
('<dir>') compgen -A directory -S / -- "$rhs" ;;
('<tbz2>') compgen -G '*.tbz2' -G '*.tar.bz2' -o plusdirs -- "$rhs" ;;
(*) compgen -o bashdefault -- "$rhs" ;; # punt
esac) )
# 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
# non-directories.
declare slash=/
args=( "${args[@]/%/ }" ) # add space to all
args=( "${args[@]/%$slash /$slash}" ) # remove space from dirs
args=( "${args[@]/%/ }" ) # add space to all
args=( "${args[@]/%$slash /$slash}" ) # remove space from dirs
# recreate COMPREPLY
if [[ $cur == "$lhs"* ]]; then
COMPREPLY=( "${args[@]}" )
COMPREPLY=( "${args[@]}" )
elif [[ ${#args[@]} -gt 0 ]]; then
COMPREPLY=( "${args[@]/#/$lhs}" )
COMPREPLY=( "${args[@]/#/$lhs}" )
fi
}

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

Loading…
Cancel
Save