From 9f98345aad41b53a853f3c2a830994cb52aee304 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Mon, 19 Nov 2012 23:52:30 +0100 Subject: [PATCH] webbuild: added another ton of changes; added webbuild-functions-private external include --- Makefile | 1 + webbuild/html/scripts/socialbox.js | 8 +- webbuild/html/scripts/webbuild.js | 9 + webbuild/webbuild-cgi | 1036 ++++++++++++++++----------- webbuild/webbuild-functions | 91 ++- webbuild/webbuild-functions-private | 168 +++++ webbuild/webbuild-sudo | 61 +- 7 files changed, 944 insertions(+), 430 deletions(-) create mode 100644 webbuild/webbuild-functions-private diff --git a/Makefile b/Makefile index 26d7b9a..6925471 100644 --- a/Makefile +++ b/Makefile @@ -76,6 +76,7 @@ install-programs: @$(INSTALL_SCRIPT) webbuild/webbuild-sudo $(DESTDIR)$(libexecdir)/webbuild-sudo @$(INSTALL_SCRIPT) webbuild/webbuild-checkpassword $(DESTDIR)$(libexecdir)/webbuild-checkpassword @$(INSTALL_SCRIPT) webbuild/webbuild-functions $(DESTDIR)$(pck_datadir)/webbuild-functions + @$(INSTALL_SCRIPT) webbuild/webbuild-functions-private $(DESTDIR)$(pck_datadir)/webbuild-functions-private @cp -a webbuild/html/* $(DESTDIR)$(htmldir) install-data: diff --git a/webbuild/html/scripts/socialbox.js b/webbuild/html/scripts/socialbox.js index eab809f..79269df 100644 --- a/webbuild/html/scripts/socialbox.js +++ b/webbuild/html/scripts/socialbox.js @@ -31,7 +31,11 @@ function socialbox_refresh_times() { function ajax_getvalues_refresh(request,user,user_email,secret) { var fromid = 0; if (document.getElementsByName("social").length > 0) { - fromid = parseInt(document.getElementsByName("social")[0].attributes[1].value) + 1; + if (document.getElementsByName("social")[0].attributes[0].name == "sid") { + fromid = parseInt(document.getElementsByName("social")[0].attributes[0].value) + 1; + } else { + fromid = parseInt(document.getElementsByName("social")[0].attributes[1].value) + 1; + } } if (request != "") request=request+"&REQUEST=refresh&USER="+user+"&USER_EMAIL="+user_email+"&SECRET="+secret+"&FROMID="+fromid; @@ -59,7 +63,7 @@ function ajax_getvalues_refresh(request,user,user_email,secret) { "" + nodes[i].childNodes[0].nodeValue + "" + document.getElementById("socialbox").innerHTML; } - if (document.getElementById("processes") != undefined) + if (xmldoc.getElementsByTagName("processes")[0] != undefined) document.getElementById("processes").innerHTML = xmldoc.getElementsByTagName("processes")[0].childNodes[0].nodeValue; $(function() { $('.scroll-pane').jScrollPane({scrollbarWidth:10}); }); // lastupdate = (+new Date()); diff --git a/webbuild/html/scripts/webbuild.js b/webbuild/html/scripts/webbuild.js index ae12621..19e0813 100644 --- a/webbuild/html/scripts/webbuild.js +++ b/webbuild/html/scripts/webbuild.js @@ -13,3 +13,12 @@ function getSelectedValueById(selectname,idx) { var i=document.getElementById(selectname).selectedIndex; return document.getElementById(selectname).options[i+idx].value; } + +function checkEnter(event) { + event=event || window.event; + getEvent=event.keyCode; + if (getEvent == "13") { + return true; + } + return false; +} diff --git a/webbuild/webbuild-cgi b/webbuild/webbuild-cgi index 7626d28..165f3af 100755 --- a/webbuild/webbuild-cgi +++ b/webbuild/webbuild-cgi @@ -5,29 +5,9 @@ # . /etc/sysconfig/autoport . /usr/share/autodist/webbuild-functions +. /usr/share/autodist/webbuild-functions-private -function print_environment_descr() { - local i=$1 - - if [ "${AUTOPORT_CHROOT_USER[$i]}" ]; then - echo -n "${AUTOPORT_CHROOT_USER[$i]} " - else - echo -n "autodist " - fi - if [ "${AUTOPORT_UPDATE[$i]}" ]; then - echo -n "autoupdate" - elif [ "${AUTOPORT_CHROOT[$i]}" ]; then - echo -n "chroot" - elif [ "${AUTOPORT_NATIVE[$i]}" ]; then - echo -n "native" - elif [ "${AUTOPORT_CROSS[$i]}" ]; then - echo -n "cross" - else - echo -n "unknown type" - fi - echo -n " for ${AUTOPORT_ARCH[$i]} (${AUTOPORT_BASE_REPOSITORY[$i]} based)" -} - +AUTOSPEC_CMD="autospec --colors web" # register all GET and POST variables cgi_getvars BOTH ALL @@ -77,7 +57,7 @@ if [ "$SECRET" -a "$USER" ]; then echo -n " " echo -n " " echo -n " " - echo -n "'$SECRET'='$USER_SECRET' Unauthorized! If this happened after you changed your password in openmamba website please ask the maintainer to be re-enabled to use this service. Thank you." + echo -n "Unauthorized! If this happened after you changed your password in openmamba website please ask the maintainer to be re-enabled to use this service. Thank you." echo -n "" echo -n " " echo -n "" @@ -124,15 +104,15 @@ if [ "$USER_ENABLED" != "1" ]; then echo -n " " if [ "$USER" -a "$SECRET" ]; then if [ "$REQUEST" = "enablerequest" ]; then - echo "`date` - USER=$USER USER_EMAIL=$USER_EMAIL REQUEST=$REQUEST SECRET=$SECRET" >> $WEBBUILD_STATEDIR/requests_log + echo "REQUEST_DATE=\"`date`\" REQUEST_USER=$USER REQUEST_USER_EMAIL=$USER_EMAIL REQUEST_TYPE=$REQUEST REQUEST_SECRET='$SECRET'" >> $WEBBUILD_STATEDIR/requests echo -n "Your request has been submitted. Please wait for approval and retry later." elif [ "$REQUEST" = "password" ]; then echo -n "Invalid password. Please reload and retry or ask the maintainer in case of problems." - elif [ "`grep \" USER=$USER \" $WEBBUILD_STATEDIR/requests_log`" ]; then + elif [ "`grep \" REQUEST_USER=$USER \" $WEBBUILD_STATEDIR/requests`" ]; then echo -n "Your request is pending for approval. Please try again later or ask the maintainer in case of problems." else echo -n "" echo -n "]]>" fi @@ -175,6 +155,13 @@ if [ "$USER" -a "$USER_ENABLED" ]; then set_user_state_var STATE_PRIVACYMODE fi fi + if [ "$JOBSSHOWALL" != "" ]; then + if [ "$JOBSSHOWALL" = "true" ]; then + set_user_state_var STATE_JOBSSHOWALL 1 + else + set_user_state_var STATE_JOBSSHOWALL + fi + fi # read user state file [ -e $WEBBUILD_STATEDIR/users/$USER.state ] && . $WEBBUILD_STATEDIR/users/$USER.state @@ -222,7 +209,7 @@ if [ "$REQUEST" = "refresh" -o ! "$USER" ]; then [ "$SID" ] || continue [ $SID -ge $FROMID ] || continue [ "$STARGET" = "developers" -a ! "$USER" ] && continue - [ "$SUSER" = "$USER" -a "$STYPE" != "broadcastmessage" ] && continue + [ "$SUSER" = "$USER" -a "$STARGET" == "developers" ] && continue if [ "$SPRIVACY" -a ! "$USER" ]; then USER_GRAVATAR= else @@ -231,7 +218,9 @@ if [ "$REQUEST" = "refresh" -o ! "$USER" ]; then echo -n "" echo -n "" if [ "$SPRIVACY" -a ! "$USER" ]; then - SUSER="A developer" + SUSER="a developer" + elif [ "$USER" = "$SUSER" ]; then + SUSER="you" fi echo -n "
$SUSER $STEXT

" echo -n "

]]>
" @@ -249,6 +238,36 @@ fi # Enabled users requests # +# delete a note +if [ "$REQUEST" = "removenote" ]; then + if [ "$USER" = "$NOTEUSER" -o "$USER_ADMIN" ]; then + [ -e $WEBBUILD_STATEDIR/notes/$PACKAGE.notes ] || break + sed -i "/^$NOTEDATE $NOTEUSER /d" $WEBBUILD_STATEDIR/notes/$PACKAGE.notes + [ ! -s $WEBBUILD_STATEDIR/notes/$PACKAGE.notes ] && rm -f $WEBBUILD_STATEDIR/notes/$PACKAGE.notes + fi + echo -n "" + exit +fi + +# enable user +if [ "$USER_ADMIN" -a "$REQUEST" = "enableuser" ]; then + if [ ! -e $WEBBUILD_STATEDIR/users/$REQUEST_USER.conf ]; then + if [ "$REQUEST_ACCEPT" = "true" ]; then + cat >> $WEBBUILD_STATEDIR/users/$REQUEST_USER.conf << _EOF +USER_ENABLED=1 +USER_SECRET='$REQUEST_SECRET' +_EOF + else + cat >> $WEBBUILD_STATEDIR/users/$REQUEST_USER.conf << _EOF +USER_ENABLED=0 +_EOF + fi + sed -i "/ REQUEST_USER=$REQUEST_USER /d" $WEBBUILD_STATEDIR/requests + fi + echo -n "" + exit +fi + # kill processes or clean log if [ "$REQUEST" = "killtree" ]; then killline=`grep "^$KILLPID " $WEBBUILD_STATEDIR/processes` @@ -266,54 +285,81 @@ if [ "$REQUEST" = "killtree" ]; then fi # refresh processes list -if [ "$REQUEST" = "refresh" ]; then +if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshjobs" ]; then echo -n "Pending admin requests:" + while read line; do + eval $line + echo -n "
$REQUEST_USER: " + case $REQUEST_TYPE in + "enablerequest") echo -n "enable request" ;; + *) echo -n "unknown request" ;; + esac + echo -n " " + echo -n " " + done < $WEBBUILD_STATEDIR/requests + echo -n "" + fi + numprocess=0 while read line; do set -- $line RETCODE=$6 # if [ -e /proc/$1 -o $5 -lt 256 ]; then - numprocess=`expr $numprocess + 1` - cmdline=`echo $line | sed "s|$1 $2 $3 $4 $5 $RETCODE ||"` - PACKAGE_ENCODED=`cgi_encodevar $4` - [ $numprocess -eq 1 ] && { - echo -n "
" - echo -n "Webbuild jobs: (please click on [x] to clean your build logs when you are done)
" - } - 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...)" + numprocess=`expr $numprocess + 1` + cmdline=`echo $line | sed "s|$1 $2 $3 $4 $5 $RETCODE ||"` + PACKAGE_ENCODED=`cgi_encodevar $4` + [ $numprocess -eq 1 ] && { + echo -n "
" + echo -n "Webbuild jobs: " + if [ "$STATE_JOBSSHOWALL" != "1" ]; then + echo "[ Show all ]" else - echo -n "\"" - echo -n "$cmdline\" " - if [ $RETCODE -eq 256 ]; 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 - echo -n " [" - echo -n "kill" - else - echo -n " [" - echo -n "x" - fi - echo -n "]" + echo "[ Show mine only ]" fi + #echo -n "(please click on [x] to clean your build logs when you are done)" echo -n "
" -# fi + } + [ "$STATE_JOBSSHOWALL" = "1" -o "$USER" = "$2" ] || continue + 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 "\"" + echo -n "$cmdline\" " + if [ $RETCODE -eq 256 ]; 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 + echo -n " [" + echo -n "kill" + else + echo -n " [" + echo -n "x" + fi + echo -n "]" + fi + echo -n "
" done < $WEBBUILD_STATEDIR/processes [ $numprocess -gt 0 ] && echo -n "
" echo -n "]]>" @@ -332,9 +378,39 @@ fi # repsearch request if [ "$REQUEST" = "repsearch" ]; then echo -n "Console output:
" + echo -n "
Repository search results for \"$REPSEARCHTEXT\":
" echo -n "
"
-   $SUDO_WRAPPER 0 local "$USER" "" "openmamba-repository search -i $REPSEARCHTEXT"
+   $SUDO_WRAPPER 0 local "$USER" "" "openmamba-repository search -i $REPSEARCHTEXT" | \
+      parse_search_output ${AUTOPORT_ARCH[$ENVIRONMENT]}
+#      sed "s|\(.*(source).*\)|\1|;
+#           s|\(.*(${AUTOPORT_ARCH[$ENVIRONMENT]}).*\)|\1|"
+   echo -n "
" + echo "
]]>" + exit +fi + +# environment search request +if [ "$REQUEST" = "environmentsearch" ]; then + echo -n "Environment search results for \"$ENVSEARCHTEXT\":
" + echo -n "
"
+   echo -n "Installed packages providing '$ENVSEARCHTEXT':
" + WHAT_PROVIDES=`$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "rpm -q --what-provides \"$ENVSEARCHTEXT\"" | sort -u` + echo -n "$WHAT_PROVIDES
" + if [ "${WHAT_PROVIDES:0:10}" != "no package" ]; then + for f in $WHAT_PROVIDES; do + echo -n "$f installed package info:
" + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "rpm -qi $f" + if [ $? -eq 0 ]; then + echo -n "$f provides:
" + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "rpm -q $f --provides" + echo -n "$f requirements:
" + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "rpm -q $f --requires" + fi + done + fi +# sed "s|\(.*(source).*\)|\1|; +# s|\(.*(${AUTOPORT_ARCH[$ENVIRONMENT]}).*\)|\1|" echo -n "
" echo "
]]>
" exit @@ -374,60 +450,7 @@ fi # show log if [ "$REQUEST" = "showlog" -o "$REQUEST" = "autobuildedit" ]; then - echo -n "Console output:" - if [ "$LOGTYPE" = "processoutput" -o "$LOGTYPE" = "processtail" ]; then - LOGFILES=$LOGFILE - else - case $LOGTYPE in - autoupdate) LOGFILE=update ;; - buildinstall|rebuild) LOGFILE=build ;; - *) LOGFILE=$LOGTYPE ;; - esac - if [ "$LOGSTATUSOK" = "true" ]; then - LOGFILE=$LOGFILE/ok - else - LOGFILE=$LOGFILE/failed - fi - LOGFILE1=$LOGFILE/$PACKAGE.${AUTOPORT_ARCH[$ENVIRONMENT]} - LOGFILE2=$LOGFILE/${PACKAGE}__*.${AUTOPORT_ARCH[$ENVIRONMENT]} - LOGFILE3=$LOGFILE/*_${PACKAGE}__*.${AUTOPORT_ARCH[$ENVIRONMENT]} - LOGFILE4=$LOGFILE/*_${PACKAGE}.${AUTOPORT_ARCH[$ENVIRONMENT]} - LOGFILES="$BUILDLOGDIR/$LOGFILE1 $BUILDLOGDIR/$LOGFILE2 $BUILDLOGDIR/$LOGFILE3 $BUILDLOGDIR/$LOGFILE4" - fi - echo "
" - for f in $LOGFILES; do - [ -r $f ] || continue - LOGFILESIZE=`stat -c %s $f` - echo -n "`basename $f` (`stat -c %y $f`; $LOGFILESIZE)
"
-      if [ "$LOGTYPE" = "processtail" ]; then
-         echo -n ""
-         tail -n +0 -f $f --pid $PROCESSPID | sed "s|<|\<|g"
-         echo -n ""
-      else
-         if [ $LOGFILESIZE -lt 64512 ]; then
-            cat $f | parse_build_output $PACKAGE
-#            sed "s|<|\<|g;s|[[:cntrl:]]\[[0-9;]*m||g;
-#                          s|^\([\+#] .*\)|\1|;
-#                          s|\(.*error[[:space:]]*:[[:space:]]*\)\(.*\)|\1\2|i;
-#                          s|^\([%?=][%!=>] .*\)|\1|" | google_search $PACKAGE
-##                          s|\(.*error[[:space:]]*:.*\)|\1|i;
-         else
-            head -c 31744 $f | parse_build_output $PACKAGE
-#            sed "s|<|\<|g;s|[[:cntrl:]]\[[0-9;]*m||g;
-#                          s|^\([\+#] .*\)|\1|;
-#                          s|\(.*error[[:space:]]*:.*\)|\1|i;
-#                          s|^\([%?=][%!=>] .*\)|\1|"
-            echo "
<------ CUT (long file) ------->" - tail -c 31744 $f | parse_build_output $PACKAGE -# sed "s|<|\<|g;s|[[:cntrl:]]\[[0-9;]*m||g; -# s|^\([\+#] .*\)|\1|; -# s|\(.*error[[:space:]]*:\)\(.*\)|\1\2|i; -# s|^\([%?=][%!=>] .*\)|\1|" - fi - fi - echo -n "
" - done - echo -n "
]]>
" + showlog if [ "$REQUEST" = "autobuildedit" ]; then REQUEST=edit else @@ -482,36 +505,36 @@ if [ "$HOST_IS_X86_64" -a "${AUTOPORT_ARCH[$ENVIRONMENT]}" != "x86_64" ]; then SUDO_WRAPPER="linux32 $SUDO_WRAPPER" fi +echo -n "Build environment:" +echo -n "]]>" + if [ "$MAINTAINERMODE" = "true" ]; then - echo -n " " echo -n " " elif [ ! "$REQUEST" -o "$REQUEST" = "changeenvironment" -o "$REQUEST" = "switchmaintainermode" -o "$REQUEST" = "prepare" ]; then - echo -n "Build environment:" - echo -n "]]>" # SPECFILES select echo -n "" echo -n "" - for f in `$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "ls *.spec"`; do + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "ls *.spec | sort -f" | while read f; do specname=${f/.spec} [ "$PACKAGE" = "$specname" ] && SELECTED="selected=\"selected\"" || SELECTED= echo -n "" @@ -524,21 +547,25 @@ fi # clean output when changing environment if [ ! "$REPOSITORY" -a ! "$PACKAGE" -a ! "$REQUEST" = "repsearch" ]; then echo -n " " -# echo -n "]]>" -# echo -n "]]>" + echo -n " " fi # REPOSITORIES search if [ ! "$REPSEARCHTEXT" ]; then echo -n "Search repositories:" +#" + if [ "$PACKAGE" ]; then + echo -n "" - if [ "$PACKAGE" ]; then - echo -n "" - else - echo -n "" - fi echo -n "
]]>" fi @@ -568,28 +595,37 @@ if [ ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" -o "$MAINTAINERMODE" = "true" ]; then done echo -n "" echo -n "]]>" - echo -n " " +# echo -n " " echo -n " " echo -n " " fi else echo -n "" + # autobuild edit select echo -n "" + # autobuild edit next echo -n " \" onclick=" echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&" + echo -n "AUTODISTCURRENT=\"+getElementById('autodistcurrentcheckbox').checked+\"&" echo -n "PACKAGE=\"+encodeURIComponent(getSelectedValueById(\"autobuildedit\",1).substring(0,getSelectedValueById(\"autobuildedit\",1).indexOf(';')))+\"&" echo -n "LOGTYPE=\"+getSelectedValueById(\"autobuildedit\",1).substring(getSelectedValueById(\"autobuildedit\",1).indexOf(';')+1)+\"&REQUEST=autobuildedit\");>" + # autodist current checkbox (in progress) + [ "$AUTODISTCURRENT" = "true" ] && SELECTED="checked" || SELECTED= + echo -n "" echo -n " ]]>" echo -n " " echo -n " " echo -n " " + if [ "$REQUEST" = "skip" ]; then + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "autodist-tool skip $AUTODISTJOB" + RET=$? + if [ $RET -eq 0 ]; then + social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"added autodist job $AUTODISTJOB to skipped list\" STIME=`date +%s`" + fi + if [ "$NEXTPACKAGE" ]; then + PACKAGE=$NEXTPACKAGE + PACKAGEENCODED=`cgi_encodevar $PACKAGE` + LOGTYPE=$NEXTLOGTYPE + AUTODISTJOB= + showlog + REQUEST="edit" + fi + fi fi if [ "$MAINTAINERMODE" = "true" -o ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then @@ -618,7 +680,8 @@ if [ "$MAINTAINERMODE" = "true" -o ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then #(getElementById('package').selectedIndex);>" echo "" SRPMBUTTONDISABLED="disabled=disabled" - for f in $local_ftp/$REPOSITORY/SRPMS.base/*.src.rpm; do + ls $local_ftp/$REPOSITORY/SRPMS.base/*.src.rpm | sort -f > $WEBBUILD_STATEDIR/cache/repository-src-$REPOSITORY + while read f; do [ -r $f ] || continue pkgname=`basename $f` pkgname=${pkgname/.src.rpm} @@ -627,13 +690,13 @@ if [ "$MAINTAINERMODE" = "true" -o ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then pkgver=${pkgname/*-} pkgname=${pkgname/-$pkgver} if [ "$PACKAGE" = "$pkgname" ]; then - SELECTED="selected=\"selected\""; + SELECTED="selected=\"selected\"" SRPMBUTTONDISABLED= else SELECTED= fi echo -n "" - done + done < $WEBBUILD_STATEDIR/cache/repository-src-$REPOSITORY echo -n "" echo -n "]]>" if [ "$MAINTAINERMODE" != "true" ]; then @@ -687,42 +750,45 @@ elif [ "$REQUEST" = "broadcastmessage" ]; then REQUEST= fi -#if [ "$MAINTAINERMODE" != "true" -a ! "$PACKAGE" ]; then -# echo " " -# echo " " -# echo " " -#fi - if [ "$SPECTEXT" ]; then # save specfile - tmpfile=`mktemp --suffix=webbuildspectmp` + tmpfile=`mktemp --suffix=.webbuildspectmp` echo -n $SPECTEXT | perl -MURI::Escape -e 'print uri_unescape(<>)' > $tmpfile chmod 644 $tmpfile - $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cat $tmpfile > $PACKAGE.spec" $tmpfile + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" ${PACKAGE/*\/} "cat $tmpfile > ${PACKAGE/*\/}.spec" $tmpfile + RET=$? + [ $RET -eq 0 ] || { + echo -n "ERROR: could not save file ${PACKAGE/*\/}.spec! Please report the problem, thanks.
]]>
" + exit 1 + } rm -f $tmpfile fi if [ "$REQUEST" = "edit" -o "$REQUEST" = "prepare" ]; then - social_log "SUSER=$USER SEMAIL=$USER_EMAIL STARGET=developers STEXT=\"is working on $PACKAGE\" STIME=`date +%s`" + if [ ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then + social_log "SUSER=$USER SEMAIL=$USER_EMAIL STARGET=developers STEXT=\"is working on $PACKAGE\" STIME=`date +%s`" + fi fi # Here requests which update the specfile, so editor is refreshed after if [ "$REQUEST" = "prepare" -o "$REQUEST" = "updatespec" -o "$REQUEST" = "speccreate" -o \ "$REQUEST" = "rebuildspec" -o "$REQUEST" = "renamespec" -o "$REQUEST" = "deletespec" -o \ - "$REQUEST" = "autodistprepare" -o "$REQUEST" = "autodistupdate" ]; then + "$REQUEST" = "autodistprepare" -o "$REQUEST" = "autodistupdate" -o "$REQUEST" = "addpkgnote" ]; then echo -n "Console output:
" echo -n "
"
    RET=255
    case $REQUEST in
-      "prepare") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "autospec -u $PACKAGE -a1 --server $REPOSITORY"; RET=$? ;;
-      "updatespec") if [ "$UPDATESPECVERSION" -a "$REBUILDSPECCHANGELOG" ]; then
+      "prepare") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a1 --server $REPOSITORY"; RET=$? ;;
+      "updatespec") [ "$RPMFORCE" = "true" ] && RPMFORCEADD="--force-update"
+                    if [ "$UPDATESPECVERSION" -a "$REBUILDSPECCHANGELOG" ]; then
                        echo "ERROR: new version and changelog can't be specified together"
                     elif [ "$REBUILDSPECCHANGELOG" ]; then
-                       $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "autospec -u $PACKAGE -a4 --rebuild --changelog \"$REBUILDSPECCHANGELOG\""
-                    elif [ "$UPDATESSPECVERSION" ]; then
-                       $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "autospec -u $PACKAGE -a3,4 $UPDATESPECVERSION"
+                       echo "$AUTOSPEC_CMD -u $PACKAGE -a4 $RPMFORCEADD --rebuild --changelog \"$REBUILDSPECCHANGELOG\""
+                       $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a4 $RPMFORCEADD --rebuild --changelog \"$REBUILDSPECCHANGELOG\""
+                    elif [ "$UPDATESPECVERSION" ]; then
+                       $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a3,4 $RPMFORCEADD $UPDATESPECVERSION"
                     else
-                       $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "autospec -u $PACKAGE -a2:4 $UPDATESPECVERSION"
+                       $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a2:4 $RPMFORCEADD $UPDATESPECVERSION"
                     fi
                     RET=$?
                     ;;
@@ -731,10 +797,12 @@ if [ "$REQUEST" = "prepare" -o "$REQUEST" = "updatespec" -o "$REQUEST" = "speccr
                        #DECODEDURL=`cgi_decodevar $SPECCREATEURL`
                        [ "$SPECCREATETYPE" ] && AUTOSPEC_CMDLINE="$AUTOSPEC_CMDLINE -t $SPECCREATETYPE"
                        [ "$SPECCREATEVERSION" ] && AUTOSPEC_CMDLINE="$AUTOSPEC_CMDLINE -v $SPECCREATEVERSION"
-                       $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "autospec -s \"$SPECCREATEURL\" $AUTOSPEC_CMDLINE"
+                       $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "$AUTOSPEC_CMD -s \"$SPECCREATEURL\" $AUTOSPEC_CMDLINE --changelog \"package created by $USER using the webbuild interface\""
                        RET=$?
-                       [ $RET -eq 0 ] && social_log "SUSER=$USER SEMAIL=$USER_EMAIL STARGET=developers STEXT=\"is working on $PACKAGE new package\" STIME=`date +%s`"
-#                          --changelog \"package created by $USER from autodist webbuild interface\""
+                       [ $RET -eq 0 ] && {
+                          social_log "SUSER=$USER SEMAIL=$USER_EMAIL STARGET=developers STEXT=\"is working on $PACKAGE new package\" STIME=`date +%s`"
+                          echo "
HINT: don't forget to add build requirements after successful build! Edit specfile and check recreate SRPM before sending the package." + } else echo "ERROR: both source archive URL and name are needed." RET=1 @@ -760,7 +828,8 @@ if [ "$REQUEST" = "prepare" -o "$REQUEST" = "updatespec" -o "$REQUEST" = "speccr else autodistjobs="$AUTODISTJOB" fi - $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "autodist -v -p $autodistjobs --repository ${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]} --arch $AUTODISTARCH $AUTODISTADD" + [ "$REPOSITORY" ] && REPOSITORYADD="--repository $REPOSITORY" || REPOSITORYADD="--repository ${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]}" + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "autodist -v -p $autodistjobs $REPOSITORYADD --arch $AUTODISTARCH $AUTODISTADD" RET=$? ;; "autodistupdate") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD= @@ -772,9 +841,11 @@ if [ "$REQUEST" = "prepare" -o "$REQUEST" = "updatespec" -o "$REQUEST" = "speccr else autodistjobs="$AUTODISTJOB" fi - $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "autodist -v -u $autodistjobs --repository ${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]} --arch $AUTODISTARCH $AUTODISTADD" + [ "$REPOSITORY" ] && REPOSITORYADD="--repository $REPOSITORY" || REPOSITORYADD="--repository ${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]}" + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "autodist -v -u $autodistjobs $REPOSITORYADD --arch $AUTODISTARCH $AUTODISTADD" RET=$? ;; + "addpkgnote") echo "`date +%s` $USER $ENVIRONMENT $PKGNOTE" >> $WEBBUILD_STATEDIR/notes/$PACKAGE.notes; RET=$? ;; esac echo -n "
" if [ $RET -eq 0 ]; then @@ -791,7 +862,12 @@ if [ "$REQUEST" = "prepare" -o "$REQUEST" = "updatespec" -o "$REQUEST" = "speccr echo -n "" exit fi - [ $RET -eq 0 ] && REQUEST="edit" || REQUEST= + if [ $RET -eq 0 ]; then + REQUEST="edit" + print_editorcontrols + else + REQUEST= + fi fi # maintainer mode editor @@ -804,7 +880,7 @@ if [ "$MAINTAINERMODE" = "true" ]; then echo -n "" echo -n "Recent packages in $REPOSITORY:
" - cat $local_ftp/distromatic/$REPOSITORY/_recent.inc + cat $local_ftp/distromatic/$REPOSITORY/_recent.inc | sed "s|a href=|a target=new href=|g" echo -n "
Log:
"
          cat $local_ftp/$REPOSITORY/distromatic.log
          echo -n "
" @@ -823,49 +899,36 @@ if [ "$REQUEST" = "changerepository" -o "$REQUEST" = "switchmaintainermode" -o " REQUEST= fi +if [ "$PACKAGE" ]; then + [ "$AUTODISTJOB" ] || AUTODISTJOB=${PACKAGE/\/*} + AUTODISTJOB="${AUTODISTJOB/-/_}" + PACKAGE=${PACKAGE/*\/} + eval `$SUDO_WRAPPER specinfo $ENVIRONMENT "$USER" $PACKAGE ""` + [ $? -eq 0 ] && SPECAVAILABLE=1 +fi + # specfile editor -if [ "$REQUEST" = "edit" -o "$REQUEST" = "reloadspec" -o "$REQUEST" = "switchmaintainermode" -a "$MAINTAINERMODE" != "true" ]; then - if [ "$PACKAGE" ]; then - $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "ls $PACKAGE.spec" - [ $? -eq 0 ] && SPECAVAILABLE=1 - fi +if [ "$REQUEST" = "edit" -o "$REQUEST" = "reloadspec" -o "$REQUEST" = "switchmaintainermode" -o \ + "$REQUEST" = "renamespec" -o "$REQUEST" = "addpkgnote" -a "$MAINTAINERMODE" != "true" ]; then if [ "$SPECAVAILABLE" ]; then - echo -n "" - echo -n " (specify new version:" - echo -n " or changelog for a new release:)" - echo -n "]]>" # editor textarea - echo -n "$PACKAGE.spec in build environment:" - # specfile save - echo -n "" - # specfile reload - echo -n "$PACKAGE.spec?

Warning: current unsaved .spec file changes will be lost."`\");>" - # specfile rename - echo -n "" - echo -n ".spec" - # specfile delete - echo -n "$PACKAGE.spec?"`\")>" - echo -n "]]>
" + echo -n "]]>" # else # echo "" # echo "No pre-existing .spec file $PACKAGE.spec in current working environment. Choose package from a repository and press 'Unpack and edit' to edit." @@ -878,32 +941,9 @@ fi # operation panel if [ "$MAINTAINERMODE" != "true" ]; then echo -n "" - if [ "${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}" ]; then - echo -n "${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} " - else - echo -n "autodist " - fi - if [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then - echo -n "autoupdate" - elif [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then - echo -n "chroot" - elif [ "${AUTOPORT_NATIVE[$ENVIRONMENT]}" ]; then - echo -n "native" - elif [ "${AUTOPORT_CROSS[$ENVIRONMENT]}" ]; then - echo -n "cross" - else - echo -n "unknown type" - fi - echo -n " for ${AUTOPORT_ARCH[$ENVIRONMENT]}" - # smart upgrade - echo -n "" - + showEnvironmentPanel echo -n "
" - [ "$PACKAGE" ] && echo -n "Package: $PACKAGE
" + [ "$PACKAGE" ] && echo -n "Package: $PACKAGE
Version: ${SPECVAR_Version[0]}-${SPECVAR_Release[0]}
" echo -n "Target arch:" - echo -n "" + echo -n "" # destination repository select echo -n "
Send to:" echo -n "
" - [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" -o "$STATE_ADVANCEDCONTROLS" ] && echo -n "
Autodist batch builds:
" + [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" -o "$STATE_ADVANCEDCONTROLS" ] && echo -n "
Autodist batch builds:
" if [ "$PACKAGE" ]; then if [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then echo -n "Patch for $PACKAGE:
" # autodist show patch - echo -n "" # autodist remove patch @@ -947,23 +987,23 @@ if [ "$MAINTAINERMODE" != "true" ]; then echo -n "REQUEST=removepatch\"" echo -n ",\"`cgi_encodevar "Remove current autodist patch for package $PACKAGE?"`\"); class=redbutton>" # autodist auto patch - echo -n "$PACKAGE?
Note: patch type will be autodetected."`\"); class=redboldbutton>" - # autodist update patch - echo -n "update patch for package $PACKAGE?"`\"); class=redbutton>" - # autodist build patch - echo -n "build patch for package $PACKAGE?"`\"); class=redbutton>" + echo -n ",\"`cgi_encodevar "Create or refresh autodist patch for package $PACKAGE?"`\"); class=redboldbutton>" + ## autodist update patch + #echo -n "update patch for package $PACKAGE?"`\"); class=redbutton>" + ## autodist build patch + #echo -n "build patch for package $PACKAGE?"`\"); class=redbutton>" fi fi if [ "$STATE_ADVANCEDCONTROLS" -o "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then @@ -974,25 +1014,26 @@ if [ "$MAINTAINERMODE" != "true" ]; then echo -n "AUTODISTFORCE=\"+getElementById('rpmforce').checked+\"&" echo -n "AUTODISTARCH=\"+getSelectedValueById('rpmbuildarch')+\"&" echo -n "AUTODISTJOB=\"+getSelectedValueById('autodistjobs')+\"&" - echo -n "ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&REQUEST=autodistjobchange\");>" + echo -n "ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=autodistjobchange\");>" echo -n "" + AUTODISTJOBSELECTED= for f in `$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "autodist --list-jobs"`; do SELECTED= - if [ "$AUTODISTJOB" ]; then - [ "$AUTODISTJOB" = "$f" ] && SELECTED="selected=\"selected\"" + if [ "$AUTODISTJOB" -a "$AUTODISTJOB" = "$f" ]; then + SELECTED="selected=\"selected\"" + AUTODISTJOBSELECTED=1 elif [ "$PACKAGE" = "$f" ]; then SELECTED="selected=\"selected\"" AUTODISTJOB=$f + AUTODISTJOBSELECTED=1 fi JOBENCODED=`cgi_encodevar $f` echo -n "" done - if [ "$PACKAGE" ]; then - [ "$AUTODISTJOB" ] && SELECTED= || { - SELECTED="selected=\"selected\"" - AUTODISTJOB=$PACKAGE - } - echo -n "" + if [ "$PACKAGE" -a ! "$AUTODISTJOBSELECTED" ]; then + SELECTED="selected=\"selected\"" + AUTODISTJOB=$PACKAGE + echo -n "" fi echo -n "" if [ "$AUTODISTJOB" ]; then @@ -1003,7 +1044,7 @@ if [ "$MAINTAINERMODE" != "true" ]; then [ "$i" = "$p" ] && { SELECTED=checked; break; } || SELECTED= done else - [ "$p" = "$AUTODISTJOB" ] && SELECTED=checked || SELECTED= + [ "$p" = "$PACKAGE" ] && SELECTED=checked || SELECTED= fi echo -n "" done @@ -1015,7 +1056,7 @@ if [ "$MAINTAINERMODE" != "true" ]; then echo -n "AUTODISTARCH=\"+getSelectedValueById('rpmbuildarch')+\"&" echo -n "AUTODISTJOB=\"+getSelectedValueById('autodistjobs')+\"&" echo -n "AUTODISTPKGS=\"+encodeURIComponent(p)+\"&" - echo -n "ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&REQUEST=autodistprepare\");>" + echo -n "ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=autodistprepare\");>" # autodist update echo -n "" + echo -n "ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=autodistupdate\");>" # autodist build echo -n "" + echo -n "ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=autodistbuild\"); class=boldbutton>" # autodist install [ ! "$USER_CANINSTALL" ] && DISABLED="disabled=disabled" || DISABLED= echo -n ""`\"+getSelectedValueById('autodistjobs')+\"`cgi_encodevar " job in current environment?"`\"" echo -n "); class=redbutton $DISABLED>" # autodist send @@ -1053,38 +1094,45 @@ if [ "$MAINTAINERMODE" != "true" ]; then echo -n "AUTODISTJOB=\"+getSelectedValueById('autodistjobs')+\"&" echo -n "AUTODISTPKGS=\"+encodeURIComponent(p)+\"&" echo -n "SENDREPOSITORY=\"+getSelectedValueById('sendrepository')+\"&" - echo -n "ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&REQUEST=autodistsend\"" + echo -n "ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=autodistsend\"" echo -n ",\"`cgi_encodevar "Send selected packages for "`\"+getSelectedValueById('autodistjobs')+\"`cgi_encodevar " job to "`\"+" echo -n "getSelectedValueById('sendrepository')+\"`cgi_encodevar "?"`\"); class=redbutton $DISABLED>" # autodist schedule echo -n "
"`\"+getSelectedValueById('autodistjobs')+\"`cgi_encodevar " autodist job for automatic update?"`\"); class=boldbutton>" echo -n "(version:)" # autodist show schedule - echo -n "" # autodist unschedule - echo -n "" # autodist skip - echo -n "
" + echo -n "AUTODISTCURRENT=\"+getElementById('autodistcurrentcheckbox').checked+\"&" + echo -n "REQUEST=skip\"" + echo -n ",\"`cgi_encodevar "Skip "`\"+getSelectedValueById('autodistjobs')+\"`cgi_encodevar " from being checked for automatic updates for a period?"`\"" + echo -n "); class=redbutton>
" else echo -n "
" fi # automatic port if [ ! "${AUTOPORT_DISABLE[$ENVIRONMENT]}" -a ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then - echo -n "
Automatic port:" + echo -n "Automatic port:" echo -n "$PACKAGE package with current specfile changes?"`\"); class=redbutton>" + echo -n ",\"`cgi_encodevar "Port $PACKAGE package in "`\"+p+\"`cgi_encodevar " with current specfile changes?"`\"); class=redbutton>" echo -n "" fi @@ -1092,7 +1140,7 @@ if [ "$MAINTAINERMODE" != "true" ]; then if [ "$PACKAGE" ]; then if [ "$STATE_ADVANCEDCONTROLS" -o "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then # autodist logs - echo -n "
Last autodist logs: " + echo -n "

Last autodist logs: " echo -n "OK " echo -n "FAILED
" echo -n "" fi - echo -n "
RPM packaging commands:
" + echo -n "
RPM packaging commands:
" # check for updates echo -n "" + echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=autospecupdatescheck&" + echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue()));>" # unpack echo -n "" - # recreate SRPM - echo -n "" + ## recreate SRPM + #echo -n "" # rpm checks echo -n "" @@ -1144,33 +1194,72 @@ if [ "$MAINTAINERMODE" != "true" ]; then echo -n ",\"`cgi_encodevar "Install $PACKAGE in current environment?"`\"" echo -n "); class=redbutton $DISABLED>" # rpm send + if [ "$SPECVAR_CHECK_NOAUTOBUILDREQ" ]; then + HREFADD="disabled=disabled title=\"WARNING: fix specfile build requirements before you can send the package\"" + else + HREFADD= + fi echo -n "$PACKAGE built packages to "`\"+getSelectedValueById('sendrepository')+" echo -n "\"`cgi_encodevar "?"`\"" - echo -n "); class=redbutton>" + echo -n "); class=redbutton $HREFADD>" # recreate and send SRPM - echo -n "$PACKAGE source package only and send to "`\"+getSelectedValueById('sendrepository')+" - echo -n "\"`cgi_encodevar "?"`\"" - echo -n "); class=redbutton>" + echo -n ",\"`cgi_encodevar "Send $PACKAGE source package only to "`\"+getSelectedValueById('sendrepository')+" + echo -n "\"`cgi_encodevar "?

WARNING: use this to refresh the SRPM of a package which already exists with same release in repository"`\"" + echo -n "); class=redbutton $HREFADD>" + # recreate SRPM before sending checkbox + echo -n "" # add patches echo -n "
Add patches:" echo -n "
" + echo -n "ADDPATCHNAME=\"+encodeURIComponent(getElementById('addpatchname').value));>" + echo -n " pastebin
" echo -n "URL:" - echo -n "As: $PACKAGE-.patch" - + echo -n "
As: $PACKAGE-.patch" + echo -n "

" # info from package sources - echo -n "
Info from package in the works:
" - # source files - echo -n "Info from package in the works:
" + # show sources + echo -n "" + # show patches + echo -n "" + # list build dir files + echo -n "" # show package licenses echo -n "" # buildroot files echo -n "" # show package changelog echo -n "" # macros - echo -n "
" - echo -n "" -echo -n "Write a message to all developers:
" +echo -n "" +#echo -n "" if [ "$REQUEST" != "" ]; then - echo -n "Console output:" + echo -n "Console output ($REQUEST for $PACKAGE):" echo -n "
$PACKAGE.spec saved." + RET=-1 + ;; "smartupgrade") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "export LANG=C;sudo smart update && sudo smart upgrade" RET=$? ;; + "runldconfig") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "/sbin/ldconfig" + RET=$? + ;; "showpatch") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "autodist-tool makepatch $PACKAGE"; RET=$? ;; "removepatch") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "autodist-tool makepatch $PACKAGE remove" RET=$? @@ -1278,7 +1374,7 @@ case $REQUEST in $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "autodist-tool schedule $AUTODISTJOB" RET=$? if [ $RET -eq 0 ]; then - social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"scheduled autodist job $PAUTODISTJOB for automatic update\" STIME=`date +%s`" + social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"scheduled autodist job $AUTODISTJOB for automatic update\" STIME=`date +%s`" fi fi ;; @@ -1287,11 +1383,6 @@ case $REQUEST in if [ $RET -eq 0 ]; then social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"unscheduled autodist job $AUTODISTJOB\" STIME=`date +%s`" fi ;; - "skip") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "autodist-tool skip $AUTODISTJOB" - RET=$? - if [ $RET -eq 0 ]; then - social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"added autodist job $AUTODISTJOB to skipped list\" STIME=`date +%s`" - fi ;; "autodistbuild") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD= autodistjobs= if [ "$AUTODISTPKGS" ]; then @@ -1301,8 +1392,11 @@ case $REQUEST in else autodistjobs="$AUTODISTJOB" fi - $SUDO_WRAPPER background $ENVIRONMENT "$USER" "$PACKAGE" "autodist -v -b $autodistjobs --repository ${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]} --arch $AUTODISTARCH $AUTODISTADD" - RET=$? + $SUDO_WRAPPER background $ENVIRONMENT "$USER" "$PACKAGE" "autodist -v -b $autodistjobs --repository ${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]} --arch $AUTODISTARCH $AUTODISTADD" &>/dev/null + [ $? -ne 0 ] && RET=$? || { + RET=-1 + echo "Autodist build start. You may see the output in the Webbuild jobs box above." + } #[ $RET -eq 0 ] && social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"successfully built $PACKAGE\" STIME=`date +%s`" ;; "autodistinstall") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD= @@ -1314,8 +1408,12 @@ case $REQUEST in else autodistjobs="$AUTODISTJOB" fi - $SUDO_WRAPPER background $ENVIRONMENT "$USER" "$PACKAGE" "autodist -v -i $autodistjobs --repository ${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]} --arch $AUTODISTARCH $AUTODISTADD" - RET=$? ;; + $SUDO_WRAPPER background $ENVIRONMENT "$USER" "$PACKAGE" "autodist -v -i $autodistjobs --repository ${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]} --arch $AUTODISTARCH $AUTODISTADD" &>/dev/null + [ $? -ne 0 ] && RET=$? || { + RET=-1 + echo "Autodist install start. You may see the output in the Webbuild jobs box above." + } + ;; "autodistsend") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD= autodistjobs= if [ "$AUTODISTPKGS" ]; then @@ -1329,59 +1427,100 @@ 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 -v" - RET=$? + "autoport") $SUDO_WRAPPER background $ENVIRONMENT "$USER" $PACKAGE "autoport $PACKAGE -r $REPOSITORY" &>/dev/null + [ $? -ne 0 ] && RET=$? || { + RET=-1 + echo "Autoport started. You may see the output in the Webbuild jobs box above." + } ;; - "buildrootfiles") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd @RPMBUILDROOT@ && find @BUILDROOT@"; RET=$? ;; - "autospecupdatescheck") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "autospec -u $PACKAGE -a2"; RET=$? ;; + "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" [ "$RPMBUILDARCH" -a "$RPMBUILDARCH" != "${AUTOPORT_ARCH[$ENVIRONMENT]}" ] && \ RPMARCHADD="-A $RPMBUILDARCH --define \"cross_target_cpu=$RPMBUILDARCH\"" - $SUDO_WRAPPER background $ENVIRONMENT "$USER" $PACKAGE "autospec -u $PACKAGE -a5,6 $RPMFORCEADD $RPMARCHADD" + $SUDO_WRAPPER background $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a5,6 $RPMFORCEADD $RPMARCHADD" &>/dev/null # && echo \"Webbuild HINT: now you may want to click on 'build requirements', add build requirements in .spec file and then 'recreate SRPMS'\"" - RET=$? + [ $? -ne 0 ] && RET=$? || { + RET=-1 + echo -n "Build started. You may see the output in the Webbuild jobs box above." + echo -n "

HINT: when build is done add or update build requirements to specfile and recreate SRPM." + } ;; - "srpmbuild") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "rpmbuild -bs --define=\"_sourcedir @WORKINGHOME@/RPM/SOURCES\" $PACKAGE.spec" - RET=$? ;; + "srpmbuild") [ "$RPMFORCE" = "true" ] && RPMFORCEADD="--nodeps" + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "rpmbuild -bs --define=\"_sourcedir $SPECVAR_WORKINGHOME/RPM/SOURCES\" $RPMFORCEADD $PACKAGE.spec" + RET=$? ;; "autospeclistcheck") [ "$RPMBUILDARCH" -a "$RPMBUILDARCH" != "${AUTOPORT_ARCH[$ENVIRONMENT]}" ] && \ RPMARCHADD="-A $RPMBUILDARCH --define \"cross_target_cpu=$RPMBUILDARCH\"" - $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "autospec -u $PACKAGE -a5 --list-check $RPMARCHADD" + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a5 --list-check --force $RPMARCHADD" RET=$? ;; - "autospecbuildreq") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "autospec -u $PACKAGE -a6" + "autospecbuildreq") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a6" RET=$? ;; - "rpmchecks") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "autospec -u $PACKAGE -a8"; RET=$? ;; - "rpmsimulateinstall") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "autospec -u $PACKAGE -a7"; RET=$? ;; + "rpmchecks") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a8"; RET=$? ;; + "rpmsimulateinstall") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a7"; RET=$? ;; "rpminstall") if [ "$USER_CANINSTALL" ]; then [ "$RPMFORCE" = "true" ] && RPMFORCEADD="--force-install" - $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "autospec -u $PACKAGE -a11 $RPMFORCEADD"; RET=$? + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a11 $RPMFORCEADD"; RET=$? else echo "Install function disabled." RET=1 fi ;; - "sendpackage") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "autospec -u $PACKAGE -a10 --server $SENDREPOSITORY" - RET=$? + "sendpackage") if [ "$SENDREPOSITORY" ]; then + if [ "$SENDRECREATESRPM" ]; then + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "rpmbuild -bs --define=\"_sourcedir $SPECVAR_WORKINGHOME/RPM/SOURCES\" $PACKAGE.spec $RPMFORCEADD && $AUTOSPEC_CMD -u $PACKAGE -a10 --server $SENDREPOSITORY" + RET=$? + else + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a10 --server $SENDREPOSITORY" + RET=$? + fi if [ $RET -eq 0 ]; then social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"sent $PACKAGE to $SENDREPOSITORY\" STIME=`date +%s`" - fi ;; - "sendsource") [ "$RPMFORCE" = "true" ] && RPMFORCEADD="--force --nodeps" - if [ "$SENDREPOSITORY" ]; then - $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "rpmbuild -bs --define=\"_sourcedir @WORKINGHOME@/RPM/SOURCES\" $PACKAGE.spec $RPMFORCEADD && autospec -u $PACKAGE -a10 --server $SENDREPOSITORY --norpm" + fi + else + echo "ERROR: send repository is not defined." + RET=255 + fi + ;; + "sendsource") [ "$RPMFORCE" = "true" ] && RPMFORCEADD="--nodeps" + if [ "$SENDREPOSITORY" ]; then + if [ "$SENDRECREATESRPM" ]; then + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "rpmbuild -bs --define=\"_sourcedir $SPECVAR_WORKINGHOME/RPM/SOURCES\" $PACKAGE.spec $RPMFORCEADD && $AUTOSPEC_CMD -u $PACKAGE -a10 --server $SENDREPOSITORY --norpm" RET=$? + if [ $RET -eq 0 ]; then + social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"sent edited $PACKAGE source to $SENDREPOSITORY\" STIME=`date +%s`" + fi else - echo "ERROR: send repository is not defined." - RET=255 - fi ;; + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a10 --server $SENDREPOSITORY --norpm" + RET=$? + if [ $RET -eq 0 ]; then + social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"sent $PACKAGE source to $SENDREPOSITORY\" STIME=`date +%s`" + fi + fi + else + echo "ERROR: send repository is not defined." + RET=255 + fi + ;; "addpatch") if [ "$ADDPATCHURL" -a "$ADDPATCHNAME" ]; then $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "curl -skL \"$ADDPATCHURL\" -o ../SOURCES/$PACKAGE-$ADDPATCHNAME.patch" RET=$? - [ $RET -eq 0 ] && echo "Patch added with name $PACKAGE-$ADDPATCHNAME.patch" + [ $RET -eq 0 ] && { + echo -n "Patch added with name $PACKAGE-$ADDPATCHNAME.patch." + echo -n "

HINT: add the following lines to the .spec file in the appropriate sections (fix indexes if needed):
" + NEWPATCHNUM=`expr ${#SPECVAR_Patch[*]} + 1` + echo -ne "
Patch$NEWPATCHNUM:        $PACKAGE-$ADDPATCHNAME.patch\n\n%patch$NEWPATCHNUM -p1
" + RET=-1 + } else echo "Patch URL or destination name not provided." RET=1 fi ;; "repositoryimport") + [ "$PACKAGES" ] || { + echo "ERROR: no packages(s) selected." + RET=1 + break + } for p in $PACKAGES; do [ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANMAINTAIN" ] && SIMULATEADD="-s" || SIMULATEADD= [ "$REPOSITORYFORCE" = "true" ] && FORCEADD="-f" @@ -1394,6 +1533,11 @@ case $REQUEST in done ;; "repositoryrelease") + [ "$PACKAGES" ] || { + echo "ERROR: no package(s) selected." + RET=1 + break + } for p in $PACKAGES; do [ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANMAINTAIN" ] && SIMULATEADD="-s" || SIMULATEADD= [ "$REPOSITORYFORCE" = "true" ] && SIMULATEADD="$SIMULATEADD -f" @@ -1406,6 +1550,11 @@ case $REQUEST in done ;; "repositorydiff") + [ "$PACKAGES" ] || { + echo "ERROR: no package(s) selected." + RET=1 + break + } for p in $PACKAGES; do $SUDO_WRAPPER 0 local "$USER" "" "openmamba-repository diff $SENDREPOSITORY $p -d $REPOSITORYIMPORTTO" RET=$? @@ -1413,6 +1562,11 @@ case $REQUEST in done ;; "repositoryarchive") + [ "$PACKAGES" ] || { + echo "ERROR: no package(s) selected." + RET=1 + break + } for p in $PACKAGES; do [ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANMAINTAIN" ] && SIMULATEADD="-s" || SIMULATEADD= $SUDO_WRAPPER 0 local "$USER" "$PACKAGE" "openmamba-repository archive $SENDREPOSITORY $p -y" @@ -1423,25 +1577,67 @@ case $REQUEST in [ $RET -eq 0 ] || break done ;; + "repositorymassrebuild") + if [ ! "$PACKAGES" ]; then + echo "ERROR: no package(s) selected." + RET=1 + elif [ ! "$MASSREBUILDCHANGELOG" ]; then + echo "ERROR: changelog was not specified." + RET=1 + else + $SUDO_WRAPPER background $ENVIRONMENT "$USER" "$PACKAGE" "autoport -r $SENDREPOSITORY -d $REPOSITORYIMPORTTO $PACKAGES -u \"$MASSREBUILDCHANGELOG\"" &>/dev/null + [ $? -ne 0 ] && RET=$? || { + RET=-1 + echo -n "Mass rebuild started. You may see the output in the Webbuild jobs box above." + } +# if [ $RET -eq 0 ]; then +# social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"mass rebuilt $PACKAGES from $SENDREPOSITORY and sent them to $REPOSITORYIMPORTTO\" STIME=`date +%s`" +# fi + fi + ;; "repositorysync") if [ "$REPOSITORY" ]; then $SUDO_WRAPPER background local "$USER" "" "/etc/cron.hourly/20-openmamba-apt $REPOSITORY" - RET=$? - [ $RET -eq 0 ] && $SUDO_WRAPPER background local "$USER" "" "/etc/cron.hourly/40-openmamba-rsync $REPOSITORY" - RET=$? - [ $RET -eq 0 ] || break + LOCALRET=$? + [ $LOCALRET -eq 0 ] && $SUDO_WRAPPER background local "$USER" "" "/etc/cron.hourly/40-openmamba-rsync $REPOSITORY" + LOCALRET=$? + [ $LOCALRET -ne 0 ] && RET=$LOCALRET || RET=-1 fi ;; - "autoportnp") $SUDO_WRAPPER background $ENVIRONMENT "$USER" $PACKAGE "autoport -v -np $PACKAGE"; RET=$? ;; + "autoportnp") $SUDO_WRAPPER background $ENVIRONMENT "$USER" $PACKAGE "autoport -np $PACKAGE -r $PORTREPOSITORY" &>/dev/null + [ $? -ne 0 ] && RET=$? || { + RET=-1 + echo -n "Autoport started. You may see the output in the Webbuild jobs box above." + } + ;; "autoportlog") cat "$AUTOPORTLOGDIR/current.log"; RET=$? ;; - "allowedgroups") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "autospec --eval rpm_allowed_groups"; RET=$? ;; - "approvedlicenses") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "autospec --eval rpm_approved_licenses | grep -v \"^#\"" | \ + "allowedgroups") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "$AUTOSPEC_CMD --eval rpm_allowed_groups" + RET=$? + [ $RET -eq 0 ] && RET=-1 + ;; + "approvedlicenses") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "$AUTOSPEC_CMD --eval rpm_approved_licenses | grep -v \"^#\"" | \ while read line; do echo $line done - RET=0 + RET=-1 ;; - "builddirfiles") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd @RPMBUILDDIR@ && find @BUILDDIR@"; RET=$? ;; + "builddirfiles") if [ ! "$SPECVAR_BUILDDIR" ]; then + echo "ERROR: BUILDDIR is undefined" + RET=1 + else + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDDIR && find $SPECVAR_BUILDDIR" + RET=$? + [ $RET -eq 0 ] && RET=-1 + fi + ;; + "buildrootfiles") if [ ! "$SPECVAR_BUILDROOT" ]; then + echo "ERROR: BUILDROOT is undefined" + RET=1 + else + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDROOT && find $SPECVAR_BUILDROOT" + RET=$? + fi + ;; "showchangelogs"|"showbuilddocs"|"showlicenses") if [ "$REQUEST" = "showchangelogs" ]; then PATTERN="-iname changelog -or -iname news -and -type f" @@ -1450,24 +1646,49 @@ case $REQUEST in elif [ "$REQUEST" = "showbuilddocs" ]; then PATTERN="-iname readme\* -or -iname install\* -or -iname todo\* -or -iname pkgbuild\* -and -type f" fi - files=`$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd @RPMBUILDDIR@/@BUILDDIR@ && find . $PATTERN -maxdepth 2"` + files=`$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDDIR/$SPECVAR_BUILDDIR && find . $PATTERN -maxdepth 2"` cnt=0 for f in $files; do echo -n "$f
" done echo -n "
" for f in $files; do - echo -n "

File $f:

"
+                          echo -n "

File $f:

"
                           $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE \
-                             "cd @RPMBUILDDIR@/@BUILDDIR@ && head -c 10240 $f | sed \"s|<|\<|g;s|[[:cntrl:]]\[[0-9;]*m||g\"" | \
-                             tee /tmp/prova5
+                             "cd $SPECVAR_RPMBUILDDIR/$SPECVAR_BUILDDIR && head -c 10240 $f | sed \"s|<|\<|g;s|[[:cntrl:]]\[[0-9;]*m||g\"" | parse_generic_output
                           RET=$?
+                          [ $RET -eq 0 ] && RET=-1
                           echo -n "
" done ;; - "configurehelp") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd @RPMBUILDDIR@/@BUILDDIR@ && ./configure --help"; RET=$? ;; - "configurelog") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd @RPMBUILDDIR@/@BUILDDIR@ && cat config.log"; RET=$? ;; - "showmacrosfile") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cat /etc/rpm/macros.$MACROSFILE"; RET=$? ;; + "configurehelp") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDDIR/$SPECVAR_BUILDDIR && ./configure --help" + RET=$? + [ $RET -eq 0 ] && RET=-1 ;; + "configurelog") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDDIR/$SPECVAR_BUILDDIR && cat config.log" + RET=$? + [ $RET -eq 0 ] && RET=-1 ;; + "showmacrosfile") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cat /etc/rpm/macros.$MACROSFILE" + RET=$? + [ $RET -eq 0 ] && RET=-1 ;; + "showpatchfile") OUTPATCHFILE=${PATCHFILE/*\/} + case ${OUTPATCHFILE/*.} in + gz|gzip) $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "gunzip -c $SPECVAR_RPMSOURCESDIR/$OUTPATCHFILE" | parse_patch_output ;; + bz2) $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "bzcat $SPECVAR_RPMSOURCESDIR/$OUTPATCHFILE" | parse_patch_output ;; + *) $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cat $SPECVAR_RPMSOURCESDIR/$OUTPATCHFILE" | parse_patch_output ;; + esac + RET=$? + [ $RET -eq 0 ] && RET=-1 + ;; + "showsourcefile") OUTSOURCEFILE=${SOURCEFILE/*\/} + case ${OUTSOURCEFILE} in + *.tar.*) $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "tar tvf $SPECVAR_RPMSOURCESDIR/$OUTSOURCEFILE" ;; + *.gz|*.gzip) $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "gunzip -c $SPECVAR_RPMSOURCESDIR/$OUTSOURCEFILE" ;; + *.bz2) $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "bzcat $SPECVAR_RPMSOURCESDIR/$OUTSOURCEFILE" ;; + *) $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cat $SPECVAR_RPMSOURCESDIR/$OUTSOURCEFILE" | parse_patch_output ;; + esac + RET=$? + [ $RET -eq 0 ] && RET=-1 + ;; *) RET=0 ;; esac @@ -1477,16 +1698,23 @@ if [ "$REQUEST" != "" ]; then fi if [ $RET -eq 0 ]; then echo "Result: OK" - else + elif [ $RET -gt 0 ]; then echo "Result: ERROR ($RET)" fi echo -n "
" echo -n "]]>
" + # editor controls + if [ $RET -le 0 -a "$SPECAVAILABLE" -a ! "$MAINTAINERMODE" ]; then + print_editorcontrols + fi fi + if [ "$MAINTAINERMODE" = "true" ]; then echo -n " " echo -n "" if [ "$REPOSITORY" ]; then echo -n "Repository maintenance:
" # echo -n "select/unselect all" echo -n "
" - for f in $local_ftp/$REPOSITORY/SRPMS.base/*.src.rpm; do + ls $local_ftp/$REPOSITORY/SRPMS.base/*.src.rpm | sort -f | while read f; do [ -r $f ] || continue pkgname=`basename $f` pkgname=${pkgname/.src.rpm} @@ -1513,8 +1742,16 @@ if [ "$MAINTAINERMODE" = "true" ]; then echo -n "" done echo -n "
" - echo -n "Origin: $REPOSITORY
" - echo -n "Destination: " + echo -n "Origin: $REPOSITORY" + # repository sync + echo -n " $REPOSITORY updates immediately available from public server?"`\"" + echo -n "); class=redbutton>" + echo -n "
Destination: " echo -n "
" @@ -1578,58 +1817,39 @@ if [ "$MAINTAINERMODE" = "true" ]; then echo -n "REQUEST=repositoryarchive\"" echo -n ",\"`cgi_encodevar "Archive "`\"+p+\"`cgi_encodevar " in $REPOSITORY?"`\"" echo -n "); class=redbutton>" - echo -n "" - echo -n "" - # repository sync - echo -n " $REPOSITORY updates immediately available from public server?"`\"" + echo -n "REPOSITORYIMPORTTO=\"+getSelectedValueById('repositoryimportto')+\"&" + echo -n "REPOSITORYSIMULATE=\"+getElementById('repositorysimulate').checked+\"&" + echo -n "REPOSITORYFORCE=\"+getElementById('repositoryforce').checked+\"&" + echo -n "MASSREBUILDCHANGELOG=\"+encodeURIComponent(getElementById('massrebuildchangelog').value)+\"&" + echo -n "SENDREPOSITORY=$REPOSITORY&REQUEST=repositorymassrebuild\"" + echo -n ",\"`cgi_encodevar "Rebuild "`\"+p+\"`cgi_encodevar " from $REPOSITORY and send to "`\"+getSelectedValueById('repositoryimportto')+" + echo -n "\"`cgi_encodevar "?"`\"" echo -n "); class=redbutton>" + echo -n " Changelog:" + echo -n "" + # force checkbox + echo -n "" + # simulate checkbox + echo -n "" fi echo -n "]]>
" fi -#if [ ! "$REQUEST" -o "$REQUEST" = "output" ]; then -# echo -n "All hosts] [Build hosts monitor]
" -# for h in `seq 0 ${#AUTOPORT_CGI_HOST[*]}`; do -# curl "${AUTOPORT_CGI_HOST[$h]}?AS_HOST=$h&SHOWINDEX=1" 2>/dev/null -# done -# echo "
" -# -# [ "$HOST" = "$AS_HOST" ] && echo "

Host: `hostname -s` (`uname -m`, kernel `uname -r`)

" -# -# echo -n "]]>
" -#fi - echo -n "" if [ "$MAINTAINERMODE" = "true" ]; then [ "$REPOSITORY" ] && echo -n "$REPOSITORY " || echo -n "no repository " echo -n "(Maintainer mode)" else - [ "$PACKAGE" ] && echo -n "$PACKAGE " || echo -n "no package " + [ "$PACKAGE" ] && echo -n "$PACKAGE $SPECVAR_Version-$SPECVAR_Release " || echo -n "no package " echo -n "(" - if [ "${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}" ]; then - echo -n "${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} " - else - echo -n "autodist " - fi - if [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then - echo -n "autoupdate" - elif [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then - echo -n "chroot" - elif [ "${AUTOPORT_NATIVE[$ENVIRONMENT]}" ]; then - echo -n "native" - elif [ "${AUTOPORT_CROSS[$ENVIRONMENT]}" ]; then - echo -n "cross" - else - echo -n "unknown type" - fi - echo -n " for ${AUTOPORT_ARCH[$ENVIRONMENT]})" + print_environment_descr + echo -n ")" fi echo -n " :: openmamba webbuild" diff --git a/webbuild/webbuild-functions b/webbuild/webbuild-functions index c72ef44..258cf45 100644 --- a/webbuild/webbuild-functions +++ b/webbuild/webbuild-functions @@ -155,12 +155,74 @@ function kill_tree() { return $? } +function parse_search_output() { + local SEARCHARCH=$1 + echo -n "" + while read line; do + [ "$line" ] || continue + set -- $line + local REPOSITORY=${1/(*} + local ARCH=`echo $1 | sed "s|.*(\(.*\)):|\1|"` + local PKG=`echo $2 | sed "s|\(.*\)-[^-]*-[^-]*|\1|"` + if [ "$ARCH" = "source" ]; then + echo -n "" + elif [ "$ARCH" = "$SEARCHARCH" ]; then + echo -n "" + else + echo -n "" + fi + echo -n "$REPOSITORY($ARCH): " + echo -n "$2
" + echo -n "
" +# if [ "$ARCH" ] +# $SUDO_WRAPPER 0 local "$USER" "" "openmamba-repository search -i $REPSEARCHTEXT" | \ +# sed "s|\(.*(source).*\)|\1|; +# s|\(.*(${AUTOPORT_ARCH[$ENVIRONMENT]}).*\)|\1|" + done + echo -n "
" +} + +function parse_patch_output() { + local PATCH_STARTED SAVE_IFS=$IFS + + IFS='' + echo -n "" + while read line; do + [ "${line:0:3}" = "+++" ] && echo -n "" + echo "$line" | sed "s|<|\<|g;s|[[:cntrl:]]\[[0-9;]*m||g; + s|^\(+++.*\)|\1|; + s|^\(---.*\)|\1|; + s|^\(-.*\)|\1|; + s|^\(+.*\)|\1|; + s|^ |\ |;" + done + IFS=$SAVE_IFS +} + function parse_build_output() { sed "s|<|\<|g;s|[[:cntrl:]]\[[0-9;]*m||g; + s|<font|\1|; - s|\(.*error[[:space:]]*:[[:space:]]*\)\(.*\)|\1\2|i; + s|\(ftp[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|\1|; + s|\(http[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|\1|; + s|\(.*error[^0-9A-Za-z]*:[[:space:]]*\)\(.*\)|\1\2|i; s|^\(== =.*\)|\1|; - s|^[[:cntrl:]]*\([!%?=][!%!=>] .*\)|\1|;" | google_search $1 + s|^[[:cntrl:]]*\([!%?=][!%!=>] .*\)|\1|; + s|[[:cntrl:]]||g;" | google_search $1 +} + +function parse_generic_output() { + sed "s|<|\<|g;s|[[:cntrl:]]\[[0-9;]*m||g; + s|<font|\1|; + s|\(ftp[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|\1|; + s|\(http[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|\1|;" | google_search $1 } function google_search() { @@ -171,7 +233,30 @@ function google_search() { else SEARCH_STRING=`echo $SEARCH_STRING | sed "s|\<|<|"` local SEARCH_STRING_ENCODED=`cgi_encodevar "$1 $SEARCH_STRING"` - echo "$line" | sed "s|%SRCURL%.*%SRCURLEND%|href=\"http://www.google.com/search?q=$SEARCH_STRING_ENCODED\" target=_new title=\"Search this error on the Web\"|" + echo "$line" | sed "s|%SRCURL%.*%SRCURLEND%|href=\"http://www.google.com/search?q=$SEARCH_STRING_ENCODED\" target=_new title=\"Search this error on the Web\"|g" fi done } + +function print_environment_descr() { + local i=$1 + + if [ "${AUTOPORT_CHROOT_USER[$i]}" ]; then + echo -n "${AUTOPORT_CHROOT_USER[$i]} - " + else + echo -n "autodist - " + fi + if [ "${AUTOPORT_UPDATE[$i]}" ]; then + echo -n "update" + elif [ "${AUTOPORT_CHROOT[$i]}" ]; then + echo -n "chroot" + elif [ "${AUTOPORT_NATIVE[$i]}" ]; then + echo -n "native" + elif [ "${AUTOPORT_CROSS[$i]}" ]; then + echo -n "cross" + else + echo -n "unknown type" + fi + echo -n " for ${AUTOPORT_ARCH[$i]}" + # (${AUTOPORT_BASE_REPOSITORY[$i]} based)" +} diff --git a/webbuild/webbuild-functions-private b/webbuild/webbuild-functions-private new file mode 100644 index 0000000..fd7e34b --- /dev/null +++ b/webbuild/webbuild-functions-private @@ -0,0 +1,168 @@ +function showlog() { + local LOGDIR LOGFILES LOGFILE1 LOGFILE2 LOGFILE3 LOGFILE4 + + if [ "$LOGTYPE" = "processoutput" -o "$LOGTYPE" = "processtail" ]; then + LOGFILES=$LOGFILE + LOGOUTPUTID=outputbottom + else + LOGOUTPUTID=outputbottom + case $LOGTYPE in + autoupdate) LOGFILE=update; ;; + buildinstall|rebuild) LOGFILE=build ;; + *) LOGFILE=$LOGTYPE ;; + esac + if [ "$LOGSTATUSOK" = "true" ]; then + LOGFILE=$LOGFILE/ok + LOGSTATUSAPPEND=" ok" + else + LOGFILE=$LOGFILE/failed + LOGSTATUSAPPEND=" failed" + fi + LOGFILE1=$LOGFILE/${PACKAGE/\//_}.${AUTOPORT_ARCH[$ENVIRONMENT]} + LOGFILE2=$LOGFILE/${PACKAGE/\//_}__*.${AUTOPORT_ARCH[$ENVIRONMENT]} + 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 + LOGFILES="$LOGDIR/$LOGFILE1 $LOGDIR/$LOGFILE2 $LOGDIR/$LOGFILE3 $LOGDIR/$LOGFILE4" + + for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do + [ "$i" = "$ENVIRONMENT" ] && continue + if [ "${AUTOPORT_UPDATE[$i]}" ]; then + LOGDIR="/var/autodist/log" + LOGFILES="$LOGFILES $LOGDIR/$LOGFILE1 $LOGDIR/$LOGFILE2 $LOGDIR/$LOGFILE3 $LOGDIR/$LOGFILE4" + fi + done + fi + echo -n "Console output for $PACKAGE ($LOGTYPE$LOGSTATUSAPPEND):" + echo "
" + for f in $LOGFILES; do + if [ -r $f ]; then + LOGFILESIZE=`stat -c %s $f` + LOGDATE=`stat -c %y $f` + else + LOGFILESIZE=`$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "stat -c %s $f"` + LOGDATE=`$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "stat -c %y $f"` + [ $? -eq 0 ] || continue + fi + echo -n "`basename $f` ($LOGDATE; $LOGFILESIZE):" + echo -n "
"
+      if [ "$LOGTYPE" = "processtail" ]; then
+         echo -n ""
+         tail -n +0 -f $f --pid $PROCESSPID | sed "s|<|\<|g"
+         echo -n ""
+      else
+         if [ $LOGFILESIZE -lt 131072 ]; then
+            if [ -r $f ]; then
+               cat $f | parse_build_output $PACKAGE
+            else
+               $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "cat $f" | parse_build_output $PACKAGE
+            fi
+         else
+            if [ -r $f ]; then
+               head -c 65535 $f | parse_build_output $PACKAGE
+               echo "
<------ CUT (long file) ------->" + tail -c 65535 $f | parse_build_output $PACKAGE + else + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "head -c 65535 $f" | parse_build_output $PACKAGE + echo "
<------ CUT (long file) ------->" + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "tail -c 65535 $f" | parse_build_output $PACKAGE + fi + fi + fi + echo -n "
" + done + echo -n "
]]>
" +} + +function showEnvironmentPanel() { + + echo -n "Environment: " + if [ "${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}" ]; then + echo -n "${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} - " + else + echo -n "autodist - " + fi + if [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then + echo -n "update" + elif [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then + echo -n "chroot" + elif [ "${AUTOPORT_NATIVE[$ENVIRONMENT]}" ]; then + echo -n "native" + elif [ "${AUTOPORT_CROSS[$ENVIRONMENT]}" ]; then + echo -n "cross" + else + echo -n "unknown type" + fi + echo -n " (${AUTOPORT_ARCH[$ENVIRONMENT]})" + + #echo "
Base repository: ${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]}" + + # smart upgrade + echo -n "" + + ## run ldconfig + #echo -n "" + + # environment search + echo -n "
Installed:" + +} + +function print_editorcontrols() { + + echo -n "" + # specfile reload + echo -n "$PACKAGE.spec?

Warning: current unsaved .spec file changes will be lost."`\");>" + # specfile rename + echo -n "" + echo -n ".spec" + # specfile delete + echo -n "$PACKAGE.spec?"`\")>" + # add a note + echo -n "" + echo -n "" + # specfile update + echo -n "
" + echo -n " (specify new version:" + echo -n " or new release changelog:)" + # close tag + echo -n "]]>
" + +} diff --git a/webbuild/webbuild-sudo b/webbuild/webbuild-sudo index 5d1975e..a495470 100755 --- a/webbuild/webbuild-sudo +++ b/webbuild/webbuild-sudo @@ -60,32 +60,53 @@ else WORKINGHOME="/var/autodist" SUCMDPREFIX="su -l autodist -c" RPMBUILDROOT="/var/tmp/autodist" - [ "$TMPFILE" ] && chown autodist $TMPFILE +# [ "$TMPFILE" ] && chown autodist $TMPFILE fi -if [ "$WORKINGHOME" ]; then +if [ "$MODE" = "specinfo" ]; then eval `$SUCMDPREFIX "autospec --eval=tmppath_dir|grep -v '^#'"` RPMBUILDROOT=$tmppath_dir SPECFILE=${ENVPREFIX}${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec if [ "$PACKAGE" -a -r "$SPECFILE" ]; then rm -f $SPECFILE.tmp + while read line; do + case "$line" in + "## AUTOBUILDREQ-BEGIN"*) AUTOBUILDREQ_BEGIN=1 ;; + "## AUTOBUILDREQ-END"*) AUTOBUILDREQ_END=1 ;; + "## note: run "*" to get the list of build requirements") AUTOBUILDREQ_UNDONE=1 ;; + esac + done < ${ENVPREFIX}${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec + [ "$AUTOBUILDREQ_BEGIN" -a "$AUTOBUILDREQ_END" -a ! "$AUTOBUILDREQ_UNDONE" ] || \ + echo "SPECVAR_CHECK_NOAUTOBUILDREQ=1" $SUCMDPREFIX "rpm -q --specfile ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec --specedit > ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec.tmp 2>/dev/null" if [ -e $SPECFILE.tmp ]; then + echo "SPECVAR_Specfile=\"$SPECFILE\"" BUILDDIR=`grep -m1 "^%setup.*-n " $SPECFILE.tmp | sed "s|.*-n \([^[:space:]]*\).*|\1|"` + while read line; do + set -- $line + [ "$1" = "%package" -o "$1" = "%description" ] && break + if [[ "$1" =~ ^[a-zA-Z]*[0-9]*:.* ]]; then + line="$(echo ${line/$1})" + specvar="SPECVAR_${1/:*}" + specvar="${specvar/[0-9]*}" + [ "$specvar" = "$lastspecvar" ] && varidx=`expr $varidx + 1` || varidx=0 + echo "$specvar[$varidx]=\"${line}\"" + [ "$specvar" = "SPECVAR_Version" -a ! "$BUILDDIR" ] && BUILDDIR="$PACKAGE-${line}" + fi + lastspecvar=$specvar + done < $SPECFILE.tmp rm -f $SPECFILE.tmp + echo "SPECVAR_BUILDDIR=\"$BUILDDIR\"" + echo "SPECVAR_BUILDROOT=\"$PACKAGE-root\"" + echo "SPECVAR_RPMBUILDDIR=\"${WORKINGHOME}/RPM/BUILD\"" + echo "SPECVAR_RPMSOURCESDIR=\"${WORKINGHOME}/RPM/SOURCES\"" + echo "SPECVAR_RPMBUILDROOT=\"$RPMBUILDROOT\"" + echo "SPECVAR_WORKINGHOME=\"$WORKINGHOME\"" + exit 0 fi - SPECVERSION=`grep -m1 "^Version:" ${SPECFILE} | sed "s|Version:[[:space:]]*||"` - BUILDROOT=$PACKAGE-root - #`grep ^BuildRoot: ${_tmpfile} | sed "s|BuildRoot:[[:space:]]*||"` -# SPECSETUP=`grep %setup ${_tmpfile} | sed "s|.*-n ||"` - [ "$BUILDDIR" ] || BUILDDIR=$PACKAGE-$SPECVERSION + else + exit 1 fi fi -RPMBUILDDIR=${WORKINGHOME}/RPM/BUILD -COMMAND=`echo $COMMAND | sed "s|@BUILDDIR@|$BUILDDIR|g"` -COMMAND=`echo $COMMAND | sed "s|@BUILDROOT@|$BUILDROOT|g"` -COMMAND=`echo $COMMAND | sed "s|@RPMBUILDDIR@|$RPMBUILDDIR|g"` -COMMAND=`echo $COMMAND | sed "s|@RPMBUILDROOT@|$RPMBUILDROOT|g"` -COMMAND=`echo $COMMAND | sed "s|@WORKINGHOME@|$WORKINGHOME|g"` echo "COMMAND: $COMMAND" >> $WEBBUILD_STATEDIR/commands_log cmdtmpfile=`mktemp --suffix=.webbuildcmd` @@ -93,23 +114,28 @@ cmdtmpfile=`mktemp --suffix=.webbuildcmd` [ "$PACKAGE" ] || PACKAGE=nopackage if [ "$MODE" = "background" ]; then if [ "$WORKINGHOME" ]; then - $SUCMDPREFIX ". /etc/profile;cd $WORKINGHOME/RPM/SPECS;$COMMAND;echo \"# WEBBUILD_EXITCODE=\$?\"" 2>&1 | sed "s|<|\<|g" | tr -d '\f' > $cmdtmpfile & + $SUCMDPREFIX ". /etc/profile;cd $WORKINGHOME/RPM/SPECS;$COMMAND;echo \"# WEBBUILD_EXITCODE=\$?\"" 2>&1 | tr -d '\f' > $cmdtmpfile & + #sed "s|<|\<|g" | else $SUCMDPREFIX "$COMMAND;echo \"# WEBBUILD_EXITCODE=\$?\"" 2>&1 | sed "s|<|\<|g" | tr -d '\f' > $cmdtmpfile & fi echo "$! $USER $ENVIRONMENT $PACKAGE $cmdtmpfile 256 $COMMAND" >> $WEBBUILD_STATEDIR/processes echo "Started background command: $COMMAND" + echo + echo "You may watch command live output and result in the Webbuild jobs box above." RET=0 else echo "$$ $USER $ENVIRONMENT $PACKAGE $cmdtmpfile 256 $COMMAND" >> $WEBBUILD_STATEDIR/processes rettmpfile=`$SUCMDPREFIX "mktemp --suffix=.webbuildret"` if [ "$WORKINGHOME" ]; then - $SUCMDPREFIX ". /etc/profile;cd $WORKINGHOME/RPM/SPECS;$COMMAND;echo \$? > $rettmpfile" 2>&1 | sed "s|<|\<|g" | tr -d '\f' | tee $cmdtmpfile + $SUCMDPREFIX ". /etc/profile;cd $WORKINGHOME/RPM/SPECS;$COMMAND;echo \$? > $rettmpfile" 2>&1 | tr -d '\f' | tee $cmdtmpfile + # sed "s|<|\<|g" | else - $SUCMDPREFIX "$COMMAND;echo \$? > $rettmpfile" 2>&1 | sed "s|<|\<|g" | tr -d '\f' | tee $cmdtmpfile + $SUCMDPREFIX "$COMMAND;echo \$? > $rettmpfile" 2>&1 | tr -d '\f' | tee $cmdtmpfile + # sed "s|<|\<|g" | fi RET=`cat $ENVPREFIX/$rettmpfile` - [ "$RET" ] || RET=255 + [ "$RET" ] || RET=254 $SUCMDPREFIX "rm -f $rettmpfile" sed -i "/^$$ $USER/d" $WEBBUILD_STATEDIR/processes if [ "$MODE" != "keeplog" ]; then @@ -128,4 +154,5 @@ if [ -e $cmdtmpfile ]; then chmod 666 $cmdtmpfile chown apache.nobody $cmdtmpfile fi + exit $RET