webbuild: improve patch management and minor bash code changes

This commit is contained in:
Silvan Calarco 2013-06-01 00:30:05 +02:00
parent 74876ce852
commit 56923432c9
3 changed files with 21 additions and 13 deletions

View File

@ -208,9 +208,9 @@ if [ "$REQUEST" = "refresh" -o ! "$USER" ]; then
count=0 count=0
if [ ! "$FROMID" -o "$FROMID" = "0" -o "$FROMID" = "NaN" ]; then if [ ! "$FROMID" -o "$FROMID" = "0" -o "$FROMID" = "NaN" ]; then
if [ "$USER" ]; 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 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 fi
eval $line eval $line
FROMID=$SID FROMID=$SID
@ -240,7 +240,7 @@ if [ "$REQUEST" = "refresh" -o ! "$USER" ]; then
fi fi
echo -n "<div style=\"position:relative;margin-left:24px;height:auto;padding:0;\"><b>$SUSER</b> $STEXT <i><span name=socialtime time=$STIME></span></i></div>" echo -n "<div style=\"position:relative;margin-left:24px;height:auto;padding:0;\"><b>$SUSER</b> $STEXT <i><span name=socialtime time=$STIME></span></i></div>"
echo -n "</div><div style=\"clear:both;\"><hr></div>]]></add>" echo -n "</div><div style=\"clear:both;\"><hr></div>]]></add>"
count=`expr $count + 1` count=$(($count + 1))
done done
echo -n "</socialbox>" echo -n "</socialbox>"
fi fi
@ -353,7 +353,7 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshjobs" ]; then
set -- $line set -- $line
RETCODE=$6 RETCODE=$6
# if [ -e /proc/$1 -o $5 -lt 256 ]; then # 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 $line | sed "s|$1 $2 $3 $4 $5 $RETCODE ||"`
cmdline=`echo $cmdline | sed "s| --colors web||"` cmdline=`echo $cmdline | sed "s| --colors web||"`
PACKAGE_ENCODED=`cgi_encodevar $4` PACKAGE_ENCODED=`cgi_encodevar $4`
@ -1319,6 +1319,7 @@ if [ "$MAINTAINERMODE" != "true" ]; then
echo -n "<hr><b>Add patches:</b>" echo -n "<hr><b>Add patches:</b>"
echo -n "<input type=button id=addpatchbutton value=\"submit\" onclick=ajax_getvalues(\"" echo -n "<input type=button id=addpatchbutton value=\"submit\" onclick=ajax_getvalues(\""
echo -n "REQUEST=addpatch&ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&" echo -n "REQUEST=addpatch&ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&"
echo -n "ADDPATCHURL=\"+encodeURIComponent(getElementById('addpatchurl').value)+\"&" echo -n "ADDPATCHURL=\"+encodeURIComponent(getElementById('addpatchurl').value)+\"&"
echo -n "ADDPATCHNAME=\"+encodeURIComponent(getElementById('addpatchname').value));>" echo -n "ADDPATCHNAME=\"+encodeURIComponent(getElementById('addpatchname').value));>"
echo -n "&nbsp;<a href=\"http://pastebin.com\" target=_new>pastebin</a><br>" echo -n "&nbsp;<a href=\"http://pastebin.com\" target=_new>pastebin</a><br>"
@ -1344,11 +1345,12 @@ if [ "$MAINTAINERMODE" != "true" ]; then
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=showpatchfile&" echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=showpatchfile&"
echo -n "PATCHFILE=\"+getSelectedValueById('patchfile'));>" echo -n "PATCHFILE=\"+getSelectedValueById('patchfile'));>"
echo -n "<option value=\"\">-- select a patch to display --</option>" echo -n "<option value=\"\">-- select a patch to display --</option>"
for f in ${SPECVAR_Patch[*]}; do for i in `seq 1 ${#SPECVAR_Patch[*]}`; do
f=${SPECVAR_Patch[$i-1]}
patchname=${f/*\/} patchname=${f/*\/}
patchname=${patchname/.patch} patchname=${patchname/.patch}
patchname=${patchname/$PACKAGE-} patchname=${patchname/$PACKAGE-}
echo -n "<option value=\"$f\">$patchname</option>" echo -n "<option value=\"$f\">${SPECVAR_Patch_idx[$i-1]}: $patchname</option>"
done done
echo -n "</select>" echo -n "</select>"
# list build dir files # list build dir files
@ -1617,9 +1619,13 @@ case $REQUEST in
RET=$? RET=$?
[ $RET -eq 0 ] && { [ $RET -eq 0 ] && {
echo -n "Patch added with name <b>$PACKAGE-${SPECVAR_Version}-$ADDPATCHNAME.patch</b>." echo -n "Patch added with name <b>$PACKAGE-${SPECVAR_Version}-$ADDPATCHNAME.patch</b>."
echo -n "<br><br><font color=gold>HINT: add the following lines to the .spec file in the appropriate sections (fix indexes if needed):</font><br>" echo -n "<br><br><font color=gold>HINT: add the following lines in the appropriate sections:</font><br><br>"
NEWPATCHNUM=`expr ${#SPECVAR_Patch[*]} + 1` echo -n "<font color=gold>1) in the header after Source[0-9]: and Patch[0-9]: lines:</font><br>"
echo -ne "<br><pre>Patch$NEWPATCHNUM: $PACKAGE-${SPECVAR_Version}-$ADDPATCHNAME.patch\n\n%patch$NEWPATCHNUM -p1</pre>" NEWPATCHNUM=$((${SPECVAR_Patch_idx[${#SPECVAR_Patch_idx[@]}-1]}+1))
echo "<br>${SPECVAR_Version}: ${SPECVAR_Patch_idx[*]} : ${SPECVAR_Patch[*]}<br>"
echo -ne "<br><pre>Patch$NEWPATCHNUM: $PACKAGE-${SPECVAR_Version}-$ADDPATCHNAME.patch</pre>"
echo -n "<font color=gold>2) in %prep section after %setup:</font><br>"
echo -ne "<br><pre>%patch$NEWPATCHNUM -p1</pre>"
RET=-1 RET=-1
} }
else else

View File

@ -33,7 +33,7 @@ function social_log() {
if [ ! "$STATE_FAKEUSER" ]; then if [ ! "$STATE_FAKEUSER" ]; then
STATE_SOCIALLOG_ID=0 STATE_SOCIALLOG_ID=0
. $WEBBUILD_STATEDIR/users/webbuild.state . $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 set_user_state_var STATE_SOCIALLOG_ID $STATE_SOCIALLOG_ID webbuild
echo "SID=$STATE_SOCIALLOG_ID SPRIVACY=$STATE_PRIVACYMODE $line" >> $WEBBUILD_STATEDIR/social_log echo "SID=$STATE_SOCIALLOG_ID SPRIVACY=$STATE_PRIVACYMODE $line" >> $WEBBUILD_STATEDIR/social_log
fi fi

View File

@ -94,10 +94,12 @@ if [ "$MODE" = "specinfo" ]; then
[ "$1" = "%package" -o "$1" = "%description" ] && break [ "$1" = "%package" -o "$1" = "%description" ] && break
if [[ "$1" =~ ^[a-zA-Z]*[0-9]*:.* ]]; then if [[ "$1" =~ ^[a-zA-Z]*[0-9]*:.* ]]; then
line="$(echo ${line/$1})" line="$(echo ${line/$1})"
specvar="SPECVAR_${1/:*}" specvarfull="SPECVAR_${1/:*}"
specvar="${specvar/[0-9]*}" specvar="${specvarfull/[0-9]*}"
[ "$specvar" = "$lastspecvar" ] && varidx=`expr $varidx + 1` || varidx=0 specvaridx="${specvarfull/$specvar}"
[ "$specvar" = "$lastspecvar" ] && varidx=$(($varidx + 1)) || varidx=0
echo "$specvar[$varidx]=\"${line//\"/}\"" echo "$specvar[$varidx]=\"${line//\"/}\""
[ "$specvaridx" != "" ] && echo "${specvar}_idx[$varidx]=$specvaridx"
[ "$specvar" = "SPECVAR_Version" -a ! "$BUILDDIR" ] && BUILDDIR="$PACKAGE-${line}" [ "$specvar" = "SPECVAR_Version" -a ! "$BUILDDIR" ] && BUILDDIR="$PACKAGE-${line}"
fi fi
lastspecvar=$specvar lastspecvar=$specvar