about summary refs log tree commit diff stats
path: root/common
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-06-11 09:05:24 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-06-11 09:05:24 +0200
commit58078de0ca0ad563b90caec78190dc17f492678d (patch)
tree18c1e6a8a60d7bafae51c53f03a1c954e9b58929 /common
parentrefactor(templates/): Move `LICENSE.spdx` and `README.md` to `common` (diff)
downloadflake-templates-58078de0ca0ad563b90caec78190dc17f492678d.tar.gz
flake-templates-58078de0ca0ad563b90caec78190dc17f492678d.zip
feat(common/init): Add basic handling of licenses
The license handling is still very WIP, as the `licensure.yml` file and the
README are not yet updated to the new license.
Diffstat (limited to '')
-rwxr-xr-xcommon/files/init43
1 files changed, 42 insertions, 1 deletions
diff --git a/common/files/init b/common/files/init
index b9b4f80..dfdf8c6 100755
--- a/common/files/init
+++ b/common/files/init
@@ -68,10 +68,51 @@ prompt CURRENT_DATE "The stylized version of the current date" "$(date +'%b %Y')
 prompt YEAR "The year the work on this has begun (for copyright reasons)" "$(date +'%Y')"
 
 # LICENSE.spdx data (source: https://github.com/david-a-wheeler/spdx-tutorial)
+if [ -e ./lpm.toml ]; then
+    # Use a different default license in latex projects.
+    init_default_license="CC-BY-SA-4.0"
+else
+    init_default_license="GPL-3.0-or-later"
+fi
+prompt SPDX_LICENSE_IDENTIFIER "THE SPDX identifer of your choosen license" "$init_default_license"
 prompt APPLICATION_ORIGINATOR "The person or organization from whom the package originally came" "$AUTHOR_NAME"
 prompt APPLICATION_HOME_PAGE "The package's home page URL" "https://$REMOTE/$OWNER/$REPOSITORY"
 
-echo "$DESCRIPTION" > .git/description
+echo "Downloading license .."
+case "$SPDX_LICENSE_IDENTIFIER" in
+"AGPL-3.0-or-later")
+    default_license_url="https://www.gnu.org/licenses/agpl-3.0.txt"
+    curl "$default_license_url" >COPYING
+    ;;
+"GPL-3.0-or-later")
+    default_license_url="https://www.gnu.org/licenses/gpl-3.0.txt"
+    curl "$default_license_url" >COPYING
+    ;;
+"LGPL-3.0-or-later")
+    default_license_url="https://www.gnu.org/licenses/lgpl+gpl-3.0.txt"
+    curl "https://www.gnu.org/licenses/gpl-3.0.txt" >COPYING
+    curl "https://www.gnu.org/licenses/lgpl-3.0-standalone.html" >COPYING.LESSER
+    ;;
+
+"Apache-2.0")
+    default_license_url="https://www.apache.org/licenses/LICENSE-2.0.txt"
+    curl "$default_license_url" >LICENSE
+    ;;
+
+"CC-BY-SA-4.0")
+    default_license_url="https://creativecommons.org/licenses/by-sa/4.0/legalcode.txt"
+    curl "$default_license_url" >LICENSE
+    ;;
+
+*)
+    default_license_url="file:///dev/null"
+    echo "    -> No license found for your identifier: '$SPDX_LICENSE_IDENTIFIER'"
+    ;;
+esac
+
+prompt LICENSE_URL "The url of the license" "$default_license_url" "dont_ask"
+
+echo "$DESCRIPTION" >.git/description
 
 while read -r var; do
     var_name="${var%=*}"