* updated libxspf (1.2.0 -> 1.2.1)
[t2-trunk.git] / scripts / Build-Job
blob9a45099fb543f6c6fbe939ada1ab11d92d32b34b
1 #!/bin/bash
3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # This copyright note is auto-generated by scripts/Create-CopyPatch.
5 #
6 # T2 SDE: scripts/Build-Job
7 # Copyright (C) 2004 - 2020 The T2 SDE Project
8 # Copyright (C) 1998 - 2003 ROCK Linux Project
9 #
10 # More information can be found in the files COPYING and README.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; version 2 of the License. A copy of the
15 # GNU General Public License can be found in the file COPYING.
16 # --- T2-COPYRIGHT-NOTE-END ---
18 config=default
19 xdaemon=0
20 daemon=0
22 while [ "$1" ]; do
23 case "$1" in
24 -daemon)
25 daemon=1 ; shift ;;
26 -xdaemon)
27 xdaemon=1; shift ;;
28 -cfg)
29 config=$2; shift; shift ;;
30 -*)
31 echo "Usage: $0 [ -cfg config ] { -daemon | job(s) }"
32 exit 1 ;;
34 break ;;
35 esac
36 done
38 . scripts/parse-config
39 qdir="build/$SDECFG_ID/TOOLCHAIN/queue"
41 build_logs="build/$SDECFG_ID/TOOLCHAIN/logs"
42 mkdir -p "${build_logs}"
44 if [ $daemon = 1 ]; then
45 if [ -f $qdir/queue.txt ]; then
46 if [ -f $qdir/use_build_job_daemon ]; then
47 nohup $0 -cfg $config -xdaemon > /dev/null &
48 sleep 1; exit 0
49 else
50 echo
51 echo "The build has been configured to use a command for"
52 echo "adding jobs (useing another job scheduler)."
53 echo
54 exit 1
56 else
57 echo
58 echo "$qdir:"
59 echo "Queue not found! Please start 'Build-Target -cfg $config'"
60 echo "first on the master node ..."
61 echo
62 exit 1
66 if [ $xdaemon = 1 ]; then
67 echo "Writing output to $build_logs/build_job_${HOSTNAME}_$$.log." >&2
68 exec > "$build_logs/build_job_${HOSTNAME}_$$.log" 2>&1 < /dev/null
70 echo -e "Build-Job (daemon mode)\trunning on ${HOSTNAME} with PID $$" \
71 > "$qdir/build_job_${HOSTNAME}_$$.stat"
72 date "+%H:%M ${HOSTNAME} new build-job daemon with PID $$" \
73 >> $qdir/1_$qid.msg
75 while [ -f $qdir/queue.txt -a -f $qdir/use_build_job_daemon -a \
76 -f "$qdir/build_job_${HOSTNAME}_$$.stat" ]; do
77 didsomething=0
78 while read next && [ "$next" ]; do
79 set $next; qid="$1-$6"
80 if [ -f $qdir/$qid.job -a ! -f $qdir/$qid.lock ]; then
81 $0 -cfg $config $qid
82 didsomething=1; break
84 done < $qdir/queue.txt
85 [ $didsomething = 1 ] || sleep 3
86 done
88 rm -f "$qdir/build_job_${HOSTNAME}_$$.stat"
89 if [ -f $qdir/queue.txt ]; then
90 date "+%H:%M ${HOSTNAME}%tbuild-job daemon ended ($$)" \
91 >> $qdir/8_$qid.msg
93 echo "Queue has been removed. exit now."
94 exit 0
97 for qid; do
98 if [ -f $qdir/$qid.job ]; then
99 if ! mv $qdir/$qid.todo $qdir/$qid.lock 2> /dev/null; then
100 echo "Job locked by other build proc:" \
101 "$qid ($qdir/$qid.lock)!"
102 exit 1
105 . $qdir/$qid.job
106 date "+Job $qid%t$HOSTNAME ($PPID) since %H:%M %Y-%m-%d" \
107 > $qdir/$qid.lock
108 date "+%H:%M ${HOSTNAME}:%tbuilding job '$qid' ($PPID) .." \
109 >> $qdir/6_$qid.msg
110 pkgloop_package $next
111 if [ -f "${build_root}/var/adm/logs/$qid.log" ]; then
112 date "+%H:%M ${HOSTNAME}:%tfinished job '$qid' `
113 `(ok)" >> $qdir/3_$qid.msg
114 else
115 date "+%H:%M ${HOSTNAME}:%tfinished job '$qid' `
116 `(ERROR)" >> $qdir/3_$qid.msg
118 rm -f $qdir/$qid.lock $qdir/$qid.job
119 else
120 echo "No such job: $qid ($qdir/$qid.job)!"; exit 1
122 done