From a939e6217a759c681f1f9ea1733f23ce5b790916 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sat, 9 Nov 2013 14:31:17 +0100 Subject: [PATCH] webbuild: sync to current running files with lots of fixes and small changes --- webbuild/webbuild-cgi | 81 ++++++++++++++++++----------- webbuild/webbuild-functions | 29 +++++++++-- webbuild/webbuild-functions-private | 14 +++-- webbuild/webbuild-sudo | 6 ++- 4 files changed, 89 insertions(+), 41 deletions(-) diff --git a/webbuild/webbuild-cgi b/webbuild/webbuild-cgi index 84e22c6..819df8a 100755 --- a/webbuild/webbuild-cgi +++ b/webbuild/webbuild-cgi @@ -391,7 +391,7 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshjobs" ]; then else echo "[ Show mine only ]" fi - #echo -n "(please click on [x] to clean your build logs when you are done)" + echo -n "(please click on [x] to clean your jobs when they are done)" echo -n "
" } [ "$STATE_JOBSSHOWALL" = "1" -o "$USER" = "$2" ] || continue @@ -451,14 +451,17 @@ fi # repsearch request if [ "$REQUEST" = "repsearch" ]; then echo -n "Repository search results for \"$REPSEARCHTEXT\":
" - echo -n "
"
-   $SUDO_WRAPPER 0 local "$USER" "" "openmamba-repository search -i ${REPSEARCHTEXT/-/\-}" | \
-      parse_search_output ${AUTOPORT_ARCH[$ENVIRONMENT]}
+   echo -n "
Search results for \"$REPSEARCHTEXT\":
" +# echo -n "
"
+   curl -s "http://test.openmamba.org/cgi-bin/distroquery?query=$REPSEARCHTEXT&search_milestone2=true&search_devel=true\
+&search_i586=true&search_x86_64=true&search_arm=true&search_sources=true&query_compact=true&replyplain=true"
+#   $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 "
]]>" +# echo -n "
" + echo "
" + echo "]]>
" exit fi @@ -491,10 +494,10 @@ fi # rpm manager if [ "$REQUEST" = "rpmmanager" ]; then - environment_descr=`print_environment_descr $i` + environment_descr=`print_environment_descr $ENVIRONMENT` echo -n "
" - echo -n "
" + echo -n "
" echo -n "RPM manager for $environment_descr environment
" # select rpm manager resource directory to display @@ -533,7 +536,7 @@ if [ "$REQUEST" = "rpmmanager" ]; then echo -n "${pkgname} " echo -n "" + echo -n "&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&RPMMANAGERPACKAGES=\"+encodeURIComponent('$pkgname'));>" echo -n "" echo -n "" done @@ -546,7 +549,7 @@ if [ "$REQUEST" = "rpmmanager" ]; then echo -n "${pkgname} " echo -n "" + echo -n "&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&RPMMANAGERPACKAGES=\"+encodeURIComponent('$pkgname'));>" echo -n "" echo -n "" done @@ -560,7 +563,7 @@ if [ "$REQUEST" = "rpmmanager" ]; then # rpm manager install packages echo -n "" if [ "$MAINTAINERMODE" = "true" ]; then echo -n " " -elif [ ! "$REQUEST" -o "$REQUEST" = "changeenvironment" -o "$REQUEST" = "switchmaintainermode" -o "$REQUEST" = "prepare" -o "$REQUEST" = "reloadspec" ]; then +elif [ ! "$REQUEST" -o "$REQUEST" = "changeenvironment" -o "$REQUEST" = "switchmaintainermode" \ + -o "$REQUEST" = "prepare" -o "$REQUEST" = "reloadspec" -o "$REQUEST" = "edit" ]; then # SPECFILES select echo -n "Search repositories:" + #" + if [ "$PACKAGE" ]; then - echo -n "" - if [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then + if [ "${AUTOPORT_PORT[$ENVIRONMENT]}" ]; then echo -n ")' > $tmpfile chmod 644 $tmpfile - $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" ${PACKAGE/*\/} "cat $tmpfile > ${PACKAGE/*\/}.spec" $tmpfile + if [ "REQUEST" = "renamespec" -a "$RENAMESPECFROM" ]; then + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" ${PACKAGE/*\/} "cat $tmpfile > ${RENAMESPECFROM/*\/}.spec" $tmpfile + else + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" ${PACKAGE/*\/} "cat $tmpfile > ${PACKAGE/*\/}.spec" $tmpfile + fi RET=$? [ $RET -eq 0 ] || { echo -n "ERROR: could not save file ${PACKAGE/*\/}.spec! Please report the problem, thanks.
]]>" @@ -978,24 +988,34 @@ if [ "$REQUEST" = "prepare" -o "$REQUEST" = "updatespec" -o "$REQUEST" = "speccr "prepare") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a1 --server $REPOSITORY"; RET=$? ;; "updatespec") [ "$RPMFORCE" = "true" ] && RPMFORCEADD="--force-update" [ "$DEBUG" = "true" ] && RPMFORCEADD="$RPMFORCEADD --debug" + [ "$USER_FULLNAME" -a "$USER_EMAIL" ] && RPMUSERADD="--packager-fullname=\"$USER_FULLNAME\" --packager-email=\"$USER_EMAIL\"" 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_CMD -u $PACKAGE -a4 $RPMFORCEADD --rebuild --changelog \"$REBUILDSPECCHANGELOG\"" + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a4 $RPMFORCEADD --rebuild \ + --changelog \"$REBUILDSPECCHANGELOG\" $RPMUSERADD" elif [ "$UPDATESPECVERSION" ]; then - $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a3,4 $RPMFORCEADD $UPDATESPECVERSION" + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a3,4 $RPMFORCEADD $UPDATESPECVERSION \ + $RPMUSERADD" else - $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a2:4 $RPMFORCEADD $UPDATESPECVERSION" + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a2:4 $RPMFORCEADD $UPDATESPECVERSION \ + $RPMUSERADD" fi RET=$? ;; "speccreate") if [ "$SPECCREATEURL" -a "$PACKAGE" ]; then + if [ "${SPECCREATEURL/\/}" = "$SPECCREATEURL" ]; then + # local source in /SOURCES + SPECCREATEURL="../SOURCES/$SPECCREATEURL" + fi 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" [ "$SPECCREATEGITBRANCH" ] && AUTOSPEC_CMDLINE="$AUTOSPEC_CMDLINE --git-branch $SPECCREATEGITBRANCH" - $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "$AUTOSPEC_CMD -s \"$SPECCREATEURL\" $AUTOSPEC_CMDLINE --changelog \"package created by $USER using the webbuild interface\"" + [ "$USER_FULLNAME" -a "$USER_EMAIL" ] && AUTOSPEC_CMDLINE="$AUTOSPEC_CMDLINE --packager-fullname=\"$USER_FULLNAME\" --packager-email=\"$USER_EMAIL\"" + $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 in `print_environment_descr $ENVIRONMENT` environment\" STIME=`date +%s`" @@ -1592,11 +1612,11 @@ case $REQUEST in RET=-1 ;; "smartupgrade") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "export LANG=C;sudo smart update && sudo smart upgrade" - RET=$? - ;; + RET=$? + ;; "runldconfig") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "/sbin/ldconfig" - RET=$? - ;; + 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=$? @@ -1683,9 +1703,9 @@ case $REQUEST in [ $RET -eq 0 ] && social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"sent $AUTODISTPKGS $SPECVAR_Version-$SPECVAR_Release from `print_environment_descr $ENVIRONMENT` to $SENDREPOSITORY\" STIME=`date +%s`" ;; "autoport") if [ "$AUTOPORTPACKAGE" ]; then - $SUDO_WRAPPER background $ENVIRONMENT "$USER" $AUTOPORTPACKAGE "autoport $AUTOPORTPACKAGE -r $REPOSITORY" &>/dev/null + $SUDO_WRAPPER background $ENVIRONMENT "$USER" $AUTOPORTPACKAGE "autoport $AUTOPORTPACKAGE -r $REPOSITORY --user $USER" &>/dev/null RET=$? - [ $REQ -eq 0 ] && { + [ $RET -eq 0 ] && { RET=-1 echo "Autoport started. You may see the output in the Webbuild jobs box above." } @@ -1768,7 +1788,7 @@ case $REQUEST in [ $RET -eq 0 ] && { echo -n "Patch added to sources with name '$PACKAGE-${SPECVAR_Version}-$ADDPATCHNAME.patch'." for l in 1 0 2 3; do - $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDDIR/$SPECVAR_BUILDDIR && patch --dry-run -s -p1 < $SPECVAR_RPMSOURCESDIR/$PACKAGE-${SPECVAR_Version}-$ADDPATCHNAME.patch >/dev/null" + $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDDIR/$SPECVAR_BUILDDIR && patch --dry-run -s -p$l < $SPECVAR_RPMSOURCESDIR/$PACKAGE-${SPECVAR_Version}-$ADDPATCHNAME.patch >/dev/null" RET=$? [ $RET -eq 0 ] && break done @@ -1776,6 +1796,7 @@ case $REQUEST in echo -n "
Info: good, patch applies successfully with -p$l option!" echo -n "

HINT: add the following lines in the appropriate sections:
" else + l=0 echo -n "
Warning: patch does not apply with '-p0' to '-p3' options!" echo "

HINT: you might want to retry from a clean build dir after pressing the 'unpack' button or check if it applies after changing working subdirectory in build tree." echo -n "
HINT: add anyway the following lines in the appropriate sections and press 'prepare' to see patch command output:
" @@ -1895,7 +1916,7 @@ case $REQUEST in 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 + $SUDO_WRAPPER background $ENVIRONMENT "$USER" "$PACKAGE" "autoport -r $SENDREPOSITORY -d $REPOSITORYIMPORTTO $PACKAGES -u \"$MASSREBUILDCHANGELOG\" --user $USER" &>/dev/null [ $? -ne 0 ] && RET=$? || { RET=-1 echo -n "Mass rebuild started. You may see the output in the Webbuild jobs box above." @@ -1917,7 +1938,7 @@ case $REQUEST in fi ;; "autoportnp") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="-f" || AUTODISTADD= - $SUDO_WRAPPER background $ENVIRONMENT "$USER" $PACKAGE "autoport -np $PACKAGE -r $SENDREPOSITORY $AUTODISTADD" &>/dev/null + $SUDO_WRAPPER background $ENVIRONMENT "$USER" $PACKAGE "autoport -np $PACKAGE -r $SENDREPOSITORY $AUTODISTADD --user $USER" &>/dev/null [ $? -ne 0 ] && RET=$? || { RET=-1 echo -n "Autoport started. You may see the output in the Webbuild jobs box above." diff --git a/webbuild/webbuild-functions b/webbuild/webbuild-functions index 0c4d5c7..9373eae 100644 --- a/webbuild/webbuild-functions +++ b/webbuild/webbuild-functions @@ -230,7 +230,8 @@ function parse_patch_output() { } function parse_build_output() { - sed "s|\(.\{10000\}\).*|\1 [CUT - LONG LINE]|;s|\\\|\\\\\\\|g;s|<|\<|g;s|[[:cntrl:]]\[[0-9;]*m||g; + sed "s|\r.*||; + s|\(.\{10000\}\).*|\1 [CUT - LONG LINE]|;s|\\\|\\\\\\\|g;s|<|\<|g;s|[[:cntrl:]]\[[0-9;]*m||g; s|<font|\1|; @@ -243,7 +244,8 @@ function parse_build_output() { } function parse_generic_output() { - sed "s|\(.\{10000\}\).*|\1 [CUT - LONG LINE]|;s|<|\<|g;s|[[:cntrl:]]\[[0-9;]*m||g; + sed "s|\r.*||; + s|\(.\{10000\}\).*|\1 [CUT - LONG LINE]|;s|<|\<|g;s|[[:cntrl:]]\[[0-9;]*m||g; s|<font|\1|; @@ -289,6 +291,15 @@ function print_environment_descr() { # (${AUTOPORT_BASE_REPOSITORY[$i]} based)" } +function environment_rootdir() { + local env=$1 + if [ "${AUTOPORT_CHROOT[$env]}" ]; then + echo "/var/autoport/${AUTOPORT_CHROOT[$env]}" + else + echo "" + fi +} + function environment_autoport_logdir() { local env=$1 if [ "${AUTOPORT_CHROOT[$env]}" ]; then @@ -305,11 +316,21 @@ function environment_autoport_logdir() { function environment_logdir() { local env=$1 + local chroot=$2 + if [ "${AUTOPORT_CHROOT[$env]}" ]; then if [ "${AUTOPORT_CHROOT_USER[$env]}" != "autodist" ]; then - echo "/var/autoport/${AUTOPORT_CHROOT[$env]}/home/${AUTOPORT_CHROOT_USER[$env]}/.autodist/log/" + if [ "$chroot" ]; then + echo "/home/${AUTOPORT_CHROOT_USER[$env]}/.autodist/log/" + else + echo "/var/autoport/${AUTOPORT_CHROOT[$env]}/home/${AUTOPORT_CHROOT_USER[$env]}/.autodist/log/" + fi else - echo "/var/autoport/${AUTOPORT_CHROOT[$env]}/var/autodist/log/" + if [ "$chroot" ]; then + echo "/var/autodist/log/" + else + echo "/var/autoport/${AUTOPORT_CHROOT[$env]}/var/autodist/log/" + fi fi elif [ "${AUTOPORT_NATIVE[$env]}" ]; then local envhome=`eval echo ~${AUTOPORT_CHROOT_USER[$env]}` diff --git a/webbuild/webbuild-functions-private b/webbuild/webbuild-functions-private index a27af51..e857ee2 100644 --- a/webbuild/webbuild-functions-private +++ b/webbuild/webbuild-functions-private @@ -31,11 +31,10 @@ function showlog() { LOGFILE3=$LOGFILE/*_${PACKAGE/\//_}__*.${AUTOPORT_ARCH[$ENVIRONMENT]} LOGFILE4=$LOGFILE/*_${PACKAGE/\//_}.${AUTOPORT_ARCH[$ENVIRONMENT]} - LOGDIR=`environment_logdir $ENVIRONMENT` + LOGDIR=`environment_logdir $ENVIRONMENT 1` LOGFILES="$LOGDIR/$LOGFILE1 $LOGDIR/$LOGFILE2 $LOGDIR/$LOGFILE3 $LOGDIR/$LOGFILE4" # sort by most recent and take first - LOGFILES=`ls -t $LOGFILES 2>/dev/null | head -1` -# LOGFILES=`$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "ls -t $LOGFILES 2>/dev/null | head -1"` + LOGFILES=`$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "ls -t $LOGFILES 2>/dev/null | head -1"` fi echo -n "Console output for $PACKAGE ($LOGTYPE$LOGSTATUSAPPEND):" echo "
" @@ -161,7 +160,7 @@ function print_editorcontrols() { echo -n "
" echo -n "" # specfile reload echo -n "$f
" @@ -216,6 +215,11 @@ function show_docs() { echo -n "
" for f in $@; do echo -n "

File $f:

"
+      ftype="`$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDDIR/$SPECVAR_BUILDDIR && file $f"`"
+      if [ "${ftype/text}" = "${ftype}" ]; then
+         echo "

Binary file; skipping." + continue + fi $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE \ "cd $SPECVAR_RPMBUILDDIR/$SPECVAR_BUILDDIR && head -c 10240 $f | sed \"s|<|\<|g;s|[[:cntrl:]]\[[0-9;]*m||g\"" | parse_generic_output RET=$? diff --git a/webbuild/webbuild-sudo b/webbuild/webbuild-sudo index 9b3aa83..315fb0d 100755 --- a/webbuild/webbuild-sudo +++ b/webbuild/webbuild-sudo @@ -32,8 +32,10 @@ elif [ "$MODE" = "finishprocess" ]; then exit $RETCODE elif [ "$ENVIRONMENT" = "local" ]; then echo "COMMAND: $COMMAND" >> $WEBBUILD_STATEDIR/commands_log - $COMMAND 2>&1 | sed "s|<|\<|g" - exit 0 + $COMMAND 2>&1 + # | sed "s|<|\<|g" + RET=$? + exit $RET fi if [ "$ENVIRONMENT" = "local" ]; then