#! /bin/sh # # $OpenBSD: license-check,v 1.2 1998/04/13 05:16:02 marc Exp $ # # This script verifies that all files in a given directory are # mentioned in the ports LICENSE file as Distribution allowed. # Output is three lists: # # Missing files: files that should be in the directory (if the # intent is to obtain all files that can be # re-distributed) but are not. # # Bad files: files that must NOT be in a distribution # directory. These are listed in the form # of a shell `rm -f xxx' command so they can # be fed to the shell after manual verification. # # Extra files: Files that are in the given directory that are # not mentioned in the ports LICENSE file. # # The ports base directory. Note: this may be supplied from the environment # using the standard bsd.port.mkl name of PORTSDIR # LICENCE=${PORTSDIR:-/usr/ports}/LICENSE # Our name and a function to spit out the usage. Exit. # prog=`basename $0` usage () { if [ ! -z "$1" ]; then echo "$prog: $1" fi echo "usage: $prog distribution-directory" exit 1 } # Verify we have one param and that it is the name of a directory. # If not spit out our usage and exit # if [ $# -eq 1 ]; then if [ -d $1 ]; then DIST=$1 else usage "$1 is not a directory" fi else usage fi # This awk script matches the licence file agains an `ls' of of the given # distribution directory and spits instructions out to stdout. # /bin/ls $DIST | awk -v L=$LICENCE ' BEGIN { # Process license file # while ( getline 0 ) { print "The following files/dirs are extra and " \ "should probably be removed:" print for ( i = 0; i < unk_count; i += 1 ) { print "/bin/rm -rf", unk_files[ i ] } print } } ' exit 0