webbuild: support automatic local environments when none is set in configuration

This commit is contained in:
Silvan Calarco 2013-05-23 13:02:22 +02:00
parent 19233fce7d
commit 9cfdccccc0
2 changed files with 29 additions and 2 deletions

View File

@ -3,7 +3,6 @@
# webbuild cgi script
# Copyright (c) 2012-2013 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
. /etc/sysconfig/autoport
. /usr/share/autodist/webbuild-functions
. /usr/share/autodist/webbuild-functions-private
@ -20,6 +19,9 @@ if [ "$REQUEST" != "refresh" ]; then
echo "`date` - USER=$USER&REQUEST=$REQUEST&ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&MAINTAINERMODE=$MAINTAINERMODE" >> $LOG
fi
# read configuration after cgi_getvars to prevent variables overriding
. /etc/sysconfig/autoport
echo -e "Content-type: text/xml\nPragma: no-cache\n"
echo -n "<webbuild>"
@ -29,6 +31,7 @@ USER_ADMIN=
USER_CANMAINTAIN=
USER_CANSENDMESSAGES=
USER=${USER/.*\/}
if [ "$REMOTE_ADDR" = "127.0.0.1" -a "$USER" = "" ]; then
USER=admin
fi
@ -251,6 +254,26 @@ fi
# Enabled users requests
#
rm -f $WEBBUILD_STATEDIR/cache/config-dynamic
if [ "${#AUTOPORT_ARCH[*]}" = "0" ]; then
LOCAL_PACKAGER_USERS=`getent group packager | cut -d: -f4 | tr , ' '`
LOCAL_ARCH=`uname -m`
case $LOCAL_ARCH in
i386|i486|i686|athlon) LOCAL_ARCH="i586" ;;
esac
i=0
for u in $LOCAL_PACKAGER_USERS; do
cat >> $WEBBUILD_STATEDIR/cache/config-dynamic << _EOF
AUTOPORT_DISABLE[$i]=1
AUTOPORT_CHROOT_USER[$i]=$u
AUTOPORT_NATIVE[$i]=1
AUTOPORT_ARCH[$i]="$LOCAL_ARCH"
_EOF
i=$((i + 1))
done
. $WEBBUILD_STATEDIR/cache/config-dynamic
fi
# delete a note
if [ "$REQUEST" = "removenote" ]; then
if [ "$USER" = "$NOTEUSER" -o "$USER_ADMIN" ]; then
@ -463,6 +486,7 @@ if [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then
elif [ "${AUTOPORT_NATIVE[$ENVIRONMENT]}" ]; then
WORKINGROOT="/"
WORKINGHOME=`getent passwd ${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} | cut -d: -f6`
[ -e "$WORKINGHOME/RPM" ] || WORKINGHOME="/usr/src/"
BUILDLOGDIR="/home/${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}/.autodist/log/"
AUTOPORTLOGDIR="/home/${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}/.autoport/${AUTOPORT_ARCH[$ENVIRONMENT]}/"
else
@ -558,7 +582,7 @@ elif [ ! "$REQUEST" -o "$REQUEST" = "changeenvironment" -o "$REQUEST" = "switchm
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 | sed \"s|.spec$||\" | sort -f" | while read f; do
$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "ls *.spec 2>/dev/null| sed \"s|.spec$||\" | sort -f" | while read f; do
specname=${f/.spec}
[ "$PACKAGE" = "$specname" ] && SELECTED="selected=\"selected\"" || SELECTED=
echo -n "<option value=\"$specname\" $SELECTED>${specname}</option>"

View File

@ -9,6 +9,8 @@ PACKAGE=$4
COMMAND=$5
TMPFILE=$6
[ -e $WEBBUILD_STATEDIR/cache/config-dynamic ] && . $WEBBUILD_STATEDIR/cache/config-dynamic
echo "REQUEST: $@" >> $WEBBUILD_STATEDIR/commands_log
if [ "$MODE" = "killtree" ]; then
KILLPID=$2
@ -58,6 +60,7 @@ elif [ "${AUTOPORT_NATIVE[$ENVIRONMENT]}" ]; then
ENVPREFIX=
ENVUSER=${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}
WORKINGHOME=`getent passwd ${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} | cut -d: -f6`
[ -e "$WORKINGHOME/RPM" ] || WORKINGHOME="/usr/src/"
SUCMDPREFIX="su -l ${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} -c"
else
ENVPREFIX=