diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-03 18:08:22 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-03 18:08:22 +0200 |
commit | d4c8bfd6f9fc4617b8abf7296cf65bcf5f7cc395 (patch) | |
tree | 8ae948332bcd44edc7c48e2d0698326dde6a66f2 /build/awk | |
parent | chore(templates): Use new common files (diff) | |
download | flake-templates-d4c8bfd6f9fc4617b8abf7296cf65bcf5f7cc395.tar.gz flake-templates-d4c8bfd6f9fc4617b8abf7296cf65bcf5f7cc395.zip |
chore(build): Regenerate
Diffstat (limited to '')
-rw-r--r-- | build/awk/.licensure.yml | 186 | ||||
-rw-r--r-- | build/awk/.reuse/templates/default.jinja2 | 2 | ||||
-rw-r--r-- | build/awk/LICENSE.spdx | 7 | ||||
-rw-r--r-- | build/awk/README.md | 15 | ||||
-rw-r--r-- | build/awk/docs/%INIT_APPLICATION_NAME.1.md | 16 | ||||
-rw-r--r-- | build/awk/init | 77 | ||||
-rwxr-xr-x | build/awk/scripts/renew_copyright_header.sh | 92 |
7 files changed, 47 insertions, 348 deletions
diff --git a/build/awk/.licensure.yml b/build/awk/.licensure.yml deleted file mode 100644 index 639d750..0000000 --- a/build/awk/.licensure.yml +++ /dev/null @@ -1,186 +0,0 @@ ---- -# Regexes which if matched by a file path will always be excluded from -# getting a license header -excludes: - - .*lock - - \.git/.* - - LICENSE.spdx - - LICENSE - - COPYING - - COPYING.LESSER - - .*\.(rst|txt|pdf) -# Definition of the licenses used on this project and to what files -# they should apply. -# -# No default license configuration is provided. This section must be -# configured by the user. -licenses: - - files: \.tex - ident: CC-BY-SA-4.0 - authors: - - name: "%INIT_AUTHOR_NAME" - email: "%INIT_AUTHOR_EMAIL" - - template: | - %INIT_APPLICATION_NAME_STYLIZED %INIT_YEAR - [year] (C) by [name of author] - SPDX-License-Identifier: CC-BY-SA-4.0 - - %INIT_APPLICATION_NAME_STYLIZED is licensed under a - Creative Commons Attribution-ShareAlike 4.0 International License. - - You should have received a copy of the license along with this - work. If not, see <https://creativecommons.org/licenses/by-sa/4.0/>. - - unwrap_text: false - - # Either a regex or the string "any" to determine to what files this - # license should apply. It is common for projects to have files - # under multiple licenses or with multiple copyright holders. This - # provides the ability to automatically license files correctly - # based on their file paths. - # - # If "any" is provided all files will match this license. - - files: any - # - # The license identifier, a list of common identifiers can be - # found at: https://spdx.org/licenses/ but existence of the ident - # in this list it is not enforced unless auto_template is set to - # true. - ident: GPL-3.0-or-later - # - # A list of authors who hold copyright over these files - authors: - # Provide either your full name or company name for copyright purposes - - name: "%INIT_AUTHOR_NAME" - # Optionally provide email for copyright purposes - email: "%INIT_AUTHOR_EMAIL" - - # The template that will be rendered to generate the header before - # comment characters are applied. Available variables are: - # - [year]: substituted with the current year. - # - [name of author]: Substituted with name of the author and email - # if provided. If email is provided the output appears as Full - # Name <email@example.com>. If multiple authors are provided the - # list is concatenated together with commas. - template: | - Copyright (C) %INIT_YEAR - [year]: - [name of author] - SPDX-License-Identifier: GPL-3.0-or-later - - This file is part of %INIT_APPLICATION_NAME_STYLIZED. - - %INIT_APPLICATION_NAME_STYLIZED is free software: you can redistribute it and/or modify - it under the terms of the Lesser GNU General Public License as - published by the Free Software Foundation, either version 3 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - and the Lesser GNU General Public License along with this program. - If not, see <https://www.gnu.org/licenses/>. - - - # If auto_template is true then template is ignored and the SPDX - # API will be queried with the ident value to automatically - # determine the license header template. auto_template works best - # with licenses that have a standardLicenseHeader field defined in - # their license info JSON, if it is not then we will use the full - # licenseText to generate the header which works fine for short - # licenses like MIT but can be quite lengthy for other licenses - # like BSD-4-Clause. The above default template is valid for most - # licenses and is recommended for MIT, and BSD licenses. Common - # licenses that work well with the auto_template feature are GPL - # variants, and the Apache 2.0 license. - # - # Important Note: this means the ident must be a valid SPDX identifier - # auto_template: true - - # If true try to detect the text wrapping of the template, and unwrap it - unwrap_text: false - -# Define type of comment characters to apply based on file extensions. -comments: - # The extensions (or singular extension) field defines which file - # extensions to apply the commenter to. - - extensions: - - js - - go - # The commenter field defines the kind of commenter to - # generate. There are two types of commenters: line and block. - # - # This demonstrates a line commenter configuration. A line - # commenter type will apply the comment_char to the beginning of - # each line in the license header. It will then apply a number of - # empty newlines to the end of the header equal to trailing_lines. - # - # If trailing_lines is omitted it is assumed to be 0. - commenter: - type: line - comment_char: "//" - trailing_lines: 1 - - - extensions: - - rs - - tri - - css - - cpp - - c - - h - # This demonstrates a block commenter configuration. A block - # commenter type will add start_block_char as the first character - # in the license header and add end_block_char as the last character - # in the license header. If per_line_char is provided each line of - # the header between the block start and end characters will be - # line commented with the per_line_char - # - # trailing_lines works the same for both block and line commenter - # types - commenter: - type: block - start_block_char: "/*\n" - end_block_char: "*/\n" - per_line_char: "*" - trailing_lines: 1 - - - extension: - - html - - md - commenter: - type: block - start_block_char: "<!--\n" - end_block_char: "-->\n" - trailing_lines: 1 - - - extensions: - - el - - lisp - commenter: - type: line - comment_char: ";;;" - trailing_lines: 1 - - - extensions: - - tex - - bib - commenter: - type: line - comment_char: "%" - trailing_lines: 1 - - # The extension string "any" is special and so will match any file - # extensions. Commenter configurations are always checked in the - # order they are defined, so if any is used it should be the last - # commenter configuration or else it will override all others. - # - # In this configuration if we can't match the file extension we fall - # back to the popular '#' line comment used in most scripting - # languages. - - extension: any - commenter: - type: line - comment_char: '#' - trailing_lines: 1 diff --git a/build/awk/.reuse/templates/default.jinja2 b/build/awk/.reuse/templates/default.jinja2 new file mode 100644 index 0000000..688bffc --- /dev/null +++ b/build/awk/.reuse/templates/default.jinja2 @@ -0,0 +1,2 @@ +%INIT_REUSE_TEMPLATE +<!-- vim: ft=htmldjango --> diff --git a/build/awk/LICENSE.spdx b/build/awk/LICENSE.spdx deleted file mode 100644 index 2b99390..0000000 --- a/build/awk/LICENSE.spdx +++ /dev/null @@ -1,7 +0,0 @@ -SPDXVersion: SPDX-2.3 -DataLicense: CC0-1.0 -Creator: flake template init -PackageName: %INIT_APPLICATION_NAME -PackageOriginator: %INIT_APPLICATION_ORIGINATOR -PackageHomePage: %INIT_APPLICATION_HOME_PAGE -PackageLicenseDeclared: %INIT_SPDX_LICENSE_IDENTIFIER diff --git a/build/awk/README.md b/build/awk/README.md index 46287a6..9c5c6da 100644 --- a/build/awk/README.md +++ b/build/awk/README.md @@ -2,11 +2,10 @@ > %INIT_DESCRIPTION -Some text about the project. - -## Licence - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. +## Licensing +This project complies with the REUSE v3.2 specification. This means that every file +clearly states its copyright. +Please run `./scripts/cprh.sh contributer NAME EMAIL FILES..` after you +contributed to `FILES..` to record your contribution (obviously replacing +the `NAME`, `EMAIL` and `FILES..` placeholders with your name, email, and +the paths to the changed files respectively (see the `--help` output for more)). diff --git a/build/awk/docs/%INIT_APPLICATION_NAME.1.md b/build/awk/docs/%INIT_APPLICATION_NAME.1.md index e044647..5546aad 100644 --- a/build/awk/docs/%INIT_APPLICATION_NAME.1.md +++ b/build/awk/docs/%INIT_APPLICATION_NAME.1.md @@ -34,21 +34,13 @@ TODO # BUGS -Report bugs to <https://%INIT_REMOTE/%INIT_OWNER/%INIT_REPOSITORY/issues>. +Report bugs to <%INIT_BUG_URL>. # COPYRIGHT Copyright (C) %INIT_YEAR %INIT_AUTHOR_NAME -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. +This program is free software. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <https://www.gnu.org/licenses/>. +You should have received a copy of the License +along with this program. If not, see <%INIT_LICENSE_URL>. diff --git a/build/awk/init b/build/awk/init index f416b34..edb0d1e 100644 --- a/build/awk/init +++ b/build/awk/init @@ -51,8 +51,8 @@ git init # necessary meta data prompt APPLICATION_NAME "The name of the application" "$(basename "$PWD")" -prompt APPLICATION_NAME_STYLIZED "The stylized name of the application (for documentation)" "$(echo "$APPLICATION_NAME" | sed 's/\([a-z]*\)/\u\1/')" -prompt APPLICATION_NAME_CAPITALIZED_MAN_PART "The capitalized name of the application (for documentation also with a man section part)" "$(echo "$APPLICATION_NAME" | sed 's/\([a-z]*\)/\U\1(1)/')" "dont_ask" +prompt APPLICATION_NAME_STYLIZED "The stylized name of the application (for documentation)" "$(echo "$APPLICATION_NAME" sed 's/[_-]/ /g' | sed 's/^\(\w\)/\U\1/g' | sed 's/ \(\w\)/ \U\1/g')" +prompt APPLICATION_NAME_CAPITALIZED_MAN_PART "The capitalized name of the application (for documentation also with a man section part)" "$(echo "$APPLICATION_NAME" | sed 's/_/-/g' | sed 's/\(.*\)/\U\1(1)/')" "dont_ask" prompt APPLICATION_VERSION "The version of this program, without the prefix" "0.1.0" prompt AUTHOR_NAME "The name of the author (or authors)" "$(git config --get user.name)" @@ -60,59 +60,50 @@ prompt AUTHOR_EMAIL "The email of the author (or authors)" "$(git config --get u # cog change-log variables prompt REMOTE "The remote, this project will be pushed to" "git.vhack.eu" -prompt REPOSITORY "The name of the repository in the remote" "$APPLICATION_NAME" +prompt REPOSITORY "The path of the repository on the remote" "$APPLICATION_NAME" prompt OWNER "The name of owner of the repository" "$AUTHOR_NAME" # nice meta data -prompt DESCRIPTION "The description of this project" "[can be empty]" +prompt DESCRIPTION "The description of this project" "" 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')" prompt APPLICATION_SOURCE_CODE_REPOSITORY "The package's source code repository URL" "https://$REMOTE/$OWNER/$REPOSITORY" +prompt HOME_PAGE "The home page URL of the project" "https://$REPOSITORY.org/" +prompt BUG_URL "The URL people should report bugs to" "$APPLICATION_SOURCE_CODE_REPOSITORY/issues" -# 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" + init_default_license="AGPL-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 "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" +prompt SPDX_LICENSE_IDENTIFIER "THE SPDX identifer of your choosen license" "$init_default_license" "dont_ask" + +default_license_url="$(curl --silent --show-error "https://spdx.org/licenses/$SPDX_LICENSE_IDENTIFIER.json" | jq --raw-output '.seeAlso[0]')" + +# Prefer possible text versions of the license +if curl --fail --silent --show-error "$default_license_url.txt" >/dev/null; then + default_license_url="$default_license_url.txt" +fi +prompt LICENSE_URL "The url of the license" "$default_license_url" +prompt REUSE_TEMPLATE "The template used in reuse annotate" "$( + cat <<EOF | fmt --uniform-spacing --width=75 +{% for copyright_line in copyright_lines %} +{{ copyright_line }} +{% endfor %} +{% for contributor_line in contributor_lines %} +SPDX-FileContributor: {{ contributor_line }} +{% endfor %} +{% for expression in spdx_expressions %} +SPDX-License-Identifier: {{ expression }} +{% endfor %} + +This file is part of $APPLICATION_NAME_STYLIZED - $DESCRIPTION. + +You should have received a copy of the License along with this program. +If not, see <$LICENSE_URL>. +EOF +)" "dont_ask" echo "$DESCRIPTION" >.git/description diff --git a/build/awk/scripts/renew_copyright_header.sh b/build/awk/scripts/renew_copyright_header.sh deleted file mode 100755 index 423547f..0000000 --- a/build/awk/scripts/renew_copyright_header.sh +++ /dev/null @@ -1,92 +0,0 @@ -#! /usr/bin/env sh - -# NOTE: This is the line length of the .licensure.yml header template **plus** the extra -# line after the template comment. -TEMPLATE_LINE_LENGTH=20 -LATEX_TEMPLATE_LINE_LENGTH=9 - -PROJECT_ROOT="$(git rev-parse --show-toplevel)" - -remove() { - extension="$1" - file="$2" - - # We need to differentiate, when removing the old copyright header, as some - # formatters do weird things to the file - case "$extension" in - # normal '#' comments (these are $TEMPLATE_LINE_LENGTH lines long) - "Makefile" | "makefile" | "toml" | "envrc" | "yml" | "gitignore" | "awk" | "pest" | "lua") - sed --in-place "1,${TEMPLATE_LINE_LENGTH}d" "$file" - ;; - # LaTeX files (or TeX files in general) have a different license, use the - # $LATEX_TEMPLATE_LINE_LENGTH variable. - "tex") - sed --in-place "1,${LATEX_TEMPLATE_LINE_LENGTH}d" "$file" - ;; - # normal '/* ... */' like comments (these are $TEMPLATE_LINE_LENGTH + 2 lines long) - "c" | "h" | "md" | "rs" | "html" | "svg" | "drawio" | "tri") - length="$((TEMPLATE_LINE_LENGTH + 2))" - sed --in-place "1,${length}d;" "$file" - ;; - # alejandra (the nix formatter) removes the blank line after the comment, - # thus only $TEMPLATE_LINE_LENGTH - 1 lines - "nix") - length="$((TEMPLATE_LINE_LENGTH - 1))" - sed --in-place "1,${length}d;" "$file" - ;; - # Shell needs a shebang on the first line, only after the first line can we - # remove the $TEMPLATE_LINE_LENGTH lines - "sh") - sed --in-place "2,${TEMPLATE_LINE_LENGTH}d;" "$file" - licensure --in-place "$file" - - TEMPLATE_LINE_LENGTH_NEW="$(($(yq --raw-output '.licenses | map(.template) | join("")' "$PROJECT_ROOT/.licensure.yml" | wc -l) + $(yq '.comments | last | .commenter.trailing_lines' "$PROJECT_ROOT/.licensure.yml")))" - - # delete the current shebang - to="$((TEMPLATE_LINE_LENGTH_NEW + 1))" - sed --in-place "${TEMPLATE_LINE_LENGTH_NEW},${to}d;" "$file" - - # add a new one - sed --in-place "1i#! /usr/bin/env sh" "$file" - ;; - *) - echo "File '$file' with extension '$extension' is not know yet, please add it!" - ;; - esac -} - -list() { - echo "$extension -> $file" -} - -if [ -f "$1" ]; then - file="$(realpath "$1")" - filename="$(basename -- "$file")" - extension="${filename##*.}" - filename="${filename%.*}" - - if [ -n "$DRY_RUN" ]; then - list "$extension" "$file" - else - remove "$extension" "$file" - fi -else - fd --type file --hidden . | while read -r file; do - if grep --quiet 'SPDX-License-Identifier' "$file"; then - filename="$(basename -- "$file")" - extension="${filename##*.}" - filename="${filename%.*}" - - if [ -n "$DRY_RUN" ]; then - list "$extension" "$file" - else - remove "$extension" "$file" - fi - fi - done - - if [ -z "$DRY_RUN" ]; then - licensure --in-place --project - nix fmt - fi -fi |