#!/usr/bin/env bash # # --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: scripts/Check-PkgFormat # Copyright (C) 2004 - 2024 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 [ "$1" = "-all" ]; then $0 -repository `ls package/. | egrep -v '(CVS|\.svn)'` exit 0 fi if [ "$1" = "-repository" ]; then shift; for y; do for x in package/$y/[a-z0-9]*; do [ -f "$x/${x##*/}.desc" ] && $0 ${x##*/} done done exit 0 fi if [ "$1" != "${1#-}" -o $# -eq 0 ]; then echo "Usage: $0 " echo "or $0 -repository " echo "or $0 -all" exit 1 fi for package; do lastpdir="" for pdir in package/*/$package; do [ -f $pdir/$package.desc ] || continue [ "$lastpdir" ] && echo "$package: Found dup: $pdir $lastpdir" lastpdir="$pdir" done if [ -z "$lastpdir" ]; then pdir="..." else pdir="$lastpdir" fi if [ -f $pdir/$package.conf ]; then if egrep -q '^[^#]*\bflistdel' $pdir/$package.conf; then echo "$package: Use of \$flistdel is deprecated!" fi fi if [ -f $pdir/$package.desc ]; then grep -a '[^ ]' $pdir/$package.desc | egrep -av '^(\[[A-Z0-9-]+\]( |$)|#)' | sed "s,^,$package: Syntax error in $package.desc: ," egrep -a '^\[[A-Z0-9-]+\]( |$)' $pdir/$package.desc | tr '[]' '||' | cut -f2 -d'|' | while read tag; do grep -q "\\[$tag\\]" misc/share/PKG-DESC-FORMAT && continue [ "${tag#X-}" != "$tag" ] && continue echo "$package: Unknown tag in $package.desc: [$tag]" done for x in `egrep -a '^\[(C|CATEGORY)\]' $pdir/$package.desc | cut -f2- -d']'`; do egrep -q "^$x( |$)" misc/share/PKG-CATEGORIES && continue echo "$package: Unknown package category: $x" done for x in `egrep -a '^\[(F|FLAG)\]' $pdir/$package.desc | cut -f2- -d']'`; do x=${x%.*} # remove conditional suffixes egrep -q "^$x " misc/share/PKG-FLAGS && continue echo "$package: Unknown package flag: $x" done for x in `egrep -a '^\[(S|STATUS)\]' $pdir/$package.desc | cut -f2- -d']'`; do case $x in Alpha|Beta|Gamma|Stable) ;; *) echo "$package: Unknown package" \ "status: $x" ;; esac done for x in `egrep -a '^\[(L|LICENSE)\]' $pdir/$package.desc | cut -f2- -d']'`; do case $x in Unknown|GPL|LGPL|GPL3|LGPL3|AGPL|AGPL3|MPL|FDL|MIT|BSD|EUPL|ISC|APL|APSL|BSL|CDDL|QPL|OFL|ZLIB|UNL|CC0) ;; OpenSource|Free-to-use|Commercial) ;; IBM-Public-License|Restricted|Artistic) ;; PublicDomain) ;; *) echo "$package: Unknown package" \ "license: $x" ;; esac done grep '^\[.*(\*)' misc/share/PKG-DESC-FORMAT | sed 's/][^]]*$//; s/. ./|/g; s/^\[//;' | while read line; do egrep -q "^\[($line)\]" $pdir/$package.desc || echo "$package: No [$line] tag found." done grep '^\[.*(1)' misc/share/PKG-DESC-FORMAT | sed 's/][^]]*$//; s/. ./|/g; s/^\[//;' | while read line; do lines=`egrep -a "^\[($line)\]" $pdir/$package.desc` [ "$lines" != "${lines// /}" ] && echo "$package: More than one [$line] tag found." done else echo "$package: File not found: $pdir/$package.desc" fi if [ -f $pdir/$package.conf ]; then bash -n $pdir/$package.conf 2>&1 | sed "s,^,$package: ," fi done