From d72c4be3c7848d7162456c49a349f3f8941a6d85 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sun, 10 Jun 2018 16:22:09 +0200 Subject: [PATCH] Allow other licenses than apache-2.0 Signed-off-by: Knut Ahlers --- bin/mklicense | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/mklicense b/bin/mklicense index 52ef961..54a862a 100755 --- a/bin/mklicense +++ b/bin/mklicense @@ -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