webbuild: small fixes and code organization

This commit is contained in:
Silvan Calarco 2012-12-01 23:36:43 +01:00
parent 432f79fa29
commit 03a198fec4
4 changed files with 68 additions and 25 deletions

View File

@ -8,6 +8,14 @@ function getCheckedValuesByName(checkboxname) {
return p;
}
function checkAllBoxes(checkboxname,checked) {
var e=document.getElementsByName(checkboxname);
for (var j=0;j<e.length;j++) {
e[j].checked=checked;
};
}
function getSelectedValueById(selectname,idx) {
if (idx == undefined) idx = 0;
var i=document.getElementById(selectname).selectedIndex;

View File

@ -327,12 +327,22 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshjobs" ]; then
echo -n "<br>"
}
[ "$STATE_JOBSSHOWALL" = "1" -o "$USER" = "$2" ] || continue
if [ $RETCODE -eq 256 -a -e /proc/$1 ]; then
echo -n "<img style=\"margin-top:-1px;margin-right:2px;\" width=10 height=10 src=\"/images/inprogress.gif\" alt=\"running...\" title=\"running...\">"
else
if [ $RETCODE -eq 0 ]; then
# echo -n "<font color=green><b>OK</b></font>"
echo -n "<img style=\"margin-top:-1px;margin-right:2px;\" src=\"/images/ok.png\" width=10 height=10 alt=\"OK\" title=\"Job successfully completed\">"
else
# echo -n "<font color=red><b>ERROR ($RETCODE)</b></font>"
echo -n "<img style=\"margin-top:-1px;margin-right:2px;\" src=\"/images/fail.png\" width=10 height=10 alt=\"ERROR\" title=\"Job returned with error $RETCODE\">"
fi
fi
echo -n "<b>$2</b> on <i>`print_environment_descr $3`</i>: "
if [ $RETCODE -eq 256 -a -e /proc/$1 ]; then
echo -n "\"<a href=# title=\"Click to see live output log\" onclick=ajax_getvalues(\"ENVIRONMENT=$3&PACKAGE=$PACKAGE_ENCODED&"
echo -n "REQUEST=showlog&LOGTYPE=processtail&PROCESSPID=$1&LOGFILE=$5\")>"
echo -n "<b><i>$cmdline</i></b></a>\" "
echo -n "<i>(running...)</i>"
else
echo -n "\"<a href=# title=\"Click to see output log\" onClick=ajax_getvalues(\"ENVIRONMENT=$3&PACKAGE=$PACKAGE_ENCODED&"
echo -n "REQUEST=showlog&LOGTYPE=processoutput&LOGFILE=$5\")>"
@ -341,11 +351,6 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshjobs" ]; then
$SUDO_WRAPPER finishprocess $1 "$USER" $5
RETCODE=$?
fi
if [ $RETCODE -eq 0 ]; then
echo -n "<font color=green><b>OK</b></font>"
else
echo -n "<font color=red><b>ERROR ($RETCODE)</b></font>"
fi
fi
if [ "$2" = "$USER" -o "$USER_ADMIN" ]; then
if [ $RETCODE -eq 256 -a -e /proc/$1 ]; then
@ -531,7 +536,7 @@ elif [ ! "$REQUEST" -o "$REQUEST" = "changeenvironment" -o "$REQUEST" = "switchm
# SPECFILES select
echo -n "<specedit><![CDATA["
echo -n " Edit:<select id=specfile "
echo -n "onchange=ajax_getvalues(\"REQUEST=edit&ENVIRONMENT=$ENVIRONMENT&"
echo -n "onchange=ajax_getvalues(\"REQUEST=edit&ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&"
echo -n "PACKAGE=\"+encodeURIComponent(this.value)+\"&REQUEST=changespec\");>"
echo -n "<option value=\"\">-- Select a .spec file --</option>"
$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "ls *.spec | sort -f" | while read f; do
@ -709,7 +714,8 @@ if [ "$MAINTAINERMODE" = "true" -o ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then
echo -n "<input type=button name=port value=\"Port\" id=portbutton onclick="
echo -n "ajax_getvalues(\"REQUEST=autoport&REPOSITORY=\"+getSelectedValueById('repository')+\""
echo -n "&ENVIRONMENT=$ENVIRONMENT&MAINTAINERMODE=\"+getElementById('maintain').checked+\"&"
echo -n "PACKAGE=\"+encodeURIComponent(getSelectedValueById('package'))); $SRPMBUTTONDISABLED>"
echo -n "PACKAGE=\"+encodeURIComponent(getSelectedValueById('specfile'))+\"&"
echo -n "AUTOPORTPACKAGE=\"+encodeURIComponent(getSelectedValueById('package'))); $SRPMBUTTONDISABLED>"
fi
echo -n "]]></operations>"
fi
@ -934,6 +940,7 @@ if [ "$REQUEST" = "edit" -o "$REQUEST" = "reloadspec" -o "$REQUEST" = "switchmai
# echo "No pre-existing .spec file $PACKAGE.spec in current working environment. Choose package from a repository and press 'Unpack and edit' to edit."
# echo -n "</div>"
# echo -n "]]></output>"
print_editorcontrols
fi
REQUEST=
fi
@ -1022,7 +1029,7 @@ if [ "$MAINTAINERMODE" != "true" ]; then
if [ "$AUTODISTJOB" -a "$AUTODISTJOB" = "$f" ]; then
SELECTED="selected=\"selected\""
AUTODISTJOBSELECTED=1
elif [ "$PACKAGE" = "$f" ]; then
elif [ "$PACKAGE" = "$f" -a ! "$AUTODISTJOBSELECTED" ]; then
SELECTED="selected=\"selected\""
AUTODISTJOB=$f
AUTODISTJOBSELECTED=1
@ -1083,7 +1090,8 @@ if [ "$MAINTAINERMODE" != "true" ]; then
echo -n "AUTODISTJOB=\"+getSelectedValueById('autodistjobs')+\"&"
echo -n "AUTODISTPKGS=\"+encodeURIComponent(p)+\"&"
echo -n "ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=autodistinstall\""
echo -n ",\"`cgi_encodevar "Install built packages for <b>"`\"+getSelectedValueById('autodistjobs')+\"`cgi_encodevar "</b> job in current environment?"`\""
echo -n ",\"`cgi_encodevar "Install built packages for <b>"`\"+getSelectedValueById('autodistjobs')+\""
echo -n "`cgi_encodevar "</b> job in current environment?"`\""
echo -n "); class=redbutton $DISABLED>"
# autodist send
[ ! "$USER_ALLREPOSITORIES" ] && DISABLED="disabled=disabled" || DISABLED=
@ -1205,7 +1213,7 @@ if [ "$MAINTAINERMODE" != "true" ]; then
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&"
echo -n "SENDREPOSITORY=\"+getSelectedValueById('sendrepository')"
echo -n ",\"`cgi_encodevar "Send <b>$PACKAGE</b> built packages to <b>"`\"+getSelectedValueById('sendrepository')+"
echo -n "\"`cgi_encodevar "</b>?"`\""
echo -n "\"`cgi_encodevar "</b>?<br><br><font color=green>HINT: does summary look short and good?</font><br><b>${SPECVAR_Name[0]} - ${SPECVAR_Summary[0]}.</b>"`\""
echo -n "); class=redbutton $HREFADD>"
# recreate and send SRPM
if [ "$SPECVAR_CHECK_NOAUTOBUILDREQ" ]; then
@ -1427,12 +1435,18 @@ case $REQUEST in
RET=$?
[ $RET -eq 0 ] && social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"sent <b>$AUTODISTPKGS</b> to <b>$SENDREPOSITORY</b>\" STIME=`date +%s`"
;;
"autoport") $SUDO_WRAPPER background $ENVIRONMENT "$USER" $PACKAGE "autoport $PACKAGE -r $REPOSITORY" &>/dev/null
[ $? -ne 0 ] && RET=$? || {
"autoport") if [ "$AUTOPORTPACKAGE" ]; then
$SUDO_WRAPPER background $ENVIRONMENT "$USER" $AUTOPORTPACKAGE "autoport $AUTOPORTPACKAGE -r $REPOSITORY" &>/dev/null
RET=$?
[ $REQ -eq 0 ] && {
RET=-1
echo "Autoport started. You may see the output in the <b>Webbuild jobs</b> box above."
}
;;
else
echo "ERROR: no port package specified!"
RET=1
fi
;;
"autospecupdatescheck") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a2"; RET=$? ;;
"rpmprepare") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "rpmbuild -bp $PACKAGE.spec --nodeps"; RET=$? ;;
"rpmbuild") [ "$RPMFORCE" = "true" ] && RPMFORCEADD="--force-build"
@ -1634,7 +1648,7 @@ case $REQUEST in
echo "ERROR: BUILDROOT is undefined"
RET=1
else
$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDROOT && find $SPECVAR_BUILDROOT"
$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDROOT/$SPECVAR_BUILDROOT && find"
RET=$?
fi
;;
@ -1661,7 +1675,7 @@ case $REQUEST in
echo -n "</pre>"
done
;;
"configurehelp") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDDIR/$SPECVAR_BUILDDIR && ./configure --help"
"configurehelp") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDDIR/$SPECVAR_BUILDDIR && ./configure --help || ./waf configure --help"
RET=$?
[ $RET -eq 0 ] && RET=-1 ;;
"configurelog") $SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "cd $SPECVAR_RPMBUILDDIR/$SPECVAR_BUILDDIR && cat config.log"
@ -1848,7 +1862,7 @@ if [ "$MAINTAINERMODE" = "true" ]; then
else
[ "$PACKAGE" ] && echo -n "$PACKAGE $SPECVAR_Version-$SPECVAR_Release " || echo -n "no package "
echo -n "("
print_environment_descr
print_environment_descr $ENVIRONMENT
echo -n ")"
fi

View File

@ -210,7 +210,7 @@ function parse_build_output() {
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>|;
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|\(.*\)\(error[^0-9A-Za-z]*:[[: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>|;
s|[[:cntrl:]]||g;" | google_search $1
@ -260,3 +260,29 @@ function print_environment_descr() {
echo -n " for ${AUTOPORT_ARCH[$i]}"
# (${AUTOPORT_BASE_REPOSITORY[$i]} based)"
}
function environment_autoport_logdir() {
local env=$1
if [ "${AUTOPORT_CHROOT[$env]}" ]; then
echo "/var/autoport/${AUTOPORT_CHROOT[$env]}/home/${AUTOPORT_CHROOT_USER[$env]}/.autoport/"
elif [ "${AUTOPORT_NATIVE[$env]}" ]; then
local envhome=`eval echo ~${AUTOPORT_CHROOT_USER[$env]}`
echo "$envhome/.autoport"
fi
}
function environment_logdir() {
local env=$1
if [ "${AUTOPORT_CHROOT[$env]}" ]; then
echo "/var/autoport/${AUTOPORT_CHROOT[$env]}/home/${AUTOPORT_CHROOT_USER[$env]}/.autodist/log/"
elif [ "${AUTOPORT_NATIVE[$env]}" ]; then
local envhome=`eval echo ~${AUTOPORT_CHROOT_USER[$env]}`
if [ "${AUTOPORT_CHROOT_USER[$env]}" = "autodist" ]; then
echo "$envhome/log"
else
echo "$envhome/.autodist/log/"
fi
else
echo "/var/autodist/log/"
fi
}

View File

@ -23,17 +23,12 @@ function showlog() {
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
LOGDIR=`environment_logdir $ENVIRONMENT`
LOGFILES="$LOGDIR/$LOGFILE1 $LOGDIR/$LOGFILE2 $LOGDIR/$LOGFILE3 $LOGDIR/$LOGFILE4"
for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
[ "$i" = "$ENVIRONMENT" ] && continue
[ "${AUTOPORT_ARCH[$i]}" = "${AUTOPORT_ARCH[$ENVIRONMENT]}" ] || continue
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
LOGDIR="/var/autodist/log"
LOGFILES="$LOGFILES $LOGDIR/$LOGFILE1 $LOGDIR/$LOGFILE2 $LOGDIR/$LOGFILE3 $LOGDIR/$LOGFILE4"