diff --git a/autoport b/autoport index 31070b5..6958919 100755 --- a/autoport +++ b/autoport @@ -1,6 +1,6 @@ #!/bin/bash # autoport -- batch cross-build tool based on autodist -# Copyright (C) 2011 by Silvan Calarco +# Copyright (C) 2011-2012 by Silvan Calarco # # Released under the terms of the GNU GPL release 3 license # @@ -16,7 +16,7 @@ me=(${0##*/} $VERSION "Sat Mar 20 2011") function usage() { echo "\ ${me[0]} ${me[1]} -"$"Copyright (C) 2010 Silvan Calarco "" +"$"Copyright (C) 2011-2012 Silvan Calarco "" "$"Released under the terms of the GNU GPL v3 license" echo " "$"Batch port and cross-build tool based on autodist."" @@ -121,6 +121,13 @@ JOB_FAILED=(${JOB_FAILED[*]}) _EOF } +function find_source_by_provide() { + local pkg=`echo $2 | sed "s|(|\\\\\[|g;s|)|\\\\\]|g;s|:|_|g"` + grep "^$pkg:" $DATADIR/$1/sources-$BASE_ARCH | \ + awk '{ $1=""; print $0 }' | \ + sed "s|[[:space:]]_| |g" +} + function find_requirements() { [ "$1" ] || return 1 local tf=`mktemp` || { @@ -142,9 +149,9 @@ function find_requirements() { echo -n " | missing requirements: " > $tf cat $tf1 | while read line; do - REQ=`grep "^$line:" $DATADIR/$PORT_REPOSITORY/sources-$BASE_ARCH | awk '{ print $2 }'` + REQ=`find_source_by_provide $PORT_REPOSITORY $line` [ "$REQ" ] && \ - echo "${REQ/_}" >> $tf || \ + echo "${REQ}" >> $tf || \ echo -n "$line(unresolved) " done > $tf1 @@ -335,6 +342,7 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do JOB_MAYBEINSTALLED_NEW=() JOB_FAILED_OLD=(${JOB_FAILED[*]}) JOB_FAILED=() + JOB_CANTINSTALL_OLD=(${JOB_CANTINSTALL[*]}) for JOB_NUM in `seq 1 ${#JOB[*]}`; do JOB_CURRENT=${JOB[$JOB_NUM-1]} if [ "`grep "^${JOB_CURRENT}$" /etc/autodist/unstage 2>/dev/null`" -o \ @@ -373,8 +381,17 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do %% COMMAND: LANG=C LC_ALL=C autodist -p ${JOB_CURRENT} --server $PORT_REPOSITORY --repository $PORT_REPOSITORY --severity 2 -- $STAGEOPTS" LANG=C LC_ALL=C autodist -p ${JOB_CURRENT} --server $PORT_REPOSITORY --repository $PORT_REPOSITORY --severity 2 -- $STAGEOPTS &>>$logfile [ $? -gt 0 ] && { + RES=`find_source_by_provide $PORT_REPOSITORY $JOB_CURRENT` + for j in ${RES}; do + [ "$j" != "$JOB_CURRENT" ] && RESOLVED_JOB="$RESOLVED_JOB $j" + done + if [ "$RESOLVED_JOB" ]; then + echo "(FAILED) [but scheduling $RESOLVED_JOB]" + JOB_FAILED=(${JOB_FAILED[*]} $RESOLVED_JOB) + else + echo "(FAILED) " + fi JOB_CANTPREPARE=(${JOB_CANTPREPARE[*]} $JOB_CURRENT) - echo "(FAILED) " continue } || { echo $JOB_CURRENT >> $DATAARCHDIR/preparedjobs @@ -460,6 +477,53 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do } echo done + if [ "${JOB[*]}" == "${JOB_FAILED[*]}" -a "${JOB_MISSINGREQ[*]}" == "" ]; then + # some new build, retry cantinstall jobs + JOB_CANTINSTALL=() + for JOB_NUM in `seq 1 ${#JOB_CANTINSTALL_OLD[*]}`; do + JOB_CURRENT=${JOB_CANTINSTALL_OLD[$JOB_NUM-1]} + if [ "`grep "^${JOB_CURRENT}$" /etc/autodist/unstage 2>/dev/null`" -o \ + "`grep "^${JOB_CURRENT}$" /etc/autodist/unstage.${TARGET_ARCH} 2>/dev/null`" ]; then + echo -n "$JOB_CURRENT: " + STAGEOPTS= + else + echo -n "$JOB_CURRENT(staging): " + STAGEOPTS="$AUTOPORT_STAGEVARS" + fi + echo -n "retryinstall" + LANG=C LC_ALL=C autodist -i ${JOB_CURRENT} --arch $TARGET_ARCH --force --severity 2 -- $STAGEOPTS &>>$tmpfile + # --server $DEST_REPOSITORY --repository $PORT_REPOSITORY + [ $? -gt 0 ] && { + if [ "$VERBOSE_MODE" ]; then + echo + echo "Failed output:" + echo "==============" + cat $tmpfile + echo "==============" + echo + fi + cat $tmpfile >> $logfile + JOB_CANTINSTALL=(${JOB_CANTINSTALL[*]} $JOB_CURRENT) + echo $JOB_CURRENT >> $DATAARCHDIR/checkinstalljobs + echo "(FAILED)" + # sometimes script fails but package is installed; run fix_la_files anyway + sudo autoport-fix-environment $TARGET_ARCH + + JOB_MAYBEINSTALLED_NEW=(${JOB_MAYBEINSTALLED_NEW[*]} $JOB_CURRENT) + JOB_LOG=`grep "^?= See " $tmpfile | awk '{ print $3 }'` + [ "$JOB_LOG" ] || JOB_LOG=$tmpfile + find_requirements $JOB_LOG + continue + } || { + cat $tmpfile >> $logfile + sudo autoport-fix-environment $TARGET_ARCH + JOB_MAYBEINSTALLED_NEW=(${JOB_MAYBEINSTALLED_NEW[*]} $JOB_CURRENT) + JOB_COMPLETED=(${JOB_COMPLETED[*]} $JOB_CURRENT) + echo -n "(OK)" + } + echo + done + fi echo "Skipped jobs: ${JOB_SKIPPED[*]}" echo "Unpreparable jobs: ${JOB_CANTPREPARE[*]}" echo "Missing requirements: ${JOB_MISSINGREQ[*]}" @@ -468,7 +532,9 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do echo "Failed jobs: ${JOB_FAILED[*]}" write_last_file - [ "${JOB[*]}" == "${JOB_FAILED[*]}" -a "${JOB_MISSINGREQ[*]}" == "" ] && { + [ "${JOB[*]}" == "${JOB_FAILED[*]}" -a \ + "${JOB_MISSINGREQ[*]}" == "" -a \ + "${JOB_CANTINSTALL_OLD[*]}" == "${JOB_CANTINSTALL[*]}" ] && { echo "Loop detected. Finishing. See $logfile for details." rm -f $tmpfile $tmpfile1 exit 1