autodist: sync with current production changes:

- fix support for multiple words arg passed to autospec (--changelog)
- yet some logs path and cleaning fixes
- temporary workaround: hardcoded skipping of java-*, apache-*, jakarta-*, compiz* packages (TODO: make this configurable)
This commit is contained in:
Silvan Calarco 2013-01-19 16:12:37 +01:00
parent 24afa0b07b
commit 6d278e3a20

128
autodist
View File

@ -1,7 +1,7 @@
#!/bin/bash
#
# Autodist -- batch build tool for RPM based distributions
# Copyright (C) 2006-2012 by Silvan Calarco <silvan.calarco@mambasoft.it>
# Copyright (C) 2006-2013 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
# Released under the terms of the GNU GPL release 3 license
#
@ -179,9 +179,14 @@ for ((i=1; i<=$#; i++)); do
*) if [ "$AUTOSPEC_ARGS_MODE" != "1" ]; then
JOBNAME[${#JOBNAME[@]}]="${!i/\#*}"
[ "${!i/*\#}" != "${!i}" ] && JOBVER[${#JOBNAME[@]}]="+${!i/*\#}"
else
if [ "${!i/ }" != "${!i}" ]; then
# pass multiple word arguments inside quotation marks
AUTOSPEC_ARGS="$AUTOSPEC_ARGS \"${!i}\""
else
AUTOSPEC_ARGS="$AUTOSPEC_ARGS ${!i}"
fi
fi
;;
esac
done
@ -520,12 +525,30 @@ function launch_pkgs_loop() {
# launch loop for each package
for pkg in ${JOB_PKGS[*]}; do
unset LOGFILE_SUFFIX
for a in ${JOB_VALUES[*]}; do
tr_job=`echo $a | tr / _`
LOGFILE_SUFFIX=${LOGFILE_SUFFIX}__$tr_job
done
LOGFILE_SUFFIX=$LOGFILE_SUFFIX.$TARGETARCH
[ "$JOB_NAME" = "${pkg}" ] &&
LOGFILE_PKG_NAME=${pkg}${LOGFILE_SUFFIX} ||
LOGFILE_PKG_NAME=${JOB_NAME}_${pkg}${LOGFILE_SUFFIX}
LOGFILE_PKG=${LOGDIR}/${LOGFILE_PKG_NAME}
# clean previous logs for this package
[ -e ${LOGDIR}/ok/${LOGFILE_PKG_NAME}${LOGFILE_SUFFIX} ] &&
rm -f ${LOGDIR}/ok/${LOGFILE_PKG_NAME}${LOGFILE_SUFFIX}
[ -e ${LOGDIR}/failed/${LOGFILE_PKG_NAME}${LOGFILE_SUFFIX} ] &&
rm -f ${LOGDIR}/failed/${LOGFILE_PKG_NAME}-${LOGFILE_SUFFIX}
case $operation in
autoupdate|update|build|buildinstall)
[ -e $spec_dir/$pkg.spec ] || {
case $SEVERITY in
0) ;;
1) echo "!! Error: spec filename must be the same as package name or invalid job name; skipping $pkg package."
[ "$do_autobuild" ] && autobuild_log $pkg $operation failed $JOB_NAME $LOGDIR/failed/${LOGFILE_PKG_NAME}
continue ;;
*) echo "!! Error: spec filename must be the same as package name or invalid job name; aborting."
exit 1 ;;
@ -542,6 +565,7 @@ function launch_pkgs_loop() {
case $SEVERITY in
0) ;;
1) echo "%! Error: could not apply patch to specfile; skipping $pkg package."
[ "$do_autobuild" ] && autobuild_log $pkg $operation failed $JOB_NAME $LOGDIR/failed/${LOGFILE_PKG_NAME}
ret=1
continue ;;
*) echo "!! Error: could not apply patch to specfile; aborting."
@ -561,22 +585,6 @@ function launch_pkgs_loop() {
SPEC_RELEASE=`grep "Release:" $spec_dir/$pkg.spec | sed "s|Release:[[:space:]]*||"`
}
unset LOGFILE_SUFFIX
for a in ${JOB_VALUES[*]}; do
tr_job=`echo $a | tr / _`
LOGFILE_SUFFIX=${LOGFILE_SUFFIX}__$tr_job
done
LOGFILE_SUFFIX=$LOGFILE_SUFFIX.$TARGETARCH
[ "$JOB_NAME" = "${pkg}" ] &&
LOGFILE_PKG_NAME=${pkg}${LOGFILE_SUFFIX} ||
LOGFILE_PKG_NAME=${JOB_NAME}_${pkg}${LOGFILE_SUFFIX}
LOGFILE_PKG=${LOGDIR}/${LOGFILE_PKG_NAME}
# clean previous logs for this package
[ -e ${LOGDIR}/ok/${LOGFILE_PKG_NAME}${LOGFILE_SUFFIX} ] &&
rm -f ${LOGDIR}/ok/${LOGFILE_PKG_NAME}${LOGFILE_SUFFIX}
[ -e ${LOGDIR}/failed/${LOGFILE_PKG_NAME}${LOGFILE_SUFFIX} ] &&
rm -f ${LOGDIR}/failed/${LOGFILE_PKG_NAME}-${LOGFILE_SUFFIX}
[ -e "$SRCPKGLIST" ] && PKGLINE=`grep "^${pkg} " $SRCPKGLIST` || PKGLINE=
[ -e "$SRCPKGLIST_DELAYED" ] && PKGLINE_DELAYED=`grep "^${pkg} " $SRCPKGLIST_DELAYED` || PKGLINE_DELAYED=
@ -951,47 +959,10 @@ if [ "$do_autobuild" = "1" ]; then
# check blacklist
awk '{ print $1 }' $BLACKLIST | grep "^$PKGNAME$" >/dev/null && {
BLACKLISTCOUNT=`expr $BLACKLISTCOUNT + 1`
#echo "?= Job $PKGNAME is in the blacklist; skipping"
# echo "?= Job $PKGNAME is in the blacklist; skipping"
continue
}
if [ "${VERSION:0:1}" == "+" -a "$VERSION" != "+0" ]; then
TRVER=`echo ${VERSION:1} | tr - .`
get_job_vector $PKGNAME
NEED_REBUILD=0
if [ ${#JOB_PKGS[*]} -gt 1 ]; then
# jobs are not fully rebuilt
for j in ${JOB_PKGS[*]}; do
REPVER=`grep "^$j " $SRCPKGLIST | gawk '{ print $2 }'`
version_find_bigger "$TRVER" "$REPVER"
[ $? -eq 1 ] && NEED_REBUILD=1
done
else
# single packages are rebuilt if scheduled
NEED_REBUILD=1
fi
if [ "$NEED_REBUILD" = "0" ]; then
echo "?= Job $PKGNAME is already up to date; skipping"
continue
fi
elif [ "$VERSION" != "+0" ]; then
# check successlist
SUCCESSLINE=`awk '{ print $1" "$2 }' $SUCCESSLISTDIR/*.success | grep -m1 "^$PKGNAME "`
if [ "$SUCCESSLINE" ]; then
set -- $SUCCESSLINE
SUCCESSTIME=$2
[ "$SUCCESSTIME" ] || SUCCESSTIME=0
SUCCESSDAYS=`expr \( $DATE_NOW - $SUCCESSTIME \) / 86400`
if [ "$SUCCESSDAYS" -le "$AUTOBUILD_SUCCESS_DAYS" ]; then
SUCCESSLISTCOUNT=`expr $SUCCESSLISTCOUNT + 1`
#echo "?= Job $PKGNAME has been in the successlist for $SUCCESSDAYS days; skipping"
continue
else
sed -i "/^$PKGNAME /d" $SUCCESSLISTDIR/*.success
fi
fi
# check skippedlist
SKIPPEDLINE=`awk '{ print $1" "$2 }' $SKIPPEDLISTDIR/*.skip | grep -m1 "^$PKGNAME "`
if [ "$SKIPPEDLINE" ]; then
@ -1013,11 +984,52 @@ if [ "$do_autobuild" = "1" ]; then
echo "$PKGNAME $DATE_NOW 100" >> $SKIPPEDLISTDIR/auto.skip
continue
}
# manually or from lists scheduled jobs
if [ "${VERSION:0:1}" == "+" -a "$VERSION" != "+0" ]; then
TRVER=`echo ${VERSION:1} | tr - .`
get_job_vector $PKGNAME
NEED_REBUILD=0
if [ ${#JOB_PKGS[*]} -gt 1 ]; then
# jobs are not fully rebuilt
for j in ${JOB_PKGS[*]}; do
REPVER=`grep "^$j " $SRCPKGLIST | gawk '{ print $2 }'`
version_find_bigger "$TRVER" "$REPVER"
[ $? -eq 1 ] && NEED_REBUILD=1
done
else
# single packages are rebuilt if scheduled
NEED_REBUILD=1
fi
if [ "$NEED_REBUILD" = "0" ]; then
echo "?= Job $PKGNAME is already up to date; skipping"
continue
fi
elif [ "$VERSION" != "+0" ]; then
# check successlist
SUCCESSLINE=`awk '{ print $1" "$2 }' $SUCCESSLISTDIR/*.success | grep -m1 "^$PKGNAME "`
if [ "$SUCCESSLINE" ]; then
set -- $SUCCESSLINE
SUCCESSTIME=$2
[ "$SUCCESSTIME" ] || SUCCESSTIME=0
SUCCESSDAYS=`expr \( $DATE_NOW - $SUCCESSTIME \) / 86400`
if [ "$SUCCESSDAYS" -le "$AUTOBUILD_SUCCESS_DAYS" ]; then
SUCCESSLISTCOUNT=`expr $SUCCESSLISTCOUNT + 1`
#echo "?= Job $PKGNAME has been in the successlist for $SUCCESSDAYS days; skipping"
continue
else
sed -i "/^$PKGNAME /d" $SUCCESSLISTDIR/*.success
fi
fi
fi
if [ $AUTOBUILD_NUMADDED -ge $AUTOBUILD_MAXNUM ]; then
break
elif [ $BUILDDATE -ge $AUTOBUILD_DATEFROM -o $BUILDDATE -eq 0 ]; then
[ $AUTOBUILD_NUMADDED -ge $AUTOBUILD_MAXNUM ] && break
# FIXME: hardcoded skipped packages
[ "${PKGNAME:0:5}" = "java-" -o "${PKGNAME:0:7}" = "apache-" -o \
"${PKGNAME:0:8}" = "jakarta-" -o "${PKGNAME:0:6}" = "compiz" ] && continue
if [ $BUILDDATE -ge $AUTOBUILD_DATEFROM -o $BUILDDATE -eq 0 ]; then
AUTOBUILD_NUMADDED=`expr $AUTOBUILD_NUMADDED + 1`
echo "$PKGNAME $VERSION" >> $pkgtmpfile
fi