* fix firefox sandbox patch
[t2sde.git] / scripts / Create-PkgQueue
blob4f7906a08916976a4a51902c6cd2b6c2d308c081
1 #!/usr/bin/env bash
3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # T2 SDE: scripts/Create-PkgQueue
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 logdir=""
17 single=0
18 debug=0
19 nobrokendeps=0
20 index=0
22 while [ "$1" ]; do
23 case "$1" in
24 -cfg)
25 config=$2; shift; shift ;;
26 -single)
27 single=1 ; shift ;;
28 -logdir)
29 logdir=$2; shift; shift ;;
30 -debug)
31 debug=1 ; shift ;;
32 -index)
33 index=1 ; shift ;;
34 -nobrokendeps)
35 nobrokendeps=1; shift ;;
37 echo "Usage: $0 [ -cfg config ] [ -single ] [ -index ]\\"
38 echo " ${0//?/ } [ -logdir logdir ] [ -debug ]"
39 exit 1 ;;
40 esac
41 done
43 . scripts/parse-config
45 gawk '
46 function check_package() {
47 split(pkgline, a); dep=a[2];
48 if (a[1] != "X" || ! index(a[2], stagelevel)) return;
50 ++stepi;
51 repository = a[4];
52 package = a[5];
54 logfile = logfile_tpl;
55 gsub("<stagelevel>", stagelevel, logfile);
56 gsub("<repository>", repository, logfile);
57 gsub("<package>", package, logfile);
59 errfile = logfile; outfile = logfile;
60 gsub("<log>", "log", logfile);
61 gsub("<log>", "err", errfile);
62 gsub("<log>", "out", outfile);
65 if ((getline dummy < logfile == -1) &&
66 (getline dummy < errfile == -1)) {
67 build_this_package = 1;
68 found_dependencies = 0;
69 buildtime = 60;
70 priority = 0;
72 if (getline dummy < outfile != -1)
73 build_this_package = 0;
75 if (index(not_present, " " package " ")) {
76 if (debug && build_this_package)
77 print "DEBUG: Not building " stagelevel "-" \
78 package ": earlier stages not done " \
79 "for this package."
80 build_this_package = 0;
83 if (build_this_package && (package in database)) {
84 split(database[package], a);
85 buildtime = a[2];
86 priority = a[3];
88 for (c in a) {
89 # if (a[c] == package) continue;
90 # if (strtonum(c) <= 3) continue;
91 if (debug && 0)
92 print "DEBUG: Checking " stagelevel \
93 "-" package ": needs " a[c];
94 if (index(not_present, " " a[c] " ") &&
95 stagelevel != stage9_no_deps) {
96 if (debug && build_this_package)
97 print "DEBUG: Not building " \
98 stagelevel "-" package \
99 ": " a[c] " is missing";
100 build_this_package=0;
102 found_dependencies = 1;
106 # Do not build packages parallel in stage 0
108 if (stagelevel == 0 && not_present != "")
109 build_this_package = 0;
111 # Do not build packages from stages > 0 if packages
112 # from stage 0 are still missing
114 if (stagelevel == 0)
115 stage0_not_present=1;
116 if (stagelevel > 0 && stage0_not_present)
117 build_this_package = 0;
119 # Do not build packages from stages >= 2 if packages
120 # from stages <= 1 are not build already.
122 if (stagelevel <= 1)
123 stage01_not_present=1;
124 if (stagelevel >= 2 && stage01_not_present)
125 build_this_package = 0;
127 # Only ignore deps in stage 9 if everything < stage 9
128 # is already there
129 if (stagelevel < 9)
130 stage9_no_deps = "x";
132 # A packages without dependencies automatically depend
133 # on all packages build before it
134 if (found_dependencies == 0 && not_present != "" &&
135 stagelevel != stage9_no_deps)
136 build_this_package = 0;
138 # t2-debug must be build _after_ all other packages
139 if (package == "t2-debug" && not_present != "")
140 build_this_package = 0;
142 if (build_this_package) {
143 sub("^X ", priority " ", pkgline);
144 sub(" 0$", " " buildtime, pkgline);
145 if (idx > 0)
146 print stepi, stagelevel, pkgline;
147 else
148 print stagelevel, pkgline;
149 if (single) exit 0;
152 not_present = not_present " " package " ";
154 else
155 if (nobrokendeps) {
156 close(errfile);
157 if ((getline dummy < errfile != -1)) {
158 not_present = not_present " " package " ";
162 close(logfile); # ignore errors here if we
163 close(errfile); # did not open this files
164 close(outfile);
165 close(depfile);
168 BEGIN {
169 not_present="";
170 stage0_not_present=0;
171 stage01_not_present=0;
172 stage9_no_deps=9;
173 stepi=0;
175 nobrokendeps='$nobrokendeps';
176 config="'$config'"; single='$single'; debug='$debug'; idx='$index';
177 logdir="'"${logdir:-build/$SDECFG_ID/var/adm/logs}"'";
179 logfile_tpl = logdir "/<stagelevel>-<package>.<log>";
180 #depdb_file = "scripts/dep_db.txt";
181 packages_file = "config/" config "/packages";
183 #while ((getline depline < depdb_file) > 0)
184 # { $0 = depline; sub(/:/, "", $1); database[$1]=$0; }
185 #close(depdb_file);
187 for (stagelevel=0; stagelevel<=9; stagelevel++) {
188 while ((getline pkgline < packages_file) > 0) {
189 check_package();
191 close(packages_file);