From 03a198fec4b5e5c693b12d821960ebd2c2542812 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sat, 1 Dec 2012 23:36:43 +0100 Subject: [PATCH] webbuild: small fixes and code organization --- webbuild/html/scripts/webbuild.js | 8 +++++ webbuild/webbuild-cgi | 48 +++++++++++++++++++---------- webbuild/webbuild-functions | 28 ++++++++++++++++- webbuild/webbuild-functions-private | 9 ++---- 4 files changed, 68 insertions(+), 25 deletions(-) diff --git a/webbuild/html/scripts/webbuild.js b/webbuild/html/scripts/webbuild.js index 19e0813..2d6d579 100644 --- a/webbuild/html/scripts/webbuild.js +++ b/webbuild/html/scripts/webbuild.js @@ -8,6 +8,14 @@ function getCheckedValuesByName(checkboxname) { return p; } +function checkAllBoxes(checkboxname,checked) { + var e=document.getElementsByName(checkboxname); + + for (var j=0;j" } [ "$STATE_JOBSSHOWALL" = "1" -o "$USER" = "$2" ] || continue + if [ $RETCODE -eq 256 -a -e /proc/$1 ]; then + echo -n "\"running...\"" + else + if [ $RETCODE -eq 0 ]; then +# echo -n "OK" + echo -n "\"OK\"" + else +# echo -n "ERROR ($RETCODE)" + echo -n "\"ERROR\"" + fi + fi echo -n "$2 on `print_environment_descr $3`: " if [ $RETCODE -eq 256 -a -e /proc/$1 ]; then echo -n "\"" echo -n "$cmdline\" " - echo -n "(running...)" else echo -n "\"" @@ -341,11 +351,6 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshjobs" ]; then $SUDO_WRAPPER finishprocess $1 "$USER" $5 RETCODE=$? fi - if [ $RETCODE -eq 0 ]; then - echo -n "OK" - else - echo -n "ERROR ($RETCODE)" - fi fi if [ "$2" = "$USER" -o "$USER_ADMIN" ]; then if [ $RETCODE -eq 256 -a -e /proc/$1 ]; then @@ -531,7 +536,7 @@ elif [ ! "$REQUEST" -o "$REQUEST" = "changeenvironment" -o "$REQUEST" = "switchm # SPECFILES select echo -n "" echo -n "" $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "ls *.spec | sort -f" | while read f; do @@ -709,7 +714,8 @@ if [ "$MAINTAINERMODE" = "true" -o ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then echo -n "" + echo -n "PACKAGE=\"+encodeURIComponent(getSelectedValueById('specfile'))+\"&" + echo -n "AUTOPORTPACKAGE=\"+encodeURIComponent(getSelectedValueById('package'))); $SRPMBUTTONDISABLED>" fi echo -n "]]>" fi @@ -934,6 +940,7 @@ if [ "$REQUEST" = "edit" -o "$REQUEST" = "reloadspec" -o "$REQUEST" = "switchmai # echo "No pre-existing .spec file $PACKAGE.spec in current working environment. Choose package from a repository and press 'Unpack and edit' to edit." # echo -n "" # echo -n "]]>" + print_editorcontrols fi REQUEST= fi @@ -1022,7 +1029,7 @@ if [ "$MAINTAINERMODE" != "true" ]; then if [ "$AUTODISTJOB" -a "$AUTODISTJOB" = "$f" ]; then SELECTED="selected=\"selected\"" AUTODISTJOBSELECTED=1 - elif [ "$PACKAGE" = "$f" ]; then + elif [ "$PACKAGE" = "$f" -a ! "$AUTODISTJOBSELECTED" ]; then SELECTED="selected=\"selected\"" AUTODISTJOB=$f AUTODISTJOBSELECTED=1 @@ -1083,7 +1090,8 @@ if [ "$MAINTAINERMODE" != "true" ]; then echo -n "AUTODISTJOB=\"+getSelectedValueById('autodistjobs')+\"&" echo -n "AUTODISTPKGS=\"+encodeURIComponent(p)+\"&" echo -n "ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=autodistinstall\"" - echo -n ",\"`cgi_encodevar "Install built packages for "`\"+getSelectedValueById('autodistjobs')+\"`cgi_encodevar " job in current environment?"`\"" + echo -n ",\"`cgi_encodevar "Install built packages for "`\"+getSelectedValueById('autodistjobs')+\"" + echo -n "`cgi_encodevar " job in current environment?"`\"" echo -n "); class=redbutton $DISABLED>" # autodist send [ ! "$USER_ALLREPOSITORIES" ] && DISABLED="disabled=disabled" || DISABLED= @@ -1205,7 +1213,7 @@ if [ "$MAINTAINERMODE" != "true" ]; then echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&" echo -n "SENDREPOSITORY=\"+getSelectedValueById('sendrepository')" echo -n ",\"`cgi_encodevar "Send $PACKAGE built packages to "`\"+getSelectedValueById('sendrepository')+" - echo -n "\"`cgi_encodevar "?"`\"" + echo -n "\"`cgi_encodevar "?

HINT: does summary look short and good?
${SPECVAR_Name[0]} - ${SPECVAR_Summary[0]}."`\"" echo -n "); class=redbutton $HREFADD>" # recreate and send SRPM if [ "$SPECVAR_CHECK_NOAUTOBUILDREQ" ]; then @@ -1427,12 +1435,18 @@ case $REQUEST in RET=$? [ $RET -eq 0 ] && social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"sent $AUTODISTPKGS to $SENDREPOSITORY\" STIME=`date +%s`" ;; - "autoport") $SUDO_WRAPPER background $ENVIRONMENT "$USER" $PACKAGE "autoport $PACKAGE -r $REPOSITORY" &>/dev/null - [ $? -ne 0 ] && RET=$? || { + "autoport") if [ "$AUTOPORTPACKAGE" ]; then + $SUDO_WRAPPER background $ENVIRONMENT "$USER" $AUTOPORTPACKAGE "autoport $AUTOPORTPACKAGE -r $REPOSITORY" &>/dev/null + RET=$? + [ $REQ -eq 0 ] && { RET=-1 echo "Autoport started. You may see the output in the Webbuild jobs box above." } - ;; + else + echo "ERROR: no port package specified!" + RET=1 + fi + ;; "autospecupdatescheck") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a2"; RET=$? ;; "rpmprepare") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "rpmbuild -bp $PACKAGE.spec --nodeps"; RET=$? ;; "rpmbuild") [ "$RPMFORCE" = "true" ] && RPMFORCEADD="--force-build" @@ -1634,7 +1648,7 @@ case $REQUEST in echo "ERROR: BUILDROOT is undefined" RET=1 else - $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDROOT && find $SPECVAR_BUILDROOT" + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDROOT/$SPECVAR_BUILDROOT && find" RET=$? fi ;; @@ -1661,7 +1675,7 @@ case $REQUEST in echo -n "" done ;; - "configurehelp") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDDIR/$SPECVAR_BUILDDIR && ./configure --help" + "configurehelp") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDDIR/$SPECVAR_BUILDDIR && ./configure --help || ./waf configure --help" RET=$? [ $RET -eq 0 ] && RET=-1 ;; "configurelog") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDDIR/$SPECVAR_BUILDDIR && cat config.log" @@ -1848,7 +1862,7 @@ if [ "$MAINTAINERMODE" = "true" ]; then else [ "$PACKAGE" ] && echo -n "$PACKAGE $SPECVAR_Version-$SPECVAR_Release " || echo -n "no package " echo -n "(" - print_environment_descr + print_environment_descr $ENVIRONMENT echo -n ")" fi diff --git a/webbuild/webbuild-functions b/webbuild/webbuild-functions index 258cf45..6f5ad2d 100644 --- a/webbuild/webbuild-functions +++ b/webbuild/webbuild-functions @@ -210,7 +210,7 @@ function parse_build_output() { s|^\([\+#] .*\)|\1|; s|\(ftp[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|
\1|; s|\(http[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|\1|; - s|\(.*error[^0-9A-Za-z]*:[[:space:]]*\)\(.*\)|\1\2|i; + s|\(.*\)\(error[^0-9A-Za-z]*:[[:space:]]*.*\)|\1\2|i; s|^\(== =.*\)|\1|; s|^[[:cntrl:]]*\([!%?=][!%!=>] .*\)|\1|; s|[[:cntrl:]]||g;" | google_search $1 @@ -260,3 +260,29 @@ function print_environment_descr() { echo -n " for ${AUTOPORT_ARCH[$i]}" # (${AUTOPORT_BASE_REPOSITORY[$i]} based)" } + +function environment_autoport_logdir() { + local env=$1 + if [ "${AUTOPORT_CHROOT[$env]}" ]; then + echo "/var/autoport/${AUTOPORT_CHROOT[$env]}/home/${AUTOPORT_CHROOT_USER[$env]}/.autoport/" + elif [ "${AUTOPORT_NATIVE[$env]}" ]; then + local envhome=`eval echo ~${AUTOPORT_CHROOT_USER[$env]}` + echo "$envhome/.autoport" + fi +} + +function environment_logdir() { + local env=$1 + if [ "${AUTOPORT_CHROOT[$env]}" ]; then + echo "/var/autoport/${AUTOPORT_CHROOT[$env]}/home/${AUTOPORT_CHROOT_USER[$env]}/.autodist/log/" + elif [ "${AUTOPORT_NATIVE[$env]}" ]; then + local envhome=`eval echo ~${AUTOPORT_CHROOT_USER[$env]}` + if [ "${AUTOPORT_CHROOT_USER[$env]}" = "autodist" ]; then + echo "$envhome/log" + else + echo "$envhome/.autodist/log/" + fi + else + echo "/var/autodist/log/" + fi +} diff --git a/webbuild/webbuild-functions-private b/webbuild/webbuild-functions-private index fd7e34b..7b5bc70 100644 --- a/webbuild/webbuild-functions-private +++ b/webbuild/webbuild-functions-private @@ -23,17 +23,12 @@ function showlog() { LOGFILE3=$LOGFILE/*_${PACKAGE/\//_}__*.${AUTOPORT_ARCH[$ENVIRONMENT]} LOGFILE4=$LOGFILE/*_${PACKAGE/\//_}.${AUTOPORT_ARCH[$ENVIRONMENT]} - if [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then - LOGDIR="/var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/home/${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}/.autodist/log/" - elif [ "${AUTOPORT_NATIVE[$ENVIRONMENT]}" ]; then - LOGDIR="/home/${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}/.autodist/log/" - else - LOGDIR="/var/autodist/log/" - fi + LOGDIR=`environment_logdir $ENVIRONMENT` LOGFILES="$LOGDIR/$LOGFILE1 $LOGDIR/$LOGFILE2 $LOGDIR/$LOGFILE3 $LOGDIR/$LOGFILE4" for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do [ "$i" = "$ENVIRONMENT" ] && continue + [ "${AUTOPORT_ARCH[$i]}" = "${AUTOPORT_ARCH[$ENVIRONMENT]}" ] || continue if [ "${AUTOPORT_UPDATE[$i]}" ]; then LOGDIR="/var/autodist/log" LOGFILES="$LOGFILES $LOGDIR/$LOGFILE1 $LOGDIR/$LOGFILE2 $LOGDIR/$LOGFILE3 $LOGDIR/$LOGFILE4"