Marcel Telka
2022-11-24 e1d0369c2511dbd104cb24adaaa40b0ed9294853
tools/license-detector: refactor to move filters to separate files and to support license headers

1 files deleted
1 files copied
8 files added
1 files modified
7 files renamed
269 ■■■■ changed files
tools/license-detector 17 ●●●● patch | view | raw | blame | history
tools/licenses/BSD-3-Clause 35 ●●●●● patch | view | raw | blame | history
tools/licenses/license.BSD-2-Clause 6 ●●●●● patch | view | raw | blame | history
tools/licenses/license.BSD-2-Clause.filter 23 ●●●●● patch | view | raw | blame | history
tools/licenses/license.BSD-3-Clause 10 ●●●●● patch | view | raw | blame | history
tools/licenses/license.BSD-3-Clause.filter 26 ●●●●● patch | view | raw | blame | history
tools/licenses/license.ISC 5 ●●●●● patch | view | raw | blame | history
tools/licenses/license.ISC.filter 22 ●●●●● patch | view | raw | blame | history
tools/licenses/license.LGPL-2.1-only 2 ●●●●● patch | view | raw | blame | history
tools/licenses/license.LGPL-2.1-only.filter 19 ●●●●● patch | view | raw | blame | history
tools/licenses/license.LGPL-3.0-only 3 ●●●●● patch | view | raw | blame | history
tools/licenses/license.LGPL-3.0-only.filter 20 ●●●●● patch | view | raw | blame | history
tools/licenses/license.MIT 6 ●●●●● patch | view | raw | blame | history
tools/licenses/license.MIT.filter 23 ●●●●● patch | view | raw | blame | history
tools/licenses/license.MPL-2.0 5 ●●●●● patch | view | raw | blame | history
tools/licenses/license.MPL-2.0.filter 22 ●●●●● patch | view | raw | blame | history
tools/licenses/license.PSF-2.0 4 ●●●● patch | view | raw | blame | history
tools/licenses/license.PSF-2.0.filter 21 ●●●●● patch | view | raw | blame | history
tools/license-detector
@@ -86,21 +86,25 @@
for l in "$WS_TOOLS"/licenses/* ; do
    [[ -f "$l" ]] || continue
    # skip filters
    [[ "$l" != "${l%.filter}" ]] && continue
    LICCMD="$(grep '^# ' "$l" | sed -e 's/^# //' | tr '\n' ' ')"
    cat <<#EOF > "$TMPFILE"
        dos2unix -ascii \\
            | awk '/^#/{next}/^\$/{\$0="\n"}1' ORS=' ' \\
            | sed -E -e 's/[[:space:]]+/ /g' -e 's/^ //' -e 's/ \$//' -e '/^\$/d' \\
            | ${LICCMD:-cat} \\
            | tr ' ' '\\n' | gfmt -w 80
    EOF
    # Apply filter if any
    [[ -x "$l.filter" ]] && printf "\t| %s \\\n" "$l.filter" >> "$TMPFILE"
    cat <<#EOF >> "$TMPFILE"
            | tr ' ' '\\n' | fmt
    EOF
    REDIRECT="/dev/null"
    if ((DEBUG)) ; then
        REDIRECT="/dev/stdout"
        printf "[DBG] TEMPLATE %s\n" "$(basename "$l")"
        printf "[DBG] TEMPLATE %s\n" "${l##*/}"
        . "$TMPFILE" < "$l"
        printf "[DBG] FILE\n"
        . "$TMPFILE" < "$F"
@@ -110,7 +114,10 @@
    diff -i <(. "$TMPFILE" < "$l") <(. "$TMPFILE" < "$F") > "$REDIRECT" || continue
    [[ -n "$L" ]] && L="$L OR "
    L="$L$(basename "$l")"
    l="${l##*/}"
    l="${l#header.}"
    l="${l#license.}"
    L="$L$l"
done
rm -f "$TMPFILE"
tools/licenses/BSD-3-Clause
File was deleted
tools/licenses/license.BSD-2-Clause
File was renamed from tools/licenses/BSD-2-Clause
@@ -1,9 +1,3 @@
# sed -E -n
# -e 's/[0-9]+\. *(Redistributions)/\1/g'
# -e 's/``/"/g' -e "s/''/\"/g"
# -e 's/(THIS SOFTWARE IS PROVIDED BY).*("AS IS" AND ANY).*(OR IMPLIED WARRANTIES)/\1 REPLACEABLE \2 REPLACEABLE \3/'
# -e 's/(IN NO EVENT SHALL).*(BE LIABLE)/\1 REPLACEABLE \2/'
# -e '/^Redistribution and use/,/^THIS SOFTWARE/p'
Copyright (c) <year> <owner>.
Redistribution and use in source and binary forms, with or without
tools/licenses/license.BSD-2-Clause.filter
New file
@@ -0,0 +1,23 @@
#! /usr/bin/sh
#
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2022 Marcel Telka
#
sed -E -n \
    -e 's/[0-9]+\. *(Redistributions)/\1/g' \
    -e 's/``/"/g' -e "s/''/\"/g" \
    -e 's/(THIS SOFTWARE IS PROVIDED BY).*("AS IS" AND ANY).*(OR IMPLIED WARRANTIES)/\1 REPLACEABLE \2 REPLACEABLE \3/' \
    -e 's/(IN NO EVENT SHALL).*(BE LIABLE)/\1 REPLACEABLE \2/' \
    -e '/^Redistribution and use/,/^THIS SOFTWARE/p'
tools/licenses/license.BSD-3-Clause
copy from tools/licenses/BSD-2-Clause copy to tools/licenses/license.BSD-3-Clause
File was copied from tools/licenses/BSD-2-Clause
@@ -1,9 +1,3 @@
# sed -E -n
# -e 's/[0-9]+\. *(Redistributions)/\1/g'
# -e 's/``/"/g' -e "s/''/\"/g"
# -e 's/(THIS SOFTWARE IS PROVIDED BY).*("AS IS" AND ANY).*(OR IMPLIED WARRANTIES)/\1 REPLACEABLE \2 REPLACEABLE \3/'
# -e 's/(IN NO EVENT SHALL).*(BE LIABLE)/\1 REPLACEABLE \2/'
# -e '/^Redistribution and use/,/^THIS SOFTWARE/p'
Copyright (c) <year> <owner>.
Redistribution and use in source and binary forms, with or without
@@ -16,6 +10,10 @@
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
tools/licenses/license.BSD-3-Clause.filter
New file
@@ -0,0 +1,26 @@
#! /usr/bin/sh
#
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2022 Marcel Telka
#
sed -n \
    -e 's/``/"/g' -e "s/''/\"/g" \
    -e 's/[123]\./*/g' \
    -e 's/^Neither/* &/' \
    -e 's/\*[^*]*\(be used to endorse or promote products\)/* REPLACEABLE \1/' \
    -e 's/\* *//g' \
    -e 's/\(THIS SOFTWARE IS PROVIDED BY\).*\("AS IS" AND ANY\).*\(OR IMPLIED WARRANTIES\)/\1 REPLACEABLE \2 REPLACEABLE \3/' \
    -e 's/\(IN NO EVENT SHALL\).*\(BE LIABLE\)/\1 REPLACEABLE \2/' \
    -e '/^Redistribution and use/,/^THIS SOFTWARE/p'
tools/licenses/license.ISC
File was renamed from tools/licenses/ISC
@@ -1,8 +1,3 @@
# sed -n
# -e 's/and \{0,1\}\/or distribute/and distribute/'
# -e 's/\(AND\) .* \(DISCLAIMS ALL WARRANTIES\)/\1 REPLACEABLE \2/'
# -e 's/\(IN NO EVENT SHALL\) .* \(BE LIABLE FOR ANY\)/\1 REPLACEABLE \2/'
# -e '/^Permission to use, copy, modify/,/^THE SOFTWARE IS PROVIDED/p'
ISC License
<copyright notice>
tools/licenses/license.ISC.filter
New file
@@ -0,0 +1,22 @@
#! /usr/bin/sh
#
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2022 Marcel Telka
#
sed -n \
    -e 's/and \{0,1\}\/or distribute/and distribute/' \
    -e 's/\(AND\) .* \(DISCLAIMS ALL WARRANTIES\)/\1 REPLACEABLE \2/' \
    -e 's/\(IN NO EVENT SHALL\) .* \(BE LIABLE FOR ANY\)/\1 REPLACEABLE \2/' \
    -e '/^Permission to use, copy, modify/,/^THE SOFTWARE IS PROVIDED/p'
tools/licenses/license.LGPL-2.1-only
File was renamed from tools/licenses/LGPL-2.1-only
@@ -1,5 +1,3 @@
# sed -n
# -e '/^Copyright (C) 1991, 1999 Free Software Foundation, Inc\./,/IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW/p'
                  GNU LESSER GENERAL PUBLIC LICENSE
                       Version 2.1, February 1999
tools/licenses/license.LGPL-2.1-only.filter
New file
@@ -0,0 +1,19 @@
#! /usr/bin/sh
#
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2022 Marcel Telka
#
sed -n \
    -e '/^Copyright (C) 1991, 1999 Free Software Foundation, Inc\./,/IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW/p'
tools/licenses/license.LGPL-3.0-only
File was renamed from tools/licenses/LGPL-3.0-only
@@ -1,6 +1,3 @@
# gsed
# -e '0,/^GNU LESSER GENERAL PUBLIC LICENSE/d'
# -e '/^GNU GENERAL PUBLIC LICENSE/,$d'
                   GNU LESSER GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007
tools/licenses/license.LGPL-3.0-only.filter
New file
@@ -0,0 +1,20 @@
#! /usr/bin/sh
#
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2022 Marcel Telka
#
gsed \
    -e '0,/^GNU LESSER GENERAL PUBLIC LICENSE/d' \
    -e '/^GNU GENERAL PUBLIC LICENSE/,$d'
tools/licenses/license.MIT
File was renamed from tools/licenses/MIT
@@ -1,9 +1,3 @@
# sed -E -n
# -e 's/“/"/g' -e 's/”/"/g'
# -e 's/(obtaining a copy of).*(\(the "Software"\))/\1 REPLACEABLE \2/'
# -e 's/(this permission notice).*(shall be included)/\1 \2/'
# -e 's/(IN NO EVENT SHALL).*(BE LIABLE)/\1 REPLACEABLE \2/'
# -e '/^Permission is hereby granted/,/^THE SOFTWARE/p'
MIT License
Copyright (c) <year> <copyright holders>
tools/licenses/license.MIT.filter
New file
@@ -0,0 +1,23 @@
#! /usr/bin/sh
#
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2022 Marcel Telka
#
sed -E -n \
    -e 's/“/"/g' -e 's/”/"/g' \
    -e 's/(obtaining a copy of).*(\(the "Software"\))/\1 REPLACEABLE \2/' \
    -e 's/(this permission notice).*(shall be included)/\1 \2/' \
    -e 's/(IN NO EVENT SHALL).*(BE LIABLE)/\1 REPLACEABLE \2/' \
    -e '/^Permission is hereby granted/,/^THE SOFTWARE/p'
tools/licenses/license.MPL-2.0
File was renamed from tools/licenses/MPL-2.0
@@ -1,8 +1,3 @@
# sed -n
# -e 's/ \(\* \)\{1,\}/ /g' -e 's/^\* //' -e 's/ \*$//'
# -e 's/ -\{3,\} / /g' -e 's/ -\{3,\}$//'
# -e 's/ \*\{3,\} / /g' -e 's/^\*\{3,\} //' -e 's/ \*\{3,\}$//' -e '/^\*\{3,\}$/d'
# -e '/Definitions$/,/Exhibit B of this License must be attached\.$/p'
Mozilla Public License Version 2.0
==================================
tools/licenses/license.MPL-2.0.filter
New file
@@ -0,0 +1,22 @@
#! /usr/bin/sh
#
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2022 Marcel Telka
#
sed -n \
    -e 's/ \(\* \)\{1,\}/ /g' -e 's/^\* //' -e 's/ \*$//' \
    -e 's/ -\{3,\} / /g' -e 's/ -\{3,\}$//' \
    -e 's/ \*\{3,\} / /g' -e 's/^\*\{3,\} //' -e 's/ \*\{3,\}$//' -e '/^\*\{3,\}$/d' \
    -e '/Definitions$/,/Exhibit B of this License must be attached\.$/p'
tools/licenses/license.PSF-2.0
File was renamed from tools/licenses/PSF-2.0
@@ -1,7 +1,3 @@
# sed -n
# -e 's/^[1-8]\. \{1,\}//'
# -e 's/\(Copyright (c)\) .* \(Python Software Foundation\)/\1 \2/'
# -e '/^This LICENSE AGREEMENT is between the Python Software Foundation/,/By copying, installing or otherwise using Python/p'
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"),
tools/licenses/license.PSF-2.0.filter
New file
@@ -0,0 +1,21 @@
#! /usr/bin/sh
#
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2022 Marcel Telka
#
sed -n \
    -e 's/^[1-8]\. \{1,\}//' \
    -e 's/\(Copyright (c)\) .* \(Python Software Foundation\)/\1 \2/' \
    -e '/^This LICENSE AGREEMENT is between the Python Software Foundation/,/By copying, installing or otherwise using Python/p'