Commit 9f3654f1 authored by Vitaly Lipatov's avatar Vitaly Lipatov

add new mode to loginhsh: -a for run from rpmbsh

fix arg handling in loginhsh
parent 881a2f43
...@@ -32,17 +32,20 @@ phelp() ...@@ -32,17 +32,20 @@ phelp()
echog " -i - initialize hasher" echog " -i - initialize hasher"
echog " -c - cleanup hasher" echog " -c - cleanup hasher"
echog " -o - log in as root user" echog " -o - log in as root user"
echog " -t - use test hasher dir" echog " -t - use test hasher dir (different to build hasher)"
echog " -r - remote login to hasher"
echog " -M?? - branch name" echog " -M?? - branch name"
echog "Extra options:"
echog " -a - auto test mode for post myhsh build checking"
echog " -r - remote login to hasher"
} }
while getopts :chito opt; do while getopts :chitoa opt; do
case $opt in case $opt in
h) phelp; exit 0;; h) phelp; exit 0;;
t) TESTMODE=1 ;; t) TESTMODE=1 ;;
i) INITIALIZE=1 ;; i) INITIALIZE=1 ;;
c) CLEANUP=1 ;; c) CLEANUP=1 ;;
a) AUTOMODE=1 ;;
r) REMOTE=1 ;; r) REMOTE=1 ;;
o) ROOTER="--rooter" ;; o) ROOTER="--rooter" ;;
+?) echog "$name: options should not be preceded by a '+'." 1>&2; exit 2;; +?) echog "$name: options should not be preceded by a '+'." 1>&2; exit 2;;
...@@ -52,7 +55,7 @@ while getopts :chito opt; do ...@@ -52,7 +55,7 @@ while getopts :chito opt; do
done done
# remove args that were options # remove args that were options
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
shift $((OPTIND - 1)) shift $((OPTIND - 1))
fi fi
...@@ -61,34 +64,33 @@ LISTRPMARGS=$@ ...@@ -61,34 +64,33 @@ LISTRPMARGS=$@
parse_cmd_pre "$@" -- parse_cmd_pre "$@" --
set_hasherdir mygetopts $LISTARGS
[ -n "$TESTMODE" ] && HASHERDIR=$HASHERDIR-test
if [ -n "$TESTMODE" ] || [ -n "$AUTOMODE" ] ; then
HASHERDIR=$HASHERDIR-test
fi
# export OURAPTCONF with temp. file contains correct path to sources.list # export OURAPTCONF with temp. file contains correct path to sources.list
prepare_aptconfig prepare_aptconfig
HASHERARG="$HASHERARG --apt-config=$OURAPTCONF --target $DEFAULTARCH" HASHERARG="$HASHERARG --apt-config=$OURAPTCONF --target $DEFAULTARCH"
mygetopts $LISTARGS set_hasherdir
if [ -n "$TESTMODE" ] || [ -n "$AUTOMODE" ] ; then
HASHERDIR=$HASHERDIR-test
fi
if [ -n "$REMOTE" ] ; then if [ -n "$REMOTE" ] ; then
check_key check_key
test -n "$BUILDSERVER" || fatal "Please set BUILDSERVER in config file" test -n "$BUILDSERVER" || fatal "Please set BUILDSERVER in config file"
ssh -t $BUILDSERVER loginhsh ${SAVEOPT/-r/} ssh -t $BUILDSERVER loginhsh ${SAVEOPT/-r/}
exit 0 exit
fi fi
if [ "$CLEANUP" = "1" ]; then if [ "$CLEANUP" = "1" ] ; then
echog "Cleanup $HASHERDIR ..." echog "Cleanup hasher in $HASHERDIR..."
$HSH --cleanup-only $HASHERDIR $HASHERARG || fatal "cleanup" $HSH --cleanup-only $HASHERDIR $HASHERARG || fatal "cleanup"
exit 0 exit
fi fi
if [ ! -d $HASHERDIR -o "$INITIALIZE" = "1" ]; then if [ ! -d $HASHERDIR ] || [ "$INITIALIZE" = "1" ] || [ -n "$AUTOMODE" ]; then
echog "Initialize $HASHERDIR ..." echog "Initialize $HASHERDIR ..."
mkdir -p $HASHERDIR && $HSH $HASHERARG --initroot-only $HASHERDIR || fatal "mkdir" mkdir -p $HASHERDIR && $HSH $HASHERARG --initroot-only $HASHERDIR || fatal "mkdir"
fi fi
...@@ -107,11 +109,14 @@ else ...@@ -107,11 +109,14 @@ else
UTILPKG="$UTILPKG etersoft-build-utils" UTILPKG="$UTILPKG etersoft-build-utils"
fi fi
$HSH-install $HASHERDIR --wait-lock $UTILPKG $LISTRPMARGS $LISTNAMES || fatal "Error with install" $HSH-install $HASHERDIR --wait-lock $UTILPKG $LISTRPMARGS $LISTNAMES || fatal "Error with install"
echog "You are in hasher shell" echog "You are in hasher shell"
$HSH-shell $HASHERDIR $SHELLHASHERARG $ROOTER -Y --shell $HSH-shell $HASHERDIR $SHELLHASHERARG $ROOTER -Y --shell
if [ -n "$TESTMODE" ] ; then
if [ -n "$AUTOMODE" ] ; then
# FIXME: do not remove on x86_64
echo "Remove package for test preun scripts" echo "Remove package for test preun scripts"
$HSH-run --rooter $HASHERDIR -- rpm -e $(drop_pkg_extensions $LISTNAMES) $HSH-run --rooter $HASHERDIR -- rpm -e $(drop_pkg_extensions $LISTNAMES)
echo "Cleanup hasher..." echo "Cleanup hasher in $HASHERDIR..."
$HSH --cleanup-only $HASHERDIR $HSH --cleanup-only $HASHERDIR
fi fi
...@@ -99,7 +99,7 @@ do ...@@ -99,7 +99,7 @@ do
# Note: hasher is already use renice for low priority # Note: hasher is already use renice for low priority
($HSH $HASHERARG --build-args "$BUILDARGS" -- $HASHERDIR $i 2>&1 || touch $LOGFILE.failed) | tee -a $LOGFILE ($HSH $HASHERARG --build-args "$BUILDARGS" -- $HASHERDIR $i 2>&1 || touch $LOGFILE.failed) | tee -a $LOGFILE
test -L $HASHERDIR/BUILD || ln -s chroot/usr/src/RPM/BUILD $HASHERDIR/ test -L $HASHERDIR/BUILD || ln -s chroot/usr/src/RPM/BUILD $HASHERDIR/
if [ -f $LOGFILE.failed ] ; then if [ -f $LOGFILE.failed ] ; then
RESULT=1 RESULT=1
break break
fi fi
...@@ -122,8 +122,6 @@ fi ...@@ -122,8 +122,6 @@ fi
print_list $LISTBUILTSH print_list $LISTBUILTSH
echo echo
if [ "$RESULT" = "0" -a -n "$TESTINSTALL" ] ; then if [ "$RESULT" = "0" -a -n "$TESTINSTALL" ] ; then
# test install (only for last package in list) # test install (only for last package in list)
# some key for build hasher from scratch # some key for build hasher from scratch
...@@ -132,7 +130,7 @@ if [ "$RESULT" = "0" -a -n "$TESTINSTALL" ] ; then ...@@ -132,7 +130,7 @@ if [ "$RESULT" = "0" -a -n "$TESTINSTALL" ] ; then
test -n "$BINPACKAGES" || fatal "Can't find binary packages for $LASTPACKAGE in `ls -l $HASHERDIR/repo/$DEFAULTARCH/RPMS.hasher`" test -n "$BINPACKAGES" || fatal "Can't find binary packages for $LASTPACKAGE in `ls -l $HASHERDIR/repo/$DEFAULTARCH/RPMS.hasher`"
echo "List: $BINPACKAGES" echo "List: $BINPACKAGES"
echo echo
$ETERBUILDBIN/loginhsh -t -i $MENVARG $BINPACKAGES || exit 1 exec $ETERBUILDBIN/loginhsh -a $MENVARG $BINPACKAGES
fi fi
exit $RESULT exit $RESULT
...@@ -112,14 +112,14 @@ else ...@@ -112,14 +112,14 @@ else
echo "-------------------------------" echo "-------------------------------"
fi fi
# make src.rpm if build OK and we have options for rpmbs
RPMBSARGS=$(drop_args "$LISTRPMARGS" i c l) RPMBSARGS=$(drop_args "$LISTRPMARGS" i c l)
if [ ! "$RESULT" = "0" ] || [ -z "$RPMBSARGS" ]; then if [ ! "$RESULT" = "0" ] || [ -z "$RPMBSARGS" ]; then
exit $RESULT exit $RESULT
fi fi
# make src.rpm if build OK and we have options for rpmbs
is_gear $SPECDIR && TSKLIST=$LISTNAMES || TSKLIST=$LISTBUILT is_gear $SPECDIR && TSKLIST=$LISTNAMES || TSKLIST=$LISTBUILT
$ETERBUILDBIN/rpmbs $GIRARHOST $MENVARG $RPMBSARGS $TSKLIST exec $ETERBUILDBIN/rpmbs $GIRARHOST $MENVARG $RPMBSARGS $TSKLIST
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment