webbuild: sync with current running sources (tons of changes again)

This commit is contained in:
Silvan Calarco 2012-10-18 00:49:13 +02:00
parent 12d8eafdc4
commit 0e1067c930
5 changed files with 639 additions and 395 deletions

View File

@ -1,10 +1,42 @@
var url = "/cgi-bin/webbuild.cgi"
function ajax_getvalues_refresh(request) {
function socialbox_refresh_times() {
var times = document.getElementsByName("socialtime");
var datenow = new Date();
var utcnow = parseInt(Date.UTC(datenow.getUTCFullYear(), datenow.getUTCMonth(), datenow.getUTCDate(),
datenow.getUTCHours(), datenow.getUTCMinutes(), datenow.getUTCSeconds()) / 1000);
for (var i = 0; i < times.length; i++) {
if (times[i].attributes[0].name == "time") {
var socialtime = times[i].attributes[0].value;
} else {
var socialtime = times[i].attributes[1].value;
}
var timeago = utcnow - socialtime;
var daysago = parseInt(timeago / 86400);
var hoursago = parseInt(timeago / 3600 % 24);
var minutesago = parseInt(timeago / 60 % 60);
var secondsago = parseInt(timeago % 60);
times[i].innerHTML = "(";
if (daysago > 1) times[i].innerHTML += daysago + " days";
else if (daysago == 1) times[i].innerHTML += "1 day, " + hoursago + " hours";
else if (hoursago > 1) times[i].innerHTML += hoursago + " hours";
else if (hoursago == 1) times[i].innerHTML += "1 hour, " + minutesago + " minutes";
else if (minutesago > 1) times[i].innerHTML += minutesago + " minutes";
else if (minutesago == 1) times[i].innerHTML += "1 minute, " + secondsago + " seconds";
else times[i].innerHTML += secondsago + " seconds";
times[i].innerHTML += " ago) ";
}
}
function ajax_getvalues_refresh(request,user,user_email,secret) {
var fromid = 0;
if (document.getElementsByName("social").length > 0) {
fromid = parseInt(document.getElementsByName("social")[0].attributes[1].value) + 1;
}
if (request != "")
request=request+"&REQUEST=refresh";
request=request+"&REQUEST=refresh&USER="+user+"&USER_EMAIL="+user_email+"&SECRET="+secret+"&FROMID="+fromid;
else
request="REQUEST=refresh";
request="REQUEST=refresh&USER="+user+"&USER_EMAIL="+user_email+"&SECRET="+secret+"&FROMID="+fromid;
if (window.XMLHttpRequest)
xmlhttp1 = new XMLHttpRequest();
@ -20,11 +52,18 @@ function ajax_getvalues_refresh(request) {
return;
}
var xmldoc = xmlhttp1.responseXML.documentElement;
if (xmldoc.getElementsByTagName("socialbox").length >0) {
document.getElementById("socialbox").innerHTML = xmldoc.getElementsByTagName("socialbox")[0].childNodes[0].nodeValue;
$(function() { $('.scroll-pane').jScrollPane({scrollbarWidth:10}); });
var nodes = xmldoc.getElementsByTagName("socialbox")[0].childNodes;
for (var i = 0; i < nodes.length; i++) {
id = nodes[i].attributes[0].value;
document.getElementById("socialbox").innerHTML =
"<span name=social sid=\""+ id + "\">" + nodes[i].childNodes[0].nodeValue + "</span>" +
document.getElementById("socialbox").innerHTML;
}
lastupdate = (+new Date());
if (document.getElementById("processes") != undefined)
document.getElementById("processes").innerHTML = xmldoc.getElementsByTagName("processes")[0].childNodes[0].nodeValue;
$(function() { $('.scroll-pane').jScrollPane({scrollbarWidth:10}); });
// lastupdate = (+new Date());
socialbox_refresh_times();
}
xmlhttp1.open("POST", url, true);
xmlhttp1.setRequestHeader("Content-type","application/x-www-form-urlencoded");

View File

@ -8,7 +8,8 @@ function getCheckedValuesByName(checkboxname) {
return p;
}
function getSelectedValueById(selectname) {
function getSelectedValueById(selectname,idx) {
if (idx == undefined) idx = 0;
var i=document.getElementById(selectname).selectedIndex;
return document.getElementById(selectname).options[i].value;
return document.getElementById(selectname).options[i+idx].value;
}

File diff suppressed because it is too large Load Diff

View File

@ -154,3 +154,24 @@ function kill_tree() {
kill `pstree -p $killpid | sed 's/(/\n(/g' | grep '(' | sed 's/(\(.*\)).*/\1/' | tr "\n" " "`
return $?
}
function parse_build_output() {
sed "s|<|\&lt;|g;s|[[:cntrl:]]\[[0-9;]*m||g;
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|^\(== =.*\)|<font style=\"background-color:green;color:white\">\1</font>|;
s|^[[:cntrl:]]*\([!%?=][!%!=>] .*\)|<font style=\"color:gold\">\1</font>|;" | google_search $1
}
function google_search() {
while read line; do
local SEARCH_STRING=`echo "$line" | sed "s|.*%SRCURL%\(.*\)%SRCURLEND%.*|\1|"`
if [ "$SEARCH_STRING" = "$line" ]; then
echo "$line"
else
SEARCH_STRING=`echo $SEARCH_STRING | sed "s|\&lt;|<|"`
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\"|"
fi
done
}

View File

@ -4,23 +4,32 @@
MODE=$1
ENVIRONMENT=$2
PACKAGE=$3
COMMAND=$4
TMPFILE=$5
USER=$3
PACKAGE=$4
COMMAND=$5
TMPFILE=$6
echo "REQUEST: $@" >> $WEBBUILD_STATEDIR/commands_log
if [ "$MODE" = "killtree" ]; then
KILLPID=$2
[ $KILLPID -gt 1 ] && kill_tree $KILLPID
[ $KILLPID -gt 1 ] && {
echo "COMMAND: kill_tree $KILLPID" >> $WEBBUILD_STATEDIR/commands_log
kill_tree $KILLPID
}
exit $?
elif [ "$MODE" = "finishprocess" ]; then
PROCESSPID=$2
PROCESSLOG=$3
RETCODE=`tail -n1 $PROCESSLOG | grep "^# WEBBUILD_EXITCODE=" | sed "s|^# WEBBUILD_EXITCODE=||"`
[ "$RETCODE" ] || RETCODE=257
sed -i "s|\(^$PROCESSPID [^[:space:]]* [^[:space:]]* [^[:space:]]* \)[^[:space:]]*|\1$RETCODE|" $WEBBUILD_STATEDIR/processes
PROCESSLOG=$4
if [ -e $PROCESSLOG ]; then
RETCODE=`tail -n1 $PROCESSLOG | grep "^# WEBBUILD_EXITCODE=" | sed "s|^# WEBBUILD_EXITCODE=||"`
[ "$RETCODE" ] || RETCODE=257
else
RETCODE=0
fi
sed -i "s|\(^$PROCESSPID [^[:space:]]* [^[:space:]]* [^[:space:]]* [^[:space:]]* \)[^[:space:]]*|\1$RETCODE|" $WEBBUILD_STATEDIR/processes
exit $RETCODE
elif [ "$ENVIRONMENT" = "local" ]; then
# echo "Command: $COMMAND"
echo "COMMAND: $COMMAND" >> $WEBBUILD_STATEDIR/commands_log
$COMMAND 2>&1 | sed "s|<|\&lt;|g"
exit 0
fi
@ -57,7 +66,7 @@ if [ "$WORKINGHOME" ]; then
eval `$SUCMDPREFIX "autospec --eval=tmppath_dir|grep -v '^#'"`
RPMBUILDROOT=$tmppath_dir
SPECFILE=${ENVPREFIX}${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec
if [ -r "$SPECFILE" ]; then
if [ "$PACKAGE" -a -r "$SPECFILE" ]; then
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
@ -76,23 +85,24 @@ 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
cmdtmpfile=`mktemp`
chgrp nobody $cmdtmpfile
chmod 640 $cmdtmpfile
cmdtmpfile=`mktemp --suffix=.webbuildcmd`
[ "$PACKAGE" ] || PACKAGE=nopackage
if [ "$MODE" = "background" ]; 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 &
else
$SUCMDPREFIX "$COMMAND;echo \"# WEBBUILD_EXITCODE=\$?\"" 2>&1 | sed "s|<|\&lt;|g" | tr -d '\f' > $cmdtmpfile &
fi
echo "$! $ENVUSER $ENVIRONMENT $cmdtmpfile 256 $COMMAND" >> $WEBBUILD_STATEDIR/processes
echo "$! $USER $ENVIRONMENT $PACKAGE $cmdtmpfile 256 $COMMAND" >> $WEBBUILD_STATEDIR/processes
echo "Started background command: $COMMAND"
RET=0
else
echo "$$ $ENVUSER $ENVIRONMENT $cmdtmpfile 256 $COMMAND" >> $WEBBUILD_STATEDIR/processes
rettmpfile=`$SUCMDPREFIX mktemp`
echo "$$ $USER $ENVIRONMENT $PACKAGE $cmdtmpfile 256 $COMMAND" >> $WEBBUILD_STATEDIR/processes
rettmpfile=`$SUCMDPREFIX "mktemp --suffix=.webbuildret"`
if [ "$WORKINGHOME" ]; then
$SUCMDPREFIX ". /etc/profile;cd $WORKINGHOME/RPM/SPECS;$COMMAND;echo \$? > $rettmpfile" 2>&1 | sed "s|<|\&lt;|g" | tr -d '\f' | tee $cmdtmpfile
else
@ -101,11 +111,11 @@ else
RET=`cat $ENVPREFIX/$rettmpfile`
[ "$RET" ] || RET=255
$SUCMDPREFIX "rm -f $rettmpfile"
sed -i "/^$$ $ENVUSER/d" $WEBBUILD_STATEDIR/processes
sed -i "/^$$ $USER/d" $WEBBUILD_STATEDIR/processes
if [ "$MODE" != "keeplog" ]; then
rm -f $cmdtmpfile
else
echo "$$ $ENVUSER $ENVIRONMENT $cmdtmpfile $RET $COMMAND" >> $WEBBUILD_STATEDIR/processes
echo "$$ $USER $ENVIRONMENT $PACKAGE $cmdtmpfile $RET $COMMAND" >> $WEBBUILD_STATEDIR/processes
fi
fi
@ -114,4 +124,8 @@ if [ "$ENVIRONMENT" != "local" ]; then
rm -f /var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/$TMPFILE
fi
fi
if [ -e $cmdtmpfile ]; then
chmod 666 $cmdtmpfile
chown apache.nobody $cmdtmpfile
fi
exit $RET