Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add copyright acknowledgements #105

Merged
merged 4 commits into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
autoconf \
m4 \
gperf \
licensecheck \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /code
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 JavascriptSubtitlesOctopus contributors
Copyright (c) 2017-2021 JavascriptSubtitlesOctopus contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
39 changes: 36 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -326,16 +326,49 @@ dist/js/subtitles-octopus-worker-legacy.js: src/subtitles-octopus-worker.bc src/
-s LEGACY_VM_SUPPORT=1 \
$(EMCC_COMMON_ARGS)

dist/js/subtitles-octopus.js: src/subtitles-octopus.js
dist/js/subtitles-octopus.js: dist/license/all src/subtitles-octopus.js
mkdir -p dist/js
cp src/subtitles-octopus.js dist/js/
awk '1 {print "// "$$0}' dist/license/all | cat - src/subtitles-octopus.js > $@

LIB_LICENSES := brotli expat freetype fribidi fontconfig harfbuzz libass
LIB_LICENSES_FINDOPT_brotli := -path ./research -prune -false -o ! -path ./js/decode.min.js
LIB_LICENSES_FINDOPT_expat := -path ./expat/fuzz -prune -false -o
LIB_LICENSES_FINDOPT_freetype := -path ./src/tools -prune -false -o
LIB_LICENSES_FINDOPT_fribidi := -path ./bin -prune -false -o
LIB_LICENSES_FINDOPT_harfbuzz := -path ./test -prune -false -o

$(addprefix dist/license/, $(LIB_LICENSES)): dist/license/%: .git/modules/lib/%/HEAD build/license_extract.sh build/license_defaults
@mkdir -p dist/license
(cd "lib/$*" && FINDOPTS="$(LIB_LICENSES_FINDOPT_$*)" \
../../build/license_extract.sh ../../build/license_defaults "$*" .) > $@

dist/license/subtitlesoctopus: .git/HEAD build/license_extract.sh
@mkdir -p dist/license
build/license_extract.sh build/license_defaults subtitlesoctopus src > dist/license/subtitlesoctopus

dist/license/all: dist/license/subtitlesoctopus $(addprefix dist/license/, $(LIB_LICENSES)) build/license_fullnotice build/license_lint.awk
@echo "# The following lists all copyright notices and licenses for the" > dist/license/all
@echo "# work contained in JavascriptSubtitlesOctopus per project." >> dist/license/all
@echo "" >> dist/license/all

@echo "Concatenate extracted license info..."
@$(foreach LIB_PROJ, subtitlesoctopus $(LIB_LICENSES), \
echo "# Project: $(LIB_PROJ)" >> dist/license/all && \
cat dist/license/$(LIB_PROJ) >> dist/license/all && \
) :

mv dist/license/all dist/license/all.tmp
build/license_lint.awk dist/license/all.tmp build/license_fullnotice
cat dist/license/all.tmp build/license_fullnotice > dist/license/all

# Clean Tasks

clean: clean-dist clean-libs clean-octopus

clean-dist:
cd dist && rm -frv ./libraries/* && rm -frv ./js/*
rm -frv dist/libraries/*
rm -frv dist/js/*
rm -frv dist/license/*
clean-libs:
rm -frv dist/libraries build/lib
clean-octopus:
Expand Down
12 changes: 12 additions & 0 deletions build/license_defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Tab seperated list of default license
# and if given copyrightholder per project
subtitlesoctopus Expat 2017-2021 JavascriptSubtitlesOctopus contributors

brotli Expat 2009, 2010, 2013-2016 by the Brotli Authors
expat Expat 2000-2017 Expat development team / 1997-2000 Thai Open Source Software Center Ltd
libass ISC 2006-2016 libass contributors
fontconfig NTP~disclaimer 2000-2007 Keith Packard / 2005 Patrick Lam / 2009 Roozbeh Pournader / 2008,2009 Red Hat, Inc. / 2008 Danilo Šegan / 2012 Google, Inc.

fribidi LGPL-2.1+
harfbuzz MIT~old
freetype FTL
95 changes: 95 additions & 0 deletions build/license_extract.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/sh

# Copyright 2021 Oneric
# SPDX-License-Identifier: ISC

# Postprocesses the output of licensecheck to automatically
# generate our distribution notice.
# licensecheck is packaged in Debian and its derivatives
# and can be obtained from CPAN everywhere.

usage() {
echo "$0 <map file> <project name> <dir>" >&2
exit 1
}

set -eu

FINDOPTS="${FINDOPTS:-}"
tabulator="$(printf '\t')"

if [ "$#" -ne 3 ] || [ ! -e "$3" ] \
|| [ ! -e "$1" ] || [ -d "$1" ] ; then
usage
fi

def_license="$(awk 'BEGIN{FS="\t+"} /^'"$2"'/ {print $2" | "$3}' "$1")"
def_copy="${def_license#* | }"
def_license="${def_license%% | *}"
base_dir="$3"

if [ -z "$def_license" ] || [ "$def_license" = "$def_copy" ] ; then
echo "The map file appears to be borked or entry is missing!" >&2
exit 1
fi

find "$base_dir" $FINDOPTS -type f -regextype egrep -regex '.*\.(c|h|cpp|hpp|js)$' -exec \
licensecheck --machine --copyright --deb-fmt '{}' \; \
| awk -F"$tabulator" -v base_dir="$base_dir" \
-v def_license="$def_license" -v def_copy="$def_copy" '
BEGIN {
split("", lcfiles) # Clear array with only pre-Issue 8 POSIX
SUBSEP = sprintf("\n") # Seperator for pseudo-multidim arrays

# Add default
if(def_copy && def_license)
++lcfiles[def_license, def_copy]
}

1 {
if ($2 == "UNKNOWN")
if (def_license) {
$2 = def_license
}else {
print "ERROR: Unlicensed file "$1" matched!" | "cat>&2"
print " If there is no default license, then" | "cat>&2"
print " reporting this upstream might be a good idea." | "cat>&2"
exit 1
}
if ($3 == "*No copyright*") {
if (def_copy) {
$3 = def_copy
} else if (def_license != $2) {
print "ERROR: Orphaned file "$1" and no default attribution!" | "cat>&2"
exit 1
} else {
# Appears eg in freetype ; hope default copyright holder is correct
next
}
}

split($3, copyh, " / ")
for(i in copyh)
++lcfiles[$2, copyh[i]];
}

END {
# Group copyright holders per license
# The second pass in END is required to only add each (license, copy) pair once
# using pure POSIX-only awk.
split("", tmp)
for(lc in lcfiles) {
split(lc, lico, SUBSEP)
if(lico[1] in tmp)
tmp[lico[1]] = tmp[lico[1]]""SUBSEP" "lico[2]
else
tmp[lico[1]] = lico[2]
}

for(license in tmp) {
printf "License: %s\n", license
printf "Copyright: %s\n", tmp[license]
printf "\n"
}
}
'
Loading