rpmbsh 2.96 KB
Newer Older
1 2 3 4 5 6
#!/bin/sh
# 2003-2006 (c) Etersoft www.etersoft.ru
# Author: Vitaly Lipatov <lav@etersoft.ru>
# Public domain
#
# BSH - build source; use hasher
7
#
8 9 10 11 12 13
#  ()       hasher
#  ̣   (  -r)
#      ( -m)
# TODO:   
# TODO:    ??

14 15
# load common functions, compatible with local and installed script
. `dirname $0`/../share/eterbuild/functions/common
16
load_mod rpm
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

RESULT=0
REMCOM=

#############################
Usage="Usage: $name [-r -s -u -m -i -c] spec..."
function mygetopts()
{
name=${0##*/}
Descr="$name - BSH - build source; use hasher"

phelp()
{
	echog "$Descr"
	echog "$Usage"
	echog "Options:"
	echog " -r - remote build"
	echog " -m - sent result via email"
	echog " -u/-U - sign and upload after build"
	echog " -s - sign and and copy to upload after build"
	echog " -i - install built packages in test hasher"
	echog " -c - build without stuff (previous built packages)"
}

while getopts :hrusim opt; do
    case $opt in
    h) phelp; exit 0;;
    r) REMOTEBUILD=1 ;;
#    i) TESTINSTALL=1 ;;
#    u) UPLOADNOW="-u" ;;
#    s) UPLOADNOW="-s" ;;
    +?) echog "$name: options should not be preceded by a '+'." 1>&2; exit 2;;
#    ?)  echog "$name: $OPTARG: bad option.  Use -h for help." 1>&2 ; exit 2;;
	?) OPTIND=$((OPTIND-1)); break;
    esac
done

## remove args that were options
if [ $# -gt 0 ]; then 
	shift $((OPTIND - 1))
fi

LISTRPMARGS=$@

}
#############################

parse_cmd_pre "$@"
mygetopts $LISTARGS

# If fail, we already has correct changelog
add_changelog_helper "- new version" $LISTNAMES

#echo ${LISTRPMARGS/\-m/} @ ${LISTRPMARGS} @${LISTNAMES}
# We do not not pass args for myhsh here...
# FIXME:      
pack_src_rpm $(echo $LISTRPMARGS | sed -e "s|-[suUic]||g")

Vitaly Lipatov's avatar
Vitaly Lipatov committed
75
# Hack to pass SPECDIR to rpmbs
76
if [ -r "$LISTNAMES" ] ; then
Vitaly Lipatov's avatar
Vitaly Lipatov committed
77 78
	export SPECDIR=`dirname $LISTNAMES`
fi
79 80 81 82 83 84 85 86 87 88

if  [ -n "$REMOTEBUILD" ] ; then
	check_key
	test -n "$BUILDSERVER" || fatal "Please set BUILDSERVER in config file"
	test -n "$REMOTERPMDIR" || REMOTERPMDIR=`ssh $BUILDSERVER echo $HOME`/RPM
	echo
	echog "############ Build at build server '$BUILDSERVER' (with $LISTRPMARGS options) ############"
	echo
	echog "==== Copying to build server ====="
	#echog "It is recommended to rename old version at server for save traffic during rsync"
89
	cd $RPMTOPDIR/SRPMS && rsync -vay --partial --progress --checksum \
90 91 92 93 94 95 96
	 	-e ssh $LISTBUILT $BUILDSERVER:$REMOTERPMDIR/SRPMS/ || fatal "Error with rsync"
	ssh -t $BUILDSERVER "cd $REMOTERPMDIR/SRPMS && time myhsh $MENVARG $LISTRPMARGS $LISTBUILT"
	RESULT=$?
	date
	echo "-------------------------------"
	test "$RESULT" = "0" && echog "It was remote build at $BUILDSERVER" || echog "There is error during remote build at $BUILDSERVER"
else
97
	cd $RPMTOPDIR/SRPMS && time myhsh $MENVARG $LISTRPMARGS $LISTBUILT
98 99 100 101 102 103 104 105
	RESULT=$?
	date
	echo "-------------------------------"
fi

cd -

exit $RESULT