myhsh 4.01 KB
Newer Older
1
#!/bin/bash
2
# 2003-2006, 2008-2010, 2013 (c) Etersoft www.etersoft.ru
3 4 5
# Author: Vitaly Lipatov <lav@etersoft.ru>
# Public domain
#
6 7
# Пересборка указанных SRPM-пакетов в hasher
# -i устанавливает в тестовый hasher после пересборки
8

9 10
# load common functions, compatible with local and installed script
. `dirname $0`/../share/eterbuild/functions/common
11
load_mod hasher check
12

13
TESTINSTALL=
Vitaly Lipatov's avatar
Vitaly Lipatov committed
14 15
WITHSTUFF="--with-stuff"

16
#############################
17
Usage="Usage: $name [-i -c -l] src.rpm..."
18 19 20 21 22 23 24 25 26
function mygetopts()
{
name=${0##*/}
Descr="$name - build package via hasher"

phelp()
{
	echog "$Descr"
	echog "$Usage"
27
	echo
28
	echog "Options:"
29 30 31
	echog "   -i  install built packages in test hasher"
	echog "   -c  build without stuff (without previous built packages)"
	echog "   -l  lazy cleanup (before build, not after)"
32

33 34
}

35
while getopts :hicl opt; do
36 37 38
    case $opt in
    h) phelp; exit 0;;
    i) TESTINSTALL=1;;
39
    l) HASHERARG="$HASHERARG --lazy-cleanup";;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
40
    c) WITHSTUFF="--without-stuff";;
41
    +?) echog "$name: options should not be preceded by a '+'." 1>&2; exit 2;;
42
    ?) OPTIND=$((OPTIND-1)); break;
43 44
    esac
done
45

46 47 48 49 50 51 52 53 54 55 56 57 58 59
# remove args that were options
if [ $# -gt 0 ]; then 
	shift $((OPTIND - 1))
fi

LISTRPMARGS=$@
}


parse_cmd_pre "$@"
mygetopts $LISTARGS

RESULT=0

Vitaly Lipatov's avatar
Vitaly Lipatov committed
60
HASHERARG="$HASHERARG $WITHSTUFF"
61
set_hasherdir
62

63 64 65
mkdir -p $LOGDIR $HASHERDIR || fatal "cannot mkdir"
check_locking

66
echog "List of packages for build: \$LISTNAMES"
67

68
if [ -z "${LISTNAMES/*spec/}"  ] ; then
69 70 71 72
	echo "!!!!!!!!"
	fatal "Please use src.rpm as argument, not spec"
fi

73 74
# Skip checking for tar arg
if [ -n "${LISTNAMES/*tar/}" ] ; then
75
	echog -n "Checking with sisyphus_check... with $HASHER_NOCHECK skipping"
76 77 78
	sisyphus_check --no-check=$HASHER_NOCHECK --files $LISTNAMES || fatal "check for sisyphus failed"
	echog "OK"
fi
79

Vitaly Lipatov's avatar
Vitaly Lipatov committed
80
# export OURAPTCONF with temp. file contains correct path to sources.list
81
# use MENV
Vitaly Lipatov's avatar
Vitaly Lipatov committed
82 83
prepare_aptconfig

84
# FIXME: we override config value here?
85
# TODO: for add $LISTRPMARGS we need skip function for delete "our" params
86
# we do not need check cases for mount points, thanks ldv@ 
87
HASHERARG="--no-sisyphus-check=$HASHER_NOCHECK --apt-config=$OURAPTCONF --target $BUILDARCH $HASHERARG"
88 89 90 91 92 93
HASHERARG="--mountpoints=/proc,/dev/pts $HASHERARG"

BUILDARGS=""

if [ -z "$NOSTRICT_UNPACKAGED" ] ; then
	BUILDARGS="$BUILDARGS --define '_unpackaged_files_terminate_build 1'"
94
fi
95

96 97 98 99
LISTBUILTSH=""
for i in $LISTNAMES
do
	LOGFILE="$LOGDIR/`basename $i .src.rpm`$MENVARG.log"
100
	echo "Build in hasher ($MENV) in $HASHERDIR dir" >$LOGFILE
101
	rm -f $LOGFILE.failed
102
	echog "Build in hasher: $i (arg: $HASHERARG --build-args \"$BUILDARGS\", distro: $MENV, hasherdir: $HASHERDIR)"
103

104
	# Note: hasher is already use renice for low priority
Vitaly Lipatov's avatar
Vitaly Lipatov committed
105 106
	showcmd $HSH $HASHERARG --build-args "$BUILDARGS" -- $HASHERDIR $i
	($HSH $HASHERARG --build-args "$BUILDARGS" -- $HASHERDIR $i 2>&1 || touch $LOGFILE.failed) | tee -a $LOGFILE
107
	test -L $HASHERDIR/BUILD || ln -s chroot/usr/src/RPM/BUILD $HASHERDIR/
108
	if [ -f $LOGFILE.failed ] ; then
109 110 111 112 113 114 115 116
		RESULT=1
		break
	fi
	check_log $LOGFILE ; RESULT=$?
	test $RESULT = 1 && break
	echog "########## Build of `basename $i` is done in hasher $MENV  #############"
	echo
	LISTBUILTSH="$LISTBUILTSH$i "
117
	LASTPACKAGE=$i
118 119 120 121
done

echo
if [ "$RESULT" = "1" ] ; then
122
	echo
123
	echog "!!!!!!! Hasher: FAILED FAILED FAILED !!!!!!!!!"
124
	echog "Build failed with $i, built only"
125 126 127
else
	echog "Full list of the hashered packages:"
fi
128
print_list $LISTBUILTSH
129 130

echo
131
if [ "$RESULT" = "0" ] && [ -n "$TESTINSTALL" ] ; then
132 133
	# test install (only for last package in list)
	# some key for build hasher from scratch
134
	echog "Find binary packages for '$(basename $LASTPACKAGE)' in $HASHERDIR/repo/$BUILDARCH/RPMS.hasher..."
135
	BINPACKAGES=`get_binpkg_list $HASHERDIR/repo/$BUILDARCH/RPMS.hasher $LASTPACKAGE | estrlist reg_exclude debuginfo -`
136
	test -n "$BINPACKAGES" || fatal "Can't find binary packages for $LASTPACKAGE in `ls -l $HASHERDIR/repo/$BUILDARCH/RPMS.hasher`"
137 138
	echo "List: $BINPACKAGES"
	echo
139 140
	docmd $ETERBUILDBIN/loginhsh -a $MENVARG $BINPACKAGES
	exit
141 142 143
fi

exit $RESULT