From 2b47c96cf2cc4cdc9eb10fb61f3414984de28886 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 13 Oct 2022 21:14:42 +0200 Subject: [PATCH] move licenses into module proper --- .gitignore | 1 + scripts/genlic.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++ scripts/make-sfx.sh | 42 ++-------------------------------------- setup.py | 7 +++++++ 4 files changed, 57 insertions(+), 40 deletions(-) create mode 100755 scripts/genlic.sh diff --git a/.gitignore b/.gitignore index f97a834c..a5162eaf 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ copyparty.egg-info/ *.bak # derived +copyparty/res/COPYING.txt copyparty/web/deps/ srv/ diff --git a/scripts/genlic.sh b/scripts/genlic.sh new file mode 100755 index 00000000..6c549371 --- /dev/null +++ b/scripts/genlic.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -e + +outfile="$(realpath "$1")" + +[ -e genlic.sh ] || cd scripts +[ -e genlic.sh ] + +f=../build/mit.txt +[ -e $f ] || + curl https://opensource.org/licenses/MIT | + awk '/div>/{o=0}o>1;o{o++}/;COPYRIGHT HOLDER/{o=1}' | + awk '{gsub(/<[^>]+>/,"")};1' >$f + +f=../build/isc.txt +[ -e $f ] || + curl https://opensource.org/licenses/ISC | + awk '/div>/{o=0}o>2;o{o++}/;OWNER/{o=1}' | + awk '{gsub(/<[^>]+>/,"")};/./{b=0}!/./{b++}b>1{next}1' >$f + +f=../build/3bsd.txt +[ -e $f ] || + curl https://opensource.org/licenses/BSD-3-Clause | + awk '/div>/{o=0}o>1;o{o++}/HOLDER/{o=1}' | + awk '{gsub(/<[^>]+>/,"")};1' >$f + +f=../build/ofl.txt +[ -e $f ] || + curl https://opensource.org/licenses/OFL-1.1 | + awk '/PREAMBLE/{o=1}/sil\.org/{o=0}!o{next}/./{printf "%s ",$0;next}{print"\n"}' | + awk '{gsub(/<[^>]+>/,"");gsub(/^\s+/,"");gsub(/&/,"\\&")}/./{b=0}!/./{b++}b>1{next}1' >$f + +(sed -r 's/^L: /License: /;s/^C: /Copyright (c) /' <../docs/lics.txt +printf '\n\n--- MIT License ---\n\n'; cat ../build/mit.txt +printf '\n\n--- ISC License ---\n\n'; cat ../build/isc.txt +printf '\n\n--- BSD 3-Clause License ---\n\n'; cat ../build/3bsd.txt +printf '\n\n--- SIL Open Font License v1.1 ---\n\n'; cat ../build/ofl.txt +) | +while IFS= read -r x; do + [ "${x:0:4}" = "--- " ] || { + printf '%s\n' "$x" + continue + } + n=${#x} + p=$(( (80-n)/2 )) + printf "%${p}s\033[07m%s\033[0m\n" "" "$x" +done > "$outfile" diff --git a/scripts/make-sfx.sh b/scripts/make-sfx.sh index 3390013e..5e650e12 100755 --- a/scripts/make-sfx.sh +++ b/scripts/make-sfx.sh @@ -226,46 +226,8 @@ tmpdir="$( # remove type hints before build instead (cd copyparty; "$pybin" ../../scripts/strip_hints/a.py; rm uh) -f=../build/mit.txt -[ -e $f ] || - curl https://opensource.org/licenses/MIT | - awk '/div>/{o=0}o>1;o{o++}/;COPYRIGHT HOLDER/{o=1}' | - awk '{gsub(/<[^>]+>/,"")};1' >$f - -f=../build/isc.txt -[ -e $f ] || - curl https://opensource.org/licenses/ISC | - awk '/div>/{o=0}o>2;o{o++}/;OWNER/{o=1}' | - awk '{gsub(/<[^>]+>/,"")};/./{b=0}!/./{b++}b>1{next}1' >$f - -f=../build/3bsd.txt -[ -e $f ] || - curl https://opensource.org/licenses/BSD-3-Clause | - awk '/div>/{o=0}o>1;o{o++}/HOLDER/{o=1}' | - awk '{gsub(/<[^>]+>/,"")};1' >$f - -f=../build/ofl.txt -[ -e $f ] || - curl https://opensource.org/licenses/OFL-1.1 | - awk '/PREAMBLE/{o=1}/sil\.org/{o=0}!o{next}/./{printf "%s ",$0;next}{print"\n"}' | - awk '{gsub(/<[^>]+>/,"");gsub(/^\s+/,"");gsub(/&/,"\\&")}/./{b=0}!/./{b++}b>1{next}1' >$f - -(sed -r 's/^L: /License: /;s/^C: /Copyright (c) /' <../docs/lics.txt -printf '\n\n--- MIT License ---\n\n'; cat ../build/mit.txt -printf '\n\n--- ISC License ---\n\n'; cat ../build/isc.txt -printf '\n\n--- BSD 3-Clause License ---\n\n'; cat ../build/3bsd.txt -printf '\n\n--- SIL Open Font License v1.1 ---\n\n'; cat ../build/ofl.txt -) | -while IFS= read -r x; do - [ "${x:0:4}" = "--- " ] || { - printf '%s\n' "$x" - continue - } - n=${#x} - p=$(( (80-n)/2 )) - printf "%${p}s\033[07m%s\033[0m\n" "" "$x" -done > copyparty/res/COPYING.txt - + licfile=$(realpath copyparty/res/COPYING.txt) + (cd ../scripts; ./genlic.sh "$licfile") } ver= diff --git a/setup.py b/setup.py index 2a953d52..a9f4e63a 100755 --- a/setup.py +++ b/setup.py @@ -4,6 +4,7 @@ from __future__ import print_function import os import sys +import subprocess as sp from shutil import rmtree from setuptools import setup, Command, find_packages @@ -28,6 +29,11 @@ with open(here + "/README.md", "rb") as f: txt = f.read().decode("utf-8") long_description = txt +try: + cmd = "bash scripts/genlic.sh copyparty/res/COPYING.txt" + sp.Popen(cmd.split()).wait() +except: + pass about = {} if not VERSION: @@ -100,6 +106,7 @@ args = { "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: Jython", "Programming Language :: Python :: Implementation :: PyPy",