* added The Unlicense as valid un scripts/Check-PkgFormat too
[t2sde.git] / scripts / Check-PkgFormat
blob83209d06b69c6a4bec66910a979e111086f65476
1 #!/usr/bin/env bash
3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # T2 SDE: scripts/Check-PkgFormat
5 # Copyright (C) 2004 - 2024 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 if [ "$1" = "-all" ]; then
16 $0 -repository `ls package/. | egrep -v '(CVS|\.svn)'`
17 exit 0
20 if [ "$1" = "-repository" ]; then
21 shift; for y; do
22 for x in package/$y/[a-z0-9]*; do
23 [ -f "$x/${x##*/}.desc" ] && $0 ${x##*/}
24 done
25 done
26 exit 0
29 if [ "$1" != "${1#-}" -o $# -eq 0 ]; then
30 echo "Usage: $0 <package-names>"
31 echo "or $0 -repository <repository-names>"
32 echo "or $0 -all"
33 exit 1
36 for package; do
37 lastpdir=""
38 for pdir in package/*/$package; do
39 [ -f $pdir/$package.desc ] || continue
40 [ "$lastpdir" ] && echo "$package: Found dup: $pdir $lastpdir"
41 lastpdir="$pdir"
42 done
43 if [ -z "$lastpdir" ]; then
44 pdir="..."
45 else
46 pdir="$lastpdir"
49 if [ -f $pdir/$package.conf ]; then
50 if egrep -q '^[^#]*\bflistdel' $pdir/$package.conf; then
51 echo "$package: Use of \$flistdel is deprecated!"
55 if [ -f $pdir/$package.desc ]; then
56 grep -a '[^ ]' $pdir/$package.desc |
57 egrep -av '^(\[[A-Z0-9-]+\]( |$)|#)' |
58 sed "s,^,$package: Syntax error in $package.desc: ,"
60 egrep -a '^\[[A-Z0-9-]+\]( |$)' $pdir/$package.desc |
61 tr '[]' '||' | cut -f2 -d'|' |
62 while read tag; do
63 grep -q "\\[$tag\\]" misc/share/PKG-DESC-FORMAT &&
64 continue
65 [ "${tag#X-}" != "$tag" ] && continue
66 echo "$package: Unknown tag in $package.desc: [$tag]"
67 done
69 for x in `egrep -a '^\[(C|CATEGORY)\]' $pdir/$package.desc |
70 cut -f2- -d']'`; do
71 egrep -q "^$x( |$)" misc/share/PKG-CATEGORIES &&
72 continue
73 echo "$package: Unknown package category: $x"
74 done
76 for x in `egrep -a '^\[(F|FLAG)\]' $pdir/$package.desc |
77 cut -f2- -d']'`; do
78 x=${x%.*} # remove conditional suffixes
79 egrep -q "^$x " misc/share/PKG-FLAGS &&
80 continue
81 echo "$package: Unknown package flag: $x"
82 done
84 for x in `egrep -a '^\[(S|STATUS)\]' $pdir/$package.desc |
85 cut -f2- -d']'`; do
86 case $x in
87 Alpha|Beta|Gamma|Stable) ;;
88 *) echo "$package: Unknown package" \
89 "status: $x" ;;
90 esac
91 done
93 for x in `egrep -a '^\[(L|LICENSE)\]' $pdir/$package.desc |
94 cut -f2- -d']'`; do
95 case $x in
96 Unknown|GPL|LGPL|GPL3|LGPL3|AGPL|AGPL3|MPL|FDL|MIT|BSD|EUPL|ISC|APL|APSL|BSL|CDDL|QPL|OFL|ZLIB|UNL) ;;
97 OpenSource|Free-to-use|Commercial) ;;
98 IBM-Public-License|Restricted|Artistic) ;;
99 PublicDomain) ;;
100 *) echo "$package: Unknown package" \
101 "license: $x" ;;
102 esac
103 done
105 grep '^\[.*(\*)' misc/share/PKG-DESC-FORMAT |
106 sed 's/][^]]*$//; s/. ./|/g; s/^\[//;' |
107 while read line; do
108 egrep -q "^\[($line)\]" $pdir/$package.desc ||
109 echo "$package: No [$line] tag found."
110 done
112 grep '^\[.*(1)' misc/share/PKG-DESC-FORMAT |
113 sed 's/][^]]*$//; s/. ./|/g; s/^\[//;' |
114 while read line; do
115 lines=`egrep -a "^\[($line)\]" $pdir/$package.desc`
116 [ "$lines" != "${lines//
117 /}" ] && echo "$package: More than one [$line] tag found."
118 done
119 else
120 echo "$package: File not found: $pdir/$package.desc"
123 if [ -f $pdir/$package.conf ]; then
124 bash -n $pdir/$package.conf 2>&1 | sed "s,^,$package: ,"
126 done