webbuild: sync with current alpha development with lots of changes and improvements

This commit is contained in:
Silvan Calarco 2012-09-21 12:57:19 +02:00
parent 4021d4f7a1
commit 0601482f54
3 changed files with 559 additions and 271 deletions

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@ function set_user_state_var() {
[ "$1" ] || return
[ -e $WEBBILD_STATEDIR/users/$stateuser.state ] || touch $WEBBUILD_STATEDIR/users/$stateuser.state
[ -e $WEBBUILD_STATEDIR/users/$stateuser.state ] || touch $WEBBUILD_STATEDIR/users/$stateuser.state
sed -i "/^$statevar=/d" $WEBBUILD_STATEDIR/users/$stateuser.state
[ "$statevalue" ] && echo "$statevar=$statevalue" >> $WEBBUILD_STATEDIR/users/$stateuser.state
}
@ -28,7 +28,7 @@ function set_user_state_var() {
function social_log() {
local line=$1
[ "$1" ] || return
[ "$line" ] || return
if [ ! "$STATE_FAKEUSER" ]; then
STATE_SOCIALLOG_ID=0
@ -52,7 +52,7 @@ function cgi_encodevar() {
esac
encoded+="${o}"
done
echo "${encoded}" # You can either set a return variable (FASTER)
echo -n "${encoded}" # You can either set a return variable (FASTER)
# REPLY="${encoded}" #+or echo the result (EASIER)... or both... :p
}

View File

@ -2,18 +2,35 @@
. /usr/share/autodist/webbuild-functions
. /etc/sysconfig/autoport
ENVIRONMENT=$1
PACKAGE=$2
COMMAND=$3
TMPFILE=$4
MODE=$1
ENVIRONMENT=$2
PACKAGE=$3
COMMAND=$4
TMPFILE=$5
if [ "$ENVIRONMENT" = "local" ]; then
if [ "$MODE" = "killtree" ]; then
KILLPID=$2
[ $KILLPID -gt 1 ] && 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
exit $RETCODE
elif [ "$ENVIRONMENT" = "local" ]; then
# echo "Command: $COMMAND"
$COMMAND 2>&1 | sed "s|<|\&lt;|g"
exit 0
fi
if [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then
if [ "$ENVIRONMENT" = "local" ]; then
ENVPREFIX=
ENVUSER=root
WORKINGHOME=
SUCMDPREFIX=
elif [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then
ENVPREFIX="/var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}"
ENVUSER=${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}
WORKINGHOME="/usr/src/"
@ -36,21 +53,23 @@ else
RPMBUILDROOT="/var/tmp/autodist"
[ "$TMPFILE" ] && chown autodist $TMPFILE
fi
eval `$SUCMDPREFIX "autospec --eval=tmppath_dir|grep -v '^#'"`
RPMBUILDROOT=$tmppath_dir
SPECFILE=${ENVPREFIX}${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec
if [ -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
BUILDDIR=`grep -m1 "^%setup.*-n " $SPECFILE.tmp | sed "s|.*-n \([^[:space:]]*\).*|\1|"`
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
rm -f $SPECFILE.tmp
fi
SPECVERSION=`grep -m1 "^Version:" ${SPECFILE} | sed "s|Version:[[:space:]]*||"`
BUILDROOT=$PACKAGE-root
$SUCMDPREFIX "rpm -q --specfile ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec --specedit > ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec.tmp 2>/dev/null"
if [ -e $SPECFILE.tmp ]; then
BUILDDIR=`grep -m1 "^%setup.*-n " $SPECFILE.tmp | sed "s|.*-n \([^[:space:]]*\).*|\1|"`
rm -f $SPECFILE.tmp
fi
SPECVERSION=`grep -m1 "^Version:" ${SPECFILE} | sed "s|Version:[[:space:]]*||"`
BUILDROOT=$PACKAGE-root
#`grep ^BuildRoot: ${_tmpfile} | sed "s|BuildRoot:[[:space:]]*||"`
# SPECSETUP=`grep %setup ${_tmpfile} | sed "s|.*-n ||"`
[ "$BUILDDIR" ] || BUILDDIR=$PACKAGE-$SPECVERSION
[ "$BUILDDIR" ] || BUILDDIR=$PACKAGE-$SPECVERSION
fi
fi
RPMBUILDDIR=${WORKINGHOME}/RPM/BUILD
COMMAND=`echo $COMMAND | sed "s|@BUILDDIR@|$BUILDDIR|g"`
@ -62,19 +81,37 @@ cmdtmpfile=`mktemp`
chgrp nobody $cmdtmpfile
chmod 640 $cmdtmpfile
rettmpfile=`$SUCMDPREFIX mktemp`
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 "Started background command: $COMMAND"
RET=0
else
echo "$$ $ENVUSER $ENVIRONMENT $cmdtmpfile 256 $COMMAND" >> $WEBBUILD_STATEDIR/processes
rettmpfile=`$SUCMDPREFIX mktemp`
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
$SUCMDPREFIX "$COMMAND;echo \$? > $rettmpfile" 2>&1 | sed "s|<|\&lt;|g" | tr -d '\f' | tee $cmdtmpfile
fi
RET=`cat $ENVPREFIX/$rettmpfile`
[ "$RET" ] || RET=255
$SUCMDPREFIX "rm -f $rettmpfile"
sed -i "/^$$ $ENVUSER/d" $WEBBUILD_STATEDIR/processes
if [ "$MODE" != "keeplog" ]; then
rm -f $cmdtmpfile
else
echo "$$ $ENVUSER $ENVIRONMENT $cmdtmpfile $RET $COMMAND" >> $WEBBUILD_STATEDIR/processes
fi
fi
echo "$$ $ENVUSER $ENVIRONMENT $cmdtmpfile $COMMAND" >> $WEBBUILD_STATEDIR/processes
$SUCMDPREFIX ". /etc/profile;cd $WORKINGHOME/RPM/SPECS;$COMMAND;echo \$? > $rettmpfile" 2>&1 | sed "s|<|\&lt;|g" | tr -d '\f' | tee $cmdtmpfile
RET=`cat $rettmpfile`
$SUCMDPREFIX "rm -f $rettmpfile"
#echo "Command: $SUCMDPREFIX \"cd $WORKINGHOME/RPM/SPECS;$COMMAND\";RET=$RET" >&2
sed -i "/^$$ $ENVUSER/d" $WEBBUILD_STATEDIR/processes
rm -f $cmdtmpfile
if [ "$TMPFILE" -a "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then
rm -f /var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/$TMPFILE
if [ "$ENVIRONMENT" != "local" ]; then
if [ "$TMPFILE" -a "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then
rm -f /var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/$TMPFILE
fi
fi
exit $RET