From 6d278e3a2068eaae756a67edef23265d6f1898b8 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sat, 19 Jan 2013 16:12:37 +0100 Subject: [PATCH] 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) --- autodist | 102 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 57 insertions(+), 45 deletions(-) diff --git a/autodist b/autodist index 4075786..3ff5a2c 100755 --- a/autodist +++ b/autodist @@ -1,7 +1,7 @@ #!/bin/bash # # Autodist -- batch build tool for RPM based distributions -# Copyright (C) 2006-2012 by Silvan Calarco +# Copyright (C) 2006-2013 by Silvan Calarco # # Released under the terms of the GNU GPL release 3 license # @@ -180,7 +180,12 @@ for ((i=1; i<=$#; i++)); do JOBNAME[${#JOBNAME[@]}]="${!i/\#*}" [ "${!i/*\#}" != "${!i}" ] && JOBVER[${#JOBNAME[@]}]="+${!i/*\#}" else - AUTOSPEC_ARGS="$AUTOSPEC_ARGS ${!i}" + 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 @@ -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,10 +959,33 @@ 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 } + # check skippedlist + SKIPPEDLINE=`awk '{ print $1" "$2 }' $SKIPPEDLISTDIR/*.skip | grep -m1 "^$PKGNAME "` + if [ "$SKIPPEDLINE" ]; then + set -- $SKIPPEDLINE + SKIPPEDTIME=$2 + SKIPPEDDAYS=`expr \( $DATE_NOW - $SKIPPEDTIME \) / 86400` + if [ "$SKIPPEDDAYS" -le "$AUTOBUILD_SKIP_DAYS" ]; then + SKIPPEDCOUNT=`expr $SKIPPEDCOUNT + 1` +# echo "?= Package $PKGNAME has been in the skippedlist for $SKIPPEDDAYS days; skipping" + continue + else + sed -i "/^$PKGNAME /d" $SKIPPEDLISTDIR/*.skip + fi + fi + + # check legacylist + awk '{ print $1 }' $LEGACYLIST | grep "^$PKGNAME$" >/dev/null && { + echo "?= Job $PKGNAME is in the legacy list; skipping automatic update" + 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 @@ -975,7 +1006,6 @@ if [ "$do_autobuild" = "1" ]; then continue fi elif [ "$VERSION" != "+0" ]; then - # check successlist SUCCESSLINE=`awk '{ print $1" "$2 }' $SUCCESSLISTDIR/*.success | grep -m1 "^$PKGNAME "` if [ "$SUCCESSLINE" ]; then @@ -991,33 +1021,15 @@ if [ "$do_autobuild" = "1" ]; then sed -i "/^$PKGNAME /d" $SUCCESSLISTDIR/*.success fi fi - - # check skippedlist - SKIPPEDLINE=`awk '{ print $1" "$2 }' $SKIPPEDLISTDIR/*.skip | grep -m1 "^$PKGNAME "` - if [ "$SKIPPEDLINE" ]; then - set -- $SKIPPEDLINE - SKIPPEDTIME=$2 - SKIPPEDDAYS=`expr \( $DATE_NOW - $SKIPPEDTIME \) / 86400` - if [ "$SKIPPEDDAYS" -le "$AUTOBUILD_SKIP_DAYS" ]; then - SKIPPEDCOUNT=`expr $SKIPPEDCOUNT + 1` -# echo "?= Package $PKGNAME has been in the skippedlist for $SKIPPEDDAYS days; skipping" - continue - else - sed -i "/^$PKGNAME /d" $SKIPPEDLISTDIR/*.skip - fi - fi - - # check legacylist - awk '{ print $1 }' $LEGACYLIST | grep "^$PKGNAME$" >/dev/null && { - echo "?= Job $PKGNAME is in the legacy list; skipping automatic update" - echo "$PKGNAME $DATE_NOW 100" >> $SKIPPEDLISTDIR/auto.skip - continue - } 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