* updated marble (21.12.1 -> 21.12.2), untested
[t2-trunk.git] / scripts / Check-PkgFormat
blob843573f3a1bbdec12dcf359ce834e8cb7ef5d756
1 #!/bin/bash
3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # T2 SDE: scripts/Check-PkgFormat
5 # Copyright (C) 2004 - 2021 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 as published by
13 # the Free Software Foundation; version 2 of the License. A copy of the
14 # GNU General Public License can be found in the file COPYING.
15 # --- T2-COPYRIGHT-NOTE-END ---
17 if [ "$1" = "-all" ]; then
18 $0 -repository `ls package/. | egrep -v '(CVS|\.svn)'`
19 exit 0
22 if [ "$1" = "-repository" ]; then
23 shift; for y; do
24 for x in package/$y/[a-z0-9]*; do
25 [ -f "$x/${x##*/}.desc" ] && $0 ${x##*/}
26 done
27 done
28 exit 0
31 if [ "$1" != "${1#-}" -o $# -eq 0 ]; then
32 echo "Usage: $0 <package-names>"
33 echo "or $0 -repository <repository-names>"
34 echo "or $0 -all"
35 exit 1
38 for package; do
39 lastpdir=""
40 for pdir in package/*/$package; do
41 [ -f $pdir/$package.desc ] || continue
42 [ "$lastpdir" ] && echo "$package: Found dup: $pdir $lastpdir"
43 lastpdir="$pdir"
44 done
45 if [ -z "$lastpdir" ]; then
46 pdir="..."
47 else
48 pdir="$lastpdir"
51 if [ -f $pdir/$package.conf ]; then
52 if egrep -q '^[^#]*\bflistdel' $pdir/$package.conf; then
53 echo "$package: Use of \$flistdel is evil!"
57 if [ -f $pdir/$package.desc ]; then
58 grep -a '[^ ]' $pdir/$package.desc |
59 egrep -av '^(\[[A-Z0-9-]+\]( |$)|#)' |
60 sed "s,^,$package: Syntax error in $package.desc: ,"
62 egrep -a '^\[[A-Z0-9-]+\]( |$)' $pdir/$package.desc |
63 tr '[]' '||' | cut -f2 -d'|' |
64 while read tag; do
65 grep -q "\\[$tag\\]" misc/share/PKG-DESC-FORMAT &&
66 continue
67 [ "${tag#X-}" != "$tag" ] && continue
68 echo "$package: Unknown tag in $package.desc: [$tag]"
69 done
71 for x in `egrep -a '^\[(C|CATEGORY)\]' $pdir/$package.desc |
72 cut -f2- -d']'`; do
73 egrep -q "^$x( |$)" misc/share/PKG-CATEGORIES &&
74 continue
75 echo "$package: Unknown package category: $x"
76 done
78 for x in `egrep -a '^\[(F|FLAG)\]' $pdir/$package.desc |
79 cut -f2- -d']'`; do
80 egrep -q "^$x " misc/share/PKG-FLAGS &&
81 continue
82 echo "$package: Unknown package flag: $x"
83 done
85 for x in `egrep -a '^\[(S|STATUS)\]' $pdir/$package.desc |
86 cut -f2- -d']'`; do
87 case $x in
88 Alpha|Beta|Gamma|Stable) ;;
89 *) echo "$package: Unknown package" \
90 "status: $x" ;;
91 esac
92 done
94 for x in `egrep -a '^\[(L|LICENSE)\]' $pdir/$package.desc |
95 cut -f2- -d']'`; do
96 case $x in
97 Unknown|GPL|LGPL|GPL3|LGPL3|AGPL|AGPL3|MPL|FDL|MIT|BSD|ISC|APL|APSL|CDDL|QPL) ;;
98 OpenSource|Free-to-use|Commercial) ;;
99 IBM-Public-License|Restricted|Artistic) ;;
100 PublicDomain) ;;
101 *) echo "$package: Unknown package" \
102 "license: $x" ;;
103 esac
104 done
106 grep '^\[.*(\*)' misc/share/PKG-DESC-FORMAT |
107 sed 's/][^]]*$//; s/. ./|/g; s/^\[//;' |
108 while read line; do
109 egrep -q "^\[($line)\]" $pdir/$package.desc ||
110 echo "$package: No [$line] tag found."
111 done
113 grep '^\[.*(1)' misc/share/PKG-DESC-FORMAT |
114 sed 's/][^]]*$//; s/. ./|/g; s/^\[//;' |
115 while read line; do
116 lines=`egrep -a "^\[($line)\]" $pdir/$package.desc`
117 [ "$lines" != "${lines//
118 /}" ] && echo "$package: More than one [$line] tag found."
119 done
120 else
121 echo "$package: File not found: $pdir/$package.desc"
124 if [ -f $pdir/$package.conf ]; then
125 bash -n $pdir/$package.conf 2>&1 | sed "s,^,$package: ,"
127 done