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 1: skip current job on error
2: abort on error"" 2: abort on error""
--arch "$"Build packages for specified target architecture"" --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: job "$"Job specification in the form pkg#version, job#version, job/pkg#version, examples:
glibc#2.11.1 glibc#2.11.1
@ -129,7 +130,6 @@ for ((i=1; i<=$#; i++)); do
exit 1 exit 1
} }
} }
;; ;;
-c|--cleanlogs) do_cleanlogs=1 ;; -c|--cleanlogs) do_cleanlogs=1 ;;
-h|--help) usage -h|--help) usage
@ -159,32 +159,39 @@ for ((i=1; i<=$#; i++)); do
;; ;;
--server) let i+=1 --server) let i+=1
[ "${!i}" ] || { [ "${!i}" ] || {
echo "Error: server parameter not given, aborting." echo "Error: --server parameter not given, aborting."
exit 1 exit 1
} }
SEND_SERVER="${!i}" SEND_SERVER="${!i}"
;; ;;
--repository) let i+=1 --repository) let i+=1
[ "${!i}" ] || { [ "${!i}" ] || {
echo "Error: repository parameter not given, aborting." echo "Error: --repository parameter not given, aborting."
exit 1 exit 1
} }
AUTODIST_REPOSITORY="${!i}" AUTODIST_REPOSITORY="${!i}"
;; ;;
--severity) let i+=1 --severity) let i+=1
[ "${!i}" ] || { [ "${!i}" ] || {
echo "Error: severity parameter not given, aborting." echo "Error: --severity parameter not given, aborting."
exit 1 exit 1
} }
SEVERITY=${!i} SEVERITY=${!i}
;; ;;
--arch) let i+=1 --arch) let i+=1
[ "${!i}" ] || { [ "${!i}" ] || {
echo "Error: arch parameter not given, aborting." echo "Error: --arch parameter not given, aborting."
exit 1 exit 1
} }
TARGETARCH=${!i} TARGETARCH=${!i}
;; ;;
--user) let i+=1
[ "${!i}" ] || {
echo "Error: --user parameter not given, aborting."
exit 1
}
WEBBUILD_USER_CMDLINE="${!i}"
;;
-*) if [ "${!i}" = "--" ]; then -*) if [ "${!i}" = "--" ]; then
AUTOSPEC_ARGS_MODE=1 AUTOSPEC_ARGS_MODE=1
elif [ "$AUTOSPEC_ARGS_MODE" ]; then 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 # send operation: check for --norpm (source send) to avoid sending notification twice
[ "$WEBBUILD_URL" -a "$WEBBUILD_USER" ] && { [ "$WEBBUILD_URL" -a "$WEBBUILD_USER" ] && {
SPEC_VERSION=`grep -m1 "^Version:" $spec_dir/$pkg.spec | sed "s|Version:[[:space:]]*||"` SPEC_VERSION=`grep -m1 "^Version:" $spec_dir/$pkg.spec | sed "s|Version:[[:space:]]*||"`
if [ "$WEBBUILD_USER_CMDLINE" ]; 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 \"sent <b>$pkg $SPEC_VERSION</b> for ${TARGETARCH} to <b>$SEND_SERVER</b>\"`" >/dev/null 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 fi
;; ;;
@ -948,6 +960,7 @@ if [ "$do_autobuild" = "1" ]; then
SKIPPEDCOUNT=0 SKIPPEDCOUNT=0
BLACKLISTCOUNT=0 BLACKLISTCOUNT=0
SUCCESSLISTCOUNT=0 SUCCESSLISTCOUNT=0
REBUILDOLDCOUNT=0
> $pkgtmpfile > $pkgtmpfile
@ -971,8 +984,13 @@ if [ "$do_autobuild" = "1" ]; then
continue continue
} }
# check skippedlist (but ignore for scheduled updates)
if [ "${VERSION:0:1}" != "+" ]; then if [ "${VERSION:0:1}" != "+" ]; then
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 "` SKIPPEDLINE=`awk '{ print $1" "$2 }' $SKIPPEDLISTDIR/*.skip | grep -m1 "^$PKGNAME "`
if [ "$SKIPPEDLINE" ]; then if [ "$SKIPPEDLINE" ]; then
set -- $SKIPPEDLINE set -- $SKIPPEDLINE
@ -987,6 +1005,7 @@ if [ "$do_autobuild" = "1" ]; then
fi fi
fi fi
fi fi
fi
# check legacylist # check legacylist
awk '{ print $1 }' $LEGACYLIST | grep "^$PKGNAME$" >/dev/null && { awk '{ print $1 }' $LEGACYLIST | grep "^$PKGNAME$" >/dev/null && {
@ -1045,7 +1064,7 @@ if [ "$do_autobuild" = "1" ]; then
fi fi
done < $srctmpfile 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 while read line; do
set -- $line set -- $line
PKGNAME=${1} PKGNAME=${1}
@ -1112,8 +1131,8 @@ for JOB_NUM in `seq 1 ${#JOBNAME[*]}`; do
} }
if [ ! "$do_update" -a "$do_autobuild" = "1" ]; then if [ ! "$do_update" -a "$do_autobuild" = "1" ]; then
[ "${AUTOSPEC_ARGS/--changelog}" = "${AUTOSPEC_ARGS}" ] && [ "${AUTOSPEC_ARGS/--changelog}" = "${AUTOSPEC_ARGS}" ] &&
AUTOSPEC_ARGS="$AUTOSPEC_ARGS --changelog \"automatic rebuild by autodist\"" AUTOSPEC_CHANGELOG="--changelog \"automatic rebuild by autodist\"" || AUTOSPEC_CHANGELOG=
launch_pkgs_loop rebuild "$AUTOSPEC_ARGS" || { launch_pkgs_loop rebuild "$AUTOSPEC_ARGS $AUTOSPEC_CHANGELOG" || {
case $SEVERITY in case $SEVERITY in
0) ;; 0) ;;
1) echo "%! Error during package update for rebuild; skipping $JOB_NAME job." 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" echo "?= Job $JOB_NAME is in the legacy list; forcing rebuild"
} || { } || {
[ "${AUTOSPEC_ARGS/--changelog}" = "${AUTOSPEC_ARGS}" ] && [ "${AUTOSPEC_ARGS/--changelog}" = "${AUTOSPEC_ARGS}" ] &&
AUTOSPEC_ARGS="$AUTOSPEC_ARGS --changelog \"automatic update by autodist\"" AUTOSPEC_CHANGELOG="--changelog \"automatic update by autodist\"" || AUTOSPEC_CHANGELOG
launch_pkgs_loop autoupdate "$AUTOSPEC_ARGS $SEND_FORCE" launch_pkgs_loop autoupdate "$AUTOSPEC_ARGS $AUTOSPEC_CHANGELOG $SEND_FORCE"
ret=$? ret=$?
} }
fi fi
@ -1163,8 +1182,8 @@ for JOB_NUM in `seq 1 ${#JOBNAME[*]}`; do
else else
echo "%% Rebuilding package(s)" echo "%% Rebuilding package(s)"
[ "${AUTOSPEC_ARGS/--changelog}" = "${AUTOSPEC_ARGS}" ] && [ "${AUTOSPEC_ARGS/--changelog}" = "${AUTOSPEC_ARGS}" ] &&
AUTOSPEC_ARGS="$AUTOSPEC_ARGS --changelog \"automatic rebuild by autodist\"" AUTOSPEC_CHANGELOG="--changelog \"automatic rebuild by autodist\"" || AUTOSPEC_CHANGELOG=
launch_pkgs_loop rebuild "$AUTOSPEC_ARGS" || { launch_pkgs_loop rebuild "$AUTOSPEC_ARGS $AUTOSPEC_CHANGELOG" || {
case $SEVERITY in case $SEVERITY in
0) ;; 0) ;;
1) echo "%! Error during package update for rebuild; skipping $JOB_NAME job." 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}" 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 # 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/--changelog}" = "${AUTOSPEC_ARGS}" ] &&
AUTOSPEC_ARGS="$AUTOSPEC_ARGS --changelog \"automatic version update by autodist\"" AUTOSPEC_CHANGELOG="--changelog \"automatic version update by autodist\"" || AUTOSPEC_CHANGELOG=
launch_pkgs_loop update "${JOB_VER:1} $AUTOSPEC_ARGS $SEND_FORCE" || { launch_pkgs_loop update "${JOB_VER:1} $AUTOSPEC_ARGS $AUTOSPEC_CHANGELOG $SEND_FORCE" || {
if [ ! "$rebuild_packages" ]; then if [ ! "$rebuild_packages" ]; then
case $SEVERITY in case $SEVERITY in
0) ;; 0) ;;
@ -1199,8 +1218,8 @@ for JOB_NUM in `seq 1 ${#JOBNAME[*]}`; do
esac esac
else else
[ "${AUTOSPEC_ARGS/--changelog}" = "${AUTOSPEC_ARGS}" ] && [ "${AUTOSPEC_ARGS/--changelog}" = "${AUTOSPEC_ARGS}" ] &&
AUTOSPEC_ARGS="$AUTOSPEC_ARGS --changelog \"automatic rebuild by autodist\"" AUTOSPEC_CHANGELOG="--changelog \"automatic rebuild by autodist\"" || AUTOSPEC_CHANGELOG=
launch_pkgs_loop rebuild "$AUTOSPEC_ARGS" || { launch_pkgs_loop rebuild "$AUTOSPEC_ARGS $AUTOSPEC_CHANGELOG" || {
case $SEVERITY in case $SEVERITY in
0) ;; 0) ;;
1) echo "%! Error during package update for rebuild; skipping $JOB_NAME job." 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 REPS_BASE_URL=http://www.openmamba.org/pub/openmamba
LOCAL_REPS_BASE_DIR=/var/ftp/pub/openmamba LOCAL_REPS_BASE_DIR=/var/ftp/pub/openmamba
SEND_SERVER=devel-autodist SEND_SERVER=devel-autodist
GNOME_VER=3.4
#WEBBUILD_URL=http://localhost/cgi-bin/webbuild #WEBBUILD_URL=http://localhost/cgi-bin/webbuild
#WEBBUILD_USER= #WEBBUILD_USER=
#WEBBUILD_EMAIL= #WEBBUILD_EMAIL=
@ -27,3 +26,5 @@ AUTODIST_REPOSITORIES=(devel devel-games devel-makedist devel-kernel devel-xorg
AUTOPORT_STAGEVARS="--define stage1=1" AUTOPORT_STAGEVARS="--define stage1=1"
AUTOPORT_MAX_STEPS=10 AUTOPORT_MAX_STEPS=10
#RPMDIR=/usr/src/RPM #RPMDIR=/usr/src/RPM
AUTODIST_REBUILDOLD_MAX=20
AUTODIST_REBUILDOLD_FROMDATE=20090101