* added python-wheel (0.42.0) - The official binary distribution format for Python
[t2sde.git] / scripts / Build-Job
blob89d5f012c7c53e41856d4025b8771f651f975b92
1 #!/usr/bin/env bash
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
7 #
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 ---
15 config=default
16 xdaemon=0
17 daemon=0
19 while [ "$1" ]; do
20 case "$1" in
21 -daemon)
22 daemon=1 ; shift ;;
23 -xdaemon)
24 xdaemon=1; shift ;;
25 -cfg)
26 config=$2; shift; shift ;;
27 -*)
28 echo "Usage: $0 [ -cfg config ] { -daemon | job(s) }"
29 exit 1 ;;
31 break ;;
32 esac
33 done
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 &
45 sleep 1; exit 0
46 else
47 echo
48 echo "The build has been configured to use a command for"
49 echo "adding jobs (useing another job scheduler)."
50 echo
51 exit 1
53 else
54 echo
55 echo "$qdir:"
56 echo "Queue not found! Please start 'Build-Target -cfg $config'"
57 echo "first on the master node ..."
58 echo
59 exit 1
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 $$" \
70 >> $qdir/1_$qid.msg
72 while [ -f $qdir/queue.txt -a -f $qdir/use_build_job_daemon -a \
73 -f "$qdir/build_job_${HOSTNAME}_$$.stat" ]; do
74 didsomething=0
75 while read next && [ "$next" ]; do
76 set $next; qid="$1-$6"
77 if [ -f $qdir/$qid.job -a ! -f $qdir/$qid.lock ]; then
78 $0 -cfg $config $qid
79 didsomething=1; break
81 done < $qdir/queue.txt
82 [ $didsomething = 1 ] || sleep 3
83 done
85 rm -f "$qdir/build_job_${HOSTNAME}_$$.stat"
86 if [ -f $qdir/queue.txt ]; then
87 date "+%H:%M ${HOSTNAME}%tbuild-job daemon ended ($$)" \
88 >> $qdir/8_$qid.msg
90 echo "Queue has been removed. exit now."
91 exit 0
94 for qid; do
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)!"
99 exit 1
102 . $qdir/$qid.job
103 date "+Job $qid%t$HOSTNAME ($PPID) since %H:%M %Y-%m-%d" \
104 > $qdir/$qid.lock
105 date "+%H:%M ${HOSTNAME}:%tbuilding job '$qid' ($PPID) .." \
106 >> $qdir/6_$qid.msg
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
111 else
112 date "+%H:%M ${HOSTNAME}:%tfinished job '$qid' `
113 `(ERROR)" >> $qdir/3_$qid.msg
115 rm -f $qdir/$qid.lock $qdir/$qid.job
116 else
117 echo "No such job: $qid ($qdir/$qid.job)!"; exit 1
119 done