kernel-{geltast,rebuild}: updated

This commit is contained in:
Kolan Sh 2013-04-02 12:56:58 +04:00
parent 95bcb8e9ae
commit 665f96f07f
2 changed files with 106 additions and 120 deletions

View File

@ -2,12 +2,11 @@
let FORCE_REBUILD=0
KERNEL_REBUILD_ARGS=""
GENKERNEL_ARGS="--no-clean --no-mrproper"
[ -f /etc/gentoo-upgrade.conf ] && source /etc/gentoo-upgrade.conf
# available parameters
eval set -- "`getopt -o h,q,g: --long help,force-rebuild,mrproper,quiet,genkernel-args: -- \"$@\"`"
eval set -- "`getopt -o h,q --long help,force-rebuild,mrproper,quiet -- \"$@\"`"
while true ; do
case "$1" in
@ -16,7 +15,6 @@ while true ; do
echo "Keys:"
echo -e "-h, --help\t\t\tShow this help and exit."
echo -e "--force-rebuild\t\t\tForce to rebuild kernel even if no new versions found."
echo -e "-g,--genkernel-args\t\tPass arguments to genkernel."
echo -e "--mrproper\t\t\tClean kernel sources before rebuild."
echo -e "-q, --quiet\t\t\tMake kernel configuration non-interactive."
echo
@ -25,7 +23,6 @@ while true ; do
exit 0
;;
--force-rebuild) let FORCE_REBUILD=1 ; shift ;;
-g|--genkernel-args) GENKERNEL_ARGS="$GENKERNEL_ARGS $2" ; shift 2 ;;
--mrproper) KERNEL_REBUILD_ARGS="$KERNEL_REBUILD_ARGS --mrproper" ; shift ;;
-q|--quiet) KERNEL_REBUILD_ARGS="$KERNEL_REBUILD_ARGS --silent" ; shift ;;
--) shift ; break ;;
@ -57,26 +54,6 @@ kernel-clean.sh
vmlinuz_file=/boot/`echo $new_kernel | sed 's~^linux~vmlinuz~'`
[ "" == "$vmlinuz_file" ] && echo "vmlinuz_file == \"\"" && exit -1
# genkernel or kernel-rebuild ?
if [ `which genkernel 2>/dev/null` ]; then
[ -f /proc/config.gz ] && zcat /proc/config.gz >/usr/src/linux/.config
[ 0 -ne $? ] && echo "zcat /proc/config.gz >/usr/src/linux.config failed ;-( =======" && exit -1
genkernel $GENKERNEL_ARGS all
[ 0 -ne $? ] && echo "genkernel $GENKERNEL_ARGS all failed ;-( =======" && exit -1
[ -f /boot/grub/grub.conf ] && \
sed -i "s~\/boot\/vmlinuz-[0-9][^ ]*~\/boot\/vmlinuz-$REVISION~g;
s~\/boot\/initramfs-[0-9][^ ]*~\/boot\/initramfs-$REVISION.img~g" \
/boot/grub/grub.conf
[ -f /boot/grub2/grub.cfg ] && grub2-mkconfig -o /boot/grub2/grub.cfg
echo "--------- Rebuilding kernel modules ---------"
emerge -1v @module-rebuild
[ 0 -ne $? ] && echo "Upgrading kernel modules failed ;-(" && exit -1
else # using kernel-rebuild
if [[ ! -f "$vmlinuz_file" || 1 -eq $FORCE_REBUILD ]]; then
kernel-rebuild.sh $KERNEL_REBUILD_ARGS
[ 0 -ne $? ] && echo "kernel-rebuild.sh $KERNEL_REBUILD_ARGS failed" && exit -1
@ -90,7 +67,6 @@ else # using kernel-rebuild
[ 0 -ne $? ] && echo "mount -o remount,ro -force $fs failed ;-( =======" && exit -1
fi
done
fi
exit 0

View File

@ -4,6 +4,8 @@ SILENT=false
MRPROPER=false
NICE_CMD="nice -n 19 ionice -c2"
CONFIG_FILE=/proc/config.gz
GENKERNEL_ARGS="--oldconfig"
USE_GENKERNEL=true
[ -f /etc/gentoo-upgrade.conf ] && source /etc/gentoo-upgrade.conf
@ -32,6 +34,10 @@ while true ; do
esac
done
[ "$SILENT" != "true" ] && GENKERNEL_ARGS="$GENKERNEL_ARGS --menuconfig"
[ "$MRPROPER" == "true" ] && GENKERNEL_ARGS="$GENKERNEL_ARGS --mrproper"
which genkernel &>/dev/null || USE_GENKERNEL=false
# remounting file systems ro->rw
for fs in $RW_REMOUNT; do
if [[ "$fs" =~ ^/+usr/*$ || "$fs" =~ ^/+boot/*$ ]]; then
@ -52,13 +58,8 @@ echo CONFIG_FILE=$CONFIG_FILE
zcat $CONFIG_FILE >.config 2>/dev/null || cat $CONFIG_FILE >.config
[ "$?" != "0" ] && echo "$CONFIG_FILE doesn't exist or /usr mounted as read-only" && exit -1
if [ true == "$SILENT" ]; then
yes "" | make silentoldconfig
[ "$?" != "0" ] && echo "======= yes \"\" | make silentoldconfig failed ;-( =======" && exit -1
else
TERM=screen make MENUCONFIG_MODE=single_menu MENUCONFIG_COLOR=mono menuconfig
[ "$?" != "0" ] && echo "======= make menuconfig failed ;-( =======" && exit -1
fi
# aufs3 patches
if [[ `qlist -IC sys-fs/aufs3 | wc -l` != 0 ]]; then
@ -68,8 +69,16 @@ if [[ `qlist -IC sys-fs/aufs3 | wc -l` != 0 ]]; then
[ 0 -ne $? ] && echo "emerge -1 sys-fs/aufs3 failed ;-(" && exit -1
fi
# disable distcc for -march=native -mtune=native
if [ "$USE_GENKERNEL" == "true" ]
genkernel $GENKERNEL_ARGS all
[ 0 -ne $? ] && echo "genkernel $GENKERNEL_ARGS all failed ;-( =======" && exit -1
else
if [ true != "$SILENT" ]; then
TERM=screen make MENUCONFIG_MODE=single_menu MENUCONFIG_COLOR=mono menuconfig
[ "$?" != "0" ] && echo "======= make menuconfig failed ;-( =======" && exit -1
fi
# disable distcc for -march=native -mtune=native
grep 'CONFIG_X86_MARCH_NATIVE=y' .config &>/dev/null
jobs=$((`getconf _NPROCESSORS_ONLN`+1))
if [[ "$?" == 0 ]]; then
@ -87,6 +96,7 @@ $NICE_CMD make modules_install
REVISION=`cat /usr/src/linux/include/config/kernel.release`
which dracut &>/dev/null && $NICE_CMD dracut --hostonly --force /boot/initramfs-$REVISION.img $REVISION
fi
[ -f /boot/grub/grub.conf ] && \
sed -i "s~\/boot\/vmlinuz-[0-9][^ ]*~\/boot\/vmlinuz-$REVISION~g;