Allow other licenses than apache-2.0

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-06-10 16:22:09 +02:00
parent 5fdb3ae352
commit d72c4be3c7
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -1,9 +1,11 @@
#!/bin/bash
set -euo pipefail
# Download LICENSE template for Apache 2.0
LICENSE=${1:-apache-2.0}
# Download LICENSE template for selected license
curl -sSLf -H 'Accept: application/vnd.github.drax-preview+json' \
https://api.github.com/licenses/apache-2.0 | jq -r '.body' >LICENSE
https://api.github.com/licenses/${LICENSE} | jq -r '.body' >LICENSE
# Replace copyright stub with real data
NAME=$(git config --global user.name)
@ -14,4 +16,8 @@ start_year=$(date +%Y)
first_commit=$(git rev-list --max-parents=0 HEAD 2>/dev/null || echo "")
[ -n "${first_commit}" ] && start_year=$(git log --format="%cd" --date="format:%Y" "${first_commit}")
# Copyright replacement for Apache 2.0
sed -i "s/Copyright \[yyyy\] \[name of copyright owner\]/Copyright ${start_year}- ${NAME} <${MAIL}>/" LICENSE
# Copyright replacement for MIT
sed -i "s/Copyright (c) \[year\] \[fullname\]/Copyright (c) ${start_year}- ${NAME} <${MAIL}>/" LICENSE