Dash:
[t2-trunk.git] / scripts / Create-PkgList
blob5779de2e9f5cc970d4c2b6cdc9257af6a03db94a
1 #!/bin/bash
2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # T2 SDE: scripts/Create-PkgList
4 # Copyright (C) 2004 - 2021 The T2 SDE Project
5 # Copyright (C) 1998 - 2003 ROCK Linux Project
6 #
7 # This Copyright note is generated by scripts/Create-CopyPatch,
8 # more information can be found in the files COPYING and README.
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License version 2.
12 # --- T2-COPYRIGHT-NOTE-END ---
14 if [ $# -ne 1 -o ! -d "architecture/$1" ]; then
15 echo "Usage: $0 [ <arch-name> ]"
16 [ $# -eq 0 ] || echo " '$1' is not a valid architecture"
17 exit 1
18 fi 1>&2
20 echo 'BEGIN {
21 arch="'$1'";
24 function print_package() {
25 print defset, stages, pri, pkgtree,
26 package, ver, "/" categories flags, 0;
29 END {
30 if ( pkgtree ) print_package();
33 ( FNR == 1 && pkgtree ) {
34 print_package();
37 FNR == 1 {
38 split(FILENAME, a, /\//);
39 pkgtree=a[1]; package=a[2];
40 defset="X"; pri="999.999";
41 stages="-----------";
42 ver="0000"; categories=""
43 ver_dup=0; flags=""
46 /^\[(P|PRI|PRIORITY)\]/ {
47 split($0, a, /[ \t]+/);
48 defset=a[2]; stages=a[3]; pri=a[4];
51 /^\[(V|VER|VERSION)\]/ {
52 split($0, a, /[ \t]+/);
53 if ( ver_dup == 0 ) ver=a[2];
54 ver_dup = 1;
57 /^\[(C|CATEGORY)\]/ {
58 split($0, a, /[ \t]+/);
59 for (c=2; a[c]; c++) categories = categories " " a[c];
62 /^\[(F|FLAGS)\]/ {
63 split($0, a, /[ \t]+/);
64 for (c=2; a[c]; c++) flags = flags " " a[c];
67 /^\[(R|ARCH|ARCHITECTURE)\]/ {
68 n=split($0, a, /[ \t]+/);
69 #if (arch == "")
70 # next;
72 # search for an architecture match
73 if ( a[2] == "-" ) {
74 for ( i = 3; i<= n; ++i) {
75 if ( arch == a[i] ) {
76 pkgtree=""
77 next;
80 # fall thru: keep it
82 else { # intentionally start at index 2: implicit exlusive selection
83 for ( i = 2; i<= n; ++i) {
84 if ( arch == a[i] ) {
85 next;
88 # not found: remove it
89 pkgtree="";
91 }' | (cd package; gawk -f - */*/*.desc ) | sort -k3