autoport: support for new autospec needport variable in sources-* files

This commit is contained in:
Silvan Calarco 2013-05-19 16:50:59 +02:00
parent 52ea72fb98
commit 91ad537c95

126
autoport
View File

@ -76,6 +76,32 @@ function cgi_encodevar() {
# REPLY="${encoded}" #+or echo the result (EASIER)... or both... :p # REPLY="${encoded}" #+or echo the result (EASIER)... or both... :p
} }
function get_pkg_srcinfo() {
local pkg local_distromatic pkg_line
unset src_name src_version src_buildtime src_repository src_epoch src_release
[ $1 ] && local_distromatic=$1 || exit 1
[ $2 ] && pkg=$2 || return 1
[ -e $local_distromatic/srcpkglist ] || return 2
pkg_line=`grep "^$pkg " $local_distromatic/srcpkglist`
[ "$pkg_line" ] || return 3
set -- $pkg_line
src_name=$1
src_version=$2
src_buildtime=$3
src_repository=$4
src_epoch=$5
src_release=$6
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
# getting information on the repository # getting information on the repository
# #
@ -303,12 +329,18 @@ 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 || 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" echo "Warning: unable to fetch $PORT_REPOSITORY_DISTROMATIC_URL/sources-$BASE_ARCH"
curl -s $PORT_REPOSITORY_DISTROMATIC_URL/sources-$TARGET_CPU -o $DATADIR/$PORT_REPOSITORY/sources-$TARGET_CPU || # rm -f $DATADIR/$PORT_REPOSITORY/sources-$BASE_ARCH
echo "Warning: unable to fetch $PORT_REPOSITORY_DISTROMATIC_URL/sources-$TARGET_CPU" # curl -s $PORT_REPOSITORY_DISTROMATIC_URL/sources-$TARGET_CPU -o $DATADIR/$PORT_REPOSITORY/sources-$TARGET_CPU ||
curl -s $PORT_REPOSITORY_DISTROMATIC_URL/builds-$BASE_ARCH.sh -o $DATADIR/$PORT_REPOSITORY/builds-$BASE_ARCH.sh || # echo "Warning: unable to fetch $PORT_REPOSITORY_DISTROMATIC_URL/sources-$TARGET_CPU"
echo "Error: unable to fetch $PORT_REPOSITORY_DISTROMATIC_URL/builds-$BASE_ARCH.sh" rm -f $DATADIR/$PORT_REPOSITORY/sources-$TARGET_CPU
# curl -s $PORT_REPOSITORY_DISTROMATIC_URL/builds-$BASE_ARCH.sh -o $DATADIR/$PORT_REPOSITORY/builds-$BASE_ARCH.sh ||
# echo "Error: unable to fetch $PORT_REPOSITORY_DISTROMATIC_URL/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 || 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" echo "Error: unable to fetch $PORT_REPOSITORY_DISTROMATIC_URL/builds-$TARGET_ARCH.sh"
@ -317,50 +349,18 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
echo "Error: no jobs allowed in batch mode; aborting." echo "Error: no jobs allowed in batch mode; aborting."
exit 1 exit 1
} }
curl -s $BASE_REPOSITORY_DISTROMATIC_URL/builds-$BASE_ARCH.sh -o $DATADIR/$BASE_REPOSITORY/builds-$BASE_ARCH.sh || # curl -s $BASE_REPOSITORY_DISTROMATIC_URL/builds-$BASE_ARCH.sh -o $DATADIR/$BASE_REPOSITORY/builds-$BASE_ARCH.sh ||
echo "Error: unable to fetch $BASE_REPOSITORY_DISTROMATIC_URL/builds-$BASE_ARCH.sh" # echo "Error: unable to fetch $BASE_REPOSITORY_DISTROMATIC_URL/builds-$BASE_ARCH.sh"
curl -s $BASE_REPOSITORY_DISTROMATIC_URL/builds-$TARGET_ARCH.sh -o $DATADIR/$BASE_REPOSITORY/builds-$TARGET_ARCH.sh || rm -f $DATADIR/$BASE_REPOSITORY/builds-$BASE_ARCH.sh
echo "Error: unable to fetch $BASE_REPOSITORY_DISTROMATIC_URL/builds-$TARGET_ARCH.sh" # curl -s $BASE_REPOSITORY_DISTROMATIC_URL/builds-$TARGET_ARCH.sh -o $DATADIR/$BASE_REPOSITORY/builds-$TARGET_ARCH.sh ||
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $BASE_ARCH # echo "Error: unable to fetch $BASE_REPOSITORY_DISTROMATIC_URL/builds-$TARGET_ARCH.sh"
rm -f $DATADIR/$BASE_REPOSITORY/builds-$TARGET_ARCH.sh
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $TARGET_ARCH
port_pkg_list=${pkg_list[*]} port_pkg_list=${pkg_list[*]}
echo "Packages to port: ${needport_list[*]}"
for p in ${port_pkg_list}; do for p in ${needport_list[*]}; do
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $TARGET_ARCH $p JOB=(${JOB[*]} $p)
target_pkg_name=$pkg_name
target_pkg_ver=$pkg_version
target_pkg_rel=$pkg_release
[ "$pkg_name" ] || get_pkg_buildinfo $DATADIR/$BASE_REPOSITORY $TARGET_ARCH $p
if [ "$pkg_name" ]; then
base_pkg_ver=$pkg_version
base_pkg_rel=$pkg_release
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $BASE_ARCH $p
[ "$pkg_name" ] || {
echo "Error: internal error, should never be here; aborting."
exit 1
}
port_pkg_ver=$pkg_version
port_pkg_rel=$pkg_release
if [ "$target_pkg_name" ]; then
pkg_milestone=`echo $target_pkg_rel | sed "s|[0-9.]*\(.*\)|\1|"`
if [ "$target_pkg_ver" != "$port_pkg_ver" ]; then
echo "Package $pkg_name#${port_pkg_ver}-${port_pkg_rel}($TARGET_ARCH) differs from $pkg_name#${target_pkg_ver}-${target_pkg_rel}($BASE_ARCH); port needed."
JOB=(${JOB[*]} $p)
elif [ "$target_pkg_rel" != "$port_pkg_rel" ]; then
echo "Package $pkg_name#${port_pkg_ver}-${port_pkg_rel}($TARGET_ARCH) differs from $pkg_name#${target_pkg_ver}-${target_pkg_rel}($BASE_ARCH); port needed."
JOB=(${JOB[*]} $p)
elif [ "$REBUILD_MILESTONE" -a "$pkg_milestone" != "$REBUILD_MILESTONE" ]; then
echo "Package $pkg_name($TARGET_ARCH) was not built for '$REBUILD_MILESTONE' milestone; rebuild needed."
JOB=(${JOB[*]} $p)
else
[ "$VERBOSE_MODE" ] && echo "Package $pkg_name#${port_pkg_ver}-${port_pkg_rel}($TARGET_ARCH) is up to date."
fi
else
echo "$p#${port_pkg_ver}-${port_pkg_rel}($BASE_ARCH) is in port repository but $p#${base_pkg_ver}-${base_pkg_rel}($TARGET_ARCH) is in base repository; port needed."
JOB=(${JOB[*]} $p)
fi
fi
done done
[ -e $DATADIR/autoport-$PORT_REPOSITORY-current ] && \ [ -e $DATADIR/autoport-$PORT_REPOSITORY-current ] && \
mv $DATADIR/autoport-$PORT_REPOSITORY-current $DATADIR/autoport-$PORT_REPOSITORY-last mv $DATADIR/autoport-$PORT_REPOSITORY-current $DATADIR/autoport-$PORT_REPOSITORY-last
@ -429,14 +429,8 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
JOB_FAILED=(${JOB_FAILED[*]} $JOB_CURRENT) JOB_FAILED=(${JOB_FAILED[*]} $JOB_CURRENT)
continue continue
fi fi
pkg_release= get_pkg_srcinfo $DATADIR/$PORT_REPOSITORY ${JOB_CURRENT}
pkg_version=
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $TARGET_ARCH ${JOB_CURRENT} || \
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $BASE_ARCH ${JOB_CURRENT} || \
get_pkg_buildinfo $DATADIR/$BASE_REPOSITORY $TARGET_ARCH ${JOB_CURRENT} || \
get_pkg_buildinfo $DATADIR/$BASE_REPOSITORY $BASE_ARCH ${JOB_CURRENT}
pkg_milestone=`echo $pkg_release | sed "s|[0-9.]*\(.*\)|\1|"`
pkg_numrelease=`echo $pkg_release | sed "s|\([0-9.]*\).*|\1|"`
DONT_PREPARE_THIS= DONT_PREPARE_THIS=
for p in ${JOB_CMDLINE[*]}; do for p in ${JOB_CMDLINE[*]}; do
[ "$p" = "${JOB_CURRENT}" -o "$DONT_PREPARE_ANY" ] || continue [ "$p" = "${JOB_CURRENT}" -o "$DONT_PREPARE_ANY" ] || continue
@ -495,14 +489,14 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
autoport_log ${JOB_CURRENT} update ok $tmpfile autoport_log ${JOB_CURRENT} update ok $tmpfile
echo -n "(OK) " echo -n "(OK) "
} }
elif [ "$REBUILD_MILESTONE" -a "$pkg_milestone" != "$REBUILD_MILESTONE" ]; then elif [ "$REBUILD_MILESTONE" -a "$src_milestone" != "$REBUILD_MILESTONE" ]; then
echo -n "update" echo -n "update"
[ "$pkg_repository" -a "$pkg_version" -a "$pkg_release" ] || { [ "$src_repository" -a "$src_version" -a "$src_release" ] || {
echo "(FAILED) [can't get repository information for this package]" echo "(FAILED) [can't get repository information for this package]"
continue continue
} }
# FIXME: should be implemented in autodist # FIXME: should be implemented in autodist
LANG=C LC_ALL=C autospec -u ${JOB_CURRENT} -a4 ${pkg_version} ${pkg_numrelease}${REBUILD_MILESTONE} \ LANG=C LC_ALL=C autospec -u ${JOB_CURRENT} -a4 ${src_version} ${src_numrelease}${REBUILD_MILESTONE} \
--changelog "$REBUILD_MILESTONE milestone rebuild" &>$tmpfile --changelog "$REBUILD_MILESTONE milestone rebuild" &>$tmpfile
[ $? -gt 0 ] && { [ $? -gt 0 ] && {
if [ "$VERBOSE_MODE" ]; then if [ "$VERBOSE_MODE" ]; then
@ -528,20 +522,20 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
fi fi
} }
echo -n "port" echo -n "port"
if [ ! "$pkg_repository" -a "$DONT_PREPARE_THIS" != "1" ]; then if [ ! "$src_repository" -a "$DONT_PREPARE_THIS" != "1" ]; then
echo "(FAILED) [can't get repository information for this package]" echo "(FAILED) [can't get repository information for this package]"
autoport_log ${JOB_CURRENT} port failed autoport_log ${JOB_CURRENT} port failed
continue continue
fi fi
if [ "$DONT_PREPARE_THIS" = "1" -a "$pkg_repository" != "$PORT_REPOSITORY" ]; then if [ "$DONT_PREPARE_THIS" = "1" -a "$src_repository" != "$PORT_REPOSITORY" ]; then
# if both -np and -r were given send to PORT_REPOSITORY instead of pkg_repository # if both -np and -r were given send to PORT_REPOSITORY instead of src_repository
pkg_repository=$PORT_REPOSITORY src_repository=$PORT_REPOSITORY
fi fi
[ "$PORT_REPOSITORY" != "$DEST_REPOSITORY" ] && pkg_repository="$DEST_REPOSITORY" [ "$PORT_REPOSITORY" != "$DEST_REPOSITORY" ] && src_repository="$DEST_REPOSITORY"
[ ! "$DONT_PREPARE_THIS" -a "$PORT_REPOSITORY" = "$DEST_REPOSITORY" -a ! "$REBUILD_MILESTONE" ] && NOSRPM_OPTS="--nosrpm" || NOSRPM_OPTS="--force" [ ! "$DONT_PREPARE_THIS" -a "$PORT_REPOSITORY" = "$DEST_REPOSITORY" -a ! "$REBUILD_MILESTONE" ] && NOSRPM_OPTS="--nosrpm" || NOSRPM_OPTS="--force"
[ "$VERBOSE_MODE" ] && echo " [ "$VERBOSE_MODE" ] && echo "
%% COMMAND: LANG=C LC_ALL=C autodist -b -s ${JOB_CURRENT} --arch $TARGET_ARCH --server $pkg_repository --repository $PORT_REPOSITORY --severity 2 $FORCE_FLAG -- $STAGEOPTS $NOSRPM_OPTS" %% COMMAND: LANG=C LC_ALL=C autodist -b -s ${JOB_CURRENT} --arch $TARGET_ARCH --server $src_repository --repository $PORT_REPOSITORY --severity 2 $FORCE_FLAG -- $STAGEOPTS $NOSRPM_OPTS"
LANG=C LC_ALL=C autodist -b -s ${JOB_CURRENT} --arch $TARGET_ARCH --server $pkg_repository --repository $PORT_REPOSITORY --severity 2 $FORCE_FLAG -- $STAGEOPTS $NOSRPM_OPTS &>$tmpfile LANG=C LC_ALL=C autodist -b -s ${JOB_CURRENT} --arch $TARGET_ARCH --server $src_repository --repository $PORT_REPOSITORY --severity 2 $FORCE_FLAG -- $STAGEOPTS $NOSRPM_OPTS &>$tmpfile
[ $? -gt 0 ] && { [ $? -gt 0 ] && {
if [ "$VERBOSE_MODE" ]; then if [ "$VERBOSE_MODE" ]; then
echo echo
@ -567,7 +561,7 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
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
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>$pkg_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
} }
echo -n "install" echo -n "install"