From ffff0b1c10f5aced05ac05530a5d54b8f417bed9 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Mon, 10 Sep 2012 17:48:21 +0200 Subject: [PATCH] webbuild: lots of not better detailed changes; added webbuild-functions import script in /usr/share/autodist --- Makefile | 17 +- webbuild/webbuild-cgi | 1109 +++++++++++++++++------------------ webbuild/webbuild-functions | 156 +++++ webbuild/webbuild-sudo | 33 +- 4 files changed, 730 insertions(+), 585 deletions(-) create mode 100644 webbuild/webbuild-functions diff --git a/Makefile b/Makefile index b3f355c..9c15456 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,8 @@ INSTALL_DATA = ${INSTALL} -m 644 INSTALL_DIR = ${INSTALL} -d -m 755 INSTALL_SCRIPT = ${INSTALL_PROGRAM} -pck_datadir = $(localstatedir)/$(PACKAGE) +pck_datadir = $(datadir)/$(PACKAGE) +pck_statedir = $(localstatedir)/$(PACKAGE) pck_logdir = $(localstatedir)/$(PACKAGE)/log distdir = $(PACKAGE)-$(VERSION) @@ -49,14 +50,15 @@ install-dirs: @$(INSTALL_DIR) $(DESTDIR)$(sbindir) @$(INSTALL_DIR) $(DESTDIR)$(cgidir) @$(INSTALL_DIR) $(DESTDIR)$(pck_datadir) - @$(INSTALL_DIR) $(DESTDIR)$(pck_datadir)/template/autoupdate/spec-patches-build/old - @$(INSTALL_DIR) $(DESTDIR)$(pck_datadir)/template/autoupdate/spec-patches-update/old + @$(INSTALL_DIR) $(DESTDIR)$(pck_statedir) + @$(INSTALL_DIR) $(DESTDIR)$(pck_statedir)/template/autoupdate/spec-patches-build/old + @$(INSTALL_DIR) $(DESTDIR)$(pck_statedir)/template/autoupdate/spec-patches-update/old @$(INSTALL_DIR) $(DESTDIR)$(pck_logdir)/prepare/{ok,failed} @$(INSTALL_DIR) $(DESTDIR)$(pck_logdir)/update/{ok,failed} @$(INSTALL_DIR) $(DESTDIR)$(pck_logdir)/build/{ok,failed} @$(INSTALL_DIR) $(DESTDIR)$(pck_logdir)/install/{ok,failed} @$(INSTALL_DIR) $(DESTDIR)$(pck_logdir)/send/{ok,failed} - @$(INSTALL_DIR) $(DESTDIR)$(pck_datadir)/RPM/{SPECS,SRPMS,BUILD,SOURCES,RPMS/{noarch,i586,ppc,x86_64,arm}} + @$(INSTALL_DIR) $(DESTDIR)$(pck_statedir)/RPM/{SPECS,SRPMS,BUILD,SOURCES,RPMS/{noarch,i586,ppc,x86_64,arm}} @$(INSTALL_DIR) $(DESTDIR)$(piddir) @$(INSTALL_DIR) $(DESTDIR)$(libexecdir) @@ -71,6 +73,7 @@ install-programs: @$(INSTALL_SCRIPT) webbuild/webbuild-cgi $(DESTDIR)$(cgidir)/webbuild @$(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-data: @$(INSTALL_DATA) etc/autodist/config $(DESTDIR)$(configdir)/config @@ -93,9 +96,9 @@ install-data: @$(INSTALL_SCRIPT) etc/sysconfig/autoport $(DESTDIR)$(sysconfdir)/sysconfig/autoport @$(INSTALL_SCRIPT) etc/cron.hourly/65-autoport $(DESTDIR)$(sysconfdir)/cron.hourly/ @$(INSTALL_SCRIPT) etc/cron.daily/40-autodist-cleanold $(DESTDIR)$(sysconfdir)/cron.daily/ - @$(INSTALL_DATA) autospec-conf $(DESTDIR)$(pck_datadir)/.autospec - @touch $(DESTDIR)$(pck_datadir)/template/autoupdate/auto.success - @touch $(DESTDIR)$(pck_datadir)/template/autoupdate/auto.skip + @$(INSTALL_DATA) autospec-conf $(DESTDIR)$(pck_statedir)/.autospec + @touch $(DESTDIR)$(pck_statedir)/template/autoupdate/auto.success + @touch $(DESTDIR)$(pck_statedir)/template/autoupdate/auto.skip install: \ install-dirs \ diff --git a/webbuild/webbuild-cgi b/webbuild/webbuild-cgi index 9f2d305..e2ad907 100755 --- a/webbuild/webbuild-cgi +++ b/webbuild/webbuild-cgi @@ -4,147 +4,7 @@ # Copyright (c) 2012 by Silvan Calarco # . /etc/sysconfig/autoport - -SUDO_WRAPPER="sudo /usr/libexec/webbuild-sudo" -STATEDIR=/var/autodist/webbuild -LOG=/var/autodist/webbuild/access_log -DEFAULT_ENVIRONMENT=0 -[ "`uname -m`" = "x86_64" ] && HOST_IS_X86_64=1 - -function set_user_state_var() { - local statevar=$1 - local statevalue=$2 - local stateuser=$3 - - [ ! "$stateuser" ] && stateuser=$USER - - [ "$1" ] || return - - [ -e $STATEDIR/users/$stateuser.state ] || touch $STATEDIR/users/$stateuser.state - sed -i "/^$statevar=/d" $STATEDIR/users/$stateuser.state - [ "$statevalue" ] && echo "$statevar=$statevalue" >> $STATEDIR/users/$stateuser.state -} - -function social_log() { - local line=$1 - - [ "$1" ] || return - - if [ ! "$STATE_FAKEUSER" ]; then - STATE_SOCIALLOG_ID=0 - . $STATEDIR/users/webbuild.state - STATE_SOCIALLOG_ID=`expr $STATE_SOCIALLOG_ID + 1` - set_user_state_var STATE_SOCIALLOG_ID $STATE_SOCIALLOG_ID webbuild - echo "SID=$STATE_SOCIALLOG_ID SPRIVACY=$STATE_PRIVACYMODE $line" >> $STATEDIR/social_log - fi -} - -function cgi_encodevar() { - local string="${1}" - local strlen=${#string} - local encoded="" - - for (( pos=0 ; pos and flipflip industries - -# (internal) routine to store POST data -function cgi_get_POST_vars() -{ - # check content type - # FIXME: not sure if we could handle uploads with this.. - [ "${CONTENT_TYPE}" != "application/x-www-form-urlencoded" ] && \ - echo "Warning: you should probably use MIME type "\ - "application/x-www-form-urlencoded!" 1>&2 - # save POST variables (only first time this is called) - [ -z "$QUERY_STRING_POST" \ - -a "$REQUEST_METHOD" = "POST" -a ! -z "$CONTENT_LENGTH" ] && - read -n $CONTENT_LENGTH QUERY_STRING_POST - return -} - -# (internal) routine to decode urlencoded strings -function cgi_decodevar() -{ - [ $# -ne 1 ] && return - local v t h - # replace all + with whitespace and append %% - t="${1//+/ }%%" - while [ ${#t} -gt 0 -a "${t}" != "%" ]; do - v="${v}${t%%\%*}" # digest up to the first % - t="${t#*%}" # remove digested part - # decode if there is anything to decode and if not at end of string - if [ ${#t} -gt 0 -a "${t}" != "%" ]; then - h=${t:0:2} # save first two chars - t="${t:2}" # remove these - if [ "${h}" = "22" ]; then - v="${v}\\\"" - elif [ "${h}" = "0A" ]; then - v="${v}\\\n" - elif [ "${h}" = "24" ]; then - v="${v}\\\$" - elif [ "${h}" = "60" ]; then - v="${v}\\\`" - else - v="${v}"`echo -e \\\\x${h}` # convert hex to special char - fi - fi - done - # return decoded string - echo "${v}" - return -} - -# routine to get variables from http requests -# usage: cgi_getvars method varname1 [.. varnameN] -# method is either GET or POST or BOTH -# the magic varible name ALL gets everything -function cgi_getvars() -{ - [ $# -lt 2 ] && return - local q p k v s - # get query - case $1 in - GET) - [ ! -z "${QUERY_STRING}" ] && q="${QUERY_STRING}&" - ;; - POST) - cgi_get_POST_vars - [ ! -z "${QUERY_STRING_POST}" ] && q="${QUERY_STRING_POST}&" - ;; - BOTH) - [ ! -z "${QUERY_STRING}" ] && q="${QUERY_STRING}&" - cgi_get_POST_vars - [ ! -z "${QUERY_STRING_POST}" ] && q="${q}${QUERY_STRING_POST}&" - ;; - esac - shift - s=" $* " - # parse the query data - while [ ! -z "$q" ]; do - p=`echo $q | sed "s|&.*||"` - q=`echo $q | sed "s|[^&]*&||"` - k="${p%%=*}" # get the key (variable name) from it - v="${p#*=}" # get the value from it - # decode and evaluate var if requested - if [ "$k" != "SPECTEXT" ]; then - v=`cgi_decodevar "$v"` - fi - eval "$k=\"$v\"" - done - return -} +. /usr/share/autodist/webbuild-functions # register all GET and POST variables cgi_getvars BOTH ALL @@ -173,11 +33,12 @@ fi # SECURITY USER_ENABLED= USER_ADMIN= -USER_CANIMPORT= +USER_CANMAINTAIN= +USER_CANSENDMESSAGES= USER=${USER/.*\/} if [ "$SECRET" -a "$USER" ]; then - if [ -r "$STATEDIR/users/$USER.conf" ]; then - . $STATEDIR/users/$USER.conf + if [ -r "$WEBBUILD_STATEDIR/users/$USER.conf" ]; then + . $WEBBUILD_STATEDIR/users/$USER.conf fi if [ "$USER_ENABLED" ]; then USER_ENABLED= @@ -193,7 +54,7 @@ if [ "$SECRET" -a "$USER" ]; then echo -n " " echo -n " " echo -n " " - 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 "'$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 "" echo -n " " echo -n "" @@ -202,10 +63,10 @@ if [ "$SECRET" -a "$USER" ]; then /usr/libexec/webbuild-checkpassword "$PASSWORD" "$SECRET" 2>/dev/null if [ $? -eq 0 ]; then tmpfile=`mktemp` - cat $STATEDIR/users/$USER.conf > $tmpfile + cat $WEBBUILD_STATEDIR/users/$USER.conf > $tmpfile echo "USER_SECRET='$SECRET'" >> $tmpfile USER_ENABLED=1 - $SUDO_WRAPPER local "" "mv $tmpfile $STATEDIR/users/$USER.conf" + $SUDO_WRAPPER local "" "mv $tmpfile $WEBBUILD_STATEDIR/users/$USER.conf" else USER_ENABLED= fi @@ -240,11 +101,11 @@ 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" >> $STATEDIR/requests_log + echo "`date` - USER=$USER USER_EMAIL=$USER_EMAIL REQUEST=$REQUEST SECRET=$SECRET" >> $WEBBUILD_STATEDIR/requests_log 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 \" $STATEDIR/requests_log`" ]; then + elif [ "`grep \" USER=$USER \" $WEBBUILD_STATEDIR/requests_log`" ]; then echo -n "Your request is pending for approval. Please try again later or ask the maintainer in case of problems." else echo -n "
" count=0 - [ -e "$STATEDIR/social_log" ] && tail -n 100 $STATEDIR/social_log | tac | while read line; do + [ -e "$WEBBUILD_STATEDIR/social_log" ] && tail -n 100 $WEBBUILD_STATEDIR/social_log | tac | while read line; do STYPE= SPRIVACY= SUSER= @@ -359,36 +222,62 @@ if [ "$REQUEST" = "refresh" -o ! "$USER" ]; then done echo -n "
" echo -n "]]>" +fi - if [ ! "$USER_ENABLED" -o "$REQUEST" = "refresh" ]; then - echo "" - exit - fi +if [ "$USER_ENABLED" != "1" ]; then + echo -n "" + exit +fi + +# +# Enabled users requests +# + +if [ "$REQUEST" = "refresh" ]; then + echo -n "" + echo -n "Webbuild running jobs:
" + } + echo -n "$2 \"$cmdline\" " + echo -n " [ " + echo -n "show ]" + echo -n "
" + fi + done < $WEBBUILD_STATEDIR/processes + [ $numprocesses -gt 0 ] && echo -n "" + echo -n "]]>
" + exit +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`" + echo "" + exit +fi + +# repsearch request +if [ "$REQUEST" = "repsearch" ]; then + echo -n "" + echo -n "
"
+   $SUDO_WRAPPER local "" "openmamba-repository search -i $REPSEARCHTEXT"
+   echo -n "
" + echo "]]>
" + exit fi # ENVIRONMENT select echo -n "" -fi -if [ "$USER_ADMIN" -o "$STATE_FAKEUSER" ]; then - echo -n " Test user: " - echo -n " | " -fi # new session button echo -n "" @@ -397,6 +286,7 @@ echo -n "window.open(document.URL);>" echo -n " Expert:" # privacy mode checkbox [ "$STATE_PRIVACYMODE" ] && CHECKED="checked=checked" || CHECKED= @@ -405,8 +295,30 @@ echo -n "onclick=javascript:ajax_getvalues(\"" echo -n "ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&" echo -n "PRIVACYMODESWITCH=\"+getElementById('privacymode').checked); $CHECKED>" echo -n "" +# maintainer mode checkbox +if [ "$USER_CANMAINTAIN" ]; then + [ "$MAINTAINERMODE" = "true" ] && CHECKED="checked" + echo -n "Maintainer:" +fi +# switch user select +if [ "$USER_ADMIN" -o "$STATE_FAKEUSER" ]; then + echo -n " | " + echo -n " Test user: " +fi if [ "$MAINTAINERMODE" != "true" ]; then -# [ "$USER_CANIMPORT" -o "$STATE_FAKEUSER" -o "$USER_ADMIN" ] && echo -n "
" +# [ "$USER_CANMAINTAIN" -o "$STATE_FAKEUSER" -o "$USER_ADMIN" ] && echo -n "
" echo -n "
Build environment:" echo -n "]]>" @@ -539,14 +485,11 @@ if [ ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" -o "$MAINTAINERMODE" = "true" ]; then fi # PACKAGES (SRPM) select - if [ "$REPOSITORY" -a "$REQUEST" = "changerepository" ]; then + if [ "$REQUEST" = "changerepository" -o "$REQUEST" = "switchmaintainermode" -a "$MAINTAINERMODE" != "true" ]; then echo -n "" -# i=getElementById('repository').selectedIndex;ajax_getvalues(\"REQUEST=changesrpm&" -# echo -n "ENVIRONMENT=$ENVIRONMENT&MAINTAINERMODE=\"+getElementById('maintain').checked+\"&" -# echo -n "PACKAGE=\"+encodeURIComponent(this.value)+\"&" -# echo -n "REPOSITORY=\"+getElementById('repository').options[i].text);>" + echo -n "" echo -n "]]>" - echo -n "" + echo -n "]]>" +# REQUEST=changesrpm fi - echo -n "]]>" -# if [ "$MAINTAINERMODE" = "true" ]; then -# PACKAGE= -# echo " " -# fi - REQUEST=changesrpm fi # SPECFILE creation @@ -604,7 +543,7 @@ if [ ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" -o "$MAINTAINERMODE" = "true" ]; then echo -n " " fi else - echo -n " " + echo -n " " fi if [ "$REQUEST" = "changespec" ]; then if [ "$PACKAGE" ]; then @@ -631,6 +570,10 @@ if [ "$SPECTEXT" ]; then rm -f $tmpfile fi +if [ "$REQUEST" = "edit" -o "$REQUEST" = "prepare" ]; then + social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"is working on $PACKAGE\" STIME=`date +%s`" +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 @@ -656,6 +599,7 @@ if [ "$REQUEST" = "prepare" -o "$REQUEST" = "updatespec" -o "$REQUEST" = "speccr [ "$SPECCREATEVERSION" ] && AUTOSPEC_CMDLINE="$AUTOSPEC_CMDLINE -v $SPECCREATEVERSION" $SUDO_WRAPPER $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`" # --changelog \"package created by $USER from autodist webbuild interface\"" else echo "ERROR: both source archive URL and name are needed." @@ -664,6 +608,7 @@ if [ "$REQUEST" = "prepare" -o "$REQUEST" = "updatespec" -o "$REQUEST" = "speccr ;; "renamespec") $SUDO_WRAPPER $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`" ;; esac echo -n "" @@ -677,9 +622,11 @@ if [ "$REQUEST" = "prepare" -o "$REQUEST" = "updatespec" -o "$REQUEST" = "speccr REQUEST="edit" fi -if [ "$REPOSITORY" != "" -a "$MAINTAINERMODE" = "true" ]; then - if [ ! "$REQUEST" -o "$REQUEST" = "changesrpm" ]; then +if [ "$MAINTAINERMODE" = "true" -a "$REPOSITORY" != "" ]; 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:
" @@ -687,32 +634,29 @@ if [ "$REPOSITORY" != "" -a "$MAINTAINERMODE" = "true" ]; then echo -n "
Log:
"
       cat $local_ftp/$REPOSITORY/distromatic.log
       echo -n "
" - echo -n "" echo -n "]]>
" fi fi -if [ "$REQUEST" = "edit" -o "$REQUEST" = "reloadspec" ]; then +if [ "$REQUEST" = "edit" -o "$REQUEST" = "reloadspec" -o "$REQUEST" = "switchmaintainermode" -a "$MAINTAINERMODE" != "true" ]; then if [ "$PACKAGE" ]; then $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "ls $PACKAGE.spec" [ $? -eq 0 ] && SPECAVAILABLE=1 fi - if [ "$MAINTAINERMODE" != "true" -a "$SPECAVAILABLE" ]; then - if [ "$REQUEST" = "edit" ]; then - social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"is working on $PACKAGE\" STIME=`date +%s`" - fi - echo -n "$PACKAGE.spec in build environment: " - echo -n "new version (empty=autodetect):" - echo -n "or new release changelog:" - echo -n "" + echo -n " (specify new version:" + echo -n " or changelog for a new release:)" echo -n "]]>" - echo -n "$PACKAGE.spec in build environment:" @@ -728,348 +672,263 @@ if [ "$REQUEST" = "edit" -o "$REQUEST" = "reloadspec" ]; then echo -n "REQUEST=renamespec&PACKAGE=\"+encodeURIComponent(getElementById('specnewname').value));>" echo -n ".spec" echo -n "]]>" - fi - if [ "$MAINTAINERMODE" = "true" -o "$SPECAVAILABLE" ]; then - echo -n "" - if [ "$MAINTAINERMODE" != "true" ]; then - echo -n "Package: $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 "
" + [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" -o "$STATE_ADVANCEDCONTROLS" ] && echo -n "
Autodist automatic builds:
" + if [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then + echo -n "Patch:" + echo -n "" + echo -n "" + echo -n "" + # autodist schedule + echo -n "
Schedule:" + # autodist unschedule + echo -n "" + # autodist skip + echo -n "
" + fi + if [ "$STATE_ADVANCEDCONTROLS" ]; then + # autodist list-jobs + echo -n "Job:" - echo -n "" - [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" -o "$STATE_ADVANCEDCONTROLS" ] && echo -n "
Autodist automatic builds:
" - if [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then - echo -n "Patch:" - echo -n "" - echo -n "" - echo -n "" - # autodist schedule - echo -n "
Schedule:" - # autodist unschedule - echo -n "" - # autodist skip - echo -n "" - fi - if [ "$STATE_ADVANCEDCONTROLS" ]; then - # autodist list-jobs - echo -n "Job:" - # 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 - fi - if [ "$STATE_ADVANCEDCONTROLS" -o "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then - # autodist logs - echo -n "
Last autodist logs: " - echo -n "OK " - echo -n "FAILED
" - echo -n "" - echo -n "" - echo -n "" - echo -n "" - echo -n "" - fi - echo -n "
RPM packaging commands:
" - # check for updates - echo -n "" - # unpack - echo -n "" - # build + # autodist prepare + echo -n "
" + # autodist update + echo -n "" + # autodist build echo -n "" - # buildroot files - echo -n "" - # unpackaged files - echo -n "" - # build requirements - echo -n "" - # recreate SRPM - echo -n "" - # rpm checks - echo -n "" - echo -n "" - [ ! "$USER_CANINSTALL" ] && DISABLED="disabled=disabled" - echo -n "" - echo -n "
Add patches:" - echo -n "
" - echo -n "URL:" - echo -n "As: $PACKAGE-.patch" - echo -n "
Repository:" - echo -n "
" - # send - echo -n "" - # recreate and send SRPM - echo -n "" - fi - if [ "$USER_CANIMPORT" -a "$PACKAGE" ]; then - if [ "$MAINTAINERMODE" = "true" ]; then - echo -n "
Repository maintenance:
" - echo -n "Package: $PACKAGE
" - echo -n "Origin: $REPOSITORY
" - echo -n "Destination: " - echo -n "
" - fi - if [ "$MAINTAINERMODE" != "true" ]; then - echo -n "" -# echo -n "
" -# echo -n "" - else - # repository compare - echo -n "" - # repository import - echo -n "" - # repository release - echo -n "" - # repository archive - echo -n "" - fi - echo -n "simulate" + echo -n "ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&REQUEST=autodistbuild\"); class=boldbutton>" + # autodist install + [ ! "$USER_CANINSTALL" ] && DISABLED="disabled=disabled" || DISABLED= + echo -n "" + # autodist send + [ ! "$USER_ALLREPOSITORIES" ] && DISABLED="disabled=disabled" || DISABLED= + echo -n "" + # autodist force checkbox fi - if [ "$MAINTAINERMODE" != "true" ]; then - if [ ! "${AUTOPORT_DISABLE[$ENVIRONMENT]}" -a ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then - echo -n "
Automatic port:
" - echo -n "" - echo -n "" - fi - - echo -n "
Info:
" - echo -n "" - echo -n "" - echo -n "" - echo -n "" - echo -n "
" - echo -n "
" + if [ "$STATE_ADVANCEDCONTROLS" -o "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then + # autodist logs + echo -n "
Last autodist logs: " + echo -n "OK " + echo -n "FAILED
" + echo -n "" + echo -n "" + echo -n "" + echo -n "" + echo -n "" fi + echo -n "
RPM packaging commands:
" + # check for updates + echo -n "" + # unpack + echo -n "" + # build + echo -n "" + # buildroot files + echo -n "" + # unpackaged files + echo -n "" + # build requirements + echo -n "" + # recreate SRPM + echo -n "" + # rpm checks + echo -n "" + echo -n "" + # rpm install + [ ! "$USER_CANINSTALL" ] && DISABLED="disabled=disabled" + echo -n "" + # send + echo -n "" + # recreate and send SRPM + echo -n "" + # 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 "" + echo -n "" + fi + echo -n "
Info from package sources:
" + echo -n "" + echo -n "" + echo -n "" + echo -n "" + echo -n "" + echo -n "
Generic info:
" + echo -n "" + echo -n "" + echo -n "
" + echo -n "
" + # broadcast message echo -n "
Broadcast message:
" echo -n "" echo -n "" - echo -n "]]>
" else echo "" - echo "No pre-existing .spec file $PACKAGE.spec in current working environment. Use 'prepare' to edit." + 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 "]]>" fi -elif [ "$REQUEST" = "showlog" ]; then - echo -n "" - for f in $LOGFILE1 $LOGFILE2 $LOGFILE3 $LOGFILE4; do - [ -r $f ] || continue - echo "`basename $f` (`stat -c %y $f`)
"
-      cat $f | sed "s|<|\<|g"
-      echo -n "
" - done - echo -n "]]>
" else if [ "$REQUEST" != "" ]; then echo -n "" else - echo -n "id=outputtop" + echo -n "id=outputtop>" + fi + if [ "$REQUEST" != "showchangelogs" -a "$REQUEST" != "showbuilddocs" -a "$REQUEST" != "showlicenses" ]; then + echo -n "
"
       fi
-      echo ">
"
       RET=255
    fi
    case $REQUEST in
@@ -1101,24 +960,28 @@ else
                  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 -p $AUTODISTJOB --arch $AUTODISTARCH $AUTODISTADD"
+                         $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -v -p $AUTODISTJOB --arch $AUTODISTARCH $AUTODISTADD"
                          RET=$? ;;
       "autodistupdate") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
-                        $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -u $AUTODISTJOB --arch $AUTODISTARCH $AUTODISTADD"
+                        $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -v -u $AUTODISTJOB --arch $AUTODISTARCH $AUTODISTADD"
                         RET=$? ;;
       "autodistbuild") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
-                       $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -b $AUTODISTJOB --arch $AUTODISTARCH $AUTODISTADD"
-                       RET=$? ;;
+                       $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -v -b $AUTODISTJOB --arch $AUTODISTARCH $AUTODISTADD"
+                       RET=$?
+                       [ $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 -i $AUTODISTJOB --arch $AUTODISTARCH $AUTODISTADD"
+                         $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -v -i $AUTODISTJOB --arch $AUTODISTARCH $AUTODISTADD"
                          RET=$? ;;
       "autodistsend") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
-                      $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -s $AUTODISTJOB --arch $AUTODISTARCH $AUTODISTADD"
-                      RET=$? ;;
+                      $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -v -s $AUTODISTJOB --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" >> $STATEDIR/buildingnow_log
+      "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\""
@@ -1127,8 +990,7 @@ else
                   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" $STATEDIR/buildingnow_log
-                  #kill `pstree -p 25541 | sed 's/(/\n(/g' | grep '(' | sed 's/(\(.*\)).*/\1/' | tr "\n" " "`
+                  sed -i "|RPMBUILD=$PACKAGE USER=$USER ENVIRONMENT=$ENVIRONMENT|d" $WEBBUILD_STATEDIR/buildingnow_log
                   ;;
       "srpmbuild") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "rpmbuild -bs $PACKAGE.spec"
                    RET=$? ;;
@@ -1170,36 +1032,47 @@ else
                        RET=255
                     fi ;;
       "repositoryimport")
-                      [ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANIMPORT" ] && SIMULATEADD="-s" || SIMULATEADD=
-                      $SUDO_WRAPPER local $PACKAGE "openmamba-repository import $SENDREPOSITORY $PACKAGE -d $REPOSITORYIMPORTTO $SIMULATEADD -y"
-                      RET=$?
-                      if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then
-                         social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"imported $PACKAGE from $SENDREPOSITORY to $REPOSITORYIMPORTTO\" STIME=`date +%s`"
-                      fi
+                      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"
+                         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`"
+                         fi
+                         [ $RET -eq 0 ] || break
+                      done
                       ;;
       "repositoryrelease")
-                      [ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANIMPORT" ] && SIMULATEADD="-s" || SIMULATEADD=
-                      $SUDO_WRAPPER local $PACKAGE "openmamba-repository release $SENDREPOSITORY $PACKAGE -d $REPOSITORYIMPORTTO $SIMULATEADD -y"
-                      RET=$?
-                      if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then
-                         social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"released $PACKAGE from $SENDREPOSITORY to $REPOSITORYIMPORTTO\" STIME=`date +%s`"
-                      fi
+                      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"
+                         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`"
+                         fi
+                         [ $RET -eq 0 ] || break
+                      done
                       ;;
       "repositorydiff")
-                      $SUDO_WRAPPER local $PACKAGE "openmamba-repository diff $SENDREPOSITORY $PACKAGE -d $REPOSITORYIMPORTTO"
-                      RET=$?
+                      for p in $PACKAGES; do
+                         $SUDO_WRAPPER local "" "openmamba-repository diff $SENDREPOSITORY $p -d $REPOSITORYIMPORTTO"
+                         RET=$?
+                         [ $RET -eq 0 ] || break
+                      done
                       ;;
       "repositoryarchive")
-                      [ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANIMPORT" ] && SIMULATEADD="-s" || SIMULATEADD=
-                      $SUDO_WRAPPER local $PACKAGE "openmamba-repository archive $SENDREPOSITORY $PACKAGE -y"
-                      RET=$?
-                      if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then
-                         social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"archived $PACKAGE in $SENDREPOSITORY\" STIME=`date +%s`"
-                      fi
+                      for p in $PACKAGES; do
+                         [ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANMAINTAIN" ] && SIMULATEADD="-s" || SIMULATEADD=
+                         $SUDO_WRAPPER 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`"
+                         fi
+                         [ $RET -eq 0 ] || break
+                      done
                       ;;
       "autoportnp") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autoport -np $PACKAGE"; RET=$? ;;
       "autoportlog") cat "$AUTOPORTLOGDIR/current.log"; RET=$? ;;
-      "repsearch") $SUDO_WRAPPER local "" "openmamba-repository search -i $REPSEARCHTEXT"; RET=$? ;;
       "allowedgroups") $SUDO_WRAPPER $ENVIRONMENT "" "autospec --eval rpm_allowed_groups"; RET=$? ;;
       "approvedlicenses") $SUDO_WRAPPER $ENVIRONMENT "" "autospec --eval rpm_approved_licenses | grep -v \"^#\"" | \
                           while read line; do
@@ -1208,12 +1081,35 @@ else
                           RET=0
                           ;;
       "builddirfiles") $SUDO_WRAPPER $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
+                          PATTERN="-iname license\* -or -iname copying\* -or -iname authors\* -and -type f"
+                       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"`
+                       cnt=0
+                       for f in $files; do
+                          echo -n "$f
" + done + echo -n "
" + for f in $files; do + echo -n "

File $f:

"
+                          $SUDO_WRAPPER $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 - echo -n "
" + if [ "$REQUEST" != "showchangelogs" -a "$REQUEST" != "showbuilddocs" -a "$REQUEST" != "showlicenses" ]; then + echo -n "
" + fi if [ $RET -eq 0 ]; then echo "Result: OK" else @@ -1224,6 +1120,85 @@ else fi fi + +if [ "$MAINTAINERMODE" = "true" ]; then + echo -n " " + echo -n "Repository maintenance:
" +# echo -n "${pkgname} ${pkgver}-${pkgrel}" + done + echo -n "" + echo -n "Origin: $REPOSITORY
" + echo -n "Destination: " + echo -n "
" + # repository compare + echo -n "" + # repository import + echo -n "" + # repository release + echo -n "" + # repository archive + echo -n "" + echo -n "" + fi + echo -n "]]>
" +fi + #if [ ! "$REQUEST" -o "$REQUEST" = "output" ]; then # echo -n " +# +. /etc/autodist/config + +SUDO_WRAPPER="sudo /usr/libexec/webbuild-sudo" +#STATEDIR=$WEBBUILD_STATEDIR +LOG=$WEBBUILD_STATEDIR/access_log +DEFAULT_ENVIRONMENT=0 +[ "`uname -m`" = "x86_64" ] && HOST_IS_X86_64=1 + +function set_user_state_var() { + local statevar=$1 + local statevalue=$2 + local stateuser=$3 + + [ ! "$stateuser" ] && stateuser=$USER + + [ "$1" ] || return + + [ -e $WEBBILD_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 +} + +function social_log() { + local line=$1 + + [ "$1" ] || return + + if [ ! "$STATE_FAKEUSER" ]; then + STATE_SOCIALLOG_ID=0 + . $WEBBUILD_STATEDIR/users/webbuild.state + STATE_SOCIALLOG_ID=`expr $STATE_SOCIALLOG_ID + 1` + set_user_state_var STATE_SOCIALLOG_ID $STATE_SOCIALLOG_ID webbuild + echo "SID=$STATE_SOCIALLOG_ID SPRIVACY=$STATE_PRIVACYMODE $line" >> $WEBBUILD_STATEDIR/social_log + fi +} + +function cgi_encodevar() { + local string="${1}" + local strlen=${#string} + local encoded="" + + for (( pos=0 ; pos and flipflip industries + +# (internal) routine to store POST data +function cgi_get_POST_vars() +{ + # check content type + # FIXME: not sure if we could handle uploads with this.. + [ "${CONTENT_TYPE}" != "application/x-www-form-urlencoded" ] && \ + echo "Warning: you should probably use MIME type "\ + "application/x-www-form-urlencoded!" 1>&2 + # save POST variables (only first time this is called) + [ -z "$QUERY_STRING_POST" \ + -a "$REQUEST_METHOD" = "POST" -a ! -z "$CONTENT_LENGTH" ] && + read -n $CONTENT_LENGTH QUERY_STRING_POST + return +} + +# (internal) routine to decode urlencoded strings +function cgi_decodevar() +{ + [ $# -ne 1 ] && return + local v t h + # replace all + with whitespace and append %% + t="${1//+/ }%%" + while [ ${#t} -gt 0 -a "${t}" != "%" ]; do + v="${v}${t%%\%*}" # digest up to the first % + t="${t#*%}" # remove digested part + # decode if there is anything to decode and if not at end of string + if [ ${#t} -gt 0 -a "${t}" != "%" ]; then + h=${t:0:2} # save first two chars + t="${t:2}" # remove these + if [ "${h}" = "22" ]; then + v="${v}\\\"" + elif [ "${h}" = "0A" ]; then + v="${v}\\\n" + elif [ "${h}" = "24" ]; then + v="${v}\\\$" + elif [ "${h}" = "60" ]; then + v="${v}\\\`" + else + v="${v}"`echo -e \\\\x${h}` # convert hex to special char + fi + fi + done + # return decoded string + echo "${v}" + return +} + +# routine to get variables from http requests +# usage: cgi_getvars method varname1 [.. varnameN] +# method is either GET or POST or BOTH +# the magic varible name ALL gets everything +function cgi_getvars() +{ + [ $# -lt 2 ] && return + local q p k v s + # get query + case $1 in + GET) + [ ! -z "${QUERY_STRING}" ] && q="${QUERY_STRING}&" + ;; + POST) + cgi_get_POST_vars + [ ! -z "${QUERY_STRING_POST}" ] && q="${QUERY_STRING_POST}&" + ;; + BOTH) + [ ! -z "${QUERY_STRING}" ] && q="${QUERY_STRING}&" + cgi_get_POST_vars + [ ! -z "${QUERY_STRING_POST}" ] && q="${q}${QUERY_STRING_POST}&" + ;; + esac + shift + s=" $* " + # parse the query data + while [ ! -z "$q" ]; do + p=`echo $q | sed "s|&.*||"` + q=`echo $q | sed "s|[^&]*&||"` + k="${p%%=*}" # get the key (variable name) from it + v="${p#*=}" # get the value from it + # decode and evaluate var if requested + if [ "$k" != "SPECTEXT" ]; then + v=`cgi_decodevar "$v"` + fi + eval "$k=\"$v\"" + done + return +} + +function kill_tree() { + local killpid=$1 + + [ $1 ] || return + + kill `pstree -p $killpid | sed 's/(/\n(/g' | grep '(' | sed 's/(\(.*\)).*/\1/' | tr "\n" " "` + return $? +} diff --git a/webbuild/webbuild-sudo b/webbuild/webbuild-sudo index f42466b..ed52366 100755 --- a/webbuild/webbuild-sudo +++ b/webbuild/webbuild-sudo @@ -1,4 +1,5 @@ #!/bin/bash +. /usr/share/autodist/webbuild-functions . /etc/sysconfig/autoport ENVIRONMENT=$1 @@ -14,6 +15,7 @@ fi if [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then ENVPREFIX="/var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}" + ENVUSER=${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} WORKINGHOME="/usr/src/" SUCMDPREFIX="chroot $ENVPREFIX su -l ${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} -c" RPMBUILDROOT="/var/tmp/" @@ -23,10 +25,12 @@ if [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then } elif [ "${AUTOPORT_NATIVE[$ENVIRONMENT]}" ]; then ENVPREFIX= + ENVUSER=${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} WORKINGHOME=`getent passwd ${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} | cut -d: -f6` SUCMDPREFIX="su -l ${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} -c" else ENVPREFIX= + ENVUSER=autodist WORKINGHOME="/var/autodist" SUCMDPREFIX="su -l autodist -c" RPMBUILDROOT="/var/tmp/autodist" @@ -36,19 +40,17 @@ eval `$SUCMDPREFIX "autospec --eval=tmppath_dir|grep -v '^#'"` RPMBUILDROOT=$tmppath_dir SPECFILE=${ENVPREFIX}${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec if [ -r "$SPECFILE" ]; then -# _tmpfile=`mktemp` -# _errtmpfile=`mktemp` -# rpm -q --specfile $SPECFILE --specedit > ${_tmpfile} 2>${_errtmpfile} -# [ -s ${_errtmpfile} ] && { -# cat ${_errtmpfile} -# rm -f ${_tmpfile} ${_errtmpfile} -# exit 254 -# } + 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|"` + 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=$PACKAGE-$SPECVERSION + [ "$BUILDDIR" ] || BUILDDIR=$PACKAGE-$SPECVERSION fi RPMBUILDDIR=${WORKINGHOME}/RPM/BUILD COMMAND=`echo $COMMAND | sed "s|@BUILDDIR@|$BUILDDIR|g"` @@ -56,12 +58,21 @@ COMMAND=`echo $COMMAND | sed "s|@BUILDROOT@|$BUILDROOT|g"` COMMAND=`echo $COMMAND | sed "s|@RPMBUILDDIR@|$RPMBUILDDIR|g"` COMMAND=`echo $COMMAND | sed "s|@RPMBUILDROOT@|$RPMBUILDROOT|g"` +cmdtmpfile=`mktemp` +chgrp nobody $cmdtmpfile +chmod 640 $cmdtmpfile + rettmpfile=`$SUCMDPREFIX mktemp` -$SUCMDPREFIX ". /etc/profile;cd $WORKINGHOME/RPM/SPECS;$COMMAND;echo \$? > $rettmpfile" 2>&1 | sed "s|<|\<|g" + +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 +#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