From 0601482f544aed5278a7ee9403327abb67676a78 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Fri, 21 Sep 2012 12:57:19 +0200 Subject: [PATCH] webbuild: sync with current alpha development with lots of changes and improvements --- webbuild/webbuild-cgi | 725 ++++++++++++++++++++++++------------ webbuild/webbuild-functions | 6 +- webbuild/webbuild-sudo | 99 +++-- 3 files changed, 559 insertions(+), 271 deletions(-) diff --git a/webbuild/webbuild-cgi b/webbuild/webbuild-cgi index e2ad907..a672678 100755 --- a/webbuild/webbuild-cgi +++ b/webbuild/webbuild-cgi @@ -66,7 +66,7 @@ if [ "$SECRET" -a "$USER" ]; then cat $WEBBUILD_STATEDIR/users/$USER.conf > $tmpfile echo "USER_SECRET='$SECRET'" >> $tmpfile USER_ENABLED=1 - $SUDO_WRAPPER local "" "mv $tmpfile $WEBBUILD_STATEDIR/users/$USER.conf" + $SUDO_WRAPPER 0 local "" "mv $tmpfile $WEBBUILD_STATEDIR/users/$USER.conf" else USER_ENABLED= fi @@ -189,8 +189,8 @@ if [ "$REQUEST" = "refresh" -o ! "$USER" ]; then else USER_GRAVATAR=`echo -n $SEMAIL | md5sum | sed "s| .*||"` fi - echo -n "
" - echo -n "
" + echo -n "
" + echo -n "
" DATENOW=`date +%s` DAYSAGO=`expr \( $DATENOW - $STIME \) / 86400` HOURAGO=`expr \( $DATENOW - $STIME \) / 3600 % 24` @@ -233,26 +233,71 @@ fi # Enabled users requests # +if [ "$REQUEST" = "killtree" ]; then + killline=`grep "^$KILLPID " $WEBBUILD_STATEDIR/processes` + if [ "$killline" ]; then + if [ $KILLPID -ge 1 ]; then + $SUDO_WRAPPER killtree $KILLPID +# if [ $? -eq 0 ]; then + set -- $killline + rm -f $4 + sed -i "/^$KILLPID /d" $WEBBUILD_STATEDIR/processes +# else +# echo "ERROR: killtree returned $?" +# fi + else + echo "ERROR: Invalid PID" + fi + fi + echo -n "" + exit +fi + if [ "$REQUEST" = "refresh" ]; then echo -n "" - echo -n "Webbuild running jobs:
" + echo -n "Webbuild jobs:
" } - echo -n "$2 \"$cmdline\" " - echo -n " [ " - echo -n "show ]" + echo -n "$2 " + 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 $4 + RETCODE=$? + fi + if [ $RETCODE -eq 0 ]; then + echo -n "OK" + else + echo -n "ERROR ($RETCODE)" + fi + fi + echo -n " [" + if [ $RETCODE -eq 256 -a -e /proc/$1 ]; then + echo -n "kill" + else + echo -n "x" + fi + echo -n "]" echo -n "
" - fi +# fi done < $WEBBUILD_STATEDIR/processes - [ $numprocesses -gt 0 ] && echo -n "
" + [ $numprocess -gt 0 ] && echo -n "
" echo -n "]]>" exit fi @@ -260,7 +305,8 @@ fi # message send request (social_log) if [ "$REQUEST" = "message" -a "$USER" -a "$USER_CANSENDMESSAGES" ]; then # external (autodist) social messages - social_log "SUSER=$USER STYPE=broadcastmessage SEMAIL=$USER_EMAIL STEXT=\"$MESSAGE\" STIME=`date +%s`" + [ "$MESSAGETYPE" ] || MESSAGETYPE=broadcastmessage + social_log "SUSER=$USER STYPE=$MESSAGETYPE SEMAIL=$USER_EMAIL STEXT=\"$MESSAGE\" STIME=`date +%s`" echo "" exit fi @@ -270,7 +316,7 @@ if [ "$REQUEST" = "repsearch" ]; then echo -n "" echo -n "
"
-   $SUDO_WRAPPER local "" "openmamba-repository search -i $REPSEARCHTEXT"
+   $SUDO_WRAPPER 0 local "" "openmamba-repository search -i $REPSEARCHTEXT"
    echo -n "
" echo "]]>
" exit @@ -393,7 +439,7 @@ fi # show log if [ "$REQUEST" = "showlog" ]; then echo -n "`basename $f` (`stat -c %y $f`)
"
-      cat $f | sed "s|<|\<|g"
+      if [ "$LOGTYPE" = "processtail" ]; then
+         echo -n ""
+         tail -n +0 -f $f --pid $PROCESSPID | sed "s|<|\<|g"
+         echo -n ""
+      else
+         cat $f | sed "s|<|\<|g"
+      fi
       echo -n "
" done echo -n "]]>
" @@ -429,8 +481,8 @@ if [ "$ENVIRONMENT" -a "$MAINTAINERMODE" != "true" ]; then echo -n "onchange=javascript:ajax_getvalues(\"REQUEST=edit&ENVIRONMENT=$ENVIRONMENT&" echo -n "PACKAGE=\"+encodeURIComponent(this.value)+\"&REQUEST=changespec\");>" echo -n "" - for f in `$SUDO_WRAPPER $ENVIRONMENT "" "ls *.spec"`; do - specname=${f/.*} + for f in `$SUDO_WRAPPER 0 $ENVIRONMENT "" "ls *.spec"`; do + specname=${f/.spec} [ "$PACKAGE" = "$specname" ] && SELECTED="selected=\"selected\"" || SELECTED= echo -n "" done @@ -443,7 +495,7 @@ fi if [ ! "$REPOSITORY" -a ! "$PACKAGE" -a ! "$REQUEST" = "repsearch" ]; then echo -n " " # echo -n "]]>" - echo -n "]]>" +# echo -n "]]>" fi # REPOSITORIES search @@ -473,7 +525,7 @@ if [ "$MAINTAINERMODE" = "true" -o ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then fi echo -n "&REQUEST=changerepository\");>" echo -n "" - for f in `$SUDO_WRAPPER local "" "/usr/sbin/openmamba-repository list"`; do + for f in `$SUDO_WRAPPER 0 local "" "/usr/sbin/openmamba-repository list"`; do repname=`basename $f` [ "$repname" = "$REPOSITORY" ] && SELECTED="selected=selected" || SELECTED= echo -n "" @@ -488,9 +540,10 @@ if [ "$MAINTAINERMODE" = "true" -o ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then if [ "$REQUEST" = "changerepository" -o "$REQUEST" = "switchmaintainermode" -a "$MAINTAINERMODE" != "true" ]; then echo -n "" + echo -n "getElementById('preparebutton').disabled=0;getElementById('portbutton').disabled=0;>" #(getElementById('package').selectedIndex);>" echo "" + SRPMBUTTONDISABLED="disabled=disabled" for f in $local_ftp/$REPOSITORY/SRPMS.base/*.src.rpm; do [ -r $f ] || continue pkgname=`basename $f` @@ -501,7 +554,7 @@ if [ "$MAINTAINERMODE" = "true" -o ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then pkgname=${pkgname/-$pkgver} if [ "$PACKAGE" = "$pkgname" ]; then SELECTED="selected=\"selected\""; -# REQUEST="changesrpm" + SRPMBUTTONDISABLED= else SELECTED= fi @@ -511,11 +564,16 @@ if [ "$MAINTAINERMODE" = "true" -o ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then echo -n "]]>" if [ "$MAINTAINERMODE" != "true" ]; then echo -n "" + echo -n "PACKAGE=\"+encodeURIComponent(getSelectedValueById('package'))); $SRPMBUTTONDISABLED>" + if [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then + echo -n "" + fi echo -n "]]>" # REQUEST=changesrpm fi @@ -542,9 +600,10 @@ if [ "$MAINTAINERMODE" = "true" -o ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then elif [ "$MAINTAINERMODE" = "true" ]; then echo -n " " fi -else - echo -n " " +#else +# echo -n " " fi + if [ "$REQUEST" = "changespec" ]; then if [ "$PACKAGE" ]; then REQUEST="edit"; @@ -555,18 +614,18 @@ elif [ "$REQUEST" = "broadcastmessage" ]; then REQUEST= fi -if [ "$MAINTAINERMODE" != "true" -a ! "$PACKAGE" ]; then - echo " " - echo " " - echo " " -fi +#if [ "$MAINTAINERMODE" != "true" -a ! "$PACKAGE" ]; then +# echo " " +# echo " " +# echo " " +#fi if [ "$SPECTEXT" ]; then # save specfile tmpfile=`mktemp` echo -n $SPECTEXT | perl -MURI::Escape -e 'print uri_unescape(<>)' > $tmpfile chmod 644 $tmpfile - $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cat $tmpfile > $PACKAGE.spec" $tmpfile + $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "cat $tmpfile > $PACKAGE.spec" $tmpfile rm -f $tmpfile fi @@ -576,39 +635,44 @@ 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" ]; then + "$REQUEST" = "rebuildspec" -o "$REQUEST" = "renamespec" -o "$REQUEST" = "deletespec" ]; then echo -n "" echo -n "
"
    RET=255
    case $REQUEST in
-      "prepare") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a1 --server $REPOSITORY"; RET=$? ;;
+      "prepare") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a1 --server $REPOSITORY"; RET=$? ;;
       "updatespec") if [ "$UPDATESSPECVERSION" -a "$REBUILDSPECCHANGELOG" ]; then
                        echo "ERROR: new version and changelog can't be specified together"
                     elif [ "$REBUILDSPECCHANGELOG" ]; then
-                       $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a4 --rebuild --changelog \"$REBUILDSPECCHANGELOG\""
+                       $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a4 --rebuild --changelog \"$REBUILDSPECCHANGELOG\""
                     elif [ "$UPDATESSPECVERSION" ]; then
-                       $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a3,4 $UPDATESPECVERSION"
+                       $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a3,4 $UPDATESPECVERSION"
                     else
-                       $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a2:4 $UPDATESPECVERSION"
+                       $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a2:4 $UPDATESPECVERSION"
                     fi
-                    RET=$? ;;
+                    RET=$?
+                    [ ;;
       "speccreate") if [ "$SPECCREATEURL" -a "$PACKAGE" ]; then
                        AUTOSPEC_CMDLINE="-n $PACKAGE -o $PACKAGE.spec"
                        #DECODEDURL=`cgi_decodevar $SPECCREATEURL`
                        [ "$SPECCREATETYPE" ] && AUTOSPEC_CMDLINE="$AUTOSPEC_CMDLINE -t $SPECCREATETYPE"
                        [ "$SPECCREATEVERSION" ] && AUTOSPEC_CMDLINE="$AUTOSPEC_CMDLINE -v $SPECCREATEVERSION"
-                       $SUDO_WRAPPER $ENVIRONMENT "" "autospec -s \"$SPECCREATEURL\" $AUTOSPEC_CMDLINE"
+                       $SUDO_WRAPPER 0 $ENVIRONMENT "" "autospec -s \"$SPECCREATEURL\" $AUTOSPEC_CMDLINE"
                        RET=$?
-                       [ $REQ -eq 0 ] && social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"is working on $PACKAGE new package\" STIME=`date +%s`"
+                       [ $RET -eq 0 ] && social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"is working on $PACKAGE new package\" STIME=`date +%s`"
 #                          --changelog \"package created by $USER from autodist webbuild interface\""
                     else
                        echo "ERROR: both source archive URL and name are needed."
                        RET=1
                     fi
                     ;;
-      "renamespec") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "mv $RENAMESPECFROM.spec $PACKAGE.spec && sed -i \"s|\(Name:[[:space:]]*\).*|\1$PACKAGE|\" $PACKAGE.spec"
+      "renamespec") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "mv $RENAMESPECFROM.spec $PACKAGE.spec && sed -i \"s|\(Name:[[:space:]]*\).*|\1$PACKAGE|\" $PACKAGE.spec"
                     RET=$?
-                    [ $REQ -eq 0 ] && social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"renamed $RENAMESPECFROM to $PACKAGE\" STIME=`date +%s`"
+                    [ $RET -eq 0 ] && social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"renamed $RENAMESPECFROM to $PACKAGE\" STIME=`date +%s`"
+                    ;;
+      "deletespec") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "rm -f $PACKAGE.spec"
+                    RET=$?
+                    [ $RET -eq 0 ] && REQUEST="exit"
                     ;;
    esac
    echo -n "
" @@ -619,35 +683,49 @@ if [ "$REQUEST" = "prepare" -o "$REQUEST" = "updatespec" -o "$REQUEST" = "speccr fi echo -n "" echo -n "]]>
" - REQUEST="edit" + if [ "$REQUEST" = "exit" ]; then + echo -n " " + echo -n " " + echo -n " " + echo -n "" + exit + fi + [ $RET -eq 0 ] && REQUEST="edit" || REQUEST= fi -if [ "$MAINTAINERMODE" = "true" -a "$REPOSITORY" != "" ]; then +# maintainer mode editor +if [ "$MAINTAINERMODE" = "true" ]; then if [ ! "$REQUEST" -o "$REQUEST" = "changerepository" -o \ "$REQUEST" = "switchmaintainermode" -o "$REQUEST" = "reloadmaintainer" ]; then echo -n " " echo -n " " - echo -n "" - echo -n "Recent packages in $REPOSITORY:
" - cat $local_ftp/distromatic/$REPOSITORY/_recent.inc - echo -n "
Log:
"
-      cat $local_ftp/$REPOSITORY/distromatic.log
-      echo -n "
" - echo -n "" - echo -n "]]>
" + if [ "$REPOSITORY" ]; then + echo -n "" + echo -n "Recent packages in $REPOSITORY:
" + cat $local_ftp/distromatic/$REPOSITORY/_recent.inc + echo -n "
Log:
"
+         cat $local_ftp/$REPOSITORY/distromatic.log
+         echo -n "
" + echo -n "" + echo -n "]]>
" + else + echo -n " " + fi fi fi +# specfile editor if [ "$REQUEST" = "edit" -o "$REQUEST" = "reloadspec" -o "$REQUEST" = "switchmaintainermode" -a "$MAINTAINERMODE" != "true" ]; then if [ "$PACKAGE" ]; then - $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "ls $PACKAGE.spec" + $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "ls $PACKAGE.spec" [ $? -eq 0 ] && SPECAVAILABLE=1 fi if [ "$SPECAVAILABLE" ]; then echo -n "" 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 "" + # specfile rename echo -n "" echo -n ".spec" + # specfile delete + echo -n "$PACKAGE.spec?"`\")>" echo -n "]]>" - echo -n "$PACKAGE" - echo -n "
Target arch:" + for f in i586 arm x86_64 ppc; do + SELECTED= + if [ ! "$RPMBUILDARCH" -a "$f" = "${AUTOPORT_ARCH[$ENVIRONMENT]}" ]; then + SELECTED="selected=\"selected\""; + fi + echo -n "" + done + echo -n "" + echo -n "" + # destination repository select + echo -n "
Send to:" + echo -n "" - echo -n "" - # destination repository select - echo -n "
Send to:" - echo -n "
" - [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" -o "$STATE_ADVANCEDCONTROLS" ] && echo -n "
Autodist automatic builds:
" + echo -n "" + fi + done + echo -n "
" + [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" -o "$STATE_ADVANCEDCONTROLS" ] && echo -n "
Autodist batch builds:
" + if [ "$PACKAGE" ]; then if [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then + # autodist show patch echo -n "Patch:" + # autodist remove patch echo -n "" + echo -n "REQUEST=removepatch\"" + echo -n ",\"`cgi_encodevar "Remove current autodist patch for package $PACKAGE?"`\"); class=redbutton>" + # autodist update patch echo -n "" + echo -n "REQUEST=updatepatch\"" + echo -n ",\"`cgi_encodevar "Create an autodist update patch for package $PACKAGE?"`\"); class=redbutton>" + # autodist build patch echo -n "" - # autodist schedule + echo -n "REQUEST=buildpatch\"" + echo -n ",\"`cgi_encodevar "Create an autodist build patch for package $PACKAGE?"`\"); class=redbutton>" + # autodist show schedule echo -n "
Schedule:" + # autodist schedule + echo -n "$PACKAGE autodist job for automatic update?"`\"); class=redbutton>" # autodist unschedule echo -n "" @@ -729,57 +839,99 @@ if [ "$REQUEST" = "edit" -o "$REQUEST" = "reloadspec" -o "$REQUEST" = "switchmai echo -n "
" fi - if [ "$STATE_ADVANCEDCONTROLS" ]; then - # autodist list-jobs - echo -n "Job:" + echo -n "" + for f in `$SUDO_WRAPPER 0 $ENVIRONMENT "" "autodist --list-jobs"`; do + SELECTED= + if [ "$AUTODISTJOB" ]; then + [ "$AUTODISTJOB" = "$f" ] && SELECTED="selected=\"selected\"" + elif [ "$PACKAGE" = "$f" ]; then + SELECTED="selected=\"selected\"" + AUTODISTJOB=$f + fi + JOBENCODED=`cgi_encodevar $f` + echo -n "" + done + if [ "$PACKAGE" ]; then + [ "$AUTODISTJOB" ] && SELECTED= || { + SELECTED="selected=\"selected\"" + AUTODISTJOB=$PACKAGE + } + echo -n "" + fi + echo -n "" + if [ "$AUTODISTJOB" ]; then + echo -n "
Job packages:
" + for p in `$SUDO_WRAPPER 0 $ENVIRONMENT "" "autodist --list-pkgs $AUTODISTJOB"`; do + if [ "$AUTODISTPKGS" ]; then + for i in $AUTODISTPKGS; do + [ "$i" = "$p" ] && { SELECTED=checked; break; } || SELECTED= + done + else + [ "$p" = "$AUTODISTJOB" ] && SELECTED=checked || SELECTED= + fi + echo -n "" done - echo -n "" + echo -n "
" # autodist prepare - echo -n "
" # autodist update - echo -n "" # autodist build - echo -n "" # autodist install [ ! "$USER_CANINSTALL" ] && DISABLED="disabled=disabled" || DISABLED= - echo -n "" # autodist send [ ! "$USER_ALLREPOSITORIES" ] && DISABLED="disabled=disabled" || DISABLED= - echo -n "" - # autodist force checkbox + echo -n "ENVIRONMENT=$ENVIRONMENT&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>" + else + echo -n "
" fi + fi + if [ "$PACKAGE" ]; then if [ "$STATE_ADVANCEDCONTROLS" -o "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then # autodist logs echo -n "
Last autodist logs: " @@ -836,17 +988,24 @@ if [ "$REQUEST" = "edit" -o "$REQUEST" = "reloadspec" -o "$REQUEST" = "switchmai [ ! "$USER_CANINSTALL" ] && DISABLED="disabled=disabled" echo -n "" - # send + echo -n "RPMFORCE=\"+getElementById('rpmforce').checked" + echo -n ",\"`cgi_encodevar "Install $PACKAGE in current environment?"`\"" + echo -n "); class=redbutton $DISABLED>" + # rpm send echo -n "" + echo -n "SENDREPOSITORY=\"+getSelectedValueById('sendrepository')" + echo -n ",\"`cgi_encodevar "Send $PACKAGE built packages to "`\"+getSelectedValueById('sendrepository')+" + echo -n "\"`cgi_encodevar "?"`\"" + echo -n "); class=redbutton>" # recreate and send SRPM echo -n "" + echo -n "SENDREPOSITORY=\"+getSelectedValueById('sendrepository')" + echo -n ",\"`cgi_encodevar "Rebuild $PACKAGE source package only and send to "`\"+getSelectedValueById('sendrepository')+" + echo -n "\"`cgi_encodevar "?"`\"" + echo -n "); class=redbutton>" # add patches echo -n "
Add patches:" echo -n "
" echo -n "URL:" echo -n "As: $PACKAGE-.patch" -# fi -# if [ "$USER_CANMAINTAIN" -a "$PACKAGE" ]; then -# echo -n "" -# echo -n "" -# fi if [ ! "${AUTOPORT_DISABLE[$ENVIRONMENT]}" -a ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then echo -n "
Automatic port:
" echo -n "$macrosfile" done echo -n "" - # broadcast message - echo -n "
Broadcast message:
" - echo -n "" - echo -n "" - echo -n "]]>
" + fi + echo -n "]]>" +fi + +echo -n "Broadcast message:
" +echo -n "" +echo -n "" +echo -n "]]>
" + +if [ "$REQUEST" != "" ]; then + 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." - echo -n "" - echo -n "]]>" + echo -n "id=outputtop>" fi -else - if [ "$REQUEST" != "" ]; then - echo -n "" - else - echo -n "id=outputtop>" - fi - if [ "$REQUEST" != "showchangelogs" -a "$REQUEST" != "showbuilddocs" -a "$REQUEST" != "showlicenses" ]; then - echo -n "
"
-      fi
-      RET=255
+   if [ "$REQUEST" != "showchangelogs" -a "$REQUEST" != "showbuilddocs" -a "$REQUEST" != "showlicenses" ]; then
+      echo -n "
"
    fi
-   case $REQUEST in
-      "showpatch") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool makepatch $PACKAGE"; RET=$? ;;
-      "removepatch") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool makepatch $PACKAGE remove"
+   RET=255
+fi
+
+case $REQUEST in
+   "showpatch") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autodist-tool makepatch $PACKAGE"; RET=$? ;;
+   "removepatch") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autodist-tool makepatch $PACKAGE remove"
                      RET=$?
                      if [ $RET -eq 0 ]; then
                         social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"removed the autodist patch for $PACKAGE\" STIME=`date +%s`"
                      fi ;;
-      "updatepatch") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool makepatch $PACKAGE update"
+   "updatepatch") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autodist-tool makepatch $PACKAGE update"
                      RET=$?
                      if [ $RET -eq 0 ]; then
                         social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"made an autodist update patch for $PACKAGE\" STIME=`date +%s`"
                      fi ;;
-      "buildpatch") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool makepatch $PACKAGE build"
+   "buildpatch") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autodist-tool makepatch $PACKAGE build"
                     RET=$?
                     if [ $RET -eq 0 ]; then
                        social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"made an autodist build patch for $PACKAGE\" STIME=`date +%s`"
                     fi ;;
-      "showscheduled") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool schedule"; RET=$? ;;
-      "unschedule") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool unschedule $PACKAGE"
+   "showscheduled") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autodist-tool schedule"; RET=$? ;;
+   "schedule") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autodist-tool schedule $PACKAGE"
+                    RET=$?
+                    if [ $RET -eq 0 ]; then
+                       social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"scheduled autodist job $PACKAGE\" STIME=`date +%s`"
+                    fi ;;
+   "unschedule") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autodist-tool unschedule $PACKAGE"
                     RET=$?
                     if [ $RET -eq 0 ]; then
                        social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"unscheduled autodist job $PACKAGE\" STIME=`date +%s`"
                     fi ;;
-      "skip") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool skip $PACKAGE"
+   "skip") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autodist-tool skip $PACKAGE"
               RET=$?
               if [ $RET -eq 0 ]; then
                  social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"added autodist job $PACKAGE to skipped list\" STIME=`date +%s`"
               fi ;;
-      "autodistprepare") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
-                         $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -v -p $AUTODISTJOB --arch $AUTODISTARCH $AUTODISTADD"
+   "autodistprepare") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
+                         autodistjobs=
+                         if [ "$AUTODISTPKGS" ]; then
+                            for p in $AUTODISTPKGS; do
+                               autodistjobs="$autodistjobs $AUTODISTJOB/$p"
+                            done
+                         else
+                            autodistjobs="$AUTODISTJOB"
+                         fi
+                         $SUDO_WRAPPER 0 $ENVIRONMENT "" "autodist -v -p $autodistjobs --repository ${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]} --arch $AUTODISTARCH $AUTODISTADD"
                          RET=$? ;;
-      "autodistupdate") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
-                        $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -v -u $AUTODISTJOB --arch $AUTODISTARCH $AUTODISTADD"
+   "autodistupdate") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
+                        autodistjobs=
+                        if [ "$AUTODISTPKGS" ]; then
+                           for p in $AUTODISTPKGS; do
+                              autodistjobs="$autodistjobs $AUTODISTJOB/$p"
+                           done
+                        else
+                           autodistjobs="$AUTODISTJOB"
+                        fi
+                        $SUDO_WRAPPER 0 $ENVIRONMENT "" "autodist -v -u $autodistjobs --repository ${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]} --arch $AUTODISTARCH $AUTODISTADD"
                         RET=$? ;;
-      "autodistbuild") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
-                       $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -v -b $AUTODISTJOB --arch $AUTODISTARCH $AUTODISTADD"
+   "autodistbuild") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
+                       autodistjobs=
+                       if [ "$AUTODISTPKGS" ]; then
+                          for p in $AUTODISTPKGS; do
+                             autodistjobs="$autodistjobs $AUTODISTJOB/$p"
+                          done
+                       else
+                          autodistjobs="$AUTODISTJOB"
+                       fi
+                       $SUDO_WRAPPER background $ENVIRONMENT "" "autodist -v -b $autodistjobs --repository ${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]} --arch $AUTODISTARCH $AUTODISTADD"
                        RET=$?
-                       [ $RET -eq 0 ] && social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"successfully built $PACKAGE\" STIME=`date +%s`"
+                       #[ $RET -eq 0 ] && social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"successfully built $PACKAGE\" STIME=`date +%s`"
                        ;;
-      "autodistinstall") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
-                         $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -v -i $AUTODISTJOB --arch $AUTODISTARCH $AUTODISTADD"
-                         RET=$? ;;
-      "autodistsend") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
-                      $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -v -s $AUTODISTJOB --server $SENDREPOSITORY --arch $AUTODISTARCH $AUTODISTADD"
+   "autodistinstall") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
+                      autodistjobs=
+                      if [ "$AUTODISTPKGS" ]; then
+                         for p in $AUTODISTPKGS; do
+                            autodistjobs="$autodistjobs $AUTODISTJOB/$p"
+                         done
+                      else
+                         autodistjobs="$AUTODISTJOB"
+                      fi
+                      $SUDO_WRAPPER 0 $ENVIRONMENT "" "autodist -v -i $autodistjobs --repository ${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]} --arch $AUTODISTARCH $AUTODISTADD"
+                      RET=$? ;;
+   "autodistsend") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
+                      autodistjobs=
+                      if [ "$AUTODISTPKGS" ]; then
+                         for p in $AUTODISTPKGS; do
+                            autodistjobs="$autodistjobs $AUTODISTJOB/$p"
+                         done
+                      else
+                         autodistjobs="$AUTODISTJOB"
+                      fi
+                      $SUDO_WRAPPER 0 $ENVIRONMENT "" "autodist -v -s $autodistjobs --repository ${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]} --server $SENDREPOSITORY --arch $AUTODISTARCH $AUTODISTADD"
                       RET=$?
                       [ $RET -eq 0 ] && social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"sent $PACKAGE to $SENDREPOSITORY\" STIME=`date +%s`"
                       ;;
-      "buildrootfiles") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cd @RPMBUILDROOT@ && find @BUILDROOT@"; RET=$? ;;
-      "autospecupdatescheck") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a2"; RET=$? ;;
-      "rpmprepare") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "rpmbuild -bp $PACKAGE.spec"; RET=$? ;;
-      "rpmbuild") echo "`date` - RPMBUILD=$PACKAGE USER=$USER ENVIRONMENT=$ENVIRONMENT" >> $WEBBUILD_STATEDIR/buildingnow_log
+   "autoport") $SUDO_WRAPPER background $ENVIRONMENT $PACKAGE "autoport $PACKAGE -r $REPOSITORY -v"
+                  RET=$?
+                  ;;
+   "buildrootfiles") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "cd @RPMBUILDROOT@ && find @BUILDROOT@"; RET=$? ;;
+   "autospecupdatescheck") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a2"; RET=$? ;;
+   "rpmprepare") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "rpmbuild -bp $PACKAGE.spec"; RET=$? ;;
+   "rpmbuild") echo "`date` - RPMBUILD=$PACKAGE USER=$USER ENVIRONMENT=$ENVIRONMENT" >> $WEBBUILD_STATEDIR/buildingnow_log
                   [ "$RPMFORCE" = "true" ] && RPMFORCEADD="--force-build"
                   [ "$RPMBUILDARCH" -a "$RPMBUILDARCH" != "${AUTOPORT_ARCH[$ENVIRONMENT]}" ] && \
                      RPMARCHADD="-A $RPMBUILDARCH --define \"cross_target_cpu=$RPMBUILDARCH\""
-                  $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a5 $RPMFORCEADD $RPMARCHADD"
+                  $SUDO_WRAPPER background $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a5,6 $RPMFORCEADD $RPMARCHADD"
+#                   && echo \"Webbuild HINT: now you may want to click on 'build requirements', add build requirements in .spec file and then 'recreate SRPMS'\""
                   RET=$?
-                  if [ $RET -eq 0 ]; then
-                     social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"successfully built $PACKAGE\" STIME=`date +%s`"
-                  fi
+#                  if [ $RET -eq 0 ]; then
+#                     social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"successfully built $PACKAGE\" STIME=`date +%s`"
+#                  fi
                   sed -i "|RPMBUILD=$PACKAGE USER=$USER ENVIRONMENT=$ENVIRONMENT|d" $WEBBUILD_STATEDIR/buildingnow_log
                   ;;
-      "srpmbuild") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "rpmbuild -bs $PACKAGE.spec"
+   "srpmbuild") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "rpmbuild -bs $PACKAGE.spec"
                    RET=$? ;;
-      "autospeclistcheck")
+   "autospeclistcheck")
                    [ "$RPMBUILDARCH" -a "$RPMBUILDARCH" != "${AUTOPORT_ARCH[$ENVIRONMENT]}" ] && \
                       RPMARCHADD="-A $RPMBUILDARCH --define \"cross_target_cpu=$RPMBUILDARCH\""
-                   $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a5 --list-check $RPMARCHADD"
+                   $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a5 --list-check $RPMARCHADD"
                    RET=$? ;;
-      "autospecbuildreq") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a6"
+   "autospecbuildreq") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a6"
                    RET=$? ;;
-      "rpmchecks") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a8"; RET=$? ;;
-      "rpmsimulateinstall") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a7"; RET=$? ;;
-      "rpminstall") if [ "$USER_CANINSTALL" ]; then
+   "rpmchecks") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a8"; RET=$? ;;
+   "rpmsimulateinstall") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a7"; RET=$? ;;
+   "rpminstall") if [ "$USER_CANINSTALL" ]; then
                        [ "$RPMFORCE" = "true" ] && RPMFORCEADD="--force-install"
-                       $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a11 $RPMFORCEADD"; RET=$?
+                       $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a11 $RPMFORCEADD"; RET=$?
                     else
                        echo "Install function disabled."
                        RET=1
                     fi ;;
-      "addpatch") if [ "$ADDPATCHURL" -a "$ADDPATCHNAME" ]; then
-                     $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "curl -s \"$ADDPATCHURL\" -o ../SOURCES/$PACKAGE-$ADDPATCHNAME.patch"
+   "addpatch") if [ "$ADDPATCHURL" -a "$ADDPATCHNAME" ]; then
+                     $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "curl -s -k \"$ADDPATCHURL\" -o ../SOURCES/$PACKAGE-$ADDPATCHNAME.patch"
                      RET=$?
                      [ $RET -eq 0 ] && echo "Patch added with name $PACKAGE-$ADDPATCHNAME.patch"
                   else
                      echo "Patch URL or destination name not provided."
                      RET=1
                   fi ;;
-      "sendpackage") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a10 --server $SENDREPOSITORY"
+   "sendpackage") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a10 --server $SENDREPOSITORY"
                      RET=$?
                      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"
+   "sendsource") [ "$RPMFORCE" = "true" ] && RPMFORCEADD="--force --nodeps"
                     if [ "$SENDREPOSITORY" ]; then
-                       $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "rpmbuild -bs $PACKAGE.spec $RPMFORCEADD && autospec -u $PACKAGE -a10 --server $SENDREPOSITORY --norpm"
+                       $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "rpmbuild -bs $PACKAGE.spec $RPMFORCEADD && autospec -u $PACKAGE -a10 --server $SENDREPOSITORY --norpm"
                        RET=$?
                     else
                        echo "ERROR: send repository is not defined."
                        RET=255
                     fi ;;
-      "repositoryimport")
+   "repositoryimport")
                       for p in $PACKAGES; do
                          [ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANMAINTAIN" ] && SIMULATEADD="-s" || SIMULATEADD=
-                         $SUDO_WRAPPER local "$PACKAGE" "openmamba-repository import $SENDREPOSITORY $p -d $REPOSITORYIMPORTTO $SIMULATEADD -y"
+                         $SUDO_WRAPPER 0 local "$PACKAGE" "openmamba-repository import $SENDREPOSITORY $p -d $REPOSITORYIMPORTTO $SIMULATEADD -y"
                          RET=$?
                          if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then
                             social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"imported $p from $SENDREPOSITORY to $REPOSITORYIMPORTTO\" STIME=`date +%s`"
@@ -1042,10 +1239,10 @@ else
                          [ $RET -eq 0 ] || break
                       done
                       ;;
-      "repositoryrelease")
+   "repositoryrelease")
                       for p in $PACKAGES; do
                          [ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANMAINTAIN" ] && SIMULATEADD="-s" || SIMULATEADD=
-                         $SUDO_WRAPPER local "$PACKAGE" "openmamba-repository release $SENDREPOSITORY $p -d $REPOSITORYIMPORTTO $SIMULATEADD -y"
+                         $SUDO_WRAPPER 0 local "$PACKAGE" "openmamba-repository release $SENDREPOSITORY $p -d $REPOSITORYIMPORTTO $SIMULATEADD -y"
                          RET=$?
                          if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then
                             social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"released $p from $SENDREPOSITORY to $REPOSITORYIMPORTTO\" STIME=`date +%s`"
@@ -1053,17 +1250,17 @@ else
                          [ $RET -eq 0 ] || break
                       done
                       ;;
-      "repositorydiff")
+   "repositorydiff")
                       for p in $PACKAGES; do
-                         $SUDO_WRAPPER local "" "openmamba-repository diff $SENDREPOSITORY $p -d $REPOSITORYIMPORTTO"
+                         $SUDO_WRAPPER 0 local "" "openmamba-repository diff $SENDREPOSITORY $p -d $REPOSITORYIMPORTTO"
                          RET=$?
                          [ $RET -eq 0 ] || break
                       done
                       ;;
-      "repositoryarchive")
+   "repositoryarchive")
                       for p in $PACKAGES; do
                          [ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANMAINTAIN" ] && SIMULATEADD="-s" || SIMULATEADD=
-                         $SUDO_WRAPPER local "$PACKAGE" "openmamba-repository archive $SENDREPOSITORY $p -y"
+                         $SUDO_WRAPPER 0 local "$PACKAGE" "openmamba-repository archive $SENDREPOSITORY $p -y"
                          RET=$?
                          if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then
                             social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"archived $p from $SENDREPOSITORY\" STIME=`date +%s`"
@@ -1071,17 +1268,26 @@ else
                          [ $RET -eq 0 ] || break
                       done
                       ;;
-      "autoportnp") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autoport -np $PACKAGE"; RET=$? ;;
-      "autoportlog") cat "$AUTOPORTLOGDIR/current.log"; RET=$? ;;
-      "allowedgroups") $SUDO_WRAPPER $ENVIRONMENT "" "autospec --eval rpm_allowed_groups"; RET=$? ;;
-      "approvedlicenses") $SUDO_WRAPPER $ENVIRONMENT "" "autospec --eval rpm_approved_licenses | grep -v \"^#\"" | \
+   "repositorysync")
+                      if [ "$REPOSITORY" ]; then
+                         $SUDO_WRAPPER background local "" "/etc/cron.hourly/20-openmamba-apt $REPOSITORY"
+                         RET=$?
+                         [ $RET -eq 0 ] && $SUDO_WRAPPER background local "" "/etc/cron.hourly/40-openmamba-rsync $REPOSITORY"
+                         RET=$?
+                         [ $RET -eq 0 ] || break
+                      fi
+                      ;;
+   "autoportnp") $SUDO_WRAPPER keeplog $ENVIRONMENT $PACKAGE "autoport -np $PACKAGE"; RET=$? ;;
+   "autoportlog") cat "$AUTOPORTLOGDIR/current.log"; RET=$? ;;
+   "allowedgroups") $SUDO_WRAPPER 0 $ENVIRONMENT "" "autospec --eval rpm_allowed_groups"; RET=$? ;;
+   "approvedlicenses") $SUDO_WRAPPER 0 $ENVIRONMENT "" "autospec --eval rpm_approved_licenses | grep -v \"^#\"" | \
                           while read line; do
                              echo $line
                           done
                           RET=0
                           ;;
-      "builddirfiles") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cd @RPMBUILDDIR@ && find @BUILDDIR@"; RET=$? ;;
-      "showchangelogs"|"showbuilddocs"|"showlicenses")
+   "builddirfiles") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "cd @RPMBUILDDIR@ && find @BUILDDIR@"; RET=$? ;;
+   "showchangelogs"|"showbuilddocs"|"showlicenses")
                        if [ "$REQUEST" = "showchangelogs" ]; then
                           PATTERN="-iname changelog -or -iname news -and -type f"
                        elif [ "$REQUEST" = "showlicenses" ]; then
@@ -1089,7 +1295,7 @@ else
                        elif [ "$REQUEST" = "showbuilddocs" ]; then
                           PATTERN="-iname readme\* -or -iname install\* -or -iname todo\* -or -iname pkgbuild\* -and -type f"
                        fi
-                       files=`$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cd @RPMBUILDDIR@/@BUILDDIR@ && find . $PATTERN -maxdepth 2"`
+                       files=`$SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "cd @RPMBUILDDIR@/@BUILDDIR@ && find . $PATTERN -maxdepth 2"`
                        cnt=0
                        for f in $files; do
                           echo -n "$f
" @@ -1097,29 +1303,28 @@ else echo -n "
" for f in $files; do echo -n "

File $f:

"
-                          $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cd @RPMBUILDDIR@/@BUILDDIR@ && cat $f"
+                          $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "cd @RPMBUILDDIR@/@BUILDDIR@ && cat $f"
                           RET=$?
                           echo -n "
" done ;; - "configurehelp") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cd @RPMBUILDDIR@/@BUILDDIR@ && ./configure --help"; RET=$? ;; - "showmacrosfile") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cat /etc/rpm/macros.$MACROSFILE"; RET=$? ;; - *) RET=0 ;; - esac - if [ "$REQUEST" != "" ]; then - if [ "$REQUEST" != "showchangelogs" -a "$REQUEST" != "showbuilddocs" -a "$REQUEST" != "showlicenses" ]; then - echo -n "
" - fi - if [ $RET -eq 0 ]; then - echo "Result: OK" - else - echo "Result: ERROR ($RET)" - fi - echo -n "" - echo -n "]]>" - fi -fi + "configurehelp") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "cd @RPMBUILDDIR@/@BUILDDIR@ && ./configure --help"; RET=$? ;; + "showmacrosfile") $SUDO_WRAPPER 0 $ENVIRONMENT $PACKAGE "cat /etc/rpm/macros.$MACROSFILE"; RET=$? ;; + *) RET=0 ;; +esac +if [ "$REQUEST" != "" ]; then + if [ "$REQUEST" != "showchangelogs" -a "$REQUEST" != "showbuilddocs" -a "$REQUEST" != "showlicenses" ]; then + echo -n "
" + fi + if [ $RET -eq 0 ]; then + echo "Result: OK" + else + echo "Result: ERROR ($RET)" + fi + echo -n "" + echo -n "]]>
" +fi if [ "$MAINTAINERMODE" = "true" ]; then echo -n " " @@ -1172,29 +1377,48 @@ if [ "$MAINTAINERMODE" = "true" ]; then echo -n "SENDREPOSITORY=$REPOSITORY&REQUEST=repositorydiff\");>" # repository import echo -n "" + echo -n "SENDREPOSITORY=$REPOSITORY&REQUEST=repositoryimport\"" + echo -n ",\"`cgi_encodevar "Import "`\"+p+\"`cgi_encodevar " from $REPOSITORY to "`\"+getSelectedValueById('repositoryimportto')+" + echo -n "\"`cgi_encodevar "?"`\"" + echo -n "); class=redbutton>" # repository release echo -n "" + echo -n "SENDREPOSITORY=$REPOSITORY&REQUEST=repositoryrelease\"" + echo -n ",\"`cgi_encodevar "Release "`\"+p+\"`cgi_encodevar " in $REPOSITORY to "`\"+getSelectedValueById('repositoryimportto')+" + echo -n "\"`cgi_encodevar "?"`\"" + echo -n "); class=redbutton>" # repository archive echo -n "" + echo -n "REQUEST=repositoryarchive\"" + echo -n ",\"`cgi_encodevar "Archive "`\"+p+\"`cgi_encodevar " in $REPOSITORY?"`\"" + echo -n "); class=redbutton>" echo -n "" + # repository sync + echo -n " $REPOSITORY updates immediately available from public server?"`\"" + echo -n "); class=redbutton>" fi echo -n "]]>" fi @@ -1213,4 +1437,31 @@ fi # 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 " + 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]})" +fi + +echo -n " :: openmamba webbuild" echo "" diff --git a/webbuild/webbuild-functions b/webbuild/webbuild-functions index cfb5920..93629ba 100644 --- a/webbuild/webbuild-functions +++ b/webbuild/webbuild-functions @@ -20,7 +20,7 @@ function set_user_state_var() { [ "$1" ] || return - [ -e $WEBBILD_STATEDIR/users/$stateuser.state ] || touch $WEBBUILD_STATEDIR/users/$stateuser.state + [ -e $WEBBUILD_STATEDIR/users/$stateuser.state ] || touch $WEBBUILD_STATEDIR/users/$stateuser.state sed -i "/^$statevar=/d" $WEBBUILD_STATEDIR/users/$stateuser.state [ "$statevalue" ] && echo "$statevar=$statevalue" >> $WEBBUILD_STATEDIR/users/$stateuser.state } @@ -28,7 +28,7 @@ function set_user_state_var() { function social_log() { local line=$1 - [ "$1" ] || return + [ "$line" ] || return if [ ! "$STATE_FAKEUSER" ]; then STATE_SOCIALLOG_ID=0 @@ -52,7 +52,7 @@ function cgi_encodevar() { esac encoded+="${o}" done - echo "${encoded}" # You can either set a return variable (FASTER) + echo -n "${encoded}" # You can either set a return variable (FASTER) # REPLY="${encoded}" #+or echo the result (EASIER)... or both... :p } diff --git a/webbuild/webbuild-sudo b/webbuild/webbuild-sudo index ed52366..c66f4dd 100755 --- a/webbuild/webbuild-sudo +++ b/webbuild/webbuild-sudo @@ -2,18 +2,35 @@ . /usr/share/autodist/webbuild-functions . /etc/sysconfig/autoport -ENVIRONMENT=$1 -PACKAGE=$2 -COMMAND=$3 -TMPFILE=$4 +MODE=$1 +ENVIRONMENT=$2 +PACKAGE=$3 +COMMAND=$4 +TMPFILE=$5 -if [ "$ENVIRONMENT" = "local" ]; then +if [ "$MODE" = "killtree" ]; then + KILLPID=$2 + [ $KILLPID -gt 1 ] && kill_tree $KILLPID + exit $? +elif [ "$MODE" = "finishprocess" ]; then + PROCESSPID=$2 + PROCESSLOG=$3 + RETCODE=`tail -n1 $PROCESSLOG | grep "^# WEBBUILD_EXITCODE=" | sed "s|^# WEBBUILD_EXITCODE=||"` + [ "$RETCODE" ] || RETCODE=257 + sed -i "s|\(^$PROCESSPID [^[:space:]]* [^[:space:]]* [^[:space:]]* \)[^[:space:]]*|\1$RETCODE|" $WEBBUILD_STATEDIR/processes + exit $RETCODE +elif [ "$ENVIRONMENT" = "local" ]; then # echo "Command: $COMMAND" $COMMAND 2>&1 | sed "s|<|\<|g" exit 0 fi -if [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then +if [ "$ENVIRONMENT" = "local" ]; then + ENVPREFIX= + ENVUSER=root + WORKINGHOME= + SUCMDPREFIX= +elif [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then ENVPREFIX="/var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}" ENVUSER=${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} WORKINGHOME="/usr/src/" @@ -36,21 +53,23 @@ else RPMBUILDROOT="/var/tmp/autodist" [ "$TMPFILE" ] && chown autodist $TMPFILE fi -eval `$SUCMDPREFIX "autospec --eval=tmppath_dir|grep -v '^#'"` -RPMBUILDROOT=$tmppath_dir -SPECFILE=${ENVPREFIX}${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec -if [ -r "$SPECFILE" ]; then - rm -f $SPECFILE.tmp - $SUCMDPREFIX "rpm -q --specfile ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec --specedit > ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec.tmp 2>/dev/null" - if [ -e $SPECFILE.tmp ]; then - BUILDDIR=`grep -m1 "^%setup.*-n " $SPECFILE.tmp | sed "s|.*-n \([^[:space:]]*\).*|\1|"` +if [ "$WORKINGHOME" ]; then + eval `$SUCMDPREFIX "autospec --eval=tmppath_dir|grep -v '^#'"` + RPMBUILDROOT=$tmppath_dir + SPECFILE=${ENVPREFIX}${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec + if [ -r "$SPECFILE" ]; then rm -f $SPECFILE.tmp - fi - SPECVERSION=`grep -m1 "^Version:" ${SPECFILE} | sed "s|Version:[[:space:]]*||"` - BUILDROOT=$PACKAGE-root + $SUCMDPREFIX "rpm -q --specfile ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec --specedit > ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec.tmp 2>/dev/null" + if [ -e $SPECFILE.tmp ]; then + BUILDDIR=`grep -m1 "^%setup.*-n " $SPECFILE.tmp | sed "s|.*-n \([^[:space:]]*\).*|\1|"` + rm -f $SPECFILE.tmp + 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 + [ "$BUILDDIR" ] || BUILDDIR=$PACKAGE-$SPECVERSION + fi fi RPMBUILDDIR=${WORKINGHOME}/RPM/BUILD COMMAND=`echo $COMMAND | sed "s|@BUILDDIR@|$BUILDDIR|g"` @@ -62,19 +81,37 @@ cmdtmpfile=`mktemp` chgrp nobody $cmdtmpfile chmod 640 $cmdtmpfile -rettmpfile=`$SUCMDPREFIX mktemp` +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 & + else + $SUCMDPREFIX "$COMMAND;echo \"# WEBBUILD_EXITCODE=\$?\"" 2>&1 | sed "s|<|\<|g" | tr -d '\f' > $cmdtmpfile & + fi + echo "$! $ENVUSER $ENVIRONMENT $cmdtmpfile 256 $COMMAND" >> $WEBBUILD_STATEDIR/processes + echo "Started background command: $COMMAND" + RET=0 +else + echo "$$ $ENVUSER $ENVIRONMENT $cmdtmpfile 256 $COMMAND" >> $WEBBUILD_STATEDIR/processes + rettmpfile=`$SUCMDPREFIX mktemp` + if [ "$WORKINGHOME" ]; then + $SUCMDPREFIX ". /etc/profile;cd $WORKINGHOME/RPM/SPECS;$COMMAND;echo \$? > $rettmpfile" 2>&1 | sed "s|<|\<|g" | tr -d '\f' | tee $cmdtmpfile + else + $SUCMDPREFIX "$COMMAND;echo \$? > $rettmpfile" 2>&1 | sed "s|<|\<|g" | tr -d '\f' | tee $cmdtmpfile + fi + RET=`cat $ENVPREFIX/$rettmpfile` + [ "$RET" ] || RET=255 + $SUCMDPREFIX "rm -f $rettmpfile" + sed -i "/^$$ $ENVUSER/d" $WEBBUILD_STATEDIR/processes + if [ "$MODE" != "keeplog" ]; then + rm -f $cmdtmpfile + else + echo "$$ $ENVUSER $ENVIRONMENT $cmdtmpfile $RET $COMMAND" >> $WEBBUILD_STATEDIR/processes + fi +fi -echo "$$ $ENVUSER $ENVIRONMENT $cmdtmpfile $COMMAND" >> $WEBBUILD_STATEDIR/processes - -$SUCMDPREFIX ". /etc/profile;cd $WORKINGHOME/RPM/SPECS;$COMMAND;echo \$? > $rettmpfile" 2>&1 | sed "s|<|\<|g" | tr -d '\f' | tee $cmdtmpfile -RET=`cat $rettmpfile` -$SUCMDPREFIX "rm -f $rettmpfile" - -#echo "Command: $SUCMDPREFIX \"cd $WORKINGHOME/RPM/SPECS;$COMMAND\";RET=$RET" >&2 -sed -i "/^$$ $ENVUSER/d" $WEBBUILD_STATEDIR/processes -rm -f $cmdtmpfile - -if [ "$TMPFILE" -a "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then - rm -f /var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/$TMPFILE +if [ "$ENVIRONMENT" != "local" ]; then + if [ "$TMPFILE" -a "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then + rm -f /var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/$TMPFILE + fi fi exit $RET