1998-04-13 01:12:54 -04:00
|
|
|
#! /bin/sh
|
|
|
|
#
|
1998-09-24 00:27:04 -04:00
|
|
|
# $OpenBSD: license-check,v 1.3 1998/09/24 04:27:04 marc Exp $
|
1998-04-13 01:12:54 -04:00
|
|
|
#
|
|
|
|
# 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
|
1998-09-24 00:27:04 -04:00
|
|
|
# of a shell `mv -f xxx ../licensed' command so
|
|
|
|
# they can be fed to the shell (after manual
|
|
|
|
# verification) to move them into a directory
|
|
|
|
# that will not be copied to any CD-ROM.
|
|
|
|
#
|
|
|
|
# Unknown files: files that are noted in the LICENSE file but
|
|
|
|
# do not have a distribution flag of either Y or N.
|
1998-04-13 01:12:54 -04:00
|
|
|
#
|
|
|
|
# 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
|
1998-09-24 00:27:04 -04:00
|
|
|
# using the standard bsd.port.mk name of PORTSDIR
|
1998-04-13 01:12:54 -04:00
|
|
|
#
|
|
|
|
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
|
|
|
|
|
1998-09-24 00:27:04 -04:00
|
|
|
# This awk script matches the license file agains an `ls' of of the given
|
1998-04-13 01:12:54 -04:00
|
|
|
# distribution directory and spits instructions out to stdout.
|
|
|
|
#
|
|
|
|
/bin/ls $DIST |
|
|
|
|
awk -v L=$LICENCE '
|
|
|
|
BEGIN {
|
|
|
|
# Process license file
|
|
|
|
#
|
|
|
|
while ( getline <L ) {
|
|
|
|
if ( NF == 4 ) {
|
|
|
|
if ( $1 == "Y" ) {
|
|
|
|
good_files[ $3 ] = 0
|
|
|
|
} else if ( $1 == "N" ) {
|
|
|
|
bad_files[ $3 ] = 0
|
1998-09-24 00:27:04 -04:00
|
|
|
} else {
|
|
|
|
unk_files[ $3 ] = 0
|
1998-04-13 01:12:54 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-09-24 00:27:04 -04:00
|
|
|
extra_count = 0
|
1998-04-13 01:12:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
$1 in good_files {
|
|
|
|
good_files[ $1 ] = 1
|
|
|
|
next
|
|
|
|
}
|
|
|
|
$1 in bad_files {
|
|
|
|
bad_files[ $1 ] = 1
|
|
|
|
next
|
|
|
|
}
|
1998-09-24 00:27:04 -04:00
|
|
|
$1 in unk_files {
|
|
|
|
unk_files[ $1 ] = 1
|
|
|
|
next
|
|
|
|
}
|
1998-04-13 01:12:54 -04:00
|
|
|
{
|
1998-09-24 00:27:04 -04:00
|
|
|
extra_files[ extra_count++ ] = $1
|
1998-04-13 01:12:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
END {
|
|
|
|
header = 0
|
|
|
|
for ( f in good_files ) {
|
|
|
|
if ( good_files[ f ] == 0 ) {
|
|
|
|
if ( ! header ) {
|
|
|
|
print "You are missing the following files:"
|
|
|
|
print
|
|
|
|
header = 1
|
|
|
|
}
|
|
|
|
print f
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( header ) {
|
|
|
|
print
|
|
|
|
header = 0
|
|
|
|
}
|
|
|
|
for ( f in bad_files ) {
|
|
|
|
if ( bad_files[ f ] == 1 ) {
|
|
|
|
if ( ! header ) {
|
1998-09-24 00:27:04 -04:00
|
|
|
print "You MUST move the following files/directories:"
|
1998-04-13 01:12:54 -04:00
|
|
|
print
|
|
|
|
header = 1
|
|
|
|
}
|
1998-09-24 00:27:04 -04:00
|
|
|
print "/bin/mv -f", f, "../licensed"
|
1998-04-13 01:12:54 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( header ) {
|
|
|
|
print
|
|
|
|
header = 0
|
|
|
|
}
|
1998-09-24 00:27:04 -04:00
|
|
|
for ( f in unk_files ) {
|
|
|
|
if ( unk_files[ f ] == 1 ) {
|
|
|
|
if ( ! header ) {
|
|
|
|
print "The status of the following files is unknown:"
|
|
|
|
print
|
|
|
|
header = 1
|
|
|
|
}
|
|
|
|
print f
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( header ) {
|
|
|
|
print
|
|
|
|
header = 0
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( extra_count > 0 ) {
|
1998-04-13 01:16:02 -04:00
|
|
|
print "The following files/dirs are extra and " \
|
|
|
|
"should probably be removed:"
|
1998-04-13 01:12:54 -04:00
|
|
|
print
|
1998-09-24 00:27:04 -04:00
|
|
|
for ( i = 0; i < extra_count; i += 1 ) {
|
|
|
|
print "/bin/rm -rf", extra_files[ i ]
|
1998-04-13 01:12:54 -04:00
|
|
|
}
|
|
|
|
print
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'
|
|
|
|
exit 0
|