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
| | |
| | | |
| | | 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" |
| | |
| | | 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" |
File was renamed from tools/licenses/BSD-2-Clause |
| | |
| | | # 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 |
New file |
| | |
| | | #! /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' |
copy from tools/licenses/BSD-2-Clause
copy to tools/licenses/license.BSD-3-Clause
File was copied from tools/licenses/BSD-2-Clause |
| | |
| | | # 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 |
| | |
| | | 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 |
New file |
| | |
| | | #! /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' |
File was renamed from tools/licenses/ISC |
| | |
| | | # 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> |
New file |
| | |
| | | #! /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' |
File was renamed from tools/licenses/LGPL-2.1-only |
| | |
| | | # 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 |
| | | |
New file |
| | |
| | | #! /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' |
File was renamed from tools/licenses/LGPL-3.0-only |
| | |
| | | # 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 |
| | | |
New file |
| | |
| | | #! /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' |
File was renamed from tools/licenses/MIT |
| | |
| | | # 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> |
New file |
| | |
| | | #! /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' |
File was renamed from tools/licenses/MPL-2.0 |
| | |
| | | # 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 |
| | | ================================== |
| | | |
New file |
| | |
| | | #! /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' |
File was renamed from tools/licenses/PSF-2.0 |
| | |
| | | # 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"), |
New file |
| | |
| | | #! /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' |