tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Handling licenses
Am 10.07.2016 um 17:28 schrieb Greg Troxel:
> Roland Illig <roland.illig%gmx.de@localhost> writes:
>> Do we have some tool that I can feed a
>> given COPYING file into, and it tells me which of the predefined
>> licenses it is?
>
> I append a hacky script that uses wdiff, on the notion that in finding
> out if a given license text is close enough to an established one to
> call it the same, it is most useful to look at files with low diff
> distance.
The script is cool, thanks. I improved it a bit so that it doesn't "cd"
during its work. As a result, it is possible to feed it absolute or
relative pathnames. It also uses a fixed temporary directory for its
results so that the filesystem doesn't get cluttered with
license-comparing directories.
----
#! /bin/sh
set -eu
if [ $# -ne 1 ]; then
echo "usage: find-license license-file" 2>&1
exit 1
fi
: ${PKGSRCDIR:=/usr/pkgsrc}
: ${TMPDIR:=/tmp}
candidate=$1
resultdir="$TMPDIR/find-license"
mkdir -p "$resultdir"
for license in $PKGSRCDIR/licenses/*; do
if [ -f "$license" ]; then
wdiff -3 "$license" "$candidate" \
> "$resultdir/${license##*/}" || true
fi
done
echo "Best-matching licenses for $candidate:"
ls -lrS $resultdir/* | grep -v ^total | sed 10q
Home |
Main Index |
Thread Index |
Old Index