webbuild: added another ton of changes; added webbuild-functions-private external include

This commit is contained in:
Silvan Calarco 2012-11-19 23:52:30 +01:00
parent d3705b31c7
commit 9f98345aad
7 changed files with 944 additions and 430 deletions

View File

@ -76,6 +76,7 @@ install-programs:
@$(INSTALL_SCRIPT) webbuild/webbuild-sudo $(DESTDIR)$(libexecdir)/webbuild-sudo @$(INSTALL_SCRIPT) webbuild/webbuild-sudo $(DESTDIR)$(libexecdir)/webbuild-sudo
@$(INSTALL_SCRIPT) webbuild/webbuild-checkpassword $(DESTDIR)$(libexecdir)/webbuild-checkpassword @$(INSTALL_SCRIPT) webbuild/webbuild-checkpassword $(DESTDIR)$(libexecdir)/webbuild-checkpassword
@$(INSTALL_SCRIPT) webbuild/webbuild-functions $(DESTDIR)$(pck_datadir)/webbuild-functions @$(INSTALL_SCRIPT) webbuild/webbuild-functions $(DESTDIR)$(pck_datadir)/webbuild-functions
@$(INSTALL_SCRIPT) webbuild/webbuild-functions-private $(DESTDIR)$(pck_datadir)/webbuild-functions-private
@cp -a webbuild/html/* $(DESTDIR)$(htmldir) @cp -a webbuild/html/* $(DESTDIR)$(htmldir)
install-data: install-data:

View File

@ -31,7 +31,11 @@ function socialbox_refresh_times() {
function ajax_getvalues_refresh(request,user,user_email,secret) { function ajax_getvalues_refresh(request,user,user_email,secret) {
var fromid = 0; var fromid = 0;
if (document.getElementsByName("social").length > 0) { if (document.getElementsByName("social").length > 0) {
fromid = parseInt(document.getElementsByName("social")[0].attributes[1].value) + 1; if (document.getElementsByName("social")[0].attributes[0].name == "sid") {
fromid = parseInt(document.getElementsByName("social")[0].attributes[0].value) + 1;
} else {
fromid = parseInt(document.getElementsByName("social")[0].attributes[1].value) + 1;
}
} }
if (request != "") if (request != "")
request=request+"&REQUEST=refresh&USER="+user+"&USER_EMAIL="+user_email+"&SECRET="+secret+"&FROMID="+fromid; request=request+"&REQUEST=refresh&USER="+user+"&USER_EMAIL="+user_email+"&SECRET="+secret+"&FROMID="+fromid;
@ -59,7 +63,7 @@ function ajax_getvalues_refresh(request,user,user_email,secret) {
"<span name=social sid=\""+ id + "\">" + nodes[i].childNodes[0].nodeValue + "</span>" + "<span name=social sid=\""+ id + "\">" + nodes[i].childNodes[0].nodeValue + "</span>" +
document.getElementById("socialbox").innerHTML; document.getElementById("socialbox").innerHTML;
} }
if (document.getElementById("processes") != undefined) if (xmldoc.getElementsByTagName("processes")[0] != undefined)
document.getElementById("processes").innerHTML = xmldoc.getElementsByTagName("processes")[0].childNodes[0].nodeValue; document.getElementById("processes").innerHTML = xmldoc.getElementsByTagName("processes")[0].childNodes[0].nodeValue;
$(function() { $('.scroll-pane').jScrollPane({scrollbarWidth:10}); }); $(function() { $('.scroll-pane').jScrollPane({scrollbarWidth:10}); });
// lastupdate = (+new Date()); // lastupdate = (+new Date());

View File

@ -13,3 +13,12 @@ function getSelectedValueById(selectname,idx) {
var i=document.getElementById(selectname).selectedIndex; var i=document.getElementById(selectname).selectedIndex;
return document.getElementById(selectname).options[i+idx].value; return document.getElementById(selectname).options[i+idx].value;
} }
function checkEnter(event) {
event=event || window.event;
getEvent=event.keyCode;
if (getEvent == "13") {
return true;
}
return false;
}

File diff suppressed because it is too large Load Diff

View File

@ -155,12 +155,74 @@ function kill_tree() {
return $? return $?
} }
function parse_search_output() {
local SEARCHARCH=$1
echo -n "<style type=\"text/css\">\
.searchlink a:link { text-decoration:none; color:inherit; }\
.searchlink a:hover { text-decoration:underline; }\
.searchlink a:visited { text-decoration:underline; color:inherit; }\
</style><span class=searchlink>"
while read line; do
[ "$line" ] || continue
set -- $line
local REPOSITORY=${1/(*}
local ARCH=`echo $1 | sed "s|.*(\(.*\)):|\1|"`
local PKG=`echo $2 | sed "s|\(.*\)-[^-]*-[^-]*|\1|"`
if [ "$ARCH" = "source" ]; then
echo -n "<font color=lightgreen>"
elif [ "$ARCH" = "$SEARCHARCH" ]; then
echo -n "<font color=white>"
else
echo -n "<font color=gray>"
fi
echo -n "<a class=searchlink href=\"/distribution/distromatic.html?tag=$REPOSITORY\" target=_new>$REPOSITORY</a>($ARCH): "
echo -n "<a class=searchlink href=\"/distribution/distromatic.html?tag=$REPOSITORY&pkg=$PKG.$ARCH\" target=_new>$2</a><br>"
echo -n "</font>"
# if [ "$ARCH" ]
# $SUDO_WRAPPER 0 local "$USER" "" "openmamba-repository search -i $REPSEARCHTEXT" | \
# sed "s|\(.*(source).*\)|<font color=white><b>\1</b></font>|;
# s|\(.*(${AUTOPORT_ARCH[$ENVIRONMENT]}).*\)|<font color=lightgreen>\1</font>|"
done
echo -n "</span>"
}
function parse_patch_output() {
local PATCH_STARTED SAVE_IFS=$IFS
IFS=''
echo -n "<font color=gray>"
while read line; do
[ "${line:0:3}" = "+++" ] && echo -n "</font>"
echo "$line" | sed "s|<|\&lt;|g;s|[[:cntrl:]]\[[0-9;]*m||g;
s|^\(+++.*\)|<font color=white style=\"background-color:gray\"><b>\1</b></font>|;
s|^\(---.*\)|<font color=white style=\"background-color:gray\"><b>\1</b></font>|;
s|^\(-.*\)|<font color=red>\1</font>|;
s|^\(+.*\)|<font color=lightgreen>\1</font>|;
s|^ |\&nbsp;|;"
done
IFS=$SAVE_IFS
}
function parse_build_output() { function parse_build_output() {
sed "s|<|\&lt;|g;s|[[:cntrl:]]\[[0-9;]*m||g; sed "s|<|\&lt;|g;s|[[:cntrl:]]\[[0-9;]*m||g;
s|&lt;font|<font|g;
s|&lt;/font|</font|g;
s|^\([\+#] .*\)|<font style=\"color:cyan\">\1</font>|; s|^\([\+#] .*\)|<font style=\"color:cyan\">\1</font>|;
s|\(.*error[[:space:]]*:[[:space:]]*\)\(.*\)|<font style=\"background-color:red;color:white\">\1<a %SRCURL%\2%SRCURLEND%>\2</a></font>|i; s|\(ftp[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|<a href=\1 target=new>\1</a>|;
s|\(http[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|<a href=\1 target=new>\1</a>|;
s|\(.*error[^0-9A-Za-z]*:[[:space:]]*\)\(.*\)|<font style=\"background-color:red;color:white\"><a %SRCURL%\1\2%SRCURLEND%>\1\2</a></font>|i;
s|^\(== =.*\)|<font style=\"background-color:green;color:white\">\1</font>|; s|^\(== =.*\)|<font style=\"background-color:green;color:white\">\1</font>|;
s|^[[:cntrl:]]*\([!%?=][!%!=>] .*\)|<font style=\"color:gold\">\1</font>|;" | google_search $1 s|^[[:cntrl:]]*\([!%?=][!%!=>] .*\)|<font style=\"color:gold\">\1</font>|;
s|[[:cntrl:]]||g;" | google_search $1
}
function parse_generic_output() {
sed "s|<|\&lt;|g;s|[[:cntrl:]]\[[0-9;]*m||g;
s|&lt;font|<font|g;
s|&lt;/font|</font|g;
s|^\([\+#] .*\)|<font style=\"color:cyan\">\1</font>|;
s|\(ftp[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|<a href=\1 target=new>\1</a>|;
s|\(http[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|<a href=\1 target=new>\1</a>|;" | google_search $1
} }
function google_search() { function google_search() {
@ -171,7 +233,30 @@ function google_search() {
else else
SEARCH_STRING=`echo $SEARCH_STRING | sed "s|\&lt;|<|"` SEARCH_STRING=`echo $SEARCH_STRING | sed "s|\&lt;|<|"`
local SEARCH_STRING_ENCODED=`cgi_encodevar "$1 $SEARCH_STRING"` local SEARCH_STRING_ENCODED=`cgi_encodevar "$1 $SEARCH_STRING"`
echo "$line" | sed "s|%SRCURL%.*%SRCURLEND%|href=\"http://www.google.com/search?q=$SEARCH_STRING_ENCODED\" target=_new title=\"Search this error on the Web\"|" echo "$line" | sed "s|%SRCURL%.*%SRCURLEND%|href=\"http://www.google.com/search?q=$SEARCH_STRING_ENCODED\" target=_new title=\"Search this error on the Web\"|g"
fi fi
done done
} }
function print_environment_descr() {
local i=$1
if [ "${AUTOPORT_CHROOT_USER[$i]}" ]; then
echo -n "${AUTOPORT_CHROOT_USER[$i]} - "
else
echo -n "autodist - "
fi
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
echo -n "update"
elif [ "${AUTOPORT_CHROOT[$i]}" ]; then
echo -n "chroot"
elif [ "${AUTOPORT_NATIVE[$i]}" ]; then
echo -n "native"
elif [ "${AUTOPORT_CROSS[$i]}" ]; then
echo -n "cross"
else
echo -n "unknown type"
fi
echo -n " for ${AUTOPORT_ARCH[$i]}"
# (${AUTOPORT_BASE_REPOSITORY[$i]} based)"
}

View File

@ -0,0 +1,168 @@
function showlog() {
local LOGDIR LOGFILES LOGFILE1 LOGFILE2 LOGFILE3 LOGFILE4
if [ "$LOGTYPE" = "processoutput" -o "$LOGTYPE" = "processtail" ]; then
LOGFILES=$LOGFILE
LOGOUTPUTID=outputbottom
else
LOGOUTPUTID=outputbottom
case $LOGTYPE in
autoupdate) LOGFILE=update; ;;
buildinstall|rebuild) LOGFILE=build ;;
*) LOGFILE=$LOGTYPE ;;
esac
if [ "$LOGSTATUSOK" = "true" ]; then
LOGFILE=$LOGFILE/ok
LOGSTATUSAPPEND=" ok"
else
LOGFILE=$LOGFILE/failed
LOGSTATUSAPPEND=" failed"
fi
LOGFILE1=$LOGFILE/${PACKAGE/\//_}.${AUTOPORT_ARCH[$ENVIRONMENT]}
LOGFILE2=$LOGFILE/${PACKAGE/\//_}__*.${AUTOPORT_ARCH[$ENVIRONMENT]}
LOGFILE3=$LOGFILE/*_${PACKAGE/\//_}__*.${AUTOPORT_ARCH[$ENVIRONMENT]}
LOGFILE4=$LOGFILE/*_${PACKAGE/\//_}.${AUTOPORT_ARCH[$ENVIRONMENT]}
if [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then
LOGDIR="/var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/home/${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}/.autodist/log/"
elif [ "${AUTOPORT_NATIVE[$ENVIRONMENT]}" ]; then
LOGDIR="/home/${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}/.autodist/log/"
else
LOGDIR="/var/autodist/log/"
fi
LOGFILES="$LOGDIR/$LOGFILE1 $LOGDIR/$LOGFILE2 $LOGDIR/$LOGFILE3 $LOGDIR/$LOGFILE4"
for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
[ "$i" = "$ENVIRONMENT" ] && continue
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
LOGDIR="/var/autodist/log"
LOGFILES="$LOGFILES $LOGDIR/$LOGFILE1 $LOGDIR/$LOGFILE2 $LOGDIR/$LOGFILE3 $LOGDIR/$LOGFILE4"
fi
done
fi
echo -n "<output><![CDATA[<hr><b>Console output for $PACKAGE ($LOGTYPE$LOGSTATUSAPPEND):</b>"
echo "<div align=left class=output id=$LOGOUTPUTID>"
for f in $LOGFILES; do
if [ -r $f ]; then
LOGFILESIZE=`stat -c %s $f`
LOGDATE=`stat -c %y $f`
else
LOGFILESIZE=`$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "stat -c %s $f"`
LOGDATE=`$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "stat -c %y $f"`
[ $? -eq 0 ] || continue
fi
echo -n "<b>`basename $f` ($LOGDATE; $LOGFILESIZE):</b>"
echo -n "<pre>"
if [ "$LOGTYPE" = "processtail" ]; then
echo -n "<!-- SCROLL -->"
tail -n +0 -f $f --pid $PROCESSPID | sed "s|<|\&lt;|g"
echo -n "<!-- ENDSCROLL -->"
else
if [ $LOGFILESIZE -lt 131072 ]; then
if [ -r $f ]; then
cat $f | parse_build_output $PACKAGE
else
$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "cat $f" | parse_build_output $PACKAGE
fi
else
if [ -r $f ]; then
head -c 65535 $f | parse_build_output $PACKAGE
echo "<br><font style=\"background-color:yellow;color:black\">&lt;------ CUT (long file) -------&gt;</font>"
tail -c 65535 $f | parse_build_output $PACKAGE
else
$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "head -c 65535 $f" | parse_build_output $PACKAGE
echo "<br><font style=\"background-color:yellow;color:black\">&lt;------ CUT (long file) -------&gt;</font>"
$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "tail -c 65535 $f" | parse_build_output $PACKAGE
fi
fi
fi
echo -n "</pre>"
done
echo -n "</div>]]></output>"
}
function showEnvironmentPanel() {
echo -n "Environment: <b>"
if [ "${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}" ]; then
echo -n "${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} - "
else
echo -n "autodist - "
fi
if [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then
echo -n "update"
elif [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then
echo -n "chroot"
elif [ "${AUTOPORT_NATIVE[$ENVIRONMENT]}" ]; then
echo -n "native"
elif [ "${AUTOPORT_CROSS[$ENVIRONMENT]}" ]; then
echo -n "cross"
else
echo -n "unknown type"
fi
echo -n " (${AUTOPORT_ARCH[$ENVIRONMENT]})</b>"
#echo "<br>Base repository: <b>${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]}</b>"
# smart upgrade
echo -n "<input type=button id=smartupgrade value=\"system upgrade\" onclick="
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=smartupgrade\""
echo -n ",\"`cgi_encodevar "Upgrade current environment to latest updates now?"`\"); class=redbutton>"
## run ldconfig
#echo -n "<input type=button id=runldconfig value=\"run ldconfig\" onclick="
#echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
#echo -n "REQUEST=runldconfig\");>"
# environment search
echo -n "<br>Installed:<input type=text size=23 style=\"align:center;padding:0;margin:2px;\" id=environmentsearch value=\"Search package or provide...\" "
echo -n "onfocus=\"if (this.value==this.defaultValue) this.value=''\" "
echo -n "onkeypress=if(checkEnter(event))ajax_getvalues(\""
echo -n "ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=environmentsearch&ENVSEARCHTEXT=\"+encodeURIComponent(getElementById('environmentsearch').value));>"
}
function print_editorcontrols() {
echo -n "<editcontrols><![CDATA["
# specfile save
echo -n "<input type=button id=savebutton value=\"save\" onclick="
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=savespec&SPECTEXT=\"+encodeURIComponent(editor.getValue()));"
echo -n "this.disabled=true; disabled=disabled class=redbutton>"
# specfile reload
echo -n "<input type=button id=updatespecbutton value=\"reload\" onclick="
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=reloadspec\""
echo -n ",\"`cgi_encodevar "Reload <b>$PACKAGE.spec</b>?<br><br>Warning: current unsaved .spec file changes will be lost."`\");>"
# specfile rename
echo -n "<input type=button id=updatespecbutton value=\"rename to:\" onclick="
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&RENAMESPECFROM=$PACKAGE&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&"
echo -n "REQUEST=renamespec&PACKAGE=\"+encodeURIComponent(getElementById('specnewname').value));>"
echo -n "<input type=text id=specnewname value=\"\" size=\"10\">.spec"
# specfile delete
echo -n "<input type=button id=updatespecbutton value=\"delete\" onclick="
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=deletespec\",\"`cgi_encodevar "Really delete <b>$PACKAGE.spec</b>?"`\")>"
# add a note
echo -n "<input type=button id=addpkgnote value=\"add a note:\" onclick="
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&"
echo -n "REQUEST=addpkgnote&PKGNOTE=\"+encodeURIComponent(getElementById('pkgnote').value));>"
echo -n "<input type=text id=pkgnote value=\"\" size=\"55\">"
# specfile update
echo -n "<br><input type=button id=updatespecbutton value=\"update\" onclick="
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=updatespec&UPDATESPECVERSION=\"+getElementById('updatespecversion').value+\"&"
echo -n "RPMFORCE=\"+getElementById('rpmforce').checked+\"&"
echo -n "REBUILDSPECCHANGELOG=\"+encodeURIComponent(getElementById('rebuildspecchangelog').value)+\"&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue()));>"
echo -n " (specify new version:<input type=text id=updatespecversion value=\"\" size=\"12\">"
echo -n " or new release changelog:<input type=text id=rebuildspecchangelog value=\"$REBUILDSPECCHANGELOG\" size=\"45\">)"
# close tag
echo -n "]]></editcontrols>"
}

View File

@ -60,32 +60,53 @@ else
WORKINGHOME="/var/autodist" WORKINGHOME="/var/autodist"
SUCMDPREFIX="su -l autodist -c" SUCMDPREFIX="su -l autodist -c"
RPMBUILDROOT="/var/tmp/autodist" RPMBUILDROOT="/var/tmp/autodist"
[ "$TMPFILE" ] && chown autodist $TMPFILE # [ "$TMPFILE" ] && chown autodist $TMPFILE
fi fi
if [ "$WORKINGHOME" ]; then if [ "$MODE" = "specinfo" ]; then
eval `$SUCMDPREFIX "autospec --eval=tmppath_dir|grep -v '^#'"` eval `$SUCMDPREFIX "autospec --eval=tmppath_dir|grep -v '^#'"`
RPMBUILDROOT=$tmppath_dir RPMBUILDROOT=$tmppath_dir
SPECFILE=${ENVPREFIX}${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec SPECFILE=${ENVPREFIX}${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec
if [ "$PACKAGE" -a -r "$SPECFILE" ]; then if [ "$PACKAGE" -a -r "$SPECFILE" ]; then
rm -f $SPECFILE.tmp rm -f $SPECFILE.tmp
while read line; do
case "$line" in
"## AUTOBUILDREQ-BEGIN"*) AUTOBUILDREQ_BEGIN=1 ;;
"## AUTOBUILDREQ-END"*) AUTOBUILDREQ_END=1 ;;
"## note: run "*" to get the list of build requirements") AUTOBUILDREQ_UNDONE=1 ;;
esac
done < ${ENVPREFIX}${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec
[ "$AUTOBUILDREQ_BEGIN" -a "$AUTOBUILDREQ_END" -a ! "$AUTOBUILDREQ_UNDONE" ] || \
echo "SPECVAR_CHECK_NOAUTOBUILDREQ=1"
$SUCMDPREFIX "rpm -q --specfile ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec --specedit > ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec.tmp 2>/dev/null" $SUCMDPREFIX "rpm -q --specfile ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec --specedit > ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec.tmp 2>/dev/null"
if [ -e $SPECFILE.tmp ]; then if [ -e $SPECFILE.tmp ]; then
echo "SPECVAR_Specfile=\"$SPECFILE\""
BUILDDIR=`grep -m1 "^%setup.*-n " $SPECFILE.tmp | sed "s|.*-n \([^[:space:]]*\).*|\1|"` BUILDDIR=`grep -m1 "^%setup.*-n " $SPECFILE.tmp | sed "s|.*-n \([^[:space:]]*\).*|\1|"`
while read line; do
set -- $line
[ "$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
echo "$specvar[$varidx]=\"${line}\""
[ "$specvar" = "SPECVAR_Version" -a ! "$BUILDDIR" ] && BUILDDIR="$PACKAGE-${line}"
fi
lastspecvar=$specvar
done < $SPECFILE.tmp
rm -f $SPECFILE.tmp rm -f $SPECFILE.tmp
echo "SPECVAR_BUILDDIR=\"$BUILDDIR\""
echo "SPECVAR_BUILDROOT=\"$PACKAGE-root\""
echo "SPECVAR_RPMBUILDDIR=\"${WORKINGHOME}/RPM/BUILD\""
echo "SPECVAR_RPMSOURCESDIR=\"${WORKINGHOME}/RPM/SOURCES\""
echo "SPECVAR_RPMBUILDROOT=\"$RPMBUILDROOT\""
echo "SPECVAR_WORKINGHOME=\"$WORKINGHOME\""
exit 0
fi fi
SPECVERSION=`grep -m1 "^Version:" ${SPECFILE} | sed "s|Version:[[:space:]]*||"` else
BUILDROOT=$PACKAGE-root exit 1
#`grep ^BuildRoot: ${_tmpfile} | sed "s|BuildRoot:[[:space:]]*||"`
# SPECSETUP=`grep %setup ${_tmpfile} | sed "s|.*-n ||"`
[ "$BUILDDIR" ] || BUILDDIR=$PACKAGE-$SPECVERSION
fi fi
fi fi
RPMBUILDDIR=${WORKINGHOME}/RPM/BUILD
COMMAND=`echo $COMMAND | sed "s|@BUILDDIR@|$BUILDDIR|g"`
COMMAND=`echo $COMMAND | sed "s|@BUILDROOT@|$BUILDROOT|g"`
COMMAND=`echo $COMMAND | sed "s|@RPMBUILDDIR@|$RPMBUILDDIR|g"`
COMMAND=`echo $COMMAND | sed "s|@RPMBUILDROOT@|$RPMBUILDROOT|g"`
COMMAND=`echo $COMMAND | sed "s|@WORKINGHOME@|$WORKINGHOME|g"`
echo "COMMAND: $COMMAND" >> $WEBBUILD_STATEDIR/commands_log echo "COMMAND: $COMMAND" >> $WEBBUILD_STATEDIR/commands_log
cmdtmpfile=`mktemp --suffix=.webbuildcmd` cmdtmpfile=`mktemp --suffix=.webbuildcmd`
@ -93,23 +114,28 @@ cmdtmpfile=`mktemp --suffix=.webbuildcmd`
[ "$PACKAGE" ] || PACKAGE=nopackage [ "$PACKAGE" ] || PACKAGE=nopackage
if [ "$MODE" = "background" ]; then if [ "$MODE" = "background" ]; then
if [ "$WORKINGHOME" ]; then if [ "$WORKINGHOME" ]; then
$SUCMDPREFIX ". /etc/profile;cd $WORKINGHOME/RPM/SPECS;$COMMAND;echo \"# WEBBUILD_EXITCODE=\$?\"" 2>&1 | sed "s|<|\&lt;|g" | tr -d '\f' > $cmdtmpfile & $SUCMDPREFIX ". /etc/profile;cd $WORKINGHOME/RPM/SPECS;$COMMAND;echo \"# WEBBUILD_EXITCODE=\$?\"" 2>&1 | tr -d '\f' > $cmdtmpfile &
#sed "s|<|\&lt;|g" |
else else
$SUCMDPREFIX "$COMMAND;echo \"# WEBBUILD_EXITCODE=\$?\"" 2>&1 | sed "s|<|\&lt;|g" | tr -d '\f' > $cmdtmpfile & $SUCMDPREFIX "$COMMAND;echo \"# WEBBUILD_EXITCODE=\$?\"" 2>&1 | sed "s|<|\&lt;|g" | tr -d '\f' > $cmdtmpfile &
fi fi
echo "$! $USER $ENVIRONMENT $PACKAGE $cmdtmpfile 256 $COMMAND" >> $WEBBUILD_STATEDIR/processes echo "$! $USER $ENVIRONMENT $PACKAGE $cmdtmpfile 256 $COMMAND" >> $WEBBUILD_STATEDIR/processes
echo "Started background command: $COMMAND" echo "Started background command: $COMMAND"
echo
echo "You may watch command live output and result in the <b>Webbuild jobs</b> box above."
RET=0 RET=0
else else
echo "$$ $USER $ENVIRONMENT $PACKAGE $cmdtmpfile 256 $COMMAND" >> $WEBBUILD_STATEDIR/processes echo "$$ $USER $ENVIRONMENT $PACKAGE $cmdtmpfile 256 $COMMAND" >> $WEBBUILD_STATEDIR/processes
rettmpfile=`$SUCMDPREFIX "mktemp --suffix=.webbuildret"` rettmpfile=`$SUCMDPREFIX "mktemp --suffix=.webbuildret"`
if [ "$WORKINGHOME" ]; then if [ "$WORKINGHOME" ]; then
$SUCMDPREFIX ". /etc/profile;cd $WORKINGHOME/RPM/SPECS;$COMMAND;echo \$? > $rettmpfile" 2>&1 | sed "s|<|\&lt;|g" | tr -d '\f' | tee $cmdtmpfile $SUCMDPREFIX ". /etc/profile;cd $WORKINGHOME/RPM/SPECS;$COMMAND;echo \$? > $rettmpfile" 2>&1 | tr -d '\f' | tee $cmdtmpfile
# sed "s|<|\&lt;|g" |
else else
$SUCMDPREFIX "$COMMAND;echo \$? > $rettmpfile" 2>&1 | sed "s|<|\&lt;|g" | tr -d '\f' | tee $cmdtmpfile $SUCMDPREFIX "$COMMAND;echo \$? > $rettmpfile" 2>&1 | tr -d '\f' | tee $cmdtmpfile
# sed "s|<|\&lt;|g" |
fi fi
RET=`cat $ENVPREFIX/$rettmpfile` RET=`cat $ENVPREFIX/$rettmpfile`
[ "$RET" ] || RET=255 [ "$RET" ] || RET=254
$SUCMDPREFIX "rm -f $rettmpfile" $SUCMDPREFIX "rm -f $rettmpfile"
sed -i "/^$$ $USER/d" $WEBBUILD_STATEDIR/processes sed -i "/^$$ $USER/d" $WEBBUILD_STATEDIR/processes
if [ "$MODE" != "keeplog" ]; then if [ "$MODE" != "keeplog" ]; then
@ -128,4 +154,5 @@ if [ -e $cmdtmpfile ]; then
chmod 666 $cmdtmpfile chmod 666 $cmdtmpfile
chown apache.nobody $cmdtmpfile chown apache.nobody $cmdtmpfile
fi fi
exit $RET exit $RET