t2sde/scripts/Create-PkgQueue
René Rebe 9e430bea9e * more correct build-target progress count
git-svn-id: https://svn.exactcode.de/t2/trunk@73489 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc
2025-01-28 21:09:18 +00:00

195 lines
4.7 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# --- T2-COPYRIGHT-NOTE-BEGIN ---
# T2 SDE: scripts/Create-PkgQueue
# Copyright (C) 2004 - 2023 The T2 SDE Project
# Copyright (C) 1998 - 2003 ROCK Linux Project
#
# This Copyright note is generated by scripts/Create-CopyPatch,
# 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 version 2.
# --- T2-COPYRIGHT-NOTE-END ---
config=default
logdir=""
single=0
debug=0
nobrokendeps=0
index=0
while [ "$1" ]; do
case "$1" in
-cfg)
config=$2; shift; shift ;;
-single)
single=1 ; shift ;;
-logdir)
logdir=$2; shift; shift ;;
-debug)
debug=1 ; shift ;;
-index)
index=1 ; shift ;;
-nobrokendeps)
nobrokendeps=1; shift ;;
*)
echo "Usage: $0 [ -cfg config ] [ -single ] [ -index ]\\"
echo " ${0//?/ } [ -logdir logdir ] [ -debug ]"
exit 1 ;;
esac
done
. scripts/parse-config
gawk '
function check_package() {
split(pkgline, a); dep=a[2];
if (a[1] != "X" || ! index(a[2], stagelevel)) return;
++stepi;
repository = a[4];
package = a[5];
logfile = logfile_tpl;
gsub("<stagelevel>", stagelevel, logfile);
gsub("<repository>", repository, logfile);
gsub("<package>", package, logfile);
errfile = logfile; outfile = logfile;
gsub("<log>", "log", logfile);
gsub("<log>", "err", errfile);
gsub("<log>", "out", outfile);
if ((getline dummy < logfile == -1) &&
(getline dummy < errfile == -1)) {
build_this_package = 1;
found_dependencies = 0;
buildtime = 60;
priority = 0;
if (getline dummy < outfile != -1)
build_this_package = 0;
if (index(not_present, " " package " ")) {
if (debug && build_this_package)
print "DEBUG: Not building " stagelevel "-" \
package ": earlier stages not done " \
"for this package."
build_this_package = 0;
}
if (build_this_package && (package in database)) {
split(database[package], a);
buildtime = a[2];
priority = a[3];
for (c in a) {
# if (a[c] == package) continue;
# if (strtonum(c) <= 3) continue;
if (debug && 0)
print "DEBUG: Checking " stagelevel \
"-" package ": needs " a[c];
if (index(not_present, " " a[c] " ") &&
stagelevel != stage9_no_deps) {
if (debug && build_this_package)
print "DEBUG: Not building " \
stagelevel "-" package \
": " a[c] " is missing";
build_this_package=0;
}
found_dependencies = 1;
}
}
# Do not build packages parallel in stage 0
#
if (stagelevel == 0 && not_present != "")
build_this_package = 0;
# Do not build packages from stages > 0 if packages
# from stage 0 are still missing
#
if (stagelevel == 0)
stage0_not_present=1;
if (stagelevel > 0 && stage0_not_present)
build_this_package = 0;
# Do not build packages from stages >= 2 if packages
# from stages <= 1 are not build already.
#
if (stagelevel <= 1)
stage01_not_present=1;
if (stagelevel >= 2 && stage01_not_present)
build_this_package = 0;
# Only ignore deps in stage 9 if everything < stage 9
# is already there
if (stagelevel < 9)
stage9_no_deps = "x";
# A packages without dependencies automatically depend
# on all packages build before it
if (found_dependencies == 0 && not_present != "" &&
stagelevel != stage9_no_deps)
build_this_package = 0;
# t2-debug must be build _after_ all other packages
if (package == "t2-debug" && not_present != "")
build_this_package = 0;
if (build_this_package) {
sub("^X ", priority " ", pkgline);
sub(" 0$", " " buildtime, pkgline);
if (idx > 0)
print stepi, stagelevel, pkgline;
else
print stagelevel, pkgline;
if (single) exit 0;
}
not_present = not_present " " package " ";
}
else
if (nobrokendeps) {
close(errfile);
if ((getline dummy < errfile != -1)) {
not_present = not_present " " package " ";
}
}
close(logfile); # ignore errors here if we
close(errfile); # did not open this files
close(outfile);
close(depfile);
}
BEGIN {
not_present="";
stage0_not_present=0;
stage01_not_present=0;
stage9_no_deps=9;
stepi=0;
nobrokendeps='$nobrokendeps';
config="'$config'"; single='$single'; debug='$debug'; idx='$index';
logdir="'"${logdir:-build/$SDECFG_ID/var/adm/logs}"'";
logfile_tpl = logdir "/<stagelevel>-<package>.<log>";
#depdb_file = "scripts/dep_db.txt";
packages_file = "config/" config "/packages";
#while ((getline depline < depdb_file) > 0)
# { $0 = depline; sub(/:/, "", $1); database[$1]=$0; }
#close(depdb_file);
for (stagelevel=0; stagelevel<=9; stagelevel++) {
while ((getline pkgline < packages_file) > 0) {
check_package();
}
close(packages_file);
}
}
'