autoport: add -ud option to rebuild dependant packages of given package(s) using new distromatic pkg_needrebuild info

This commit is contained in:
Silvan Calarco 2014-07-06 22:18:49 +02:00
parent 45b347da76
commit fa602e75e0

View File

@ -17,7 +17,7 @@ me=(${0##*/} $VERSION "Sat Mar 20 2011")
function usage() {
echo "\
${me[0]} ${me[1]}
"$"Copyright (C) 2011-2012 Silvan Calarco <silvan.calarco@mambasoft.it>""
"$"Copyright (C) 2011-2014 Silvan Calarco <silvan.calarco@mambasoft.it>""
"$"Released under the terms of the GNU GPL v3 license"
echo "
"$"Batch port and cross-build tool based on autodist.""
@ -37,9 +37,10 @@ ${me[0]} ${me[1]}
-h "$"Show this help and exit
-s \"script_args\" "$"Send script_args as arguments for autodist update-specfile script
-u changelog "$"Rebuild packages with given changelog
-ud "$"Rebuild dependent packages that need rebuild
-v "$"More verbose output
-x "$"Operate in cross build mode
--user user "$"Pass calling user name for Webbuild social messages""
--user user "$"Pass calling user name for Webbuild social messages
arch "$"Target architecture
job "$"Job specification for autodist""
@ -240,7 +241,7 @@ fetch_repfiles() {
curl -f -L -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 -f -L -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"
echo "Warning: unable to fetch $PORT_REPOSITORY_DISTROMATIC_URL/builds-$TARGET_ARCH.sh"
for u in ${AUTOPORT_UNSTAGE_ARCHS}; do
[ "$u" = "$TARGET_ARCH" ] && {
rm -f $DATADIR/$PORT_REPOSITORY/unstage.$TARGET_ARCH
@ -248,7 +249,7 @@ fetch_repfiles() {
}
done
curl -f -L -s ${REPS_BASE_URL}/${PORT_REPOSITORY/-*}/unstage.$TARGET_ARCH -o $DATADIR/$PORT_REPOSITORY/unstage.$TARGET_ARCH ||
echo "Error: unable to fetch ${REPS_BASE_URL}/${PORT_REPOSITORY/-*}/unstage.$TARGET_ARCH"
echo "Warning: unable to fetch ${REPS_BASE_URL}/${PORT_REPOSITORY/-*}/unstage.$TARGET_ARCH"
}
[ $# -gt 0 ] || { usage ; exit 1; }
@ -278,6 +279,9 @@ for ((i=1; i<=$#; i++)); do
exit 1
}
;;
-ud) REBUILD_DEPENDANT_MODE=1
DONT_RECURSE=1
;;
-npa) DONT_PREPARE_ANY=1
DONT_PREPARE=1 ;;
-np) DONT_PREPARE=1 ;;
@ -335,10 +339,6 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
BASE_REPOSITORY_DISTROMATIC_URL=${DISTROMATIC_BASE_URL}$BASE_REPOSITORY
PORT_REPOSITORY_DISTROMATIC_URL=${DISTROMATIC_BASE_URL}$PORT_REPOSITORY
[ "$AUTO_MODE" -a -e $DATAARCHDIR/last ] && . $DATAARCHDIR/last
JOB=(${JOB_CMDLINE[*]} ${JOB_MISSINGREQ[*]} ${JOB_FAILED[*]})
[ "$FIX_MODE" -o "$BATCH_MODE" -o "${JOB[*]}" ] || { usage ; exit 1; }
[ -d $DATAARCHDIR ] || mkdir -p $DATAARCHDIR
[ -d $DATADIR/$BASE_REPOSITORY ] || mkdir -p $DATADIR/$BASE_REPOSITORY
[ -d $DATADIR/$PORT_REPOSITORY ] || mkdir -p $DATADIR/$PORT_REPOSITORY
@ -365,14 +365,46 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
echo "Port repository is $PORT_REPOSITORY"
echo "Release repository is $DEST_REPOSITORY"
# old files cleanup
rm -f $DATADIR/$PORT_REPOSITORY/sources-$TARGET_CPU
rm -f $DATADIR/$PORT_REPOSITORY/builds-$BASE_ARCH.sh
fetch_repfiles
[ "$AUTO_MODE" -a -e $DATAARCHDIR/last ] && . $DATAARCHDIR/last
if [ "$REBUILD_DEPENDANT_MODE" ]; then
for j in ${JOB_CMDLINE[*]}; do
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $TARGET_ARCH $j
port_pkg_list=${pkg_needrebuild[*]}
port_pkg_builds=" ${pkg_builds[*]} "
port_pkg_version=$pkg_version
port_pkg_release=$pkg_release
currrebuild=
currjobsscriptargs=
JOBNUM=0
for p in ${port_pkg_list}; do
if [ "${p/@*}" != "$currrebuild" ]; then
[ $JOBNUM -gt 0 ] && JOB_SCRIPTARGS[$JOBNUM-1]="$currjobscriptargs"
currjobscriptargs=
currrebuild=${p/@*}
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $TARGET_ARCH $currrebuild
JOB=(${JOB[*]} $currrebuild)
let JOBNUM+=1
fi
currprovider=${p/*@}
if [ "$port_pkgbuilds/ $currprovider-devel }" != "$port_pkgbuilds" ]; then
currprovider=${currprovider}-devel
fi
currjobscriptargs="$currjobscriptargs --buildreq ${currprovider} >= $port_pkg_version-$port_pkg_release "
done
[ "$currjobscriptargs" ] && JOB_SCRIPTARGS[$JOBNUM-1]="$currjobscriptargs"
echo "Package dependant from $j to rebuild: ${JOB[*]}"
done
else
JOB=(${JOB_CMDLINE[*]} ${JOB_MISSINGREQ[*]} ${JOB_FAILED[*]})
fi
[ "$FIX_MODE" -o "$BATCH_MODE" -o "${JOB[*]}" ] || { echo "Nothing to do."; exit 0; }
if [ "$BATCH_MODE" ]; then
[ "${JOB[*]}" ] && {
echo "Error: no jobs allowed in batch mode; aborting."
@ -521,8 +553,13 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
echo -n "(OK) "
autoport_log ${JOB_CURRENT} prepare ok $tmpfile
}
if [ "$REBUILD_MODE" = "1" ]; then
if [ "$REBUILD_MODE" = "1" -o "$REBUILD_DEPENDANT_MODE" = "1" ]; then
echo -n "update"
if [ "$REBUILD_DEPENDANT_MODE" ]; then
SCRIPT_ARGS="${JOB_SCRIPTARGS[$JOB_NUM-1]}"
changelogadd="`echo ${SCRIPT_ARGS} | sed "s|--buildreq|,|;s| ||g;s|^,||g"`"
REBUILD_CHANGELOG="rebuilt by autoport with build requirements: '${changelogadd}'"
fi
[ "$VERBOSE_MODE" ] && echo "
%% COMMAND: LANG=C LC_ALL=C autodist -u --rebuild -r ${JOB_CURRENT} --severity 2 -- $STAGEOPTS --changelog \"$REBUILD_CHANGELOG\" --- \"$SCRIPT_ARGS\""
LANG=C LC_ALL=C autodist -u --rebuild -r ${JOB_CURRENT} --severity 2 -- $STAGEOPTS --changelog \"$REBUILD_CHANGELOG\" --- $SCRIPT_ARGS &>$tmpfile