From dd53d60b853113c37a89a5811eb730904d39778f Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Tue, 4 Sep 2012 13:05:57 +0200 Subject: [PATCH] webbuild: added maintainer mode; URI-encode package names to fix packages with '+' characters; other fixes --- webbuild/webbuild-cgi | 202 ++++++++++++++++++++++++------------------ 1 file changed, 117 insertions(+), 85 deletions(-) diff --git a/webbuild/webbuild-cgi b/webbuild/webbuild-cgi index aae840a..1f62bc6 100755 --- a/webbuild/webbuild-cgi +++ b/webbuild/webbuild-cgi @@ -11,6 +11,23 @@ LOG=/var/autodist/webbuild/access_log DEFAULT_ENVIRONMENT=0 [ "`uname -m`" = "x86_64" ] && HOST_IS_X86_64=1 +function cgi_encodevar() { + local string="${1}" + local strlen=${#string} + local encoded="" + + for (( pos=0 ; pos and flipflip industries @@ -103,6 +120,10 @@ function cgi_getvars() # register all GET and POST variables cgi_getvars BOTH ALL + +#[ "$PACKAGE" ] && PACKAGEENCODED=`cgi_encodevar "$PACKAGE"` || PACKAGEENCODED= +[ "$PACKAGE" ] && PACKAGEENCODED=`cgi_encodevar "$PACKAGE"` || PACKAGEENCODED= + #cgi_getvars POST if [ "$REQUEST" != "refresh" ]; then # echo "`date` - $QUERY_STRING_POST" >> $LOG @@ -162,7 +183,7 @@ if [ "$SECRET" -a "$USER" ]; then # no "$USER_SECRET" set; require password echo -n "" echo -n " " echo -n "]]>" echo -n " " @@ -315,10 +336,11 @@ fi [ "$PACKAGE" -a ! "$REQUEST" ] && REQUEST=edit # SPECFILES select -if [ "$ENVIRONMENT" ]; then +if [ "$ENVIRONMENT" -a "$MAINTAINERMODE" != "true" ]; then echo -n "" + 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/.*} @@ -326,6 +348,8 @@ if [ "$ENVIRONMENT" ]; then echo -n "" done echo -n "]]>" +elif [ "$MAINTAINERMODE" = "true" ]; then + echo -n " " fi # clean output when changing environment @@ -339,7 +363,7 @@ fi if [ ! "$REPSEARCHTEXT" ]; then echo -n "" if [ "$PACKAGE" ]; then echo -n "" @@ -356,7 +380,7 @@ if [ ! "$REPOSITORY" ]; then if [ "$USER_CANIMPORT" ]; then echo -n "&MAINTAINERMODE=\"+getElementById('maintain').checked+\"" fi - echo -n "&PACKAGE=$PACKAGE&REQUEST=changerepository\");>" + echo -n "&PACKAGE=$PACKAGEENCODED&REQUEST=changerepository\");>" echo -n "" for f in `$SUDO_WRAPPER local "" "/usr/sbin/openmamba-repository list"`; do repname=`basename $f` @@ -369,7 +393,7 @@ if [ ! "$REPOSITORY" ]; then echo -n "onclick=javascript:i=getElementById('repository').selectedIndex;" echo -n "ajax_getvalues(\"REPOSITORY=\"+getElementById('repository').options[i].text+\"" echo -n "&MAINTAINERMODE=\"+getElementById('maintain').checked+\"" - echo -n "&PACKAGE=$PACKAGE&ENVIRONMENT=$ENVIRONMENT\");>maintainer mode " + echo -n "&PACKAGE=$PACKAGEENCODED&ENVIRONMENT=$ENVIRONMENT\");>maintainer mode " fi echo -n "]]>" echo -n " " @@ -381,8 +405,9 @@ if [ "$REPOSITORY" -a "$REQUEST" = "changerepository" ]; then echo -n "" + echo -n "ENVIRONMENT=$ENVIRONMENT&MAINTAINERMODE=\"+getElementById('maintain').checked+\"&" + echo -n "PACKAGE=\"+encodeURIComponent(this.value)+\"&" + echo -n "REPOSITORY=\"+getElementById('repository').options[i].text);>" echo "" for f in $local_ftp/$REPOSITORY/SRPMS.base/*.src.rpm; do [ -r $f ] || continue @@ -418,7 +443,7 @@ if [ ! "$REQUEST" ]; then echo -n " version:" echo -n "" @@ -432,7 +457,8 @@ if [ "$REQUEST" = "changesrpm" ]; then echo -n "" + echo -n "&ENVIRONMENT=$ENVIRONMENT&MAINTAINERMODE=\"+getElementById('maintain').checked+\"&" + echo -n "PACKAGE=\"+encodeURIComponent(getElementById('package').options[j].value));>" fi echo "]]>" REQUEST="edit" @@ -511,15 +537,17 @@ if [ "$REQUEST" = "prepare" -o "$REQUEST" = "updatespec" -o "$REQUEST" = "speccr fi if [ "$REPOSITORY" != "" -a "$MAINTAINERMODE" = "true" ]; then - 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 "]]>
" + if [ ! "$REQUEST" -o "$REQUEST" = "changesrpm" ]; then + 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 "]]>
" + fi fi if [ "$REQUEST" = "edit" -o "$REQUEST" = "reloadspec" ]; then @@ -533,13 +561,9 @@ if [ "$REQUEST" = "edit" -o "$REQUEST" = "reloadspec" ]; then fi echo -n "$PACKAGE.spec in build environment: " echo -n "new version (empty=autodetect):" -# echo -n " " echo -n "or new release changelog:" echo -n "" @@ -549,15 +573,15 @@ if [ "$REQUEST" = "edit" -o "$REQUEST" = "reloadspec" ]; then $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cat $PACKAGE.spec" echo -n "" echo -n "" echo -n "" echo -n "" + echo -n "REQUEST=renamespec&PACKAGE=\"+encodeURIComponent(getElementById('specnewname').value));>" echo -n ".spec" echo -n "]]>" fi @@ -568,56 +592,65 @@ if [ "$REQUEST" = "edit" -o "$REQUEST" = "reloadspec" ]; then echo -n "Last logs: " echo -n "OK " echo -n "FAILED
" - echo -n "" - echo -n "" - echo -n "" - echo -n "" if [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then echo -n "
Scheduled builds:
" - echo -n "" - echo -n "" - echo -n "" fi echo -n "
" fi + echo -n "Package: $PACKAGE
" echo -n "RPM packaging commands:
" + # check for updates echo -n "" + echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=autospecupdatescheck\");>" + # unpack echo -n "" + # build echo -n "" + # buildroot files echo -n "" + echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=buildrootfiles\");>" + # unpackaged files echo -n "" + # build requirements echo -n "" - echo -n "" + # recreate SRPM + echo -n "" + # rpm checks echo -n "" + echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=rpmchecks\");>" echo -n "" + echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=rpmsimulateinstall\");>" [ ! "$USER_CANINSTALL" ] && DISABLED="disabled=disabled" echo -n "" echo -n "
target arch:force" echo -n "
Add patches:" echo -n "
" echo -n "URL:" @@ -653,24 +686,24 @@ if [ "$REQUEST" = "edit" -o "$REQUEST" = "reloadspec" ]; then echo -n "" fi done - echo -n "" - echo -n "

" + # send + echo -n "" -# echo -n "" - echo -n "" fi if [ "$USER_CANIMPORT" -a "$PACKAGE" ]; then if [ "$MAINTAINERMODE" = "true" ]; then echo -n "
Repository maintenance:
" - echo -n "Package: $PACKAGE
" - echo -n "Source: $REPOSITORY
" + echo -n "Package: $PACKAGE
" + echo -n "Source: $REPOSITORY
" echo -n "Destination: " echo -n "" echo -n "
" # repository archive echo -n "Automatic port:
" echo -n "" + echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=autoportnp\"); class=boldbutton>" echo -n "" -# echo -n "
Last logs: " -# echo -n "OK " -# echo -n "FAILED
" -# echo -n "" -# echo -n "" + echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=autoportlog\");>" fi if [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then echo -n "
Autodist:
" echo -n "Patch:" echo -n "" echo -n "" echo -n "" fi echo -n "
Info:
" echo -n "" + echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=allowedgroups\");>" echo -n "" + echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=approvedlicenses\");>" echo -n "" + echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=builddirfiles\");>" echo -n "" - echo -n "
" + echo -n "
" echo -n "" echo -n "" @@ -921,8 +948,13 @@ else echo "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"sent $PACKAGE to $SENDREPOSITORY\" STIME=`date +%s`" >> $STATEDIR/social_log fi ;; "sendsource") [ "$RPMFORCE" = "true" ] && RPMFORCEADD="--force --nodeps" - $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "rpmbuild -bs $PACKAGE.spec && autospec -u $PACKAGE -a10 --server $SENDREPOSITORY --norpm" - RET=$? ;; + if [ "$SENDREPOSITORY" ]; then + $SUDO_WRAPPER $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") [ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANIMPORT" ] && SIMULATEADD="-s" || SIMULATEADD= $SUDO_WRAPPER local $PACKAGE "openmamba-repository import $SENDREPOSITORY $PACKAGE -d $REPOSITORYIMPORTTO $SIMULATEADD -y"