Clean kernel sources when rebuilding with new compiler.

This commit is contained in:
Kolan Sh 2012-12-18 21:42:33 +04:00
parent 370c5b7044
commit 54fd9a7e71
3 changed files with 18 additions and 6 deletions

View File

@ -476,7 +476,7 @@ if [ $STAGE_CNT -eq $STAGE ]; then
echo "======= STAGE $STAGE: Upgrade kernel =======" echo "======= STAGE $STAGE: Upgrade kernel ======="
if [ -f /etc/portage/need_kernel_rebuild ]; then if [ -f /etc/portage/need_kernel_rebuild ]; then
kernel-getlast.sh --force-rebuild kernel-getlast.sh --force-rebuild --mrproper
[ 0 -ne $? ] && echo "Stage $STAGE: kernel-getlast.sh --force-rebuild failed ;-( =======" && exit $STAGE [ 0 -ne $? ] && echo "Stage $STAGE: kernel-getlast.sh --force-rebuild failed ;-( =======" && exit $STAGE
rm /etc/portage/need_kernel_rebuild rm /etc/portage/need_kernel_rebuild
[ 0 -ne $? ] && echo "Stage $STAGE: cann't remove /etc/portage/need_kernel_rebuild ;-( =======" && exit $STAGE [ 0 -ne $? ] && echo "Stage $STAGE: cann't remove /etc/portage/need_kernel_rebuild ;-( =======" && exit $STAGE

View File

@ -1,9 +1,10 @@
#!/bin/bash #!/bin/bash
let FORCE_REBUILD=0 let FORCE_REBUILD=0
KERNEL_REBUILD_ARGS=""
# available parameters # available parameters
eval set -- "`getopt -o h --long help,force-rebuild -- \"$@\"`" eval set -- "`getopt -o h --long help,force-rebuild,mrproper -- \"$@\"`"
while true ; do while true ; do
case "$1" in case "$1" in
@ -12,12 +13,14 @@ while true ; do
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 "--mrproper\t\t\tClean kernel sources before rebuild."
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 1 ;; --force-rebuild) let FORCE_REBUILD=1 ; shift ;;
--mrproper) KERNEL_REBUILD_ARGS="$KERNEL_REBUILD_ARGS --mrproper" ; shift ;;
--) shift ; break ;; --) shift ; break ;;
*) echo "Internal error!" ; exit -1 ;; *) echo "Internal error!" ; exit -1 ;;
esac esac
@ -47,9 +50,10 @@ 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
if [[ ! -f "$vmlinuz_file" || 1 -eq $FORCE_REBUILD ]]; then if [[ ! -f "$vmlinuz_file" || 1 -eq $FORCE_REBUILD ]]; then
kernel-rebuild.sh kernel-rebuild.sh $KERNEL_REBUILD_ARGS
[ 0 -ne $? ] && echo "kernel-rebuild.sh failed" && exit -1 [ 0 -ne $? ] && echo "kernel-rebuild.sh $KERNEL_REBUILD_ARGS failed" && exit -1
fi fi
# remounting file systems rw->ro # remounting file systems rw->ro

View File

@ -1,12 +1,13 @@
#!/bin/bash #!/bin/bash
SILENT=false SILENT=false
MRPROPER=false
NICE_CMD="nice -n 19 ionice -c2" NICE_CMD="nice -n 19 ionice -c2"
[ -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 hs --long help,silent -- \"$@\"`" eval set -- "`getopt -o hs --long help,silent,mrproper -- \"$@\"`"
while true ; do while true ; do
case "$1" in case "$1" in
@ -15,12 +16,14 @@ while true ; do
echo "Keys:" echo "Keys:"
echo -e "-h, --help\tShow this help and exit." echo -e "-h, --help\tShow this help and exit."
echo -e "-s, --silent \tMake with silentoldconfig." echo -e "-s, --silent \tMake with silentoldconfig."
echo -e "--mrproper\tClean kernel sources before rebuild."
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 ;;
--) shift ; break ;; --) shift ; break ;;
*) echo "Internal error!" ; exit -1 ;; *) echo "Internal error!" ; exit -1 ;;
esac esac
@ -41,6 +44,11 @@ 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
make clean && make mrproper
[ 0 -ne $? ] && echo "make clean && make mrproper failed ;-( =======" && exit -1
fi
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