autodist/webbuild/webbuild-cgi

1217 lines
64 KiB
Plaintext
Raw Normal View History

2012-09-02 13:18:52 +02:00
#!/bin/bash
#
# webbuild cgi script
# Copyright (c) 2012 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
. /etc/sysconfig/autoport
. /usr/share/autodist/webbuild-functions
2012-09-02 13:18:52 +02:00
# register all GET and POST variables
cgi_getvars BOTH ALL
#[ "$PACKAGE" ] && PACKAGEENCODED=`cgi_encodevar "$PACKAGE"` || PACKAGEENCODED=
[ "$PACKAGE" ] && PACKAGEENCODED=`cgi_encodevar "$PACKAGE"` || PACKAGEENCODED=
2012-09-02 13:18:52 +02:00
#cgi_getvars POST
if [ "$REQUEST" != "refresh" ]; then
# echo "`date` - $QUERY_STRING_POST" >> $LOG
echo "`date` - USER=$USER&REQUEST=$REQUEST&ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&MAINTAINERMODE=$MAINTAINERMODE" >> $LOG
fi
[ "$HOST" ] || HOST=0
[ "$AS_HOST" ] || AS_HOST=0
[ "$AS_HOST" -a "$HOST" != "0" ] && HOST_ADD="&HOST=$HOST"
if [ "$AS_HOST" = "0" ]; then
echo -e "Content-type: text/xml\nPragma: no-cache\n"
echo -n "<webbuild>"
else
echo -e "Content-type: text/html; charset=UTF-8\n"
fi
# SECURITY
USER_ENABLED=
USER_ADMIN=
USER_CANMAINTAIN=
USER_CANSENDMESSAGES=
2012-09-02 13:18:52 +02:00
USER=${USER/.*\/}
if [ "$SECRET" -a "$USER" ]; then
if [ -r "$WEBBUILD_STATEDIR/users/$USER.conf" ]; then
. $WEBBUILD_STATEDIR/users/$USER.conf
2012-09-02 13:18:52 +02:00
fi
if [ "$USER_ENABLED" ]; then
USER_ENABLED=
if [ "$SECRET" = "$USER_SECRET" ]; then
USER_ENABLED=1
elif [ ! "$SECRET" ]; then
USER_ENABLED=
elif [ "$USER_SECRET" ]; then
echo -n "<environments> </environments>"
echo -n "<speccreate> </speccreate>"
echo -n "<specedit> </specedit>"
echo -n "<repositories> </repositories>"
echo -n "<packages> </packages>"
echo -n "<editcontrols> </editcontrols>"
echo -n "<editor> </editor>"
echo -n "<output>'$SECRET'='$USER_SECRET' Unauthorized! If this happened after you changed your password in openmamba website please ask the maintainer to be re-enabled to use this service. Thank you."
2012-09-02 13:18:52 +02:00
echo -n "</output>"
echo -n "<operationpanel> </operationpanel>"
echo -n "</webbuild>"
exit
elif [ "$REQUEST" = "password" ]; then
/usr/libexec/webbuild-checkpassword "$PASSWORD" "$SECRET" 2>/dev/null
if [ $? -eq 0 ]; then
tmpfile=`mktemp`
cat $WEBBUILD_STATEDIR/users/$USER.conf > $tmpfile
2012-09-02 13:18:52 +02:00
echo "USER_SECRET='$SECRET'" >> $tmpfile
USER_ENABLED=1
$SUDO_WRAPPER local "" "mv $tmpfile $WEBBUILD_STATEDIR/users/$USER.conf"
2012-09-02 13:18:52 +02:00
else
USER_ENABLED=
fi
else
# no "$USER_SECRET" set; require password
echo -n "<output><![CDATA[Please enter your password: <input type=password id=password>"
echo -n " <input type=button value=\"Submit\" onClick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
2012-09-02 13:18:52 +02:00
echo -n "REQUEST=password&PASSWORD=\"+encodeURIComponent(getElementById('password').value));>"
echo -n "]]></output>"
echo -n "<environments> </environments>"
echo -n "<speccreate> </speccreate>"
echo -n "<specedit> </specedit>"
echo -n "<repositories> </repositories>"
echo -n "<packages> </packages>"
echo -n "<editcontrols> </editcontrols>"
echo -n "<editor> </editor>"
echo -n "<operationpanel> </operationpanel>"
echo -n "</webbuild>"
exit
fi
fi
fi
if [ "$USER_ENABLED" != "1" ]; then
echo -n "<environments> </environments>"
echo -n "<speccreate> </speccreate>"
echo -n "<specedit> </specedit>"
echo -n "<repositories> </repositories>"
echo -n "<packages> </packages>"
echo -n "<editcontrols> </editcontrols>"
echo -n "<editor> </editor>"
if [ "$USER" -a "$SECRET" ]; then
if [ "$REQUEST" = "enablerequest" ]; then
echo "`date` - USER=$USER USER_EMAIL=$USER_EMAIL REQUEST=$REQUEST SECRET=$SECRET" >> $WEBBUILD_STATEDIR/requests_log
2012-09-02 13:18:52 +02:00
echo -n "<output>Your request has been submitted. Please wait for approval and retry later.</output>"
elif [ "$REQUEST" = "password" ]; then
echo -n "<output>Invalid password. Please reload and retry or ask the maintainer in case of problems.</output>"
elif [ "`grep \" USER=$USER \" $WEBBUILD_STATEDIR/requests_log`" ]; then
2012-09-02 13:18:52 +02:00
echo -n "<output>Your request is pending for approval. Please try again later or ask the maintainer in case of problems.</output>"
else
echo -n "<output><![CDATA[Your account is not enabled to use this service!"
echo -n " <input type=button value=\"Please, enable my account to use this service\" onClick=javascript:"
echo -n "ajax_getvalues(\"REQUEST=enablerequest\");>"
echo -n "]]></output>"
fi
# else
# echo -n "<output>Unauthorized!</output>"
2012-09-02 13:18:52 +02:00
fi
echo -n "<operationpanel> </operationpanel>"
# echo -n "</webbuild>"
# exit
2012-09-02 13:18:52 +02:00
fi
if [ -e $WEBBUILD_STATEDIR/webbuild.state ]; then
. $WEBBUILD_STATEDIR/users/webbuild.state
else
touch $WEBBUILD_STATEDIR/users/webbuild.state
2012-09-02 13:18:52 +02:00
fi
if [ "$USER_ADMIN" -a "$FAKEUSERSWITCH" != "" ]; then
if [ "$FAKEUSERSWITCH" = "_disabled_" ]; then
set_user_state_var STATE_FAKEUSER
FAKEUSER=
2012-09-02 13:18:52 +02:00
else
set_user_state_var STATE_FAKEUSER $FAKEUSERSWITCH
fi
fi
if [ "$USER" -a "$USER_ENABLED" ]; then
# set user state changes
if [ "$ADVANCEDCONTROLSSWITCH" != "" ]; then
if [ "$ADVANCEDCONTROLSSWITCH" = "true" ]; then
set_user_state_var STATE_ADVANCEDCONTROLS 1
else
set_user_state_var STATE_ADVANCEDCONTROLS
2012-09-02 13:18:52 +02:00
fi
fi
if [ "$PRIVACYMODESWITCH" != "" ]; then
if [ "$PRIVACYMODESWITCH" = "true" ]; then
set_user_state_var STATE_PRIVACYMODE 1
else
set_user_state_var STATE_PRIVACYMODE
2012-09-02 13:18:52 +02:00
fi
fi
# read user state file
[ -e $WEBBUILD_STATEDIR/users/$USER.state ] && . $WEBBUILD_STATEDIR/users/$USER.state
if [ "$USER_ADMIN" -a "$STATE_FAKEUSER" != "" ]; then
USER=$STATE_FAKEUSER
USER_ENABLED=
USER_ADMIN=
USER_CANMAINTAIN=
USER_CANINSTALL=
USER_ALLENVIRONMENTS=
USER_ALLREPOSITORIES=
[ -e $WEBBUILD_STATEDIR/users/$USER.conf ] && . $WEBBUILD_STATEDIR/users/$USER.conf
STATE_ADVANCEDCONTROLS=
[ -e $WEBBUILD_STATEDIR/users/$USER.state ] && . $WEBBUILD_STATEDIR/users/$USER.state
fi
fi
#
# Public requests
#
if [ "$REQUEST" = "refresh" -o ! "$USER" ]; then
# social box
echo -n "<socialbox><![CDATA["
echo -n "<div class=\"socialbox\"><div class=\"scroll-pane\">"
count=0
[ -e "$WEBBUILD_STATEDIR/social_log" ] && tail -n 100 $WEBBUILD_STATEDIR/social_log | tac | while read line; do
STYPE=
SPRIVACY=
SUSER=
eval $line
[ "$SUSER" = "$USER" -a "$STYPE" != "broadcastmessage" ] && continue
if [ "$SPRIVACY" -a ! "$USER" ]; then
USER_GRAVATAR=
2012-09-02 13:18:52 +02:00
else
USER_GRAVATAR=`echo -n $SEMAIL | md5sum | sed "s| .*||"`
2012-09-02 13:18:52 +02:00
fi
echo -n "<div id=\"sociallog-$SID\" style=\"height:auto;\"><div style=\"position:relative;float:left;height:26px;width:24px;\">"
echo -n "<img src=\"http://www.gravatar.com/avatar/$USER_GRAVATAR?s=22&d='http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=22'\" /></div>"
DATENOW=`date +%s`
DAYSAGO=`expr \( $DATENOW - $STIME \) / 86400`
HOURAGO=`expr \( $DATENOW - $STIME \) / 3600 % 24`
MINAGO=`expr \( $DATENOW - $STIME \) / 60 % 60`
SECAGO=`expr \( $DATENOW - $STIME \) % 60`
TIMEAGO="${SECAGO}s"
if [ $DAYSAGO -gt 1 ]; then
TIMEAGO="$DAYSAGO days"
elif [ $DAYSAGO -eq 1 ]; then
TIMEAGO="1 day ${HOURAGO} hours"
elif [ $HOURAGO -gt 1 ]; then
TIMEAGO="${HOURAGO} hours"
elif [ $HOURAGO -eq 1 ]; then
TIMEAGO="1 hour ${MINAGO} min"
elif [ $MINAGO -gt 1 ]; then
TIMEAGO="${MINAGO} minutes"
elif [ $MINAGO -eq 1 ]; then
TIMEAGO="1 min ${SECAGO} seconds"
2012-09-02 13:18:52 +02:00
else
TIMEAGO="${SECAGO} seconds"
fi
if [ "$SPRIVACY" -a ! "$USER" ]; then
SUSER="A developer"
2012-09-02 13:18:52 +02:00
fi
echo -n "<div style=\"position:relative;float:right;height:auto;width:164px;\"><b>$SUSER</b> $STEXT <i>(${TIMEAGO} ago)</i></div></div><br>"
count=`expr $count + 1`
[ $count -ge 10 ] && break
echo -n "<div style=\"clear:both;\"><hr></div>"
done
echo -n "</div></div>"
echo -n "]]></socialbox>"
fi
if [ "$USER_ENABLED" != "1" ]; then
echo -n "</webbuild>"
exit
fi
#
# Enabled users requests
#
if [ "$REQUEST" = "refresh" ]; then
echo -n "<processes><![CDATA["
numprocess=0
while read line; do
set -- $line
if [ -e /proc/$1 ]; then
numprocess=`expr $numprocess + 1`
cmdline=`echo $line | sed "s|$1 $2 $3 $4 ||"`
[ $numprocess -eq 1 ] && {
echo -n "<div align=left class=processes>"
echo -n "<b>Webbuild running jobs:</b><br>"
}
echo -n "<b>$2</b> <i>\"$cmdline\"</i> "
echo -n " [ <a onClick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=showlog&LOGTYPE=processoutput&LOGFILE=$4\")>"
echo -n "show</a> ]"
echo -n "<br>"
fi
done < $WEBBUILD_STATEDIR/processes
[ $numprocesses -gt 0 ] && echo -n "</div>"
echo -n "]]></processes></webbuild>"
exit
fi
# message send request (social_log)
if [ "$REQUEST" = "message" -a "$USER" -a "$USER_CANSENDMESSAGES" ]; then
# external (autodist) social messages
social_log "SUSER=$USER STYPE=broadcastmessage SEMAIL=$USER_EMAIL STEXT=\"$MESSAGE\" STIME=`date +%s`"
echo "</webbuild>"
exit
fi
# repsearch request
if [ "$REQUEST" = "repsearch" ]; then
echo -n "<output><![CDATA["
echo -n "<div align=left class=output id=outputtop>"
echo -n "<pre><!-- SCROLL -->"
$SUDO_WRAPPER local "" "openmamba-repository search -i $REPSEARCHTEXT"
echo -n "<!-- ENDSCROLL --></pre>"
echo "</div>]]></output></webbuild>"
exit
fi
# ENVIRONMENT select
echo -n "<environments><![CDATA["
# new session button
echo -n "<input type=button id=newsessionbutton value=\"New session\" onclick=javascript:"
echo -n "window.open(document.URL);>"
# expert mode checkbox
[ "$STATE_ADVANCEDCONTROLS" ] && CHECKED="checked=checked" || CHECKED=
echo -n " <span style=\"white-space:nowrap\">Expert:<input type=checkbox id=\"advancedcontrols\" value=\"force\" "
echo -n "onclick=javascript:ajax_getvalues(\""
echo -n "ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
echo -n "MAINTAINERMODE=\"+getElementById('maintain').checked+\"&"
echo -n "ADVANCEDCONTROLSSWITCH=\"+getElementById('advancedcontrols').checked); $CHECKED>"
# privacy mode checkbox
[ "$STATE_PRIVACYMODE" ] && CHECKED="checked=checked" || CHECKED=
echo -n " <span style=\"white-space:nowrap\">Privacy:<input type=checkbox id=\"privacymode\" value=\"force\" "
echo -n "onclick=javascript:ajax_getvalues(\""
echo -n "ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
echo -n "PRIVACYMODESWITCH=\"+getElementById('privacymode').checked); $CHECKED>"
echo -n "</span>"
# maintainer mode checkbox
if [ "$USER_CANMAINTAIN" ]; then
[ "$MAINTAINERMODE" = "true" ] && CHECKED="checked"
echo -n "Maintainer:<input type=checkbox id=\"maintain\" $CHECKED onclick=javascript:"
echo -n "ajax_getvalues(\"REPOSITORY=$REPOSITORY"
echo -n "&MAINTAINERMODE=\"+getElementById('maintain').checked+\""
echo -n "&PACKAGE=$PACKAGEENCODED&ENVIRONMENT=$ENVIRONMENT&REQUEST=switchmaintainermode\");>"
fi
# switch user select
if [ "$USER_ADMIN" -o "$STATE_FAKEUSER" ]; then
echo -n " | "
echo -n " Test user: <select id=adminuser "
echo -n "onchange=javascript:ajax_getvalues(\"REQUEST=adminuser&"
echo -n "FAKEUSERSWITCH=\"+this.value);>"
echo -n "<option value=\"_disabled_\">-- disabled --</option>"
for f in $WEBBUILD_STATEDIR/users/*.conf; do
adminuser=`basename ${f/.conf}`
[ "$STATE_FAKEUSER" = "$adminuser" ] && SELECTED="selected=\"selected\"" || SELECTED=
echo -n "<option value=\"$adminuser\" $SELECTED>$adminuser</option>"
done
echo -n "</select>"
fi
if [ "$MAINTAINERMODE" != "true" ]; then
# [ "$USER_CANMAINTAIN" -o "$STATE_FAKEUSER" -o "$USER_ADMIN" ] && echo -n "<br>"
echo -n "<br>Build environment:<select id=environment "
echo -n "onchange=javascript:ajax_getvalues(\"ENVIRONMENT=\"+this.value+\"&REQUEST=changeenvironment\");>"
echo "<option value=\"\">-- Please select a build environment --</option>"
for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
[ "${AUTOPORT_ARCH[$i]}" ] || continue
# [ "${AUTOPORT_DISABLE[$i]}" -a "${AUTOPORT_DISABLE[$i]}" != "0" ] && continue
SELECTED=
if [ "$ENVIRONMENT" ]; then
[ "$ENVIRONMENT" = "$i" ] && SELECTED="selected=\"selected\"" || SELECTED=
else
if [ "${AUTOPORT_CHROOT_USER[$i]}" = "$USER" ]; then
SELECTED="selected=\"selected\""
ENVIRONMENT=$i
fi
fi
if [ "${AUTOPORT_CHROOT_USER[$i]}" = "$USER" -o "${AUTOPORT_CHROOT_USER[$i]}" = "contrib" -o "$USER_ALLENVIRONMENTS" ]; then
if [ "${AUTOPORT_CHROOT_USER[$i]}" = "contrib" -a ! "$ENVIRONMENT" ]; then
SELECTED="selected=\"selected\""
ENVIRONMENT=$i
fi
echo -n "<option value=\"$i\" $SELECTED>"
if [ "${AUTOPORT_CHROOT_USER[$i]}" ]; then
echo -n "${AUTOPORT_CHROOT_USER[$i]} "
else
echo "autodist "
fi
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
echo -n "autoupdate"
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)"
echo -n "</option>"
fi
done
echo -n "</select>"
fi
2012-09-02 13:18:52 +02:00
echo -n "]]></environments>"
if [ ! "$ENVIRONMENT" ]; then
ENVIRONMENT=$DEFAULT_ENVIRONMENT
fi
if [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then
WORKINGROOT="/var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/"
WORKINGHOME="/var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/usr/src/"
BUILDLOGDIR="/var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/home/${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}/.autodist/log/"
AUTOPORTLOGDIR="/var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/home/${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}/.autoport/${AUTOPORT_ARCH[$ENVIRONMENT]}/"
elif [ "${AUTOPORT_NATIVE[$ENVIRONMENT]}" ]; then
WORKINGROOT="/"
WORKINGHOME=`getent passwd ${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} | cut -d: -f6`
BUILDLOGDIR="/home/${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}/.autodist/log/"
AUTOPORTLOGDIR="/home/${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}/.autoport/${AUTOPORT_ARCH[$ENVIRONMENT]}/"
else
WORKINGROOT="/"
WORKINGHOME="/var/autodist/"
BUILDLOGDIR="/var/autodist/log/"
AUTOPORTLOGDIR="/var/autodist/.autoport/${AUTOPORT_ARCH[$ENVIRONMENT]}/"
fi
if [ "$HOST_IS_X86_64" -a "${AUTOPORT_ARCH[$ENVIRONMENT]}" != "x86_64" ]; then
SUDO_WRAPPER="linux32 $SUDO_WRAPPER"
fi
# show log
if [ "$REQUEST" = "showlog" ]; then
echo -n "<output><![CDATA["
if [ "$LOGTYPE" = "processoutput" ]; then
LOGFILES=$LOGFILE
else
LOGFILE=$LOGTYPE
if [ "$LOGSTATUSOK" = "true" ]; then
LOGFILE=$LOGFILE/ok
else
LOGFILE=$LOGFILE/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]}
LOGFILES="$BUILDLOGDIR/$LOGFILE1 $BUILDLOGDIR/$LOGFILE2 $BUILDLOGDIR/$LOGFILE3 $BUILDLOGDIR/$LOGFILE4"
fi
echo "<div align=left class=output id=outputbottom>"
for f in $LOGFILES; do
[ -r $f ] || continue
echo -n "<b>`basename $f` (`stat -c %y $f`)</b><pre>"
cat $f | sed "s|<|\&lt;|g"
echo -n "</pre>"
done
echo -n "</div>]]></output>"
echo -n "</webbuild>"
exit
fi
2012-09-02 13:18:52 +02:00
[ "$PACKAGE" -a ! "$REQUEST" ] && REQUEST=edit
# SPECFILES select
if [ "$ENVIRONMENT" -a "$MAINTAINERMODE" != "true" ]; then
2012-09-02 13:18:52 +02:00
echo -n "<specedit><![CDATA["
echo -n " Edit:<select id=specfile "
echo -n "onchange=javascript:ajax_getvalues(\"REQUEST=edit&ENVIRONMENT=$ENVIRONMENT&"
echo -n "PACKAGE=\"+encodeURIComponent(this.value)+\"&REQUEST=changespec\");>"
2012-09-02 13:18:52 +02:00
echo -n "<option value=\"\">-- Select a .spec file --</option>"
for f in `$SUDO_WRAPPER $ENVIRONMENT "" "ls *.spec"`; do
specname=${f/.*}
[ "$PACKAGE" = "$specname" ] && SELECTED="selected=\"selected\"" || SELECTED=
echo -n "<option value=\"$specname\" $SELECTED>${specname}.spec</option>"
done
echo -n "</select>]]></specedit>"
elif [ "$MAINTAINERMODE" = "true" ]; then
echo -n "<specedit> </specedit>"
2012-09-02 13:18:52 +02:00
fi
# clean output when changing environment
if [ ! "$REPOSITORY" -a ! "$PACKAGE" -a ! "$REQUEST" = "repsearch" ]; then
echo -n "<editor> </editor>"
# echo -n "<editor><![CDATA[<textarea id=spectext class=editor disabled=true></textarea>]]></editor>"
echo -n "<output><![CDATA[<div align=left class=output id=outputbottom>]]></output>"
fi
# REPOSITORIES search
if [ ! "$REPSEARCHTEXT" ]; then
echo -n "<searchbox><![CDATA["
echo -n "<div class=searchbox><input type=button id=repsearchbutton value=\"Search repositories:\" onclick=javascript:ajax_getvalues(\""
echo -n "ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
2012-09-02 13:18:52 +02:00
echo -n "REQUEST=repsearch&REPSEARCHTEXT=\"+encodeURIComponent(getElementById('repsearchtext').value));>"
if [ "$PACKAGE" ]; then
echo -n "<input type=text id=repsearchtext value=\"${PACKAGE}-\" size=\"15\">"
else
echo -n "<input type=text id=repsearchtext value=\"\" size=\"15\">"
fi
echo -n "</div>]]></searchbox>"
fi
if [ "$MAINTAINERMODE" = "true" -o ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then
# REPOSITORIES select
if [ "$MAINTAINERMODE" = "true" -o ! "$REPOSITORY" -o "$REQUEST" = "changeenvironment" ]; then
echo -n "<repositories><![CDATA[Repository:<select id=repository "
echo -n "onchange=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=\"+this.value+\""
if [ "$USER_CANMAINTAIN" ]; then
echo -n "&MAINTAINERMODE=\"+getElementById('maintain').checked+\""
2012-09-02 13:18:52 +02:00
fi
if [ ! "$MAINTAINERMODE" ]; then
echo -n "&PACKAGE=\"+encodeURIComponent(getSelectedValueById('specfile'))+\""
fi
echo -n "&REQUEST=changerepository\");>"
echo -n "<option value=\"\">-- Select a repository --</option>"
for f in `$SUDO_WRAPPER local "" "/usr/sbin/openmamba-repository list"`; do
repname=`basename $f`
[ "$repname" = "$REPOSITORY" ] && SELECTED="selected=selected" || SELECTED=
echo -n "<option value=\"$repname\" $SELECTED>$repname</option>"
done
echo -n "</select>"
echo -n "]]></repositories>"
echo -n "<packages> </packages>"
echo -n "<operations> </operations>"
fi
2012-09-02 13:18:52 +02:00
# PACKAGES (SRPM) select
if [ "$REQUEST" = "changerepository" -o "$REQUEST" = "switchmaintainermode" -a "$MAINTAINERMODE" != "true" ]; then
echo -n "<packages><![CDATA[ SRPMS:"
echo -n "<select id=package onchange=javascript:"
echo -n "getElementById('preparebutton').disabled=0;>"
#(getElementById('package').selectedIndex);>"
echo "<option value=\"\">-- Select a SRPM package --</option>"
for f in $local_ftp/$REPOSITORY/SRPMS.base/*.src.rpm; do
[ -r $f ] || continue
pkgname=`basename $f`
pkgname=${pkgname/.src.rpm}
pkgrel=${pkgname/*-}
pkgname=${pkgname/-$pkgrel}
pkgver=${pkgname/*-}
pkgname=${pkgname/-$pkgver}
if [ "$PACKAGE" = "$pkgname" ]; then
SELECTED="selected=\"selected\"";
# REQUEST="changesrpm"
else
SELECTED=
fi
echo -n "<option value=\"$pkgname\" $SELECTED>${pkgname} ${pkgver}-${pkgrel}</option>"
done
echo -n "</select>"
echo -n "]]></packages>"
2012-09-02 13:18:52 +02:00
if [ "$MAINTAINERMODE" != "true" ]; then
echo -n "<operations><![CDATA["
echo -n "<input type=button name=prepare value=\"Unpack and edit\" id=preparebutton "
2012-09-02 13:18:52 +02:00
echo -n "onclick=javascript:i=getElementById('repository').selectedIndex;j=getElementById('package').selectedIndex;"
echo -n "ajax_getvalues(\"REQUEST=prepare&REPOSITORY=\"+getElementById('repository').options[i].value+\""
echo -n "&ENVIRONMENT=$ENVIRONMENT&MAINTAINERMODE=\"+getElementById('maintain').checked+\"&"
echo -n "PACKAGE=\"+encodeURIComponent(getElementById('package').options[j].value)); disabled=disabled>"
echo -n "]]></operations>"
# REQUEST=changesrpm
2012-09-02 13:18:52 +02:00
fi
fi
# SPECFILE creation
if [ ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" -a "$MAINTAINERMODE" != "true" ]; then
echo -n "<speccreate><![CDATA["
echo -n " Start from URL:<input type=text id=speccreateurl value=\"\" size=\"55\">"
echo -n " name:<input type=text id=speccreatename value=\"\" size=\"10\">"
echo -n " type:<select id=speccreatetype>"
for t in standard gnome kde3 kde4 library perl python standard-daemon; do
echo -n "<option value=\"$t\">$t</option>"
done
echo -n "</select>"
echo -n " version:<input type=text id=speccreateversion value=\"\" size=\"6\">"
echo -n "<input type=button id=speccreatebutton value=\"Create .spec\" onclick=javascript:ajax_getvalues(\""
echo -n "REQUEST=speccreate&ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&"
echo -n "PACKAGE=\"+encodeURIComponent(getElementById('speccreatename').value)+\"&"
echo -n "SPECCREATETYPE=\"+getElementById('speccreatetype').value+\"&"
echo -n "SPECCREATEVERSION=\"+getElementById('speccreateversion').value+\"&"
echo -n "SPECCREATEURL=\"+encodeURIComponent(getElementById('speccreateurl').value));>"
echo "]]></speccreate>"
elif [ "$MAINTAINERMODE" = "true" ]; then
echo -n "<speccreate> </speccreate>"
2012-09-02 13:18:52 +02:00
fi
else
echo -n "<repositories> </repositories><packages> </packages><operations> </operations><speccreate> </speccreate> <operations></operations>"
fi
if [ "$REQUEST" = "changespec" ]; then
2012-09-02 13:18:52 +02:00
if [ "$PACKAGE" ]; then
REQUEST="edit";
fi
elif [ "$REQUEST" = "broadcastmessage" ]; then
BROADCASTMESSAGE=`echo $BROADCASTMESSAGE | sed "s|<|\&lt;|g"`
social_log "SUSER=$USER STYPE=broadcastmessage SEMAIL=$USER_EMAIL STEXT=\"said:&quot;<i>$BROADCASTMESSAGE</i>&quot;\" STIME=`date +%s`"
2012-09-02 13:18:52 +02:00
REQUEST=
fi
if [ "$MAINTAINERMODE" != "true" -a ! "$PACKAGE" ]; then
2012-09-02 13:18:52 +02:00
echo "<editor> </editor>"
echo "<editcontrols> </editcontrols>"
echo "<operationpanel> </operationpanel>"
fi
if [ "$SPECTEXT" ]; then
# save specfile
tmpfile=`mktemp`
echo -n $SPECTEXT | perl -MURI::Escape -e 'print uri_unescape(<>)' > $tmpfile
chmod 644 $tmpfile
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cat $tmpfile > $PACKAGE.spec" $tmpfile
rm -f $tmpfile
fi
if [ "$REQUEST" = "edit" -o "$REQUEST" = "prepare" ]; then
social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"is working on <b>$PACKAGE</b>\" STIME=`date +%s`"
fi
2012-09-02 13:18:52 +02:00
# Here requests which update the specfile, so editor is refreshed after
if [ "$REQUEST" = "prepare" -o "$REQUEST" = "updatespec" -o "$REQUEST" = "speccreate" -o \
"$REQUEST" = "rebuildspec" -o "$REQUEST" = "renamespec" ]; then
echo -n "<output><![CDATA[<div align=left class=output id=outputbottom>"
echo -n "<pre>"
RET=255
case $REQUEST in
"prepare") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a1 --server $REPOSITORY"; RET=$? ;;
"updatespec") if [ "$UPDATESSPECVERSION" -a "$REBUILDSPECCHANGELOG" ]; then
echo "ERROR: new version and changelog can't be specified together"
elif [ "$REBUILDSPECCHANGELOG" ]; then
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a4 --rebuild --changelog \"$REBUILDSPECCHANGELOG\""
elif [ "$UPDATESSPECVERSION" ]; then
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a3,4 $UPDATESPECVERSION"
else
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a2:4 $UPDATESPECVERSION"
fi
RET=$? ;;
"speccreate") if [ "$SPECCREATEURL" -a "$PACKAGE" ]; then
AUTOSPEC_CMDLINE="-n $PACKAGE -o $PACKAGE.spec"
#DECODEDURL=`cgi_decodevar $SPECCREATEURL`
[ "$SPECCREATETYPE" ] && AUTOSPEC_CMDLINE="$AUTOSPEC_CMDLINE -t $SPECCREATETYPE"
[ "$SPECCREATEVERSION" ] && AUTOSPEC_CMDLINE="$AUTOSPEC_CMDLINE -v $SPECCREATEVERSION"
$SUDO_WRAPPER $ENVIRONMENT "" "autospec -s \"$SPECCREATEURL\" $AUTOSPEC_CMDLINE"
RET=$?
[ $REQ -eq 0 ] && social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"is working on <b>$PACKAGE</b> new package\" STIME=`date +%s`"
2012-09-02 13:18:52 +02:00
# --changelog \"package created by $USER from autodist webbuild interface\""
else
echo "ERROR: both source archive URL and name are needed."
RET=1
fi
;;
"renamespec") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "mv $RENAMESPECFROM.spec $PACKAGE.spec && sed -i \"s|\(Name:[[:space:]]*\).*|\1$PACKAGE|\" $PACKAGE.spec"
RET=$?
[ $REQ -eq 0 ] && social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"renamed <b>$RENAMESPECFROM</b> to <b>$PACKAGE</b>\" STIME=`date +%s`"
2012-09-02 13:18:52 +02:00
;;
esac
echo -n "</pre>"
if [ $RET -eq 0 ]; then
echo "Result: <font color=green><b>OK</b></font>"
else
echo "Result: <font color=red><b>ERROR ($RET)</b></font>"
fi
echo -n "</div>"
echo -n "]]></output>"
REQUEST="edit"
fi
if [ "$MAINTAINERMODE" = "true" -a "$REPOSITORY" != "" ]; then
if [ ! "$REQUEST" -o "$REQUEST" = "changerepository" -o \
"$REQUEST" = "switchmaintainermode" -o "$REQUEST" = "reloadmaintainer" ]; then
echo -n "<editcontrols> </editcontrols>"
echo -n "<operations> </operations>"
echo -n "<editor><![CDATA["
echo -n "<div class=maintainer>"
echo -n "<b>Recent packages in $REPOSITORY:</b><br>"
cat $local_ftp/distromatic/$REPOSITORY/_recent.inc
echo -n "<br><b>Log:</b><br><pre>"
cat $local_ftp/$REPOSITORY/distromatic.log
echo -n "</pre></div>"
echo -n "<input type=button id=updatespecbutton value=\"refresh\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
echo -n "MAINTAINERMODE=$MAINTAINERMODE&REQUEST=reloadmaintainer\");>"
echo -n "]]></editor>"
fi
2012-09-02 13:18:52 +02:00
fi
if [ "$REQUEST" = "edit" -o "$REQUEST" = "reloadspec" -o "$REQUEST" = "switchmaintainermode" -a "$MAINTAINERMODE" != "true" ]; then
2012-09-02 13:18:52 +02:00
if [ "$PACKAGE" ]; then
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "ls $PACKAGE.spec"
[ $? -eq 0 ] && SPECAVAILABLE=1
fi
if [ "$SPECAVAILABLE" ]; then
echo -n "<editcontrols><![CDATA["
echo -n "<br><input type=button id=updatespecbutton value=\"update\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
2012-09-02 13:18:52 +02:00
echo -n "REQUEST=updatespec&UPDATESPECVERSION=\"+getElementById('updatespecversion').value+\"&"
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 changelog for a new release:<input type=text id=rebuildspecchangelog value=\"$REBUILDSPECCHANGELOG\" size=\"40\">)"
2012-09-02 13:18:52 +02:00
echo -n "]]></editcontrols>"
echo -n "<editor><![CDATA[Current <b>$PACKAGE.spec</b> in build environment:<textarea id=spectext "
2012-09-02 13:18:52 +02:00
echo -n "onkeyup=\"getElementById('savebutton').disabled=false;getElementById('savebutton').class='redbutton';\" class=editor>"
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cat $PACKAGE.spec"
echo -n "</textarea>"
echo -n "<input type=button id=savebutton value=\"save\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
2012-09-02 13:18:52 +02:00
echo -n "REQUEST=savespec&SPECTEXT=\"+encodeURIComponent(editor.getValue()));"
echo -n "this.disabled=true; disabled=disabled class=redbutton>"
echo -n "<input type=button id=updatespecbutton value=\"reload\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
2012-09-02 13:18:52 +02:00
echo -n "REQUEST=reloadspec\");>"
echo -n "<input type=button id=updatespecbutton value=\"rename to:\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&RENAMESPECFROM=$PACKAGE&"
echo -n "REQUEST=renamespec&PACKAGE=\"+encodeURIComponent(getElementById('specnewname').value));>"
2012-09-02 13:18:52 +02:00
echo -n "<input type=text id=specnewname value=\"\" size=\"10\">.spec"
echo -n "]]></editor>"
echo -n "<operationpanel><![CDATA["
echo -n "Package: <b>$PACKAGE</b>"
echo -n "<br>Target arch:<select id=rpmbuildarch>"
for f in i586 arm x86_64 ppc; do
SELECTED=
if [ ! "$RPMBUILDARCH" -a "$f" = "${AUTOPORT_ARCH[$ENVIRONMENT]}" ]; then
SELECTED="selected=\"selected\"";
fi
echo -n "<option value=\"$f\" $SELECTED>$f</option>"
done
echo -n "</select>"
echo -n "<label><input type=checkbox id=\"rpmforce\" value=\"force\">force</label>"
# destination repository select
echo -n "<br>Send to:"
echo -n "<select id=sendrepository>"
for f in `$SUDO_WRAPPER local "" "/usr/sbin/openmamba-repository list"`; do
repname=`basename $f`
if [ "$repname" = "devel-${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}" -o \
"$repname" = "${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]}" -o \
"$repname" = "devel-$USER" -o \
"$USER_ALLREPOSITORIES" ]; then
SELECTED=
if [ "$SENDREPOSITORY" = "$repname" ]; then
SELECTED="selected=\"selected\"";
elif [ ! "$SENDREPOSITORY" -a "${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]}" = "$repname" ]; then
SELECTED="selected=\"selected\"";
fi
echo -n "<option value=\"$repname\" $SELECTED>$repname</option>"
fi
done
echo -n "</select><br>"
[ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" -o "$STATE_ADVANCEDCONTROLS" ] && echo -n "<hr><b>Autodist automatic builds:</b><br>"
if [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then
echo -n "Patch:<input type=button value=\"show\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=showpatch\");>"
echo -n "<input type=button value=\"remove\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=removepatch\"); class=redbutton>"
echo -n "<input type=button id=updatepatchbutton value=\"update\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&"
echo -n "REQUEST=updatepatch\"); class=redbutton>"
echo -n "<input type=button id=buildpatchbutton value=\"build\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&"
echo -n "REQUEST=buildpatch\"); class=redbutton>"
# autodist schedule
echo -n "<br>Schedule:<input type=button value=\"show\" onclick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=showscheduled\");>"
# autodist unschedule
echo -n "<input type=button value=\"unschedule\" onclick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=unschedule\"); class=redbutton>"
# autodist skip
echo -n "<input type=button value=\"skip\" onclick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=skip\"); class=redbutton><br>"
fi
if [ "$STATE_ADVANCEDCONTROLS" ]; then
# autodist list-jobs
echo -n "Job:<select id=autodistjobs>"
echo -n "<option value=\"$PACKAGEENCODED\">$PACKAGE</option>"
for f in `$SUDO_WRAPPER $ENVIRONMENT "" "autodist --list-jobs"`; do
[ "$AUTODISTJOB" = "$f" ] && SELECTED="selected=\"selected\"" || SELECTED=
JOBENCODED=`cgi_encodevar $f`
echo -n "<option value=\"$JOBENCODED\" $SELECTED>$f</option>"
done
echo -n "</select>"
# autodist prepare
echo -n "<br><input type=button value=\"prepare\" onclick=javascript:"
echo -n "ajax_getvalues(\""
echo -n "AUTODISTFORCE=\"+getElementById('rpmforce').checked+\"&"
echo -n "AUTODISTARCH=\"+getSelectedValueById('rpmbuildarch')+\"&"
echo -n "AUTODISTJOB=\"+getSelectedValueById('autodistjobs')+\"&"
echo -n "ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&REQUEST=autodistprepare\");>"
# autodist update
echo -n "<input type=button value=\"update\" onclick=javascript:"
echo -n "ajax_getvalues(\""
echo -n "AUTODISTFORCE=\"+getElementById('rpmforce').checked+\"&"
echo -n "AUTODISTARCH=\"+getSelectedValueById('rpmbuildarch')+\"&"
echo -n "AUTODISTJOB=\"+getSelectedValueById('autodistjobs')+\"&"
echo -n "ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&REQUEST=autodistupdate\");>"
# autodist build
2012-09-02 13:18:52 +02:00
echo -n "<input type=button value=\"build\" onclick=javascript:"
echo -n "ajax_getvalues(\""
echo -n "AUTODISTFORCE=\"+getElementById('rpmforce').checked+\"&"
echo -n "AUTODISTARCH=\"+getSelectedValueById('rpmbuildarch')+\"&"
echo -n "AUTODISTJOB=\"+getSelectedValueById('autodistjobs')+\"&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&"
echo -n "ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&REQUEST=autodistbuild\"); class=boldbutton>"
# autodist install
[ ! "$USER_CANINSTALL" ] && DISABLED="disabled=disabled" || DISABLED=
echo -n "<input type=button value=\"install\" onclick=javascript:"
echo -n "ajax_getvalues(\""
echo -n "AUTODISTFORCE=\"+getElementById('rpmforce').checked+\"&"
echo -n "AUTODISTARCH=\"+getSelectedValueById('rpmbuildarch')+\"&"
echo -n "AUTODISTJOB=\"+getSelectedValueById('autodistjobs')+\"&"
echo -n "ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&REQUEST=autodistinstall\"); class=redbutton $DISABLED>"
# autodist send
[ ! "$USER_ALLREPOSITORIES" ] && DISABLED="disabled=disabled" || DISABLED=
echo -n "<input type=button value=\"send\" onclick=javascript:"
echo -n "ajax_getvalues(\""
echo -n "AUTODISTFORCE=\"+getElementById('rpmforce').checked+\"&"
echo -n "AUTODISTARCH=\"+getSelectedValueById('rpmbuildarch')+\"&"
echo -n "AUTODISTJOB=\"+getSelectedValueById('autodistjobs')+\"&"
echo -n "SENDREPOSITORY=\"+getSelectedValueById('sendrepository')+\"&"
echo -n "ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&REQUEST=autodistsend\"); class=redbutton $DISABLED>"
# autodist force checkbox
2012-09-02 13:18:52 +02:00
fi
if [ "$STATE_ADVANCEDCONTROLS" -o "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then
# autodist logs
echo -n "<hr><b>Last autodist logs:</b> "
echo -n "OK <input id=\"logstatusOK\" type=\"radio\" name=\"logstatus\" value=\"OK\"> "
echo -n "FAILED<input type=\"radio\" name=\"logstatus\" value=\"FAILED\" checked=\"checked\"><br>"
echo -n "<input type=button value=\"prepare\" onclick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=showlog&LOGTYPE=prepare&LOGSTATUSOK=\"+document.all.logstatusOK.checked);>"
echo -n "<input type=button value=\"update\" onclick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=showlog&LOGTYPE=update&LOGSTATUSOK=\"+document.all.logstatusOK.checked);>"
echo -n "<input type=button value=\"build\" onclick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=showlog&LOGTYPE=build&LOGSTATUSOK=\"+document.all.logstatusOK.checked);>"
echo -n "<input type=button value=\"install\" onclick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=showlog&LOGTYPE=install&LOGSTATUSOK=\"+document.all.logstatusOK.checked);>"
echo -n "<input type=button value=\"send\" onclick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=showlog&LOGTYPE=send&LOGSTATUSOK=\"+document.all.logstatusOK.checked);>"
fi
echo -n "<hr><b>RPM packaging commands:</b><br>"
# check for updates
echo -n "<input type=button value=\"check for updates\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=autospecupdatescheck\");>"
# unpack
echo -n "<input type=button value=\"unpack\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=rpmprepare&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue()));>"
# build
echo -n "<input type=button value=\"build\" onclick=javascript:"
echo -n "i=getElementById('rpmbuildarch').selectedIndex;"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=rpmbuild&"
echo -n "RPMBUILDARCH=\"+getElementById('rpmbuildarch').options[i].value+\"&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&RPMFORCE=\"+getElementById('rpmforce').checked); class=boldbutton>"
# buildroot files
echo -n "<input type=button value=\"buildroot files\" onclick=javascript:"
echo -n "i=getElementById('rpmbuildarch').selectedIndex;"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=buildrootfiles\");>"
# unpackaged files
echo -n "<input type=button value=\"unpackaged files\" onclick=javascript:"
echo -n "i=getElementById('rpmbuildarch').selectedIndex;"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=autospeclistcheck&"
echo -n "RPMBUILDARCH=\"+getElementById('rpmbuildarch').options[i].value+\"&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue()));>"
# build requirements
echo -n "<input type=button value=\"build requirements\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=autospecbuildreq\");>"
# recreate SRPM
echo -n "<input type=button value=\"recreate SRPM\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=srpmbuild&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&RPMFORCE=\"+getElementById('rpmforce').checked);>"
# rpm checks
echo -n "<input type=button id=rpmchecks value=\"checks\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=rpmchecks\");>"
echo -n "<input type=button id=rpmsimulateinstallbutton value=\"simulate install\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=rpmsimulateinstall\");>"
# rpm install
[ ! "$USER_CANINSTALL" ] && DISABLED="disabled=disabled"
echo -n "<input type=button id=rpminstallbutton value=\"install\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=rpminstall&"
echo -n "RPMFORCE=\"+getElementById('rpmforce').checked); class=redbutton $DISABLED>"
# send
echo -n "<input type=button id=sendpackagebutton value=\"send\" onclick=javascript:"
echo -n "i=getElementById('sendrepository').selectedIndex;"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=sendpackage&"
echo -n "SENDREPOSITORY=\"+getElementById('sendrepository').options[i].value); class=redbutton>"
# recreate and send SRPM
echo -n "<input type=button id=sendsourcebutton value=\"recreate and send SRPM\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=sendsource&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&"
echo -n "SENDREPOSITORY=\"+getSelectedValueById('sendrepository')); class=redbutton>"
# add patches
echo -n "<hr><b>Add patches:</b>"
echo -n "<input type=button id=addpatchbutton value=\"submit\" onclick=javascript:ajax_getvalues(\""
echo -n "REQUEST=addpatch&ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
echo -n "ADDPATCHURL=\"+encodeURIComponent(getElementById('addpatchurl').value)+\"&"
echo -n "ADDPATCHNAME=\"+encodeURIComponent(getElementById('addpatchname').value));><br>"
echo -n "URL:<input type=text id=addpatchurl value=\"\" size=\"28\">"
echo -n "As: $PACKAGE-<input type=text id=addpatchname value=\"\" size=\"13\">.patch"
# fi
# if [ "$USER_CANMAINTAIN" -a "$PACKAGE" ]; then
# echo -n "<input type=button value=\"archive\" onclick=javascript:"
# echo -n "i=getElementById('sendrepository').selectedIndex;"
# echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
# echo -n "MAINTAINERMODE=\"+getElementById('maintain').checked+\"&"
# echo -n "SENDREPOSITORY=\"+getElementById('sendrepository').options[i].value+\"&"
# echo -n "REPOSITORYSIMULATE=\"+getElementById('repositorysimulate').checked+\"&"
# echo -n "REQUEST=repositoryarchive\"); class=redbutton>"
# echo -n "<label><input type=checkbox id=\"repositorysimulate\" value=\"simulate\">simulate</label>"
# fi
if [ ! "${AUTOPORT_DISABLE[$ENVIRONMENT]}" -a ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then
echo -n "<hr>Automatic port:<br>"
echo -n "<input type=button id=autoportnp value=\"port\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=autoportnp\"); class=boldbutton>"
echo -n "<input type=button id=autoportlog value=\"log\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=autoportlog\");>"
2012-09-02 13:18:52 +02:00
fi
echo -n "<hr><b>Info from package sources:</b><br>"
echo -n "<input type=button value=\"builddir files\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=builddirfiles\");>"
echo -n "<input type=button value=\"changelog(s)\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=showchangelogs\");>"
echo -n "<input type=button value=\"build docs\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=showbuilddocs\");>"
echo -n "<input type=button value=\"license(s)\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=showlicenses\");>"
echo -n "<input type=button value=\"configure help\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=configurehelp\");>"
echo -n "<hr><b>Generic info:</b><br>"
echo -n "<input type=button value=\"allowed groups\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=allowedgroups\");>"
echo -n "<input type=button value=\"approved licenses\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=approvedlicenses\");>"
echo -n "<div style=\"nowrap;\"><input type=button value=\"macros:\" onclick=javascript:"
echo -n "i=getElementById('macrosfile').selectedIndex;"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=showmacrosfile&"
echo -n "MACROSFILE=\"+getElementById('macrosfile').options[i].value);>"
echo -n "<select id=macrosfile>"
for f in $WORKINGROOT/etc/rpm/macros.*; do
macrosfilename=`basename $f`
macrosfile=`echo $macrosfilename | sed "s|macros\.||"`
echo -n "<option value=\"$macrosfile\">$macrosfile</option>"
done
echo -n "</select></div>"
# broadcast message
2012-09-02 13:18:52 +02:00
echo -n "<hr><b>Broadcast message:</b><br>"
echo -n "<input type=text id=broadcastmessage size=\"25\">"
echo -n "<input type=button value=\"send\" onClick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
2012-09-02 13:18:52 +02:00
echo -n "REQUEST=broadcastmessage&BROADCASTMESSAGE=\"+encodeURIComponent(getElementById('broadcastmessage').value));"
echo -n "getElementById('broadcastmessage').value=\"\";>"
echo -n "]]></operationpanel>"
else
echo "<output><![CDATA[<div align=left class=output id=outputtop>"
echo "No pre-existing .spec file $PACKAGE.spec in current working environment. Choose package from a repository and press 'Unpack and edit' to edit."
2012-09-02 13:18:52 +02:00
echo -n "</div>"
echo -n "]]></output>"
fi
else
if [ "$REQUEST" != "" ]; then
echo -n "<output><![CDATA["
echo -n "<div align=left class=output "
2012-09-02 13:18:52 +02:00
if [ "$REQUEST" = "rpmbuild" -o "$REQUEST" = "autoportnp" -o "$REQUEST" = "rpmprepare" \
-o "$REQUEST" = "sendpackage" -o "$REQUEST" = "sendsource" -o "$REQUEST" = "autospeclistcheck" \
-o "$REQUEST" = "autodistprepare" -o "$REQUEST" = "autodistupdate" -o "$REQUEST" = "autodistbuild" \
-o "$REQUEST" = "autodistinstall" -o "$REQUEST" = "autodistsend" ]; then
echo -n "id=outputbottom>"
2012-09-02 13:18:52 +02:00
else
echo -n "id=outputtop>"
fi
if [ "$REQUEST" != "showchangelogs" -a "$REQUEST" != "showbuilddocs" -a "$REQUEST" != "showlicenses" ]; then
echo -n "<pre><!-- SCROLL -->"
2012-09-02 13:18:52 +02:00
fi
RET=255
fi
case $REQUEST in
"showpatch") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool makepatch $PACKAGE"; RET=$? ;;
"removepatch") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool makepatch $PACKAGE remove"
RET=$?
if [ $RET -eq 0 ]; then
social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"removed the autodist patch for <b>$PACKAGE</b>\" STIME=`date +%s`"
2012-09-02 13:18:52 +02:00
fi ;;
"updatepatch") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool makepatch $PACKAGE update"
RET=$?
if [ $RET -eq 0 ]; then
social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"made an autodist <b>update</b> patch for <b>$PACKAGE</b>\" STIME=`date +%s`"
2012-09-02 13:18:52 +02:00
fi ;;
"buildpatch") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool makepatch $PACKAGE build"
RET=$?
if [ $RET -eq 0 ]; then
social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"made an autodist <b>build</b> patch for <b>$PACKAGE</b>\" STIME=`date +%s`"
2012-09-02 13:18:52 +02:00
fi ;;
"showscheduled") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool schedule"; RET=$? ;;
"unschedule") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool unschedule $PACKAGE"
RET=$?
if [ $RET -eq 0 ]; then
social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"unscheduled autodist job <b>$PACKAGE</b>\" STIME=`date +%s`"
2012-09-02 13:18:52 +02:00
fi ;;
"skip") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool skip $PACKAGE"
RET=$?
if [ $RET -eq 0 ]; then
social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"added autodist job <b>$PACKAGE</b> to skipped list\" STIME=`date +%s`"
2012-09-02 13:18:52 +02:00
fi ;;
"autodistprepare") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -v -p $AUTODISTJOB --arch $AUTODISTARCH $AUTODISTADD"
RET=$? ;;
"autodistupdate") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -v -u $AUTODISTJOB --arch $AUTODISTARCH $AUTODISTADD"
RET=$? ;;
"autodistbuild") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -v -b $AUTODISTJOB --arch $AUTODISTARCH $AUTODISTADD"
RET=$?
[ $RET -eq 0 ] && social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"successfully built <b>$PACKAGE</b>\" STIME=`date +%s`"
;;
"autodistinstall") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -v -i $AUTODISTJOB --arch $AUTODISTARCH $AUTODISTADD"
RET=$? ;;
"autodistsend") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist -v -s $AUTODISTJOB --server $SENDREPOSITORY --arch $AUTODISTARCH $AUTODISTADD"
RET=$?
[ $RET -eq 0 ] && social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"sent <b>$PACKAGE</b> to <b>$SENDREPOSITORY</b>\" STIME=`date +%s`"
;;
2012-09-02 13:18:52 +02:00
"buildrootfiles") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cd @RPMBUILDROOT@ && find @BUILDROOT@"; RET=$? ;;
"autospecupdatescheck") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a2"; RET=$? ;;
"rpmprepare") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "rpmbuild -bp $PACKAGE.spec"; RET=$? ;;
"rpmbuild") echo "`date` - RPMBUILD=$PACKAGE USER=$USER ENVIRONMENT=$ENVIRONMENT" >> $WEBBUILD_STATEDIR/buildingnow_log
2012-09-02 13:18:52 +02:00
[ "$RPMFORCE" = "true" ] && RPMFORCEADD="--force-build"
[ "$RPMBUILDARCH" -a "$RPMBUILDARCH" != "${AUTOPORT_ARCH[$ENVIRONMENT]}" ] && \
RPMARCHADD="-A $RPMBUILDARCH --define \"cross_target_cpu=$RPMBUILDARCH\""
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a5 $RPMFORCEADD $RPMARCHADD"
RET=$?
if [ $RET -eq 0 ]; then
social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"successfully built <b>$PACKAGE</b>\" STIME=`date +%s`"
2012-09-02 13:18:52 +02:00
fi
sed -i "|RPMBUILD=$PACKAGE USER=$USER ENVIRONMENT=$ENVIRONMENT|d" $WEBBUILD_STATEDIR/buildingnow_log
2012-09-02 13:18:52 +02:00
;;
"srpmbuild") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "rpmbuild -bs $PACKAGE.spec"
RET=$? ;;
"autospeclistcheck")
[ "$RPMBUILDARCH" -a "$RPMBUILDARCH" != "${AUTOPORT_ARCH[$ENVIRONMENT]}" ] && \
RPMARCHADD="-A $RPMBUILDARCH --define \"cross_target_cpu=$RPMBUILDARCH\""
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a5 --list-check $RPMARCHADD"
RET=$? ;;
"autospecbuildreq") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a6"
RET=$? ;;
"rpmchecks") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a8"; RET=$? ;;
"rpmsimulateinstall") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a7"; RET=$? ;;
"rpminstall") if [ "$USER_CANINSTALL" ]; then
[ "$RPMFORCE" = "true" ] && RPMFORCEADD="--force-install"
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a11 $RPMFORCEADD"; RET=$?
else
echo "Install function disabled."
RET=1
fi ;;
"addpatch") if [ "$ADDPATCHURL" -a "$ADDPATCHNAME" ]; then
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "curl -s \"$ADDPATCHURL\" -o ../SOURCES/$PACKAGE-$ADDPATCHNAME.patch"
2012-09-02 13:18:52 +02:00
RET=$?
[ $RET -eq 0 ] && echo "Patch added with name $PACKAGE-$ADDPATCHNAME.patch"
else
echo "Patch URL or destination name not provided."
RET=1
fi ;;
"sendpackage") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a10 --server $SENDREPOSITORY"
RET=$?
if [ $RET -eq 0 ]; then
social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"sent <b>$PACKAGE</b> to <b>$SENDREPOSITORY</b>\" STIME=`date +%s`"
2012-09-02 13:18:52 +02:00
fi ;;
"sendsource") [ "$RPMFORCE" = "true" ] && RPMFORCEADD="--force --nodeps"
if [ "$SENDREPOSITORY" ]; then
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "rpmbuild -bs $PACKAGE.spec $RPMFORCEADD && autospec -u $PACKAGE -a10 --server $SENDREPOSITORY --norpm"
RET=$?
else
echo "ERROR: send repository is not defined."
RET=255
fi ;;
2012-09-02 13:18:52 +02:00
"repositoryimport")
for p in $PACKAGES; do
[ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANMAINTAIN" ] && SIMULATEADD="-s" || SIMULATEADD=
$SUDO_WRAPPER local "$PACKAGE" "openmamba-repository import $SENDREPOSITORY $p -d $REPOSITORYIMPORTTO $SIMULATEADD -y"
RET=$?
if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then
social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"imported <b>$p</b> from <b>$SENDREPOSITORY</b> to <b>$REPOSITORYIMPORTTO</b>\" STIME=`date +%s`"
fi
[ $RET -eq 0 ] || break
done
2012-09-02 13:18:52 +02:00
;;
"repositoryrelease")
for p in $PACKAGES; do
[ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANMAINTAIN" ] && SIMULATEADD="-s" || SIMULATEADD=
$SUDO_WRAPPER local "$PACKAGE" "openmamba-repository release $SENDREPOSITORY $p -d $REPOSITORYIMPORTTO $SIMULATEADD -y"
RET=$?
if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then
social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"released <b>$p</b> from <b>$SENDREPOSITORY</b> to <b>$REPOSITORYIMPORTTO</b>\" STIME=`date +%s`"
fi
[ $RET -eq 0 ] || break
done
2012-09-02 13:18:52 +02:00
;;
"repositorydiff")
for p in $PACKAGES; do
$SUDO_WRAPPER local "" "openmamba-repository diff $SENDREPOSITORY $p -d $REPOSITORYIMPORTTO"
RET=$?
[ $RET -eq 0 ] || break
done
2012-09-02 13:18:52 +02:00
;;
"repositoryarchive")
for p in $PACKAGES; do
[ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANMAINTAIN" ] && SIMULATEADD="-s" || SIMULATEADD=
$SUDO_WRAPPER local "$PACKAGE" "openmamba-repository archive $SENDREPOSITORY $p -y"
RET=$?
if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then
social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"archived <b>$p</b> from <b>$SENDREPOSITORY</b>\" STIME=`date +%s`"
fi
[ $RET -eq 0 ] || break
done
2012-09-02 13:18:52 +02:00
;;
"autoportnp") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autoport -np $PACKAGE"; RET=$? ;;
"autoportlog") cat "$AUTOPORTLOGDIR/current.log"; RET=$? ;;
"allowedgroups") $SUDO_WRAPPER $ENVIRONMENT "" "autospec --eval rpm_allowed_groups"; RET=$? ;;
"approvedlicenses") $SUDO_WRAPPER $ENVIRONMENT "" "autospec --eval rpm_approved_licenses | grep -v \"^#\"" | \
while read line; do
echo $line
done
RET=0
;;
"builddirfiles") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cd @RPMBUILDDIR@ && find @BUILDDIR@"; RET=$? ;;
"showchangelogs"|"showbuilddocs"|"showlicenses")
if [ "$REQUEST" = "showchangelogs" ]; then
PATTERN="-iname changelog -or -iname news -and -type f"
elif [ "$REQUEST" = "showlicenses" ]; then
PATTERN="-iname license\* -or -iname copying\* -or -iname authors\* -and -type f"
elif [ "$REQUEST" = "showbuilddocs" ]; then
PATTERN="-iname readme\* -or -iname install\* -or -iname todo\* -or -iname pkgbuild\* -and -type f"
fi
files=`$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cd @RPMBUILDDIR@/@BUILDDIR@ && find . $PATTERN -maxdepth 2"`
cnt=0
for f in $files; do
echo -n "<a href=#logfile-$f>$f</a><br>"
done
echo -n "<br>"
for f in $files; do
echo -n "<a name=logfile-$f><p><b>File $f:</b></a><pre>"
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cd @RPMBUILDDIR@/@BUILDDIR@ && cat $f"
RET=$?
echo -n "</pre>"
done
;;
2012-09-02 13:18:52 +02:00
"configurehelp") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cd @RPMBUILDDIR@/@BUILDDIR@ && ./configure --help"; RET=$? ;;
"showmacrosfile") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cat /etc/rpm/macros.$MACROSFILE"; RET=$? ;;
*) RET=0 ;;
esac
if [ "$REQUEST" != "" ]; then
if [ "$REQUEST" != "showchangelogs" -a "$REQUEST" != "showbuilddocs" -a "$REQUEST" != "showlicenses" ]; then
echo -n "<!-- ENDSCROLL --></pre>"
fi
2012-09-02 13:18:52 +02:00
if [ $RET -eq 0 ]; then
echo "Result: <font color=green><b>OK</b></font>"
else
echo "Result: <font color=red><b>ERROR ($RET)</b></font>"
fi
echo -n "</div>"
echo -n "]]></output>"
fi
fi
if [ "$MAINTAINERMODE" = "true" ]; then
echo -n "<packages> </packages>"
echo -n "<operationpanel><![CDATA["
if [ "$REPOSITORY" ]; then
echo -n "<b>Repository maintenance:</b><br>"
# echo -n "<select multiple size=8 id=package onchange=javascript:"
# echo -n "i=getElementById('repository').selectedIndex;ajax_getvalues(\"REQUEST=edit&"
# echo -n "ENVIRONMENT=$ENVIRONMENT&MAINTAINERMODE=\"+getElementById('maintain').checked+\"&"
# echo -n "PACKAGE=\"+encodeURIComponent(this.value)+\"&"
# echo -n "REPOSITORY=\"+getElementById('repository').options[i].text);>"
# echo "<option value=\"\">-- Select a SRPM package --</option>"
echo -n "<div class=multiselect>"
for f in $local_ftp/$REPOSITORY/SRPMS.base/*.src.rpm; do
[ -r $f ] || continue
pkgname=`basename $f`
pkgname=${pkgname/.src.rpm}
pkgrel=${pkgname/*-}
pkgname=${pkgname/-$pkgrel}
pkgver=${pkgname/*-}
pkgname=${pkgname/-$pkgver}
if [ "$PACKAGE" = "$pkgname" ]; then
SELECTED="selected=\"selected\"";
# REQUEST="changesrpm"
else
SELECTED=
fi
echo -n "<label><input type=checkbox name=packagescheckbox value=\"$pkgname\" $SELECTED>${pkgname} ${pkgver}-${pkgrel}</label>"
done
echo -n "</div>"
echo -n "Origin: <b>$REPOSITORY</b><br>"
echo -n "Destination: "
echo -n "<select id=repositoryimportto>"
if [ "${REPOSITORY:0:10}" = "milestone2" ]; then
IMPORT_REPOSITORIES=$AUTOPORT_MILESTONE2_IMPORT_REPOSITORIES
else
IMPORT_REPOSITORIES=$AUTOPORT_DEVEL_IMPORT_REPOSITORIES
fi
for f in $IMPORT_REPOSITORIES; do
[ "$f" != "$REPOSITORY" ] && echo -n "<option value=\"$f\">$f</option>"
done
echo -n "</select><br>"
# repository compare
echo -n "<input type=button value=\"compare\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&"
echo -n "PACKAGES=\"+encodeURIComponent(getCheckedValuesByName('packagescheckbox'))+\"&"
echo -n "MAINTAINERMODE=\"+getElementById('maintain').checked+\"&"
echo -n "REPOSITORYIMPORTTO=\"+getSelectedValueById('repositoryimportto')+\"&"
echo -n "REPOSITORYSIMULATE=\"+getElementById('repositorysimulate').checked+\"&"
echo -n "SENDREPOSITORY=$REPOSITORY&REQUEST=repositorydiff\");>"
# repository import
echo -n "<input type=button value=\"import\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&"
echo -n "PACKAGES=\"+encodeURIComponent(getCheckedValuesByName('packagescheckbox'))+\"&"
echo -n "MAINTAINERMODE=\"+getElementById('maintain').checked+\"&"
echo -n "REPOSITORYIMPORTTO=\"+getSelectedValueById('repositoryimportto')+\"&"
echo -n "REPOSITORYSIMULATE=\"+getElementById('repositorysimulate').checked+\"&"
echo -n "SENDREPOSITORY=$REPOSITORY&REQUEST=repositoryimport\"); class=redbutton>"
# repository release
echo -n "<input type=button value=\"release\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&"
echo -n "PACKAGES=\"+encodeURIComponent(getCheckedValuesByName('packagescheckbox'))+\"&"
echo -n "MAINTAINERMODE=\"+getElementById('maintain').checked+\"&"
echo -n "REPOSITORYIMPORTTO=\"+getSelectedValueById('repositoryimportto')+\"&"
echo -n "REPOSITORYSIMULATE=\"+getElementById('repositorysimulate').checked+\"&"
echo -n "SENDREPOSITORY=$REPOSITORY&REQUEST=repositoryrelease\"); class=redbutton>"
# repository archive
echo -n "<input type=button value=\"archive\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&"
echo -n "PACKAGES=\"+encodeURIComponent(getCheckedValuesByName('packagescheckbox'))+\"&"
echo -n "MAINTAINERMODE=\"+getElementById('maintain').checked+\"&"
echo -n "SENDREPOSITORY=$REPOSITORY&"
echo -n "REPOSITORYSIMULATE=\"+getElementById('repositorysimulate').checked+\"&"
echo -n "REQUEST=repositoryarchive\"); class=redbutton>"
echo -n "<label><input type=checkbox id=\"repositorysimulate\" value=\"simulate\">simulate</label>"
fi
echo -n "]]></operationpanel>"
fi
2012-09-02 13:18:52 +02:00
#if [ ! "$REQUEST" -o "$REQUEST" = "output" ]; then
# echo -n "<output><![CDATA["
#
# echo "Show: [<a href=\"?NUM=\">All hosts</a>] [<a href=\"?SHOWLOG=monitor\">Build hosts monitor</a>]<br>"
# for h in `seq 0 ${#AUTOPORT_CGI_HOST[*]}`; do
# curl "${AUTOPORT_CGI_HOST[$h]}?AS_HOST=$h&SHOWINDEX=1" 2>/dev/null
# done
# echo "<hr>"
#
# [ "$HOST" = "$AS_HOST" ] && echo "<h2>Host: `hostname -s` (`uname -m`, kernel `uname -r`)</h2>"
#
# echo -n "]]></output>"
#fi
echo "</webbuild>"