autodist: added --user option to notify invoking user via webbuild social messages

- implement older packages autorebuild in batch mode
This commit is contained in:
Silvan Calarco 2013-07-11 11:07:15 +02:00
parent cbe63c0c85
commit ef98426c64
2 changed files with 51 additions and 31 deletions

View File

@ -46,6 +46,7 @@ ${me[0]} ${me[1]}
1: skip current job on error
2: abort on error""
--arch "$"Build packages for specified target architecture""
--user user "$"Pass calling user name for Webbuild social messages""
job "$"Job specification in the form pkg#version, job#version, job/pkg#version, examples:
glibc#2.11.1
@ -129,7 +130,6 @@ for ((i=1; i<=$#; i++)); do
exit 1
}
}
;;
-c|--cleanlogs) do_cleanlogs=1 ;;
-h|--help) usage
@ -159,32 +159,39 @@ for ((i=1; i<=$#; i++)); do
;;
--server) let i+=1
[ "${!i}" ] || {
echo "Error: server parameter not given, aborting."
echo "Error: --server parameter not given, aborting."
exit 1
}
SEND_SERVER="${!i}"
;;
--repository) let i+=1
[ "${!i}" ] || {
echo "Error: repository parameter not given, aborting."
echo "Error: --repository parameter not given, aborting."
exit 1
}
AUTODIST_REPOSITORY="${!i}"
;;
--severity) let i+=1
[ "${!i}" ] || {
echo "Error: severity parameter not given, aborting."
echo "Error: --severity parameter not given, aborting."
exit 1
}
SEVERITY=${!i}
;;
--arch) let i+=1
[ "${!i}" ] || {
echo "Error: arch parameter not given, aborting."
echo "Error: --arch parameter not given, aborting."
exit 1
}
TARGETARCH=${!i}
;;
--user) let i+=1
[ "${!i}" ] || {
echo "Error: --user parameter not given, aborting."
exit 1
}
WEBBUILD_USER_CMDLINE="${!i}"
;;
-*) if [ "${!i}" = "--" ]; then
AUTOSPEC_ARGS_MODE=1
elif [ "$AUTOSPEC_ARGS_MODE" ]; then
@ -836,8 +843,13 @@ function launch_pkgs_loop() {
# send operation: check for --norpm (source send) to avoid sending notification twice
[ "$WEBBUILD_URL" -a "$WEBBUILD_USER" ] && {
SPEC_VERSION=`grep -m1 "^Version:" $spec_dir/$pkg.spec | sed "s|Version:[[:space:]]*||"`
curl -s "$WEBBUILD_URL?REQUEST=message&USER=$WEBBUILD_USER&SECRET=$WEBBUILD_SECRET&USER_EMAIL=$WEBBUILD_EMAIL&\
MESSAGE=`cgi_encodevar \"sent <b>$pkg $SPEC_VERSION</b> for ${TARGETARCH} to <b>$SEND_SERVER</b>\"`" >/dev/null
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) sent <b>$pkg $SPEC_VERSION-$SPEC_RELEASE</b> for ${TARGETARCH} to <b>$SEND_SERVER</b>\"`" >/dev/null
else
curl -s "$WEBBUILD_URL?REQUEST=message&USER=$WEBBUILD_USER&SECRET=$WEBBUILD_SECRET&USER_EMAIL=$WEBBUILD_EMAIL&\
MESSAGE=`cgi_encodevar \"sent <b>$pkg $SPEC_VERSION-$SPEC_RELEASE</b> for ${TARGETARCH} to <b>$SEND_SERVER</b>\"`" >/dev/null
fi
}
fi
;;
@ -948,6 +960,7 @@ if [ "$do_autobuild" = "1" ]; then
SKIPPEDCOUNT=0
BLACKLISTCOUNT=0
SUCCESSLISTCOUNT=0
REBUILDOLDCOUNT=0
> $pkgtmpfile
@ -971,19 +984,25 @@ if [ "$do_autobuild" = "1" ]; then
continue
}
# check skippedlist (but ignore for scheduled updates)
if [ "${VERSION:0:1}" != "+" ]; then
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
if [ $REBUILDOLDCOUNT -lt $AUTODIST_REBUILDOLD_MAX -a $BUILDDATE -ge $AUTODIST_REBUILDOLD_FROMDATE ]; then
# rebuilt 20 oldest packages (but newer than 20090101)
REBUILDOLDCOUNT=$(($REBUILDOLDCOUNT + 1))
VERSION=+0
else
# check skippedlist (but ignore for scheduled updates)
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
fi
fi
@ -1045,7 +1064,7 @@ if [ "$do_autobuild" = "1" ]; then
fi
done < $srctmpfile
echo "%% Total pkgs: $PKGCOUNT, skipped list: $SKIPPEDCOUNT, blacklist: $BLACKLISTCOUNT, success list: $SUCCESSLISTCOUNT, last build date: $BUILDDATE"
echo "%% Total pkgs: $PKGCOUNT, skipped list: $SKIPPEDCOUNT, blacklist: $BLACKLISTCOUNT, success list: $SUCCESSLISTCOUNT, rebuild-old list: $REBUILDOLDCOUNT, last build date: $BUILDDATE"
while read line; do
set -- $line
PKGNAME=${1}
@ -1112,8 +1131,8 @@ for JOB_NUM in `seq 1 ${#JOBNAME[*]}`; do
}
if [ ! "$do_update" -a "$do_autobuild" = "1" ]; then
[ "${AUTOSPEC_ARGS/--changelog}" = "${AUTOSPEC_ARGS}" ] &&
AUTOSPEC_ARGS="$AUTOSPEC_ARGS --changelog \"automatic rebuild by autodist\""
launch_pkgs_loop rebuild "$AUTOSPEC_ARGS" || {
AUTOSPEC_CHANGELOG="--changelog \"automatic rebuild by autodist\"" || AUTOSPEC_CHANGELOG=
launch_pkgs_loop rebuild "$AUTOSPEC_ARGS $AUTOSPEC_CHANGELOG" || {
case $SEVERITY in
0) ;;
1) echo "%! Error during package update for rebuild; skipping $JOB_NAME job."
@ -1141,8 +1160,8 @@ for JOB_NUM in `seq 1 ${#JOBNAME[*]}`; do
echo "?= Job $JOB_NAME is in the legacy list; forcing rebuild"
} || {
[ "${AUTOSPEC_ARGS/--changelog}" = "${AUTOSPEC_ARGS}" ] &&
AUTOSPEC_ARGS="$AUTOSPEC_ARGS --changelog \"automatic update by autodist\""
launch_pkgs_loop autoupdate "$AUTOSPEC_ARGS $SEND_FORCE"
AUTOSPEC_CHANGELOG="--changelog \"automatic update by autodist\"" || AUTOSPEC_CHANGELOG
launch_pkgs_loop autoupdate "$AUTOSPEC_ARGS $AUTOSPEC_CHANGELOG $SEND_FORCE"
ret=$?
}
fi
@ -1163,8 +1182,8 @@ for JOB_NUM in `seq 1 ${#JOBNAME[*]}`; do
else
echo "%% Rebuilding package(s)"
[ "${AUTOSPEC_ARGS/--changelog}" = "${AUTOSPEC_ARGS}" ] &&
AUTOSPEC_ARGS="$AUTOSPEC_ARGS --changelog \"automatic rebuild by autodist\""
launch_pkgs_loop rebuild "$AUTOSPEC_ARGS" || {
AUTOSPEC_CHANGELOG="--changelog \"automatic rebuild by autodist\"" || AUTOSPEC_CHANGELOG=
launch_pkgs_loop rebuild "$AUTOSPEC_ARGS $AUTOSPEC_CHANGELOG" || {
case $SEVERITY in
0) ;;
1) echo "%! Error during package update for rebuild; skipping $JOB_NAME job."
@ -1186,8 +1205,8 @@ for JOB_NUM in `seq 1 ${#JOBNAME[*]}`; do
echo "%% Updating to version ${JOB_VER:1}"
# WARNING: JOB_VER must be passed to launch_pkgs_loop as the first string in the second parameter
[ "${AUTOSPEC_ARGS/--changelog}" = "${AUTOSPEC_ARGS}" ] &&
AUTOSPEC_ARGS="$AUTOSPEC_ARGS --changelog \"automatic version update by autodist\""
launch_pkgs_loop update "${JOB_VER:1} $AUTOSPEC_ARGS $SEND_FORCE" || {
AUTOSPEC_CHANGELOG="--changelog \"automatic version update by autodist\"" || AUTOSPEC_CHANGELOG=
launch_pkgs_loop update "${JOB_VER:1} $AUTOSPEC_ARGS $AUTOSPEC_CHANGELOG $SEND_FORCE" || {
if [ ! "$rebuild_packages" ]; then
case $SEVERITY in
0) ;;
@ -1199,8 +1218,8 @@ for JOB_NUM in `seq 1 ${#JOBNAME[*]}`; do
esac
else
[ "${AUTOSPEC_ARGS/--changelog}" = "${AUTOSPEC_ARGS}" ] &&
AUTOSPEC_ARGS="$AUTOSPEC_ARGS --changelog \"automatic rebuild by autodist\""
launch_pkgs_loop rebuild "$AUTOSPEC_ARGS" || {
AUTOSPEC_CHANGELOG="--changelog \"automatic rebuild by autodist\"" || AUTOSPEC_CHANGELOG=
launch_pkgs_loop rebuild "$AUTOSPEC_ARGS $AUTOSPEC_CHANGELOG" || {
case $SEVERITY in
0) ;;
1) echo "%! Error during package update for rebuild; skipping $JOB_NAME job."

View File

@ -3,7 +3,6 @@
REPS_BASE_URL=http://www.openmamba.org/pub/openmamba
LOCAL_REPS_BASE_DIR=/var/ftp/pub/openmamba
SEND_SERVER=devel-autodist
GNOME_VER=3.4
#WEBBUILD_URL=http://localhost/cgi-bin/webbuild
#WEBBUILD_USER=
#WEBBUILD_EMAIL=
@ -27,3 +26,5 @@ AUTODIST_REPOSITORIES=(devel devel-games devel-makedist devel-kernel devel-xorg
AUTOPORT_STAGEVARS="--define stage1=1"
AUTOPORT_MAX_STEPS=10
#RPMDIR=/usr/src/RPM
AUTODIST_REBUILDOLD_MAX=20
AUTODIST_REBUILDOLD_FROMDATE=20090101