kernel-{geltast,rebuild}: updated
This commit is contained in:
parent
95bcb8e9ae
commit
665f96f07f
@ -2,35 +2,32 @@
|
|||||||
|
|
||||||
let FORCE_REBUILD=0
|
let FORCE_REBUILD=0
|
||||||
KERNEL_REBUILD_ARGS=""
|
KERNEL_REBUILD_ARGS=""
|
||||||
GENKERNEL_ARGS="--no-clean --no-mrproper"
|
|
||||||
|
|
||||||
[ -f /etc/gentoo-upgrade.conf ] && source /etc/gentoo-upgrade.conf
|
[ -f /etc/gentoo-upgrade.conf ] && source /etc/gentoo-upgrade.conf
|
||||||
|
|
||||||
# available parameters
|
# 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
|
while true ; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h|--help)
|
-h|--help)
|
||||||
echo "Usage: kernel-getlast.sh [keys]..."
|
echo "Usage: kernel-getlast.sh [keys]..."
|
||||||
echo "Keys:"
|
echo "Keys:"
|
||||||
echo -e "-h, --help\t\t\tShow this help and exit."
|
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 "--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 "--mrproper\t\t\tClean kernel sources before rebuild."
|
echo -e "-q, --quiet\t\t\tMake kernel configuration non-interactive."
|
||||||
echo -e "-q, --quiet\t\t\tMake kernel configuration non-interactive."
|
echo
|
||||||
echo
|
echo -e "This program works on any GNU/Linux with GNU Baurne's shell"
|
||||||
echo -e "This program works on any GNU/Linux with GNU Baurne's shell"
|
echo -e "Report bugs to <mecareful@gmail.com>"
|
||||||
echo -e "Report bugs to <mecareful@gmail.com>"
|
exit 0
|
||||||
exit 0
|
;;
|
||||||
;;
|
--force-rebuild) let FORCE_REBUILD=1 ; shift ;;
|
||||||
--force-rebuild) let FORCE_REBUILD=1 ; shift ;;
|
--mrproper) KERNEL_REBUILD_ARGS="$KERNEL_REBUILD_ARGS --mrproper" ; shift ;;
|
||||||
-g|--genkernel-args) GENKERNEL_ARGS="$GENKERNEL_ARGS $2" ; shift 2 ;;
|
-q|--quiet) KERNEL_REBUILD_ARGS="$KERNEL_REBUILD_ARGS --silent" ; shift ;;
|
||||||
--mrproper) KERNEL_REBUILD_ARGS="$KERNEL_REBUILD_ARGS --mrproper" ; shift ;;
|
--) shift ; break ;;
|
||||||
-q|--quiet) KERNEL_REBUILD_ARGS="$KERNEL_REBUILD_ARGS --silent" ; shift ;;
|
*) echo "Internal error!" ; exit -1 ;;
|
||||||
--) shift ; break ;;
|
esac
|
||||||
*) echo "Internal error!" ; exit -1 ;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
|
||||||
kernel_regex=`kernel-config list | grep \* | cut -d" " -f6 | sed 's~[0-9]*\.[0-9]*\.[0-9]*~[0-9]*\.[0-9]*\.[0-9]*~ ; s~-r[0-9]*$~~; s~$~\\\(-r[0-9]\\\)\\\?~'`
|
kernel_regex=`kernel-config list | grep \* | cut -d" " -f6 | sed 's~[0-9]*\.[0-9]*\.[0-9]*~[0-9]*\.[0-9]*\.[0-9]*~ ; s~-r[0-9]*$~~; s~$~\\\(-r[0-9]\\\)\\\?~'`
|
||||||
@ -41,11 +38,11 @@ new_kernel=`kernel-config list | cut -d" " -f6 | grep ^$kernel_regex$ | sort -V
|
|||||||
|
|
||||||
# remounting file systems ro->rw
|
# remounting file systems ro->rw
|
||||||
for fs in $RW_REMOUNT; do
|
for fs in $RW_REMOUNT; do
|
||||||
if [[ "$fs" =~ ^/+usr/*$ || "$fs" =~ ^/+boot/*$ ]]; then
|
if [[ "$fs" =~ ^/+usr/*$ || "$fs" =~ ^/+boot/*$ ]]; then
|
||||||
echo "remounting $fs -> rw"
|
echo "remounting $fs -> rw"
|
||||||
mount -o remount,rw $fs
|
mount -o remount,rw $fs
|
||||||
[ 0 -ne $? ] && echo "mount -o remount,rw $fs failed ;-( =======" && exit -1
|
[ 0 -ne $? ] && echo "mount -o remount,rw $fs failed ;-( =======" && exit -1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
kernel-config set $new_kernel
|
kernel-config set $new_kernel
|
||||||
@ -57,40 +54,19 @@ kernel-clean.sh
|
|||||||
vmlinuz_file=/boot/`echo $new_kernel | sed 's~^linux~vmlinuz~'`
|
vmlinuz_file=/boot/`echo $new_kernel | sed 's~^linux~vmlinuz~'`
|
||||||
[ "" == "$vmlinuz_file" ] && echo "vmlinuz_file == \"\"" && exit -1
|
[ "" == "$vmlinuz_file" ] && echo "vmlinuz_file == \"\"" && exit -1
|
||||||
|
|
||||||
# genkernel or kernel-rebuild ?
|
if [[ ! -f "$vmlinuz_file" || 1 -eq $FORCE_REBUILD ]]; then
|
||||||
if [ `which genkernel 2>/dev/null` ]; then
|
kernel-rebuild.sh $KERNEL_REBUILD_ARGS
|
||||||
[ -f /proc/config.gz ] && zcat /proc/config.gz >/usr/src/linux/.config
|
[ 0 -ne $? ] && echo "kernel-rebuild.sh $KERNEL_REBUILD_ARGS failed" && exit -1
|
||||||
[ 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
|
|
||||||
fi
|
|
||||||
|
|
||||||
# remounting file systems rw->ro
|
|
||||||
for fs in $RO_REMOUNT; do
|
|
||||||
if [[ "$fs" =~ ^/+usr/*$ || "$fs" =~ ^/+boot/*$ ]]; then
|
|
||||||
echo "remounting $fs -> ro"
|
|
||||||
mount -o remount,ro -force $fs
|
|
||||||
[ 0 -ne $? ] && echo "mount -o remount,ro -force $fs failed ;-( =======" && exit -1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# remounting file systems rw->ro
|
||||||
|
for fs in $RO_REMOUNT; do
|
||||||
|
if [[ "$fs" =~ ^/+usr/*$ || "$fs" =~ ^/+boot/*$ ]]; then
|
||||||
|
echo "remounting $fs -> ro"
|
||||||
|
mount -o remount,ro -force $fs
|
||||||
|
[ 0 -ne $? ] && echo "mount -o remount,ro -force $fs failed ;-( =======" && exit -1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ SILENT=false
|
|||||||
MRPROPER=false
|
MRPROPER=false
|
||||||
NICE_CMD="nice -n 19 ionice -c2"
|
NICE_CMD="nice -n 19 ionice -c2"
|
||||||
CONFIG_FILE=/proc/config.gz
|
CONFIG_FILE=/proc/config.gz
|
||||||
|
GENKERNEL_ARGS="--oldconfig"
|
||||||
|
USE_GENKERNEL=true
|
||||||
|
|
||||||
[ -f /etc/gentoo-upgrade.conf ] && source /etc/gentoo-upgrade.conf
|
[ -f /etc/gentoo-upgrade.conf ] && source /etc/gentoo-upgrade.conf
|
||||||
|
|
||||||
@ -11,83 +13,91 @@ CONFIG_FILE=/proc/config.gz
|
|||||||
eval set -- "`getopt -o hsc: --long help,silent,mrproper,config: -- \"$@\"`"
|
eval set -- "`getopt -o hsc: --long help,silent,mrproper,config: -- \"$@\"`"
|
||||||
|
|
||||||
while true ; do
|
while true ; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h|--help)
|
-h|--help)
|
||||||
echo "Usage: kernel-rebuild.sh [keys]..."
|
echo "Usage: kernel-rebuild.sh [keys]..."
|
||||||
echo "Keys:"
|
echo "Keys:"
|
||||||
echo -e "-h, --help\t\tShow this help and exit."
|
echo -e "-h, --help\t\tShow this help and exit."
|
||||||
echo -e "-s, --silent\t\tMake with silentoldconfig."
|
echo -e "-s, --silent\t\tMake with silentoldconfig."
|
||||||
echo -e "--mrproper\t\tClean kernel sources before rebuild."
|
echo -e "--mrproper\t\tClean kernel sources before rebuild."
|
||||||
echo -e "-c, --config [CONFIG]\tPath to custom kernel config."
|
echo -e "-c, --config [CONFIG]\tPath to custom kernel config."
|
||||||
echo
|
echo
|
||||||
echo -e "This program works on any GNU/Linux with GNU Baurne's shell"
|
echo -e "This program works on any GNU/Linux with GNU Baurne's shell"
|
||||||
echo -e "Report bugs to <mecareful@gmail.com>"
|
echo -e "Report bugs to <mecareful@gmail.com>"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-s|--silent) SILENT=true ; shift ;;
|
-s|--silent) SILENT=true ; shift ;;
|
||||||
--mrproper) MRPROPER=true ; shift ;;
|
--mrproper) MRPROPER=true ; shift ;;
|
||||||
-c|--config) CONFIG_FILE=$2 ; shift 2 ;;
|
-c|--config) CONFIG_FILE=$2 ; shift 2 ;;
|
||||||
--) shift ; break ;;
|
--) shift ; break ;;
|
||||||
*) echo "Internal error!" ; exit -1 ;;
|
*) echo "Internal error!" ; exit -1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
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
|
# remounting file systems ro->rw
|
||||||
for fs in $RW_REMOUNT; do
|
for fs in $RW_REMOUNT; do
|
||||||
if [[ "$fs" =~ ^/+usr/*$ || "$fs" =~ ^/+boot/*$ ]]; then
|
if [[ "$fs" =~ ^/+usr/*$ || "$fs" =~ ^/+boot/*$ ]]; then
|
||||||
echo "remounting $fs -> rw"
|
echo "remounting $fs -> rw"
|
||||||
mount -o remount,rw $fs
|
mount -o remount,rw $fs
|
||||||
[ 0 -ne $? ] && echo "mount -o remount,rw $fs failed ;-( =======" && exit -1
|
[ 0 -ne $? ] && echo "mount -o remount,rw $fs failed ;-( =======" && exit -1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
cd /usr/src/linux
|
cd /usr/src/linux
|
||||||
[ "$?" != "0" ] && echo /usr/src/linux doesn\'t exist && exit -1
|
[ "$?" != "0" ] && echo /usr/src/linux doesn\'t exist && exit -1
|
||||||
|
|
||||||
if [ true == "$MRPROPER" ]; then
|
if [ true == "$MRPROPER" ]; then
|
||||||
make clean && make mrproper
|
make clean && make mrproper
|
||||||
[ 0 -ne $? ] && echo "make clean && make mrproper failed ;-( =======" && exit -1
|
[ 0 -ne $? ] && echo "make clean && make mrproper failed ;-( =======" && exit -1
|
||||||
fi
|
fi
|
||||||
echo CONFIG_FILE=$CONFIG_FILE
|
echo CONFIG_FILE=$CONFIG_FILE
|
||||||
zcat $CONFIG_FILE >.config 2>/dev/null || cat $CONFIG_FILE >.config
|
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
|
[ "$?" != "0" ] && echo "$CONFIG_FILE doesn't exist or /usr mounted as read-only" && exit -1
|
||||||
|
|
||||||
if [ true == "$SILENT" ]; then
|
yes "" | make silentoldconfig
|
||||||
yes "" | make silentoldconfig
|
[ "$?" != "0" ] && echo "======= yes \"\" | make silentoldconfig failed ;-( =======" && exit -1
|
||||||
[ "$?" != "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
|
# aufs3 patches
|
||||||
if [[ `qlist -IC sys-fs/aufs3 | wc -l` != 0 ]]; then
|
if [[ `qlist -IC sys-fs/aufs3 | wc -l` != 0 ]]; then
|
||||||
make modules_prepare
|
make modules_prepare
|
||||||
[ 0 -ne $? ] && echo "make modules_prepare failed ;-(" && exit -1
|
[ 0 -ne $? ] && echo "make modules_prepare failed ;-(" && exit -1
|
||||||
emerge -1 sys-fs/aufs3
|
emerge -1 sys-fs/aufs3
|
||||||
[ 0 -ne $? ] && echo "emerge -1 sys-fs/aufs3 failed ;-(" && exit -1
|
[ 0 -ne $? ] && echo "emerge -1 sys-fs/aufs3 failed ;-(" && exit -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# disable distcc for -march=native -mtune=native
|
if [ "$USE_GENKERNEL" == "true" ]
|
||||||
|
genkernel $GENKERNEL_ARGS all
|
||||||
grep 'CONFIG_X86_MARCH_NATIVE=y' .config &>/dev/null
|
[ 0 -ne $? ] && echo "genkernel $GENKERNEL_ARGS all failed ;-( =======" && exit -1
|
||||||
jobs=$((`getconf _NPROCESSORS_ONLN`+1))
|
|
||||||
if [[ "$?" == 0 ]]; then
|
|
||||||
$NICE_CMD make -j$jobs
|
|
||||||
[ 0 -ne $? ] && echo "Kernel build failed ;-(" && exit -1
|
|
||||||
else
|
else
|
||||||
# pump make -j$((jobs*3)) || make -j$jobs
|
if [ true != "$SILENT" ]; then
|
||||||
$NICE_CMD make -j$jobs
|
TERM=screen make MENUCONFIG_MODE=single_menu MENUCONFIG_COLOR=mono menuconfig
|
||||||
[ 0 -ne $? ] && echo "Kernel build failed ;-(" && exit -1
|
[ "$?" != "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
|
||||||
|
$NICE_CMD make -j$jobs
|
||||||
|
[ 0 -ne $? ] && echo "Kernel build failed ;-(" && exit -1
|
||||||
|
else
|
||||||
|
# pump make -j$((jobs*3)) || make -j$jobs
|
||||||
|
$NICE_CMD make -j$jobs
|
||||||
|
[ 0 -ne $? ] && echo "Kernel build failed ;-(" && exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
$NICE_CMD make install
|
||||||
|
$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
|
fi
|
||||||
|
|
||||||
$NICE_CMD make install
|
|
||||||
$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
|
|
||||||
|
|
||||||
[ -f /boot/grub/grub.conf ] && \
|
[ -f /boot/grub/grub.conf ] && \
|
||||||
sed -i "s~\/boot\/vmlinuz-[0-9][^ ]*~\/boot\/vmlinuz-$REVISION~g;
|
sed -i "s~\/boot\/vmlinuz-[0-9][^ ]*~\/boot\/vmlinuz-$REVISION~g;
|
||||||
s~\/boot\/initramfs-[0-9][^ ]*~\/boot\/initramfs-$REVISION.img~g" \
|
s~\/boot\/initramfs-[0-9][^ ]*~\/boot\/initramfs-$REVISION.img~g" \
|
||||||
@ -103,11 +113,11 @@ cd $pwdtmp
|
|||||||
|
|
||||||
# remounting file systems rw->ro
|
# remounting file systems rw->ro
|
||||||
for fs in $RO_REMOUNT; do
|
for fs in $RO_REMOUNT; do
|
||||||
if [[ "$fs" =~ ^/+usr/*$ || "$fs" =~ ^/+boot/*$ ]]; then
|
if [[ "$fs" =~ ^/+usr/*$ || "$fs" =~ ^/+boot/*$ ]]; then
|
||||||
echo "remounting $fs -> ro"
|
echo "remounting $fs -> ro"
|
||||||
mount -f -o remount,ro -force $fs
|
mount -f -o remount,ro -force $fs
|
||||||
[ 0 -ne $? ] && echo "mount -f -o remount,ro -force $fs failed ;-( =======" && exit -1
|
[ 0 -ne $? ] && echo "mount -f -o remount,ro -force $fs failed ;-( =======" && exit -1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user