From c988f725fb8061f483f460684b2fdafa2c3b1675 Mon Sep 17 00:00:00 2001 From: DarkFeather Date: Sat, 21 Oct 2023 20:16:43 -0500 Subject: [PATCH] Improving checks on AniNIX standards --- .gitignore | 1 + Hooks/scripts.d/check-AniNIX-LICENSE | 18 +++++++- Hooks/scripts.d/check-AniNIX-Makefile | 21 +++++++++ Hooks/scripts.d/check-AniNIX-PKGBUILD | 22 ++++++++++ Hooks/scripts.d/check-AniNIX-READMEs | 55 ++++++++++++++++++++++++ LICENSE | 62 +++++++++++++-------------- 6 files changed, 147 insertions(+), 32 deletions(-) create mode 100755 Hooks/scripts.d/check-AniNIX-Makefile create mode 100755 Hooks/scripts.d/check-AniNIX-PKGBUILD create mode 100755 Hooks/scripts.d/check-AniNIX-READMEs diff --git a/.gitignore b/.gitignore index ad4ed58..677c6b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +wiki/ pkg/ src/ *.tar.xz diff --git a/Hooks/scripts.d/check-AniNIX-LICENSE b/Hooks/scripts.d/check-AniNIX-LICENSE index 458f1a6..1c9e319 100755 --- a/Hooks/scripts.d/check-AniNIX-LICENSE +++ b/Hooks/scripts.d/check-AniNIX-LICENSE @@ -1,3 +1,19 @@ #!/bin/bash -diff -w <(curl -s 'https://aninix.net/AniNIX/Ubiqtorate/raw/branch/main/roles/Foundation/files/custom/options/license/AniNIX-WTFPL') ./LICENSE +# If the package hasn't been installed yet, since we are the origin, we have to bootstrap. +if [ "$(basename "$PWD")" == 'Uniglot' ] && [ ! -f /usr/share/licenses/Uniglot/LICENSE ]; then + exit 0; +fi + +diff -w /usr/share/licenses/Uniglot/LICENSE ./LICENSE; + +if [ $? -ne 0 ]; then + if [ "$(basename "$PWD")" == 'Uniglot' ]; then + echo INFO: You are changing the LICENSE and need to update downstream projects. + echo INFO: You also need to redeploy AniNIX/Foundation via AniNIX/Ubiqtorate for new projects. + exit 0; + else + echo ERROR: License is out of sync with AniNIX/Uniglot or you don\'t have Uniglot locally installed. + exit 1; + fi +fi; diff --git a/Hooks/scripts.d/check-AniNIX-Makefile b/Hooks/scripts.d/check-AniNIX-Makefile new file mode 100755 index 0000000..d4be397 --- /dev/null +++ b/Hooks/scripts.d/check-AniNIX-Makefile @@ -0,0 +1,21 @@ +#!/bin/bash + +# Enforce each of the lines +for line in compile install clean uninstall test checkperm diff reverse; do + + newlinenum="$(grep -nE "^$line:" "Makefile" | cut -f 1 -d ':')" + + # Case 1: Missing section + if [ -z "$newlinenum" ]; then + echo "$file" is missing "$line" + exit 1 + fi + + # Case 2: Line is out of order + if [ "$newlinenum" -lt "$linenum" ]; then + echo "$file" has section "$line" out of order. + exit 2 + fi + linenum="$newlinenum" + +done diff --git a/Hooks/scripts.d/check-AniNIX-PKGBUILD b/Hooks/scripts.d/check-AniNIX-PKGBUILD new file mode 100755 index 0000000..2eda523 --- /dev/null +++ b/Hooks/scripts.d/check-AniNIX-PKGBUILD @@ -0,0 +1,22 @@ +#!/bin/bash + +# Ensure that the following lines match the base PKGBUILD +retcode=0 +(for term in pkgname replaces pkgver epoch pkgdesc url license ../LICENSE; do + current="$(grep "${term}" ./PKGBUILD)" + reference="$(grep "${term}" /opt/aninix/Uniglot/pacman/PKGBUILD)" + diff <(printf "${reference}") <(echo "${current}")S + retcode="$(( $retcode || $? ))"; +done) &>/dev/null + +if [ "$(basename "$0")" == 'Uniglot' ] && [ "$retcode" != 0 ]; then + if [ ! -f /opt/aninix/Uniglot/pacman/PKGBUILD ]; then + # Suppress output for this package when it isn't installed yet. + echo $0 + else + echo INFO: You have introduced delta for the PKGBUILD. You may need to update downstream projects. + exit 0 + fi +elif [ "$retcode" != 0 ]; then + echo ERROR: PKGBUILD is out of sync with AniNIX/Uniglot. +fi diff --git a/Hooks/scripts.d/check-AniNIX-READMEs b/Hooks/scripts.d/check-AniNIX-READMEs new file mode 100755 index 0000000..61248af --- /dev/null +++ b/Hooks/scripts.d/check-AniNIX-READMEs @@ -0,0 +1,55 @@ +#!/bin/bash + + +# Allow verbosity +if [ "$1" == "-v" ]; then + set -x; + shift; +fi + +# Allow passing in more than just the landing README.md, but default to ./README.md +files="$@" +if [ -z "$files" ]; then + files="./README.md" +fi + +# Iterate on each file. +for file in $files; do + + # Reset order tracking + linenum=0 + + # Enforce each of the lines + for line in '^# Etymology$' '^# Relevant Files and Software$' '^# Available Clients$' '^# Equivalents or Competition$'; do + newlinenum="$(grep -nE "$line" "$file" | cut -f 1 -d ':')" + + # Case 1: Missing section + if [ -z "$newlinenum" ]; then + echo "$file" is missing "$line" + exit 1 + fi + + # Case 2: Line is out of order + if [ "$newlinenum" -lt "$linenum" ]; then + echo "$file" has section "$line" out of order. + exit 2 + fi + linenum="$newlinenum" + + done + + # Case 3: Spelling errors are present + spellerrors="$(cat "$file" | aspell -p <(echo personal_ws-1.1 en 0; cat ~/.vim/spell/en.utf-8.add) list)" + if [ `echo "$spellerrors" | wc -l` -ne 1 ]; then + echo "$file" has spelling errors. + echo "$spellerrors" + exit 3 + fi + +done + +# Wiki documentation is procedurally generated in its own repo. +if ! grep -E ^wiki/ .gitignore 1>/dev/null; then + echo The wiki folder needs to be ignored. + exit 4 +fi diff --git a/LICENSE b/LICENSE index bffb679..e15653d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,31 +1,31 @@ -# http://www.wtfpl.net/about/ - - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - Version 2, December 2004 - - Copyright (C) 2004 Sam Hocevar - - Everyone is permitted to copy and distribute verbatim or modified - copies of this license document, and changing it is allowed as long - as the name is changed. - - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. You just DO WHAT THE FUCK YOU WANT TO. - - ANINIX ADDENDUM - - Trademark 2017 (https://aninix.net/) - - The "AniNIX" name and |> logo are trademarked as of 2017/11/21. - AniNIX materials may be reproduced and re-used (though you must - contact the admins of the network to get written permission to use - the AniNIX name or logo) so long as such reproduction or re-use - does not inhibit the original AniNIX use of the same. - - Attribution is appreciated for other materials but not legally - required or necessary. - - "AniNIX" trademark serial: 87177883 - |> Logo trademark serial: 87177887 +# http://www.wtfpl.net/about/ + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + + ANINIX ADDENDUM + + Trademark 2017 (https://aninix.net/) + + The "AniNIX" name and |> logo are trademarked as of 2017/11/21. + AniNIX materials may be reproduced and re-used (though you must + contact the admins of the network to get written permission to use + the AniNIX name or logo) so long as such reproduction or re-use + does not inhibit the original AniNIX use of the same. + + Attribution is appreciated for other materials but not legally + required or necessary. + + "AniNIX" trademark serial: 87177883 + |> Logo trademark serial: 87177887