@ -1,122 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
# --- SDE-COPYRIGHT-NOTE-BEGIN --- |
|
||||
# This copyright note is auto-generated by ./scripts/Create-CopyPatch. |
|
||||
# |
|
||||
# Filename: scripts/Build-Job |
|
||||
# Copyright (C) 2006 The OpenSDE Project |
|
||||
# Copyright (C) 2004 - 2006 The T2 SDE Project |
|
||||
# Copyright (C) 1998 - 2003 Clifford Wolf |
|
||||
# |
|
||||
# More information can be found in the files COPYING and README. |
|
||||
# |
|
||||
# This program is free software; you can redistribute it and/or modify |
|
||||
# it under the terms of the GNU General Public License as published by |
|
||||
# the Free Software Foundation; version 2 of the License. A copy of the |
|
||||
# GNU General Public License can be found in the file COPYING. |
|
||||
# --- SDE-COPYRIGHT-NOTE-END --- |
|
||||
|
|
||||
config=default |
|
||||
xdaemon=0 |
|
||||
daemon=0 |
|
||||
|
|
||||
while [ "$1" ] ; do |
|
||||
case "$1" in |
|
||||
-daemon) |
|
||||
daemon=1 ; shift ;; |
|
||||
-xdaemon) |
|
||||
xdaemon=1 ; shift ;; |
|
||||
-cfg) |
|
||||
config=$2 ; shift ; shift ;; |
|
||||
-*) |
|
||||
echo "Usage: $0 [ -cfg config ] { -daemon | job(s) }" |
|
||||
exit 1 ;; |
|
||||
*) |
|
||||
break ;; |
|
||||
esac |
|
||||
done |
|
||||
|
|
||||
. lib/parse-config |
|
||||
qdir="build/$SDECFG_ID/TOOLCHAIN/queue" |
|
||||
|
|
||||
build_logs="build/$SDECFG_ID/TOOLCHAIN/logs" |
|
||||
mkdir -p "${build_logs}" |
|
||||
|
|
||||
if [ $daemon = 1 ] ; then |
|
||||
if [ -f $qdir/queue.txt ] ; then |
|
||||
if [ -f $qdir/use_build_job_daemon ] ; then |
|
||||
nohup $0 -cfg $config -xdaemon > /dev/null & |
|
||||
sleep 1 ; exit 0 |
|
||||
else |
|
||||
echo |
|
||||
echo "The build has been configured to use a command for" |
|
||||
echo "adding jobs (useing another job scheduler)." |
|
||||
echo |
|
||||
exit 1 |
|
||||
fi |
|
||||
else |
|
||||
echo |
|
||||
echo "$qdir:" |
|
||||
echo "Queue not found! Please start 'Build-Target -cfg $config'" |
|
||||
echo "first on the master node ..." |
|
||||
echo |
|
||||
exit 1 |
|
||||
fi |
|
||||
fi |
|
||||
|
|
||||
if [ $xdaemon = 1 ] ; then |
|
||||
echo "Writing output to $build_logs/build_job_${HOSTNAME}_$$.log." >&2 |
|
||||
exec > "$build_logs/build_job_${HOSTNAME}_$$.log" 2>&1 < /dev/null |
|
||||
|
|
||||
echo -e "Build-Job (daemon mode)\trunning on ${HOSTNAME} with PID $$" \ |
|
||||
> "$qdir/build_job_${HOSTNAME}_$$.stat" |
|
||||
date "+%H:%M ${HOSTNAME} new build-job daemon with PID $$" \ |
|
||||
>> $qdir/1_$qid.msg |
|
||||
|
|
||||
while [ -f $qdir/queue.txt -a -f $qdir/use_build_job_daemon -a \ |
|
||||
-f "$qdir/build_job_${HOSTNAME}_$$.stat" ] ; do |
|
||||
didsomething=0 |
|
||||
while read next && [ "$next" ] ; do |
|
||||
set $next ; qid="$1-$6" |
|
||||
if [ -f $qdir/$qid.job -a ! -f $qdir/$qid.lock ] ; then |
|
||||
$0 -cfg $config $qid |
|
||||
didsomething=1 ; break |
|
||||
fi |
|
||||
done < $qdir/queue.txt |
|
||||
[ $didsomething = 1 ] || sleep 3 |
|
||||
done |
|
||||
|
|
||||
rm -f "$qdir/build_job_${HOSTNAME}_$$.stat" |
|
||||
if [ -f $qdir/queue.txt ] ; then |
|
||||
date "+%H:%M ${HOSTNAME}%tbuild-job daemon ended ($$)" \ |
|
||||
>> $qdir/8_$qid.msg |
|
||||
fi |
|
||||
echo "Queue has been removed. exit now." |
|
||||
exit 0 |
|
||||
fi |
|
||||
|
|
||||
for qid ; do |
|
||||
if [ -f $qdir/$qid.job ] ; then |
|
||||
if ! mv $qdir/$qid.todo $qdir/$qid.lock 2> /dev/null ; then |
|
||||
echo "Job locked by other build proc:" \ |
|
||||
"$qid ($qdir/$qid.lock)!" |
|
||||
exit 1 |
|
||||
fi |
|
||||
|
|
||||
. $qdir/$qid.job |
|
||||
date "+Job $qid%t$HOSTNAME ($PPID) since %H:%M %Y-%m-%d" \ |
|
||||
> $qdir/$qid.lock |
|
||||
date "+%H:%M ${HOSTNAME}:%tbuilding job '$qid' ($PPID) .." \ |
|
||||
>> $qdir/6_$qid.msg |
|
||||
pkgloop_package $next |
|
||||
if [ -f "${build_root}/var/adm/logs/$qid.log" ] ; then |
|
||||
date "+%H:%M ${HOSTNAME}:%tfinished job '$qid' ` |
|
||||
`(ok)" >> $qdir/3_$qid.msg |
|
||||
else |
|
||||
date "+%H:%M ${HOSTNAME}:%tfinished job '$qid' ` |
|
||||
`(ERROR)" >> $qdir/3_$qid.msg |
|
||||
fi |
|
||||
rm -f $qdir/$qid.lock $qdir/$qid.job |
|
||||
else |
|
||||
echo "No such job: $qid ($qdir/$qid.job)!" ; exit 1 |
|
||||
fi |
|
||||
done |
|