#!/usr/bin/env bash # --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: scripts/Create-PkgList # 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 --- if [ $# -lt 1 -o ! -d "architecture/$1" ]; then echo "Usage: $0 [ ] [ ]" [ $# -eq 0 ] || echo " '$1' is not a valid architecture" exit 1 fi 1>&2 if [ $# -lt 2 -o ! -d "kernel/$2" ]; then echo "Usage: $0 [ ] [ ]" [ $# -eq 0 ] || echo " '$2' is not a valid kernel" exit 1 fi 1>&2 echo 'BEGIN { arch="'$1'"; kernel="'$2'"; } function print_package() { print defset, stages, pri, pkgtree, package, ver, "/" categories flags, 0; } END { if (pkgtree) print_package(); } (FNR == 1 && pkgtree) { print_package(); } FNR == 1 { split(FILENAME, a, /\//); pkgtree=a[1]; package=a[2]; defset="X"; pri="999.999"; stages="-----------"; ver="0000"; categories="" ver_dup=0; flags="" } /^\[(P|PRI|PRIORITY)\]/ { split($0, a, /[ \t]+/); defset=a[2]; stages=a[3]; pri=a[4]; } /^\[(V|VER|VERSION)\]/ { split($0, a, /[ \t]+/); if (ver_dup == 0) ver=a[2]; ver_dup = 1; } /^\[(C|CATEGORY)\]/ { split($0, a, /[ \t]+/); for (c=2; a[c]; c++) categories = categories " " a[c]; } /^\[(F|FLAGS)\]/ { split($0, a, /[ \t]+/); for (c=2; a[c]; c++) flags = flags " " a[c]; } /^\[(R|ARCH|ARCHITECTURE)\]/ { n=split($0, a, /[ \t]+/); #if (arch == "") # next; # search for an architecture match if (a[2] == "-") { for (i = 3; i<= n; ++i) { if (arch == a[i]) { pkgtree="" next; } } # fall thru: keep it } else { # intentionally start at index 2: implicit exlusive selection for (i = 2; i<= n; ++i) { if (arch == a[i]) { next; } } # not found: remove it pkgtree=""; } } /^\[(K|KERN|KERNEL)\]/ { n=split($0, k, /[ \t]+/); # search for an kernel match if (k[2] == "-") { for (i = 3; i<= n; ++i) { if (kernel == k[i]) { pkgtree="" next; } } # fall thru: keep it } else { # intentionally start at index 2: implicit exlusive selection for (i = 2; i<= n; ++i) { if (kernel == k[i]) { next; } } # not found: remove it pkgtree=""; } }' | (cd package; gawk -f - */*/*.desc) | sort -k3