From 56923432c9fd5e4497ea2c84451ea0650e155880 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sat, 1 Jun 2013 00:30:05 +0200 Subject: [PATCH] webbuild: improve patch management and minor bash code changes --- webbuild/webbuild-cgi | 24 +++++++++++++++--------- webbuild/webbuild-functions | 2 +- webbuild/webbuild-sudo | 8 +++++--- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/webbuild/webbuild-cgi b/webbuild/webbuild-cgi index dd9e9c7..15311b3 100755 --- a/webbuild/webbuild-cgi +++ b/webbuild/webbuild-cgi @@ -208,9 +208,9 @@ if [ "$REQUEST" = "refresh" -o ! "$USER" ]; then count=0 if [ ! "$FROMID" -o "$FROMID" = "0" -o "$FROMID" = "NaN" ]; then if [ "$USER" ]; then - line=`tac $WEBBUILD_STATEDIR/social_log 2>/dev/null | grep -v " SUSER=$USER " 2>/dev/null | head -n 25 | tail -n 1` + line=`tail -n 500 $WEBBUILD_STATEDIR/social_log | grep -v " SUSER=$USER " 2>/dev/null | tail -n 25 | head -n 1` else - line=`tac $WEBBUILD_STATEDIR/social_log 2>/dev/null | grep -v " STARGET=developers " 2>/dev/null | head -n 25 | tail -n 1` + line=`tail -n 500 $WEBBUILD_STATEDIR/social_log | grep -v " STARGET=developers " 2>/dev/null | tail -n 25 | head -n 1` fi eval $line FROMID=$SID @@ -240,7 +240,7 @@ if [ "$REQUEST" = "refresh" -o ! "$USER" ]; then fi echo -n "
$SUSER $STEXT
" echo -n "

]]>" - count=`expr $count + 1` + count=$(($count + 1)) done echo -n "" fi @@ -353,7 +353,7 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshjobs" ]; then set -- $line RETCODE=$6 # if [ -e /proc/$1 -o $5 -lt 256 ]; then - numprocess=`expr $numprocess + 1` + numprocess=$(($numprocess + 1)) cmdline=`echo $line | sed "s|$1 $2 $3 $4 $5 $RETCODE ||"` cmdline=`echo $cmdline | sed "s| --colors web||"` PACKAGE_ENCODED=`cgi_encodevar $4` @@ -1319,6 +1319,7 @@ if [ "$MAINTAINERMODE" != "true" ]; then echo -n "
Add patches:" echo -n "" echo -n " pastebin
" @@ -1344,11 +1345,12 @@ if [ "$MAINTAINERMODE" != "true" ]; then echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=showpatchfile&" echo -n "PATCHFILE=\"+getSelectedValueById('patchfile'));>" echo -n "" - for f in ${SPECVAR_Patch[*]}; do + for i in `seq 1 ${#SPECVAR_Patch[*]}`; do + f=${SPECVAR_Patch[$i-1]} patchname=${f/*\/} patchname=${patchname/.patch} patchname=${patchname/$PACKAGE-} - echo -n "" + echo -n "" done echo -n "" # list build dir files @@ -1617,9 +1619,13 @@ case $REQUEST in RET=$? [ $RET -eq 0 ] && { echo -n "Patch added with name $PACKAGE-${SPECVAR_Version}-$ADDPATCHNAME.patch." - echo -n "

HINT: add the following lines to the .spec file in the appropriate sections (fix indexes if needed):
" - NEWPATCHNUM=`expr ${#SPECVAR_Patch[*]} + 1` - echo -ne "
Patch$NEWPATCHNUM:        $PACKAGE-${SPECVAR_Version}-$ADDPATCHNAME.patch\n\n%patch$NEWPATCHNUM -p1
" + echo -n "

HINT: add the following lines in the appropriate sections:

" + echo -n "1) in the header after Source[0-9]: and Patch[0-9]: lines:
" + NEWPATCHNUM=$((${SPECVAR_Patch_idx[${#SPECVAR_Patch_idx[@]}-1]}+1)) + echo "
${SPECVAR_Version}: ${SPECVAR_Patch_idx[*]} : ${SPECVAR_Patch[*]}
" + echo -ne "
Patch$NEWPATCHNUM:        $PACKAGE-${SPECVAR_Version}-$ADDPATCHNAME.patch
" + echo -n "2) in %prep section after %setup:
" + echo -ne "
%patch$NEWPATCHNUM -p1
" RET=-1 } else diff --git a/webbuild/webbuild-functions b/webbuild/webbuild-functions index 8b7c76e..e655e04 100644 --- a/webbuild/webbuild-functions +++ b/webbuild/webbuild-functions @@ -33,7 +33,7 @@ function social_log() { if [ ! "$STATE_FAKEUSER" ]; then STATE_SOCIALLOG_ID=0 . $WEBBUILD_STATEDIR/users/webbuild.state - STATE_SOCIALLOG_ID=`expr $STATE_SOCIALLOG_ID + 1` + STATE_SOCIALLOG_ID=$(($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 diff --git a/webbuild/webbuild-sudo b/webbuild/webbuild-sudo index fb586d7..d2f1666 100755 --- a/webbuild/webbuild-sudo +++ b/webbuild/webbuild-sudo @@ -94,10 +94,12 @@ if [ "$MODE" = "specinfo" ]; then [ "$1" = "%package" -o "$1" = "%description" ] && break if [[ "$1" =~ ^[a-zA-Z]*[0-9]*:.* ]]; then line="$(echo ${line/$1})" - specvar="SPECVAR_${1/:*}" - specvar="${specvar/[0-9]*}" - [ "$specvar" = "$lastspecvar" ] && varidx=`expr $varidx + 1` || varidx=0 + specvarfull="SPECVAR_${1/:*}" + specvar="${specvarfull/[0-9]*}" + specvaridx="${specvarfull/$specvar}" + [ "$specvar" = "$lastspecvar" ] && varidx=$(($varidx + 1)) || varidx=0 echo "$specvar[$varidx]=\"${line//\"/}\"" + [ "$specvaridx" != "" ] && echo "${specvar}_idx[$varidx]=$specvaridx" [ "$specvar" = "SPECVAR_Version" -a ! "$BUILDDIR" ] && BUILDDIR="$PACKAGE-${line}" fi lastspecvar=$specvar