3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # T2 SDE: scripts/Build-Job
5 # Copyright (C) 2004 - 2023 The T2 SDE Project
6 # Copyright (C) 1998 - 2003 ROCK Linux Project
8 # This Copyright note is generated by scripts/Create-CopyPatch,
9 # more information can be found in the files COPYING and README.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License version 2.
13 # --- T2-COPYRIGHT-NOTE-END ---
26 config
=$2; shift; shift ;;
28 echo "Usage: $0 [ -cfg config ] { -daemon | job(s) }"
35 .
scripts
/parse-config
36 qdir
="build/$SDECFG_ID/TOOLCHAIN/queue"
38 build_logs
="build/$SDECFG_ID/TOOLCHAIN/logs"
39 mkdir
-p "${build_logs}"
41 if [ $daemon = 1 ]; then
42 if [ -f $qdir/queue.txt
]; then
43 if [ -f $qdir/use_build_job_daemon
]; then
44 nohup
$0 -cfg $config -xdaemon > /dev
/null
&
48 echo "The build has been configured to use a command for"
49 echo "adding jobs (useing another job scheduler)."
56 echo "Queue not found! Please start 'Build-Target -cfg $config'"
57 echo "first on the master node ..."
63 if [ $xdaemon = 1 ]; then
64 echo "Writing output to $build_logs/build_job_${HOSTNAME}_$$.log." >&2
65 exec > "$build_logs/build_job_${HOSTNAME}_$$.log" 2>&1 < /dev
/null
67 echo -e "Build-Job (daemon mode)\trunning on ${HOSTNAME} with PID $$" \
68 > "$qdir/build_job_${HOSTNAME}_$$.stat"
69 date "+%H:%M ${HOSTNAME} new build-job daemon with PID $$" \
72 while [ -f $qdir/queue.txt
-a -f $qdir/use_build_job_daemon
-a \
73 -f "$qdir/build_job_${HOSTNAME}_$$.stat" ]; do
75 while read next
&& [ "$next" ]; do
76 set $next; qid
="$1-$6"
77 if [ -f $qdir/$qid.job
-a ! -f $qdir/$qid.lock
]; then
81 done < $qdir/queue.txt
82 [ $didsomething = 1 ] ||
sleep 3
85 rm -f "$qdir/build_job_${HOSTNAME}_$$.stat"
86 if [ -f $qdir/queue.txt
]; then
87 date "+%H:%M ${HOSTNAME}%tbuild-job daemon ended ($$)" \
90 echo "Queue has been removed. exit now."
95 if [ -f $qdir/$qid.job
]; then
96 if ! mv $qdir/$qid.todo
$qdir/$qid.lock
2> /dev
/null
; then
97 echo "Job locked by other build proc:" \
98 "$qid ($qdir/$qid.lock)!"
103 date "+Job $qid%t$HOSTNAME ($PPID) since %H:%M %Y-%m-%d" \
105 date "+%H:%M ${HOSTNAME}:%tbuilding job '$qid' ($PPID) .." \
107 pkgloop_package
$next
108 if [ -f "${build_root}/var/adm/logs/$qid.log" ]; then
109 date "+%H:%M ${HOSTNAME}:%tfinished job '$qid' `
110 `(ok)" >> $qdir/3_
$qid.msg
112 date "+%H:%M ${HOSTNAME}:%tfinished job '$qid' `
113 `(ERROR)" >> $qdir/3_
$qid.msg
115 rm -f $qdir/$qid.lock
$qdir/$qid.job
117 echo "No such job: $qid ($qdir/$qid.job)!"; exit 1