Marcel Telka
2022-10-02 de9d5dbf784d1fc82b4e776710b0ed9a01b311c0
tools/license-detector: add BSD-2-Clause and BSD-3-Clause, improve MIT

3 files added
2 files modified
131 ■■■■■ changed files
components/perl/Socket6/perl-integrate-module.conf 1 ●●●● patch | view | raw | blame | history
tools/license-detector 40 ●●●● patch | view | raw | blame | history
tools/licenses/BSD-2-Clause 28 ●●●●● patch | view | raw | blame | history
tools/licenses/BSD-3-Clause 35 ●●●●● patch | view | raw | blame | history
tools/licenses/MIT 27 ●●●●● patch | view | raw | blame | history
components/perl/Socket6/perl-integrate-module.conf
@@ -15,5 +15,4 @@
%hook-no-license%
cat "$SOURCE_DIR/README" | gsed -e '0,/^5\. Copyright$/d' -e '/./,$!d' > "$DISTRIBUTION.license"
LICENSE="BSD-3-Clause"
USE_DEFAULT_PERL_LICENSE=0
tools/license-detector
@@ -19,15 +19,17 @@
function usage
{
    [[ -n "$1" ]] && printf "ERROR: %s\n\n" "$1" >&2
    printf "Usage: license-detector LICENSE_FILE\n" >&2
    printf "Usage: license-detector [-d] LICENSE_FILE\n" >&2
    [[ -n "$1" ]] && exit 1
    exit 0
}
while getopts ":hl:o:u" OPT ; do
DEBUG=0
while getopts ":hd" OPT ; do
    case "$OPT" in
    "?"|"h")    usage ;;
    "d")        DEBUG=1 ;;
    esac
done
shift $((OPTIND - 1))
@@ -39,6 +41,8 @@
[[ -e "$LICENSE_FILE" ]] || usage "$LICENSE_FILE not found"
[[ -d "$LICENSE_FILE" ]] && usage "$LICENSE_FILE is directory"
[[ -r "$LICENSE_FILE" ]] || usage "Unable to read $LICENSE_FILE"
WS_TOOLS=$(dirname $0)
F="$LICENSE_FILE"
@@ -82,10 +86,32 @@
    [[ -n "$L" ]] && L="$L OR " ; L="$L$D"
fi
if grep -q "The MIT License" "$F" ; then
    D="MIT-TODO"
    grep -q "The above copyright notice and this permission notice" "$F" && D="MIT"
    [[ -n "$L" ]] && L="$L OR " ; L="$L$D"
fi
for l in "$WS_TOOLS"/licenses/* ; do
    [[ -f "$l" ]] || continue
    LICCMD="$(grep '^# ' "$l" | sed -e 's/^# //')"
    [[ -n "$LICCMD" ]] && LICCMD=" | $LICCMD"
    CMD="awk '/^#/{next}/^\$/{\$0=\"\\n\"}1' ORS=' '"
    CMD="$CMD | sed -E -e 's/ +/ /g' -e 's/^ //' -e 's/ \$//'"
    CMD="$CMD$LICCMD"
    CMD="$CMD | tr ' ' '\\n' | gfmt -w 80"
    REDIRECT="/dev/null"
    if ((DEBUG)) ; then
        REDIRECT="/dev/stdout"
        printf "[DBG] TEMPLATE %s\n" "$(basename "$l")"
        eval $CMD < "$l"
        printf "[DBG] FILE\n"
        eval $CMD < "$F"
        printf "[DBG] DIFFS\n"
    fi
    diff -i <(eval $CMD < "$l") <(eval $CMD < "$F") > "$REDIRECT" || continue
    [[ -n "$L" ]] && L="$L OR "
    L="$L$(basename "$l")"
done
[[ -n "$L" ]] && printf "%s\n" "$L"
tools/licenses/BSD-2-Clause
New file
@@ -0,0 +1,28 @@
# 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
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
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
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
tools/licenses/BSD-3-Clause
New file
@@ -0,0 +1,35 @@
# sed -E -n
# -e 's/3\..+(be used to endorse or promote products.*)$/REPLACEABLE \1/'
# -e 's/\*[^*]+(be used to endorse or promote products.*)$/REPLACEABLE \1/'
# -e 's/[0-9]+\. *(Redistributions)/\1/g'
# -e 's/\* *(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
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
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
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
tools/licenses/MIT
New file
@@ -0,0 +1,27 @@
# sed -E -n
# -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>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.