autoport: more checks on releases, repository fetch code reworked and more

This commit is contained in:
Silvan Calarco 2013-11-09 14:21:25 +01:00
parent 4cf07b63e5
commit 10b3f8eff0

View File

@ -37,6 +37,7 @@ ${me[0]} ${me[1]}
-u changelog "$"Rebuild packages with given changelog -u changelog "$"Rebuild packages with given changelog
-v "$"More verbose output -v "$"More verbose output
-x "$"Operate in cross build mode -x "$"Operate in cross build mode
--user user "$"Pass calling user name for Webbuild social messages""
arch "$"Target architecture arch "$"Target architecture
job "$"Job specification for autodist"" job "$"Job specification for autodist""
@ -99,7 +100,6 @@ function get_pkg_srcinfo() {
src_epoch=$5 src_epoch=$5
src_release=$6 src_release=$6
src_milestone=`echo $src_release | sed "s|[0-9.]*\(.*\)|\1|"` src_milestone=`echo $src_release | sed "s|[0-9.]*\(.*\)|\1|"`
} }
# get_pkg_buildinfo - uses distromatic generated build file for # get_pkg_buildinfo - uses distromatic generated build file for
@ -198,7 +198,14 @@ function find_requirements() {
local OUTFILE=$1 local OUTFILE=$1
if [ "`grep " is needed by " $OUTFILE`" ]; then if [ "`grep " is needed by " $OUTFILE`" ]; then
grep " is needed by " $OUTFILE | awk '{ print $1 }' | sort -u > $tf1 grep " is needed by " $OUTFILE | while read line; do
set -- $line
if [ "$2" = "=" -o "$2" = ">=" ]; then
awk '{ print $1#$3 }' | sort -u > $tf1
else
awk '{ print $1 }' | sort -u > $tf1
fi
done
elif [ "`grep " matches no packages" $OUTFILE`" ]; then elif [ "`grep " matches no packages" $OUTFILE`" ]; then
grep " matches no packages" $OUTFILE | awk '{ print $2 }' | tr -d \' | sort -u > $tf1 grep " matches no packages" $OUTFILE | awk '{ print $2 }' | tr -d \' | sort -u > $tf1
elif [ "`grep " no package provides " $OUTFILE`" ]; then elif [ "`grep " no package provides " $OUTFILE`" ]; then
@ -230,6 +237,15 @@ function find_requirements() {
return 0 return 0
} }
fetch_repfiles() {
curl -s ${REPS_BASE_URL}/$PORT_REPOSITORY/srcpkglist -o $DATADIR/$PORT_REPOSITORY/srcpkglist ||
echo "Warning: unable to fetch ${REPS_BASE_URL}/$PORT_REPOSITORY/srcpkglist"
curl -s $PORT_REPOSITORY_DISTROMATIC_URL/sources-$BASE_ARCH -o $DATADIR/$PORT_REPOSITORY/sources-$BASE_ARCH ||
echo "Warning: unable to fetch $PORT_REPOSITORY_DISTROMATIC_URL/sources-$BASE_ARCH"
curl -s $PORT_REPOSITORY_DISTROMATIC_URL/builds-$TARGET_ARCH.sh -o $DATADIR/$PORT_REPOSITORY/builds-$TARGET_ARCH.sh ||
echo "Error: unable to fetch $PORT_REPOSITORY_DISTROMATIC_URL/builds-$TARGET_ARCH.sh"
}
[ $# -gt 0 ] || { usage ; exit 1; } [ $# -gt 0 ] || { usage ; exit 1; }
BUILD_ARCH=`uname -i` BUILD_ARCH=`uname -i`
@ -272,6 +288,13 @@ for ((i=1; i<=$#; i++)); do
TARGET_ARCHS="`echo ${!i} | tr , ' '`" TARGET_ARCHS="`echo ${!i} | tr , ' '`"
CROSS_MODE=1 CROSS_MODE=1
;; ;;
--user) let i+=1
[ "${!i}" ] || {
echo "Error: --user parameter not given, aborting."
exit 1
}
WEBBUILD_USER_CMDLINE="${!i}"
;;
-h|--help) -h|--help)
usage usage
exit 0 exit 0
@ -334,17 +357,13 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
echo "Port repository is $PORT_REPOSITORY" echo "Port repository is $PORT_REPOSITORY"
echo "Release repository is $DEST_REPOSITORY" echo "Release repository is $DEST_REPOSITORY"
curl -s ${REPS_BASE_URL}/$PORT_REPOSITORY/srcpkglist -o $DATADIR/$PORT_REPOSITORY/srcpkglist ||
echo "Warning: unable to fetch ${REPS_BASE_URL}/$PORT_REPOSITORY/srcpkglist"
curl -s $PORT_REPOSITORY_DISTROMATIC_URL/sources-$BASE_ARCH -o $DATADIR/$PORT_REPOSITORY/sources-$BASE_ARCH ||
echo "Warning: unable to fetch $PORT_REPOSITORY_DISTROMATIC_URL/sources-$BASE_ARCH"
# old files cleanup # old files cleanup
rm -f $DATADIR/$PORT_REPOSITORY/sources-$TARGET_CPU rm -f $DATADIR/$PORT_REPOSITORY/sources-$TARGET_CPU
rm -f $DATADIR/$PORT_REPOSITORY/builds-$BASE_ARCH.sh rm -f $DATADIR/$PORT_REPOSITORY/builds-$BASE_ARCH.sh
curl -s $PORT_REPOSITORY_DISTROMATIC_URL/builds-$TARGET_ARCH.sh -o $DATADIR/$PORT_REPOSITORY/builds-$TARGET_ARCH.sh ||
echo "Error: unable to fetch $PORT_REPOSITORY_DISTROMATIC_URL/builds-$TARGET_ARCH.sh" fetch_repfiles
if [ "$BATCH_MODE" ]; then if [ "$BATCH_MODE" ]; then
[ "${JOB[*]}" ] && { [ "${JOB[*]}" ] && {
@ -403,6 +422,7 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
while [ "${JOB[*]}" ]; do while [ "${JOB[*]}" ]; do
step=`expr $step + 1` step=`expr $step + 1`
[ $step -gt 1 ] && fetch_repfiles
[ "$BATCH_MODE" -a $step -gt $AUTOPORT_MAX_STEPS ] && { [ "$BATCH_MODE" -a $step -gt $AUTOPORT_MAX_STEPS ] && {
echo "Maximum steps count reached for batch mode; exiting. See $logfile for details." echo "Maximum steps count reached for batch mode; exiting. See $logfile for details."
break break
@ -418,7 +438,12 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
JOB_FAILED=() JOB_FAILED=()
JOB_CANTINSTALL_OLD=(${JOB_CANTINSTALL[*]}) JOB_CANTINSTALL_OLD=(${JOB_CANTINSTALL[*]})
for JOB_NUM in `seq 1 ${#JOB[*]}`; do for JOB_NUM in `seq 1 ${#JOB[*]}`; do
JOB_CURRENT=${JOB[$JOB_NUM-1]} JOB_CURRENT=${JOB[$JOB_NUM-1]/\#*}
if [ "${JOB_CURRENT}" != "${JOB[$JOB_NUM-1]}" ]; then
JOB_CURRENT_VERSION=${JOB[$JOB_NUM-1]/*\#}
else
JOB_CURRENT_VERSION=
fi
if [ "`grep "^${JOB_CURRENT}$" /etc/autodist/unstage 2>/dev/null`" -o \ if [ "`grep "^${JOB_CURRENT}$" /etc/autodist/unstage 2>/dev/null`" -o \
"`grep "^${JOB_CURRENT}$" /etc/autodist/unstage.${TARGET_ARCH} 2>/dev/null`" ]; then "`grep "^${JOB_CURRENT}$" /etc/autodist/unstage.${TARGET_ARCH} 2>/dev/null`" ]; then
echo -n "^ $JOB_CURRENT: " echo -n "^ $JOB_CURRENT: "
@ -444,7 +469,18 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
JOB_FAILED=(${JOB_FAILED[*]} $JOB_CURRENT) JOB_FAILED=(${JOB_FAILED[*]} $JOB_CURRENT)
continue continue
fi fi
get_pkg_srcinfo $DATADIR/$PORT_REPOSITORY ${JOB_CURRENT} get_pkg_srcinfo $DATADIR/$PORT_REPOSITORY ${JOB_CURRENT} || {
echo "< (FAILED) [error $? in get_pkg_srcinfo]"
JOB_FAILED=(${JOB_FAILED[*]} $JOB_CURRENT)
continue
}
if [ "$JOB_CURRENT_VERSION" -a \
"$JOB_CURRENT_VERSION" != "$src_version" -a \
"$JOB_CURRENT_VERSION" != "$src_version-$src_release" ]; then
echo "< (FAILED) [wrong version $src_version-$src_release != $JOB_CURRENT_VERSION]"
JOB_FAILED=(${JOB_FAILED[*]} $JOB_CURRENT)
continue
fi
DONT_PREPARE_THIS= DONT_PREPARE_THIS=
for p in ${JOB_CMDLINE[*]}; do for p in ${JOB_CMDLINE[*]}; do
@ -575,9 +611,14 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
echo -n "(OK) " echo -n "(OK) "
autoport_log ${JOB_CURRENT} port ok $tmpfile autoport_log ${JOB_CURRENT} port ok $tmpfile
if [ "$WEBBUILD_URL" -a "$WEBBUILD_USER" ]; then if [ "$WEBBUILD_URL" -a "$WEBBUILD_USER" ]; then
if [ "$WEBBUILD_USER_CMDLINE" ]; then
curl -s "$WEBBUILD_URL?REQUEST=message&USER=$WEBBUILD_USER&SECRET=$WEBBUILD_SECRET&USER_EMAIL=$WEBBUILD_EMAIL&\
MESSAGE=`cgi_encodevar \"(invoked by $WEBBUILD_USER_CMDLINE) ported <b>$JOB_CURRENT</b> to <b>$TARGET_ARCH</b> and sent it to <b>$src_repository</b>\"`" >/dev/null
else
curl -s "$WEBBUILD_URL?REQUEST=message&USER=$WEBBUILD_USER&SECRET=$WEBBUILD_SECRET&USER_EMAIL=$WEBBUILD_EMAIL&\ curl -s "$WEBBUILD_URL?REQUEST=message&USER=$WEBBUILD_USER&SECRET=$WEBBUILD_SECRET&USER_EMAIL=$WEBBUILD_EMAIL&\
MESSAGE=`cgi_encodevar \"ported <b>$JOB_CURRENT</b> to <b>$TARGET_ARCH</b> and sent it to <b>$src_repository</b>\"`" >/dev/null MESSAGE=`cgi_encodevar \"ported <b>$JOB_CURRENT</b> to <b>$TARGET_ARCH</b> and sent it to <b>$src_repository</b>\"`" >/dev/null
fi fi
fi
} }
echo -n "install" echo -n "install"
LANG=C LC_ALL=C autodist -i ${JOB_CURRENT} --arch $TARGET_ARCH --force --severity 2 -- $STAGEOPTS &>$tmpfile LANG=C LC_ALL=C autodist -i ${JOB_CURRENT} --arch $TARGET_ARCH --force --severity 2 -- $STAGEOPTS &>$tmpfile