tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Handling licenses

On Sat, Jul 09, 2016 at 01:10:31PM +0200, Roland Illig wrote:
> Also, the pkgsrc guide does not give helpful instructions on determining
> which license a package has. 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? Recognizing the GNU GPL is easy, since it says so, but
> choosing between the various BSD licenses requires reading the whole
> text, as far as I know.

I don’t know of any standard way of recognising the
licences, but I have written a script to do just that.
It’s not efficient, but seems to be pretty accurate.

Given the licence file as the only argument, it
compares it to other licence files and ranks them by
similarity defined as a low number of differing words.

You’ll have to adjust the path to licence files, and
maybe adapt it to wdiff or some other word-oriented
diff if you prefer it over the one built into git.

==> <==

for l in ~/pkgsrc/licenses/*
    [ -f "$l" ] || continue
    printf '%s	' "`basename "$l"`"
    tr '
' ' ' < "$1"	\
    | git diff --word-diff-regex='[[:alpha:]]+' "$l" -	\
    | grep -o '\[-[^]]\+-]\|{+[^}]\++}'	\
    | wc -w 2> /dev/null
done | sort -r -n -k 2 | tail

Mateusz Poszwa

Home | Main Index | Thread Index | Old Index