-q|-quiet flag for gentoo-upgrade added

This commit is contained in:
Kolan Sh 2013-01-13 16:26:42 +04:00
parent 7893de645a
commit 578180c563
2 changed files with 16 additions and 9 deletions

View File

@ -2,12 +2,13 @@
STAGE=0 STAGE=0
NICE_CMD="nice -n 19 ionice -c2" NICE_CMD="nice -n 19 ionice -c2"
let QUIET=0
source /etc/make.conf source /etc/make.conf
[ -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,stage: -- \"$@\"`" eval set -- "`getopt -o hs:q --long help,stage:,quiet -- \"$@\"`"
while true ; do while true ; do
case "$1" in case "$1" in
@ -15,13 +16,15 @@ while true ; do
echo "Usage: upgrade-gentoo.sh [keys]..." echo "Usage: upgrade-gentoo.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 "-s [STAGE], --stage [STAGE]\t Go to STAGE upgrade level." echo -e "-s [STAGE], --stage [STAGE]\tGo to STAGE upgrade level."
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
;; ;;
-s|--stage) STAGE=$2 ; shift 2 ;; -s|--stage) STAGE=$2 ; shift 2 ;;
-q|--quiet) let QUIET=1 ; shift ;;
--) shift ; break ;; --) shift ; break ;;
*) echo "Internal error!" ; exit -1 ;; *) echo "Internal error!" ; exit -1 ;;
esac esac
@ -517,14 +520,16 @@ let STAGE_CNT++
if [ $STAGE_CNT -eq $STAGE ]; then if [ $STAGE_CNT -eq $STAGE ]; then
echo "======= STAGE $STAGE: Upgrade kernel =======" echo "======= STAGE $STAGE: Upgrade kernel ======="
[ 1 -eq $QUIET ] && KERNEL_GETLAST_OPTS="$KERNEL_GETLAST_OPTS --quiet"
if [ -f /etc/portage/need_kernel_rebuild ]; then if [ -f /etc/portage/need_kernel_rebuild ]; then
kernel-getlast.sh --force-rebuild --mrproper kernel-getlast.sh --force-rebuild --mrproper $KERNEL_GETLAST_OPTS
[ 0 -ne $? ] && echo "Stage $STAGE: kernel-getlast.sh --force-rebuild failed ;-( =======" && exit $STAGE [ 0 -ne $? ] && echo "Stage $STAGE: kernel-getlast.sh --force-rebuild $KERNEL_GETLAST_OPTS 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
else else
kernel-getlast.sh kernel-getlast.sh $KERNEL_GETLAST_OPTS
[ 0 -ne $? ] && echo "Stage $STAGE: kernel-getlast.sh failed ;-( =======" && exit $STAGE [ 0 -ne $? ] && echo "Stage $STAGE: kernel-getlast.sh $KERNEL_GETLAST_OPTS failed ;-( =======" && exit $STAGE
fi fi
let STAGE++ let STAGE++

View File

@ -4,7 +4,7 @@ let FORCE_REBUILD=0
KERNEL_REBUILD_ARGS="" KERNEL_REBUILD_ARGS=""
# available parameters # available parameters
eval set -- "`getopt -o h --long help,force-rebuild,mrproper -- \"$@\"`" eval set -- "`getopt -o h,q --long help,force-rebuild,mrproper,quiet -- \"$@\"`"
while true ; do while true ; do
case "$1" in case "$1" in
@ -14,6 +14,7 @@ while true ; do
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 -e "--mrproper\t\t\tClean kernel sources before rebuild."
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>"
@ -21,6 +22,7 @@ while true ; do
;; ;;
--force-rebuild) let FORCE_REBUILD=1 ; shift ;; --force-rebuild) let FORCE_REBUILD=1 ; shift ;;
--mrproper) KERNEL_REBUILD_ARGS="$KERNEL_REBUILD_ARGS --mrproper" ; shift ;; --mrproper) KERNEL_REBUILD_ARGS="$KERNEL_REBUILD_ARGS --mrproper" ; shift ;;
-q|--quiet) KERNEL_REBUILD_ARGS="$KERNEL_REBUILD_ARGS --silent" ; shift ;;
--) shift ; break ;; --) shift ; break ;;
*) echo "Internal error!" ; exit -1 ;; *) echo "Internal error!" ; exit -1 ;;
esac esac