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 | |
parent | chore(templates): Use new common files (diff) | |
download | flake-templates-d4c8bfd6f9fc4617b8abf7296cf65bcf5f7cc395.tar.gz flake-templates-d4c8bfd6f9fc4617b8abf7296cf65bcf5f7cc395.zip |
chore(build): Regenerate
59 files changed, 552 insertions, 1803 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 diff --git a/build/c/.licensure.yml b/build/c/.licensure.yml deleted file mode 100644 index 639d750..0000000 --- a/build/c/.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/c/.reuse/templates/default.jinja2 b/build/c/.reuse/templates/default.jinja2 new file mode 100644 index 0000000..688bffc --- /dev/null +++ b/build/c/.reuse/templates/default.jinja2 @@ -0,0 +1,2 @@ +%INIT_REUSE_TEMPLATE +<!-- vim: ft=htmldjango --> diff --git a/build/c/LICENSE.spdx b/build/c/LICENSE.spdx deleted file mode 100644 index 2b99390..0000000 --- a/build/c/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/c/README.md b/build/c/README.md index 46287a6..9c5c6da 100644 --- a/build/c/README.md +++ b/build/c/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/c/docs/%INIT_APPLICATION_NAME.1.md b/build/c/docs/%INIT_APPLICATION_NAME.1.md index e044647..5546aad 100644 --- a/build/c/docs/%INIT_APPLICATION_NAME.1.md +++ b/build/c/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/c/init b/build/c/init index f416b34..edb0d1e 100644 --- a/build/c/init +++ b/build/c/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/c/makefile b/build/c/makefile index 63ca24c..6128f06 100644 --- a/build/c/makefile +++ b/build/c/makefile @@ -12,8 +12,8 @@ BIN_PATH := $(BUILD_DIR)$(BIN_NAME) SRC := $(wildcard src/*.c) -OBJ := $(SRC:.c=.o) -DEP := $(OBJ:.o=.d) +OBJ := $(addprefix $(BUILD_DIR),$(notdir $(SRC:.c=.o))) +DEP := $(addprefix $(BUILD_DIR),$(notdir $(SRC:.c=.d))) LIBS := @@ -25,11 +25,11 @@ default: all all: $(BIN_NAME) $(BIN_NAME): $(OBJ) - $(CC) $(addprefix $(BUILD_DIR),$(notdir $(OBJ))) -o $(addprefix $(BUILD_DIR),$(notdir $(BIN_NAME))) $(ALL_CFLAGS) $(ALL_LDFLAGS) + $(CC) $^ -o $(addprefix $(BUILD_DIR),$(notdir $(BIN_NAME))) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(OBJ): $(SRC) - mkdir --parents $(BUILD_DIR) - $(CC) -c $< -o $(addprefix $(BUILD_DIR),$(notdir $(OBJ))) $(ALL_CFLAGS) + @mkdir --parents $(BUILD_DIR) + $(CC) -c -o $@ $(addprefix ./src/,$(patsubst %.o,%.c,$(notdir $@))) $(ALL_CFLAGS) manual: mkdir --parents $(BUILD_DIR)docs diff --git a/build/c/makefile.~1~ b/build/c/makefile.~1~ deleted file mode 100644 index 9352bdb..0000000 --- a/build/c/makefile.~1~ +++ /dev/null @@ -1,66 +0,0 @@ -PREFIX := /usr/local -BINPREFIX := $(DESTDIR)$(PREFIX)/bin -MANPREFIX := $(DESTDIR)$(PREFIX)/share/man/man1 - -BIN_NAME := screenr_spotify -# This version is set automatically on `cog bump --auto`; -BIN_VERSION := "v0.1.0" # GUIDING VERSION STRING - -# The trailing slash is important -BUILD_DIR := ./target/ -BIN_PATH := $(BUILD_DIR)$(BIN_NAME) - - -SRC := $(wildcard src/*.c) -OBJ := $(addprefix $(BUILD_DIR),$(notdir $(SRC:.c=.o))) -DEP := $(addprefix $(BUILD_DIR),$(notdir $(SRC:.c=.d))) - -LIBS := - -ALL_CFLAGS := -O3 -MMD -Wall -Wextra -Wno-unused-parameter $(CFLAGS) $(CPPFLAGS) -ALL_LDFLAGS := $(addprefix -l,$(LIBS)) -L $(LD_LIBRARY_PATH) $(LDFLAGS) - -default: all - -all: $(BIN_NAME) - -$(BIN_NAME): $(OBJ) - $(CC) $^ -o $(addprefix $(BUILD_DIR),$(notdir $(BIN_NAME))) $(ALL_CFLAGS) $(ALL_LDFLAGS) - -$(OBJ): $(SRC) - @mkdir --parents $(BUILD_DIR) - $(CC) -c -o $@ $(addprefix ./src/,$(patsubst %.o,%.c,$(notdir $@))) $(ALL_CFLAGS) - -manual: - mkdir --parents $(BUILD_DIR)docs - pandoc "./docs/$(BIN_NAME).1.md" -s -t man > $(BUILD_DIR)docs/$(BIN_NAME).1 - -.PHONY : clean options install memory_leak_test -options: - @echo "PREFIX = $(PREFIX)" - @echo "BINPREFIX = $(BINPREFIX)" - @echo "MANPREFIX = $(MANPREFIX)" - @echo "" - @echo "BIN_NAME = $(BIN_NAME)" - @echo "BUILD_DIR = $(BUILD_DIR)" - @echo "BIN_PATH = $(BIN_PATH)" - @echo "" - @echo "SRC = $(SRC)" - @echo "OBJ = $(OBJ)" - @echo "DEP = $(DEP)" - @echo "" - @echo "LIBS = $(LIBS)" - @echo "" - @echo "ALL_CFLAGS = $(ALL_CFLAGS)" - @echo "ALL_LDFLAGS = $(ALL_LDFLAGS)" - @echo "" - -clean : - rm --recursive $(BUILD_DIR) - -install: $(BIN_NAME) manual - install -D $(BUILD_DIR)docs/$(BIN_NAME).1 $(MANPREFIX)/$(BIN_NAME); - install -D $(BUILD_DIR)$(BIN_NAME) $(BINPREFIX)/$(BIN_NAME); - -memory_leak_test: - sh ./scripts/valgrind_test.sh $(BIN_NAME) diff --git a/build/c/scripts/cprh.sh b/build/c/scripts/cprh.sh new file mode 100755 index 0000000..9582575 --- /dev/null +++ b/build/c/scripts/cprh.sh @@ -0,0 +1,57 @@ +#! /usr/bin/env sh + +die() { + echo "$@" 1>&2 + exit 1 +} + +help() { + cat <<EOF +A copyright header managment tool. + +USAGE: + cprh.sh [OPTIONS] contribute NAME EMAIL FILE.. + +OPTIONS: + --help | -h + Display this help and exit. + +ARGUMENTS: + NAME := [[git config user.name]] + Your name. + + NAME := [[git config user.email]] + Your email address. + + FILE := [[git diff --name-only --cached]] + The file you want to change. This can be given multiple times. +EOF +} + +for arg in "$@"; do + case "$arg" in + "--help" | "-h") + help + exit 0 + ;; + *) + echo "'$1' is not a recognized option. See --help for more!" 1>&2 + exit 1 + ;; + esac +done + +user_name="$1" +[ -z "$user_name" ] && die "No NAME set! See --help for more" + +user_email="$2" +[ -z "$user_email" ] && die "No EMAIL set! See --help for more" +shift 2 + +styleOne="" +styleTwo="" +[ "$COMMENT_STYLE" ] && styleOne="--style" && styleTwo="$COMMENT_STYLE" + +# The styleTwo must be unquoted to avoid adding empty args to reuse +# shellcheck disable=2086 +reuse annotate --copyright "$user_name <$user_email>" --copyright-prefix string-c --template default --multi-line $styleOne $styleTwo diff --git a/build/c/scripts/renew_copyright_header.sh b/build/c/scripts/renew_copyright_header.sh deleted file mode 100755 index 423547f..0000000 --- a/build/c/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 diff --git a/build/latex/.licensure.yml b/build/latex/.licensure.yml deleted file mode 100644 index 639d750..0000000 --- a/build/latex/.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/latex/LICENSE.spdx b/build/latex/LICENSE.spdx deleted file mode 100644 index 2b99390..0000000 --- a/build/latex/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/latex/%INIT_APPLICATION_NAME.tex b/build/latex/academia/%INIT_APPLICATION_NAME.tex index e7934fe..e7934fe 100644 --- a/build/latex/%INIT_APPLICATION_NAME.tex +++ b/build/latex/academia/%INIT_APPLICATION_NAME.tex diff --git a/build/latex/.envrc b/build/latex/academia/.envrc index 3bc1085..3bc1085 100644 --- a/build/latex/.envrc +++ b/build/latex/academia/.envrc diff --git a/build/latex/.gitignore b/build/latex/academia/.gitignore index 539b891..539b891 100644 --- a/build/latex/.gitignore +++ b/build/latex/academia/.gitignore diff --git a/build/latex/academia/.reuse/templates/default.jinja2 b/build/latex/academia/.reuse/templates/default.jinja2 new file mode 100644 index 0000000..688bffc --- /dev/null +++ b/build/latex/academia/.reuse/templates/default.jinja2 @@ -0,0 +1,2 @@ +%INIT_REUSE_TEMPLATE +<!-- vim: ft=htmldjango --> diff --git a/build/latex/LICENSE b/build/latex/academia/LICENSE index dbb2b35..dbb2b35 100644 --- a/build/latex/LICENSE +++ b/build/latex/academia/LICENSE diff --git a/build/latex/README.md b/build/latex/academia/README.md index ffa08c2..ffa08c2 100644 --- a/build/latex/README.md +++ b/build/latex/academia/README.md diff --git a/build/latex/build.sh b/build/latex/academia/build.sh index 1206ee7..1206ee7 100755 --- a/build/latex/build.sh +++ b/build/latex/academia/build.sh diff --git a/build/latex/cog.toml b/build/latex/academia/cog.toml index ccca764..ccca764 100644 --- a/build/latex/cog.toml +++ b/build/latex/academia/cog.toml diff --git a/build/latex/content/static/title.tex b/build/latex/academia/content/static/title.tex index e4a833d..e4a833d 100644 --- a/build/latex/content/static/title.tex +++ b/build/latex/academia/content/static/title.tex diff --git a/build/latex/flake.lock b/build/latex/academia/flake.lock index e095a79..1d384fd 100644 --- a/build/latex/flake.lock +++ b/build/latex/academia/flake.lock @@ -104,17 +104,17 @@ ] }, "locked": { - "lastModified": 1711915832, - "narHash": "sha256-5vFraJ2xnDvuEI2zeUbre8amzVDLAneODNNdJb6HSZk=", + "lastModified": 1718253944, + "narHash": "sha256-22AP7h3Utx7xfJ7uyPWH2f6B6xFysCYgPQhNonTeEQ4=", "ref": "refs/heads/prime", - "rev": "67f3079cd49deb116ba215244e7a1a1575a71ede", - "revCount": 10, + "rev": "7ea10db20a83eedffd69a8c8824e14992ada3e10", + "revCount": 20, "type": "git", - "url": "https://codeberg.org/Soispha/lpm.git" + "url": "https://codeberg.org/bpeetz/lpm.git" }, "original": { "type": "git", - "url": "https://codeberg.org/Soispha/lpm.git" + "url": "https://codeberg.org/bpeetz/lpm.git" } }, "nixpkgs": { diff --git a/build/latex/flake.nix b/build/latex/academia/flake.nix index efc4f3f..1e0969e 100644 --- a/build/latex/flake.nix +++ b/build/latex/academia/flake.nix @@ -19,7 +19,7 @@ }; }; lpm = { - url = "git+https://codeberg.org/Soispha/lpm.git"; + url = "git+https://codeberg.org/bpeetz/lpm.git"; inputs = { nixpkgs.follows = "nixpkgs"; flake-compat.follows = "flake-compat"; diff --git a/build/latex/headers/preamble.tex b/build/latex/academia/headers/preamble.tex index bc8aa8a..bc8aa8a 100644 --- a/build/latex/headers/preamble.tex +++ b/build/latex/academia/headers/preamble.tex diff --git a/build/latex/headers/preamble_local.tex b/build/latex/academia/headers/preamble_local.tex index e69de29..e69de29 100644 --- a/build/latex/headers/preamble_local.tex +++ b/build/latex/academia/headers/preamble_local.tex diff --git a/build/latex/init b/build/latex/academia/init index f416b34..edb0d1e 100644 --- a/build/latex/init +++ b/build/latex/academia/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/latex/lpm.toml b/build/latex/academia/lpm.toml index 636eae9..0925886 100644 --- a/build/latex/lpm.toml +++ b/build/latex/academia/lpm.toml @@ -1,10 +1,8 @@ -[last_chapter] -user_name = "static" -number = 0 +main_file = "%INIT_APPLICATION_NAME.tex" [templates] section = ''' -%! TEX root = ../../../%INIT_APPLICATION_NAME +%! TEX root = ../../../%INIT_APPLICATION_NAME.tex % LTeX: language=en-GB \section{REPLACMENT_SECTION_TITLE} % DATE @@ -12,7 +10,7 @@ This is some text ''' chapter = ''' -%! TEX root = ../../%INIT_APPLICATION_NAME +%! TEX root = ../../%INIT_APPLICATION_NAME.tex % LTeX: language=en-GB \chapter{REPLACEMENT_CHAPTER} diff --git a/build/latex/academia/possible_resources_for_v3_template.txt b/build/latex/academia/possible_resources_for_v3_template.txt new file mode 100644 index 0000000..4232d52 --- /dev/null +++ b/build/latex/academia/possible_resources_for_v3_template.txt @@ -0,0 +1,15 @@ +https://davidcarlisle.github.io/uk-tex-faq/ +https://ctan.org/tex-archive/info/knuth-pdf +https://www.ctan.org/pkg/texinfo +https://davidcarlisle.github.io/uk-tex-faq/FAQ-LaTeX2HTML.html +https://www.w3.org/Tools/Word_proc_filters.html +https://davidcarlisle.github.io/uk-tex-faq/FAQ-mathml.html +-- +https://ctan.org/pkg/l3kernel +https://stackoverflow.com/questions/2918449/inlining-the-latex-input-command +https://ctan.org/tex-archive/support/flatten +https://ctan.org/tex-archive/support/flatex +http://www.math.tau.ac.il/~sariel/flatex.html +https://mirror.funkfreundelandshut.de/latex/macros/latex/required/l3kernel/expl3.pdf +https://tex.stackexchange.com/questions/24932/moving-to-latex3-for-package-authors +https://ctan.org/pkg/l3packages diff --git a/build/latex/references/reference.bib b/build/latex/academia/references/reference.bib index e69de29..e69de29 100644 --- a/build/latex/references/reference.bib +++ b/build/latex/academia/references/reference.bib diff --git a/build/latex/academia/scripts/cprh.sh b/build/latex/academia/scripts/cprh.sh new file mode 100755 index 0000000..9582575 --- /dev/null +++ b/build/latex/academia/scripts/cprh.sh @@ -0,0 +1,57 @@ +#! /usr/bin/env sh + +die() { + echo "$@" 1>&2 + exit 1 +} + +help() { + cat <<EOF +A copyright header managment tool. + +USAGE: + cprh.sh [OPTIONS] contribute NAME EMAIL FILE.. + +OPTIONS: + --help | -h + Display this help and exit. + +ARGUMENTS: + NAME := [[git config user.name]] + Your name. + + NAME := [[git config user.email]] + Your email address. + + FILE := [[git diff --name-only --cached]] + The file you want to change. This can be given multiple times. +EOF +} + +for arg in "$@"; do + case "$arg" in + "--help" | "-h") + help + exit 0 + ;; + *) + echo "'$1' is not a recognized option. See --help for more!" 1>&2 + exit 1 + ;; + esac +done + +user_name="$1" +[ -z "$user_name" ] && die "No NAME set! See --help for more" + +user_email="$2" +[ -z "$user_email" ] && die "No EMAIL set! See --help for more" +shift 2 + +styleOne="" +styleTwo="" +[ "$COMMENT_STYLE" ] && styleOne="--style" && styleTwo="$COMMENT_STYLE" + +# The styleTwo must be unquoted to avoid adding empty args to reuse +# shellcheck disable=2086 +reuse annotate --copyright "$user_name <$user_email>" --copyright-prefix string-c --template default --multi-line $styleOne $styleTwo diff --git a/build/latex/scripts/extract_text_from_all.sh b/build/latex/academia/scripts/extract_text_from_all.sh index 11b2ac4..11b2ac4 100755 --- a/build/latex/scripts/extract_text_from_all.sh +++ b/build/latex/academia/scripts/extract_text_from_all.sh diff --git a/build/latex/shell_line_editor.sh b/build/latex/academia/shell_line_editor.sh index 8d6833a..8d6833a 100644 --- a/build/latex/shell_line_editor.sh +++ b/build/latex/academia/shell_line_editor.sh diff --git a/build/latex/treefmt.nix b/build/latex/academia/treefmt.nix index 794e8fc..794e8fc 100644 --- a/build/latex/treefmt.nix +++ b/build/latex/academia/treefmt.nix diff --git a/build/latex/update.sh b/build/latex/academia/update.sh index 49216b8..49216b8 100755 --- a/build/latex/update.sh +++ b/build/latex/academia/update.sh diff --git a/build/latex/academia/watch.sh b/build/latex/academia/watch.sh new file mode 100755 index 0000000..e5147f2 --- /dev/null +++ b/build/latex/academia/watch.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env sh + +help() { + cat <<EOF +An simple watch script, useful to see the changes in the document as it evolves. + +USAGE: + watch.sh [OPTIONS] [COMMAND] + +OPTIONS: + --help | -h + Display this help and exit. + + --open [READER] | -o [READER] + Open the build PDF in READER before waiting for changes. + READER defaults to the READER environment variable or + 'zathura' if the env variable is unset. + --sleeptime [T] | -s [T] + How long to sleep between each build attempt in seconds. The + time defaults to 10 seconds. +ARGUMENTS: + READER := [[echo "\${READER-zathura}"]] + The reader to open the build PDF with. + + T := [[seq 1 100]] + The time to sleep between each build attempt. +EOF +} + +reader="" +time="10" +for arg in "$@"; do + case "$arg" in + "--help" | "-h") + help + exit 0 + ;; + + "--open" | "-o") + shift 1 + reader="$1" + if [ -z "$reader" ]; then + reader="${READER-zathura}" + else + shift 1 + fi + ;; + + "--sleeptime" | "-s") + shift 1 + time="$1" + if [ -z "$time" ]; then + time=10 + else + shift 1 + fi + ;; + *) + echo "'$1' is not a recognized option! See '--help' for more detail." 1>&2 + exit 1 + ;; + esac +done + +[ -n "$reader" ] && "$reader" ./build/%INIT_APPLICATION_NAME.pdf & + +while true; do + ./build.sh + sleep "$time" +done diff --git a/build/latex/scripts/renew_copyright_header.sh b/build/latex/scripts/renew_copyright_header.sh deleted file mode 100755 index 423547f..0000000 --- a/build/latex/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 diff --git a/build/rust/.licensure.yml b/build/rust/.licensure.yml deleted file mode 100644 index 639d750..0000000 --- a/build/rust/.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/rust/.reuse/templates/default.jinja2 b/build/rust/.reuse/templates/default.jinja2 new file mode 100644 index 0000000..688bffc --- /dev/null +++ b/build/rust/.reuse/templates/default.jinja2 @@ -0,0 +1,2 @@ +%INIT_REUSE_TEMPLATE +<!-- vim: ft=htmldjango --> diff --git a/build/rust/LICENSE.spdx b/build/rust/LICENSE.spdx deleted file mode 100644 index 2b99390..0000000 --- a/build/rust/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/rust/README.md b/build/rust/README.md index 46287a6..9c5c6da 100644 --- a/build/rust/README.md +++ b/build/rust/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/rust/docs/%INIT_APPLICATION_NAME.1.md b/build/rust/docs/%INIT_APPLICATION_NAME.1.md index e044647..5546aad 100644 --- a/build/rust/docs/%INIT_APPLICATION_NAME.1.md +++ b/build/rust/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/rust/init b/build/rust/init index f416b34..edb0d1e 100644 --- a/build/rust/init +++ b/build/rust/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/rust/scripts/cprh.sh b/build/rust/scripts/cprh.sh new file mode 100755 index 0000000..9582575 --- /dev/null +++ b/build/rust/scripts/cprh.sh @@ -0,0 +1,57 @@ +#! /usr/bin/env sh + +die() { + echo "$@" 1>&2 + exit 1 +} + +help() { + cat <<EOF +A copyright header managment tool. + +USAGE: + cprh.sh [OPTIONS] contribute NAME EMAIL FILE.. + +OPTIONS: + --help | -h + Display this help and exit. + +ARGUMENTS: + NAME := [[git config user.name]] + Your name. + + NAME := [[git config user.email]] + Your email address. + + FILE := [[git diff --name-only --cached]] + The file you want to change. This can be given multiple times. +EOF +} + +for arg in "$@"; do + case "$arg" in + "--help" | "-h") + help + exit 0 + ;; + *) + echo "'$1' is not a recognized option. See --help for more!" 1>&2 + exit 1 + ;; + esac +done + +user_name="$1" +[ -z "$user_name" ] && die "No NAME set! See --help for more" + +user_email="$2" +[ -z "$user_email" ] && die "No EMAIL set! See --help for more" +shift 2 + +styleOne="" +styleTwo="" +[ "$COMMENT_STYLE" ] && styleOne="--style" && styleTwo="$COMMENT_STYLE" + +# The styleTwo must be unquoted to avoid adding empty args to reuse +# shellcheck disable=2086 +reuse annotate --copyright "$user_name <$user_email>" --copyright-prefix string-c --template default --multi-line $styleOne $styleTwo diff --git a/build/rust/scripts/renew_copyright_header.sh b/build/rust/scripts/renew_copyright_header.sh deleted file mode 100755 index 423547f..0000000 --- a/build/rust/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 diff --git a/build/shell/.licensure.yml b/build/shell/.licensure.yml deleted file mode 100644 index 639d750..0000000 --- a/build/shell/.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/shell/.reuse/templates/default.jinja2 b/build/shell/.reuse/templates/default.jinja2 new file mode 100644 index 0000000..688bffc --- /dev/null +++ b/build/shell/.reuse/templates/default.jinja2 @@ -0,0 +1,2 @@ +%INIT_REUSE_TEMPLATE +<!-- vim: ft=htmldjango --> diff --git a/build/shell/LICENSE.spdx b/build/shell/LICENSE.spdx deleted file mode 100644 index 2b99390..0000000 --- a/build/shell/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/shell/README.md b/build/shell/README.md index 46287a6..9c5c6da 100644 --- a/build/shell/README.md +++ b/build/shell/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/shell/docs/%INIT_APPLICATION_NAME.1.md b/build/shell/docs/%INIT_APPLICATION_NAME.1.md index e044647..5546aad 100644 --- a/build/shell/docs/%INIT_APPLICATION_NAME.1.md +++ b/build/shell/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/shell/init b/build/shell/init index f416b34..edb0d1e 100644 --- a/build/shell/init +++ b/build/shell/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/shell/scripts/cprh.sh b/build/shell/scripts/cprh.sh new file mode 100755 index 0000000..9582575 --- /dev/null +++ b/build/shell/scripts/cprh.sh @@ -0,0 +1,57 @@ +#! /usr/bin/env sh + +die() { + echo "$@" 1>&2 + exit 1 +} + +help() { + cat <<EOF +A copyright header managment tool. + +USAGE: + cprh.sh [OPTIONS] contribute NAME EMAIL FILE.. + +OPTIONS: + --help | -h + Display this help and exit. + +ARGUMENTS: + NAME := [[git config user.name]] + Your name. + + NAME := [[git config user.email]] + Your email address. + + FILE := [[git diff --name-only --cached]] + The file you want to change. This can be given multiple times. +EOF +} + +for arg in "$@"; do + case "$arg" in + "--help" | "-h") + help + exit 0 + ;; + *) + echo "'$1' is not a recognized option. See --help for more!" 1>&2 + exit 1 + ;; + esac +done + +user_name="$1" +[ -z "$user_name" ] && die "No NAME set! See --help for more" + +user_email="$2" +[ -z "$user_email" ] && die "No EMAIL set! See --help for more" +shift 2 + +styleOne="" +styleTwo="" +[ "$COMMENT_STYLE" ] && styleOne="--style" && styleTwo="$COMMENT_STYLE" + +# The styleTwo must be unquoted to avoid adding empty args to reuse +# shellcheck disable=2086 +reuse annotate --copyright "$user_name <$user_email>" --copyright-prefix string-c --template default --multi-line $styleOne $styleTwo diff --git a/build/shell/scripts/renew_copyright_header.sh b/build/shell/scripts/renew_copyright_header.sh deleted file mode 100755 index 423547f..0000000 --- a/build/shell/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 |