Compare commits
15 Commits
Author | SHA1 | Date |
---|---|---|
DarkFeather | e4ac1b6517 | |
DarkFeather | e21233f9a2 | |
DarkFeather | 693c031124 | |
DarkFeather | 017d13681e | |
DarkFeather | c988f725fb | |
DarkFeather | 184c2c5915 | |
DarkFeather | 0ea7fe27de | |
DarkFeather | 8435ff442b | |
DarkFeather | 16c864e161 | |
DarkFeather | 133f231726 | |
DarkFeather | 87f907d948 | |
DarkFeather | dac8563a32 | |
DarkFeather | 39c2229a1e | |
DarkFeather | f9a8c19066 | |
DarkFeather | f034d627a6 |
|
@ -1,3 +1,7 @@
|
|||
wiki/
|
||||
pkg/
|
||||
src/
|
||||
*.tar.xz
|
||||
*.tar.zst
|
||||
tests/*.out
|
||||
*/__pycache__/**
|
||||
|
|
163
Bash/header
163
Bash/header
|
@ -6,13 +6,25 @@ pullcmd='wget --timeout=5 -q -O -'
|
|||
## Visual Functions ##
|
||||
# These function creates a visual indicator that a step has happened.
|
||||
function header () {
|
||||
tput setaf 1; tput bold; echo $@; tput sgr0; return
|
||||
if [[ "$TERM" =~ xterm* ]]; then
|
||||
tput setaf 1; tput bold; echo $@; tput sgr0; return
|
||||
else
|
||||
echo $@;
|
||||
fi
|
||||
}
|
||||
function errorheader () {
|
||||
tput setaf 1 1>&2; tput bold 1>&2; echo "ERROR:" $@ 1>&2; tput sgr0 1>&2; return
|
||||
if [[ "$TERM" =~ xterm* ]]; then
|
||||
tput setaf 1 1>&2; tput bold 1>&2; echo "ERROR:" $@ 1>&2; tput sgr0 1>&2; return
|
||||
else
|
||||
echo $@;
|
||||
fi
|
||||
}
|
||||
function infoheader() {
|
||||
tput setaf 3; tput bold; echo $@; tput sgr0; return
|
||||
if [[ "$TERM" =~ xterm* ]]; then
|
||||
tput setaf 3; tput bold; echo $@; tput sgr0; return
|
||||
else
|
||||
echo $@;
|
||||
fi
|
||||
}
|
||||
function colorstrip() {
|
||||
perl -e 'use strict; use warnings; while(<>) { s/\e\[[\d;]*m//g; print; }'
|
||||
|
@ -47,7 +59,7 @@ function logstatement() {
|
|||
|
||||
## Storage functions ##
|
||||
function addfs() {
|
||||
if [ -z "$1" ] || [ -z "$2" ] || (echo "$3" | egrep -v -E '^[0-9]{1,4}'); then
|
||||
if [ -z "$1" ] || [ -z "$2" ] || (echo "$3" | grep -v -E '^[0-9]{1,4}'); then
|
||||
echo "Need a filesystem(1), volume group path(2), and size (3)"
|
||||
return
|
||||
fi
|
||||
|
@ -116,14 +128,14 @@ function qaunittest {
|
|||
$(echo -ne $userinput)
|
||||
EOM
|
||||
`"
|
||||
printf "$header";
|
||||
printf ":%*s" $(($qapadding - $(echo $header | wc -c) - 1)) '['
|
||||
if [ "$actualreturn" == "$expectedreturn" ]; then
|
||||
tput setaf 2; printf "PASS"; tput sgr0; printf ']\n';
|
||||
else
|
||||
tput setaf 1; printf "FAIL"; tput sgr0; printf '] -- found %s (expected %s) running '\''%s %s < "%s"'\''\n' "$actualreturn" "$expectedreturn" "$function" "$fnargs" "$userinput";
|
||||
fi
|
||||
return
|
||||
printf "$header";
|
||||
printf ":%*s" $(($qapadding - $(echo $header | wc -c) - 1)) '['
|
||||
if [ "$actualreturn" == "$expectedreturn" ]; then
|
||||
tput setaf 2; printf "PASS"; tput sgr0; printf ']\n';
|
||||
else
|
||||
tput setaf 1; printf "FAIL"; tput sgr0; printf '] -- found %s (expected %s) running '\''%s %s < "%s"'\''\n' "$actualreturn" "$expectedreturn" "$function" "$fnargs" "$userinput";
|
||||
fi
|
||||
return
|
||||
}
|
||||
|
||||
## Prompt functions ##
|
||||
|
@ -133,73 +145,73 @@ EOM
|
|||
export maxattempts=5
|
||||
# This function will prompt the user for variable 1 with string 2 until it gets a nonempty answer.
|
||||
function prompt-var() {
|
||||
if [ -z "$1" ] || [ -z "$2" ]; then
|
||||
echo "Need a variable name (1) and a prompt string (2)"
|
||||
return 1;
|
||||
fi
|
||||
inputtime="0"
|
||||
#echo "$0 is checking for $1 -- currently set to <${!1}>"
|
||||
while [ -z "${!1}" ] || (echo "${!1}" | egrep -v '^[-0-9a-zA-Z ,.@]{1,50}$' &>/dev/null); do
|
||||
printf "%s: " "$2";
|
||||
read $1;
|
||||
if [ "${!1}" == "OPT" ] || [ $inputtime -gt $maxattempts ]; then exit 0; fi
|
||||
inputtime=$(($inputtime + 1))
|
||||
done
|
||||
return 0;
|
||||
if [ -z "$1" ] || [ -z "$2" ]; then
|
||||
echo "Need a variable name (1) and a prompt string (2)"
|
||||
return 1;
|
||||
fi
|
||||
inputtime="0"
|
||||
#echo "$0 is checking for $1 -- currently set to <${!1}>"
|
||||
while [ -z "${!1}" ] || (echo "${!1}" | grep -v -E '^[-0-9a-zA-Z ,.@]{1,50}$' &>/dev/null); do
|
||||
printf "%s: " "$2";
|
||||
read $1;
|
||||
if [ "${!1}" == "OPT" ] || [ $inputtime -gt $maxattempts ]; then exit 0; fi
|
||||
inputtime=$(($inputtime + 1))
|
||||
done
|
||||
return 0;
|
||||
}
|
||||
|
||||
# This function will prompt the user for variable 1 with string 2 until it gets a nonempty answer.
|
||||
function prompt-var-len() {
|
||||
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
|
||||
echo "Need a variable name (1), prompt string (2), and a length (3)"
|
||||
return 1;
|
||||
fi
|
||||
inputtime="0"
|
||||
#echo "$0 is checking for $1 -- currently set to <${!1}>"
|
||||
while [ -z "${!1}" ] || (echo "${!1}" | grep -v -E "^[0-9a-zA-Z]{1,$3}$" &>/dev/null); do
|
||||
printf "%s (Max length: %s): " "$2" "$3";
|
||||
read $1;
|
||||
if [ "${!1}" == "OPT" ] || [ $inputtime -gt $maxattempts ]; then exit 0; fi
|
||||
inputtime=$(($inputtime + 1))
|
||||
done
|
||||
return 0;
|
||||
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
|
||||
echo "Need a variable name (1), prompt string (2), and a length (3)"
|
||||
return 1;
|
||||
fi
|
||||
inputtime="0"
|
||||
#echo "$0 is checking for $1 -- currently set to <${!1}>"
|
||||
while [ -z "${!1}" ] || (echo "${!1}" | grep -v -E "^[0-9a-zA-Z]{1,$3}$" &>/dev/null); do
|
||||
printf "%s (Max length: %s): " "$2" "$3";
|
||||
read $1;
|
||||
if [ "${!1}" == "OPT" ] || [ $inputtime -gt $maxattempts ]; then exit 0; fi
|
||||
inputtime=$(($inputtime + 1))
|
||||
done
|
||||
return 0;
|
||||
}
|
||||
# This function will prompt the user for variable 1 with string 2 until it gets a nonempty answer.
|
||||
function prompt-password() {
|
||||
if [ -z "$1" ] || [ -z "$2" ]; then
|
||||
echo "Need a variable name (1) and a prompt string (2)"
|
||||
return 1;
|
||||
fi
|
||||
inputtime="0"
|
||||
#echo "$0 is checking for $1 -- currently set to <${!1}>"
|
||||
while [ -z "${!1}" ] || [ $(echo ${!1} | wc -c) -gt 50 ]; do
|
||||
printf "%s: " "$2";
|
||||
read -s $1;
|
||||
if [ "${!1}" == "OPT" ] || [ $inputtime -gt $maxattempts ]; then exit 0; fi
|
||||
echo
|
||||
inputtime=$(($inputtime + 1))
|
||||
done
|
||||
return 0;
|
||||
if [ -z "$1" ] || [ -z "$2" ]; then
|
||||
echo "Need a variable name (1) and a prompt string (2)"
|
||||
return 1;
|
||||
fi
|
||||
inputtime="0"
|
||||
#echo "$0 is checking for $1 -- currently set to <${!1}>"
|
||||
while [ -z "${!1}" ] || [ $(echo ${!1} | wc -c) -gt 50 ]; do
|
||||
printf "%s: " "$2";
|
||||
read -s $1;
|
||||
if [ "${!1}" == "OPT" ] || [ $inputtime -gt $maxattempts ]; then exit 0; fi
|
||||
echo
|
||||
inputtime=$(($inputtime + 1))
|
||||
done
|
||||
return 0;
|
||||
}
|
||||
#This function will prompt the user for a variable 1 with string 2 until it gets an answer between min 3 and max 4.
|
||||
function prompt-num-var() {
|
||||
if [ -z "$1" ] || [ -z "$2" ] || [ "$3" -ne "$3" ] || [ "$4" -le "$3" ]; then
|
||||
echo "Need a variable name (1), prompt string (2), min (3), and max (4)";
|
||||
echo 1: $1;
|
||||
echo 2: $2;
|
||||
echo 3: $3;
|
||||
echo 4: $4;
|
||||
return 1;
|
||||
fi
|
||||
inputtime="0"
|
||||
#echo "$0 is checking for $1 -- currently set to <${!1}>"
|
||||
while [ -z "${!1}" ] || (echo "${!1}" | grep -v -E "^[0-9]{1,8}$" &>/dev/null) || [ "${!1}" -lt "$3" ] || [ "${!1}" -gt "$4" ]; do
|
||||
printf "%s (between %s and %s): " "$2" "$3" "$4";
|
||||
read $1;
|
||||
if [ "${!1}" == "OPT" ] || [ $inputtime -gt $maxattempts ]; then exit 0; fi
|
||||
inputtime=$(($inputtime + 1))
|
||||
done
|
||||
return 0;
|
||||
if [ -z "$1" ] || [ -z "$2" ] || [ "$3" -ne "$3" ] || [ "$4" -le "$3" ]; then
|
||||
echo "Need a variable name (1), prompt string (2), min (3), and max (4)";
|
||||
echo 1: $1;
|
||||
echo 2: $2;
|
||||
echo 3: $3;
|
||||
echo 4: $4;
|
||||
return 1;
|
||||
fi
|
||||
inputtime="0"
|
||||
#echo "$0 is checking for $1 -- currently set to <${!1}>"
|
||||
while [ -z "${!1}" ] || (echo "${!1}" | grep -v -E "^[0-9]{1,8}$" &>/dev/null) || [ "${!1}" -lt "$3" ] || [ "${!1}" -gt "$4" ]; do
|
||||
printf "%s (between %s and %s): " "$2" "$3" "$4";
|
||||
read $1;
|
||||
if [ "${!1}" == "OPT" ] || [ $inputtime -gt $maxattempts ]; then exit 0; fi
|
||||
inputtime=$(($inputtime + 1))
|
||||
done
|
||||
return 0;
|
||||
}
|
||||
|
||||
## Torrenting functions ##
|
||||
|
@ -250,17 +262,18 @@ function getmagnetlink {
|
|||
fi
|
||||
}
|
||||
|
||||
### AniNIX Foundation help ###
|
||||
### AniNIX/Foundation help ###
|
||||
|
||||
function findaninixcheckouts {
|
||||
find /usr/local/src/ -type f -name config -exec egrep -l 'url[[:space:]]=[[:space:]]/srv/foundation|url[[:space:]]=[[:space:]]https://aninix.net|url[[:space:]]=[[:space:]]([a-zA-Z0-9])+@aninix.net' {} \; 2>/dev/null | sed 's#.git/config$##'
|
||||
### Find git checkouts in $pwd that are from AniNIX/Foundation
|
||||
find . -type f -name config -exec grep -l -E 'url[[:space:]]=[[:space:]]/srv/foundation|url[[:space:]]=[[:space:]]https://(foundation.)aninix.net|url[[:space:]]=[[:space:]]([a-zA-Z0-9])+@(foundation.)aninix.net' {} \; 2>/dev/null | sed 's#.git/config$##'
|
||||
}
|
||||
|
||||
function aninixgitstatus {
|
||||
for i in `findaninixcheckouts`; do
|
||||
infoheader BEGIN REPORT for "$i"
|
||||
git -C "$i" status
|
||||
infoheader END REPORT
|
||||
echo
|
||||
status="$(git -C "$i" status)"
|
||||
if [ -n "$status" ]; then
|
||||
echo "$i" has work in flight.
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed.
|
||||
# Called by "git commit" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message if
|
||||
# it wants to stop the commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-commit".
|
||||
|
||||
# Run all our checking scripts.
|
||||
for script in $(find `dirname "$0"`/scripts.d -type f); do
|
||||
echo "Running ${script}"
|
||||
"$script"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$script" failed checks.
|
||||
exit 1;
|
||||
fi
|
||||
done
|
||||
echo "Pre-commit checks passed."
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Check each commit
|
||||
while read oldrev newrev refname; do
|
||||
|
||||
# Thanks to https://blog.developer.atlassian.com/stop-foxtrots-now/ for the inspiration
|
||||
if [ "$refname" == "refs/heads/main" ]; then
|
||||
match=`git log --first-parent --pretty='%H %P' $oldrev..$newrev |
|
||||
grep $oldrev |
|
||||
awk '{ print $2 }'`
|
||||
if [ "$oldrev" != "$match" ]; then
|
||||
echo "Foxtrot detected. Please `git rebase origin/main`."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
done
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 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;
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Enforce each of the lines
|
||||
linenum=0
|
||||
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
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Ensure that the following lines match the base PKGBUILD
|
||||
|
||||
export retcode=0
|
||||
for term in ^pkgname\= ^replaces\= ^pkgver\= ^epoch\= ^pkgdesc\= ^url\= ^license\= ../LICENSE; do
|
||||
current="$(grep -E "${term}" ./PKGBUILD)"
|
||||
reference="$(grep -E "${term}" /opt/aninix/Uniglot/pacman/PKGBUILD)"
|
||||
diff -w --color=always <(printf "${reference}") <(printf "${current}")
|
||||
export retcode="$(( $retcode || $? ))";
|
||||
if [ "$retcode" != 0 ]; then
|
||||
echo "$term has delta."
|
||||
break;
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$(basename "$PWD")" == '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.
|
||||
exit 1
|
||||
fi
|
|
@ -0,0 +1,56 @@
|
|||
#!/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 -m 1 -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
|
||||
# aspell --lang=en create master $HOME/.aspell.en.pws < $HOME/.vim/spell/en.utf-8.add
|
||||
spellerrors="$(cat "$file" | aspell -p <(echo personal_ws-1.1 en 0; cat $HOME/.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
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
if git ls-files | xargs --delimiter='\n' grep -irlE 'egrep' | grep -v 'Hooks/scripts.d/egrep' ; then
|
||||
echo 'Egrep has been deprecated as of GNU grep 3.8 -- replace `egrep` with `grep -E`.'
|
||||
echo https://www.gnu.org/software/grep/manual/grep.html
|
||||
exit 1
|
||||
fi
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
# This script ensures that repos can commit personal hooks in the ./precommit-hooks folder.
|
||||
|
||||
if [ -d precommit-hooks ]; then
|
||||
for script in `find precommit-hooks -type f`; do
|
||||
if ! bash "$script"; then
|
||||
echo "Local script $script failed checks."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
fi
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Sourced from https://github.com/git/git/blob/master/templates/hooks--pre-commit.sample
|
||||
|
||||
# If you want to allow non-ASCII filenames set this variable to true.
|
||||
allownonascii=$(git config --bool hooks.allownonascii)
|
||||
|
||||
# Cross platform projects tend to avoid non-ASCII filenames; prevent
|
||||
# them from being added to the repository. We exploit the fact that the
|
||||
# printable range starts at the space character and ends with tilde.
|
||||
if [ "$allownonascii" != "true" ] &&
|
||||
# Note that the use of brackets around a tr range is ok here, (it's
|
||||
# even required, for portability to Solaris 10's /usr/bin/tr), since
|
||||
# the square bracket bytes happen to fall in the designated range.
|
||||
test $(git diff --cached --name-only --diff-filter=A -z $against |
|
||||
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
|
||||
then
|
||||
cat <<\EOF
|
||||
Error: Attempt to add a non-ASCII file name.
|
||||
|
||||
This can cause problems if you want to work with people on other platforms.
|
||||
|
||||
To be portable it is advisable to rename the file.
|
||||
|
||||
If you know what you are doing you can disable this check using:
|
||||
|
||||
git config hooks.allownonascii true
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Run python3 tests
|
||||
|
||||
if [ -d venv ]; then
|
||||
source venv/bin/activate
|
||||
elif [ -f requirements.txt ]; then
|
||||
python3 -m venv venv
|
||||
venv/bin/python3 -m pip install -r requirements.txt
|
||||
fi
|
||||
if [ -d tests/ ]; then
|
||||
python3 -m pytest
|
||||
fi
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Borrowing from https://github.com/syncier/pre-commit-hooks-jumanjihouse/blob/master/pre_commit_hooks/protect-first-parent
|
||||
|
||||
# Find the correct reference, or fallback to HEAD's abbrev-ref
|
||||
base="$(
|
||||
git rev-parse --abbrev-ref --symbolic-full-name '@{upstream}' 2>/dev/null \
|
||||
|| git branch -avv | awk '/->/ {print $NF}' 2>/dev/null \
|
||||
|| :
|
||||
)"
|
||||
if [ -z "$base" ]; then base="$(git rev-parse --abbrev-ref HEAD)"; fi
|
||||
|
||||
firstParent="$(git show-ref -s "${base}")"
|
||||
|
||||
if git rev-list --first-parent "${base}^".. | grep -q "^${firstParent}$"; then
|
||||
exit 0
|
||||
else
|
||||
echo Foxtrot detected -- please either rebase or '`git reset --soft`' to recreate your commit.
|
||||
exit 1
|
||||
fi
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Sourced from https://github.com/git/git/blob/master/templates/hooks--pre-commit.sample
|
||||
|
||||
if git ls-files | grep -v .tar.gz | xargs --delimiter='\n' grep -irlE '\s\+$'; then
|
||||
echo The above lines have trailing whitespace. Run "sed -i 's/\s\+$//'" on the affected files.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1; then
|
||||
against=HEAD
|
||||
else
|
||||
# Initial commit: diff against an empty tree object
|
||||
against=$(git hash-object -t tree /dev/null)
|
||||
fi
|
||||
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
|
||||
# If there are whitespace errors, print the offending file names and fail.
|
||||
exec git diff-index --check --cached $against --
|
62
LICENSE
62
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 <sam@hocevar.net>
|
||||
|
||||
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 <sam@hocevar.net>
|
||||
|
||||
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
|
||||
|
|
28
Makefile
28
Makefile
|
@ -1,26 +1,32 @@
|
|||
installdir = ${pkgdir}/opt/aninix/Uniglot/
|
||||
targets = Bash C CSharp
|
||||
targets = Bash C CSharp Hooks
|
||||
|
||||
compile:
|
||||
compile:
|
||||
@echo Nothing to compile.
|
||||
|
||||
install: compile
|
||||
mkdir -p ${installdir}
|
||||
for target in ${targets}; do rsync -avzzl "$$target" ${installdir}; done
|
||||
mkdir "${installdir}/pacman/"
|
||||
cp PKGBUILD "${installdir}/pacman/"
|
||||
mkdir "${installdir}/make/"
|
||||
cp Makefile "${installdir}/make/"
|
||||
mkdir -p ${pkgdir}/usr/local/bin
|
||||
find bin/ -type f -exec install -m 0755 -o root -g root {} "${pkgdir}/usr/local/bin" \;
|
||||
make checkperm
|
||||
|
||||
clean:
|
||||
for i in `cat .gitignore`; do rm -Rf $$i; done
|
||||
|
||||
uninstall:
|
||||
rm -Rf ${installdir}
|
||||
git clean -fdX
|
||||
|
||||
test:
|
||||
@echo Nothing to do.
|
||||
uninstall:
|
||||
rm -Rf ${installdir}
|
||||
|
||||
checkperm:
|
||||
chmod -R 0755 ${installdir}
|
||||
chown root:root ${installdir}
|
||||
test:
|
||||
python3 -m pytest
|
||||
|
||||
checkperm:
|
||||
chmod -R 0755 ${installdir} ${pkgdir}/usr/local/bin/uniglot-clone
|
||||
chown root:root ${installdir} ${pkgdir}/usr/local/bin/uniglot-clone
|
||||
|
||||
diff: ${INSTALLFIR}
|
||||
diff -rc . ${installdir}
|
||||
|
|
4
PKGBUILD
4
PKGBUILD
|
@ -1,5 +1,5 @@
|
|||
depends=('bash>=4.4')
|
||||
makedepends=('make>=4.2')
|
||||
makedepends=('make>=4.2','gcc','mono')
|
||||
checkdepends=()
|
||||
optdepends=()
|
||||
pkgname="$(git config remote.origin.url | rev | cut -f 1 -d '/' | rev | sed 's/.git$//')"
|
||||
|
@ -16,7 +16,7 @@ license=('custom')
|
|||
groups=()
|
||||
provides=("${pkgname}")
|
||||
conflicts=()
|
||||
replaces=("${pkgname,,}", "aninix-${pkgname,,}")
|
||||
replaces=("${pkgname,,}" "aninix-${pkgname,,}")
|
||||
backup=()
|
||||
options=()
|
||||
install=
|
||||
|
|
44
README.md
44
README.md
|
@ -1,3 +1,45 @@
|
|||
This repo holds all our standard functions that all our services should use. We include a folder for each language -- files are broken down by their inclusion method. Please follow our [development best practices](https://foundation.aninix.net/AniNIX/Wiki/src/branch/master/Operation/Development_Best_Practices.md) when contributing.
|
||||
|
||||
These functions are not intended to be invoked directly, so the package created from this repo will only provide files on disk.
|
||||
Some other functions served by this repo are included below.
|
||||
|
||||
# Etymology
|
||||
|
||||
`Uniglot` is derived from the idea of a universal language to be used by all projects. `Uni` means one, and glot [is defined](https://www.collinsdictionary.com/us/dictionary/english/glot#:~:text=%2Dglot%20in%20American%20English,polyglot) as '"speaking, writing, or written in a language" of the kind or number specified by the initial element'. So, Uniglot is thereby the single language used by all AniNIX projects. This refers both to the library files contained here and the universal hooks used in AniNIX development.
|
||||
|
||||
# Relevant Files and Software
|
||||
|
||||
## Example Packaging
|
||||
|
||||
This repo does have some example packaging for use in downstream projects. The [Makefile](./Makefile) and [PKGBUILD](./PKGBUILD) are standards the AniNIX should maintain throughout their projects.
|
||||
|
||||
## Executables
|
||||
|
||||
The following executables are available:
|
||||
|
||||
* `uniglot-clone` ensures that when repos are cloned, they are attached to the standard Uniglot hooks.
|
||||
* `home-git` is support for [User Support Repositories](https://aninix.net/AniNIX/Wiki/src/branch/main/Articles/User_Support_Repositories.md).
|
||||
|
||||
## Hooks
|
||||
|
||||
The Hooks folder includes a standard pre-commit and pre-receive that will be enforced across repos. These pre-commit and pre-receive will enforce the contents of `Hooks/scripts.d`. This allows us to enforce standards of quality across the ecosystem.
|
||||
|
||||
Notably, each repo that subscribes to this enforcement can also commit their own standards in addition to global standards. Python tests should go in a folder called `tests/` and scripts in a folder called `precommit-hooks/`. These will be run in addition to the global hooks.
|
||||
|
||||
## Standard Libraries
|
||||
|
||||
Each language for which we have libraries should have its own folder. Breakdown within each of these may be broken up by line count or topic, at the author's discretion. Once an include standard has been set, though, it should be preserved. For example, if functions in [the Bash header](./Bash/header) are to be broken out into subordinate files, then the Bash header should include these files that contain functions formally in itself.
|
||||
|
||||
# Available Clients
|
||||
|
||||
The clients for this package are the compilers for the various languages represented.
|
||||
|
||||
* `bash` for Bash
|
||||
* `mono` for C#
|
||||
* `gcc` for C
|
||||
* `javac` for Java
|
||||
|
||||
The hooks can be consumed by `git` when `uniglot-clone` is run on a repo.
|
||||
|
||||
# Equivalents or Competition
|
||||
|
||||
The equivalents for this are the -headers or -libs packages for other projects. There is not really competition, as these are things specific for our development environment.
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
#!/bin/bash
|
||||
|
||||
# File: uniglot-clone
|
||||
#
|
||||
# Description: This is a convenience script to ensure our hooks are standardized.
|
||||
#
|
||||
# Package: AniNIX/Uniglot
|
||||
# Copyright: WTFPL
|
||||
#
|
||||
# Author: DarkFeather <ircs://aninix.net:6697/DarkFeather>
|
||||
|
||||
function uniglotClone() {
|
||||
target="$1"
|
||||
git-clone "$target"
|
||||
clone="$(basename "$1" | sed 's/.git$//')"
|
||||
cd "$clone"
|
||||
}
|
||||
|
||||
|
||||
### usage
|
||||
### param retcode: what to return
|
||||
function usage() {
|
||||
retcode="$1"
|
||||
echo "Usage: $0 # Update the current clone"
|
||||
echo " $0 -t target # Clone the target and set hooks"
|
||||
echo " $0 -h # Help"
|
||||
echo Add -v for verbosity.
|
||||
}
|
||||
|
||||
### Main
|
||||
if [ `basename "$0"` == "uniglot-clone" ]; then
|
||||
while getopts 'ht:v' OPTION; do
|
||||
case "$OPTION" in
|
||||
h) echo AniNIX/Uniglot git-clone standardization; usage 0 ;;
|
||||
t) target="$OPTARG" ;;
|
||||
v) set -x ;;
|
||||
*) usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -n "$target" ]; then
|
||||
uniglotClone "$target"
|
||||
cd "$(basename "$target" | sed 's/.git$//')"
|
||||
fi
|
||||
|
||||
# Sanity
|
||||
if [ ! -d .git ]; then
|
||||
echo "This should be run from the root of the clone."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Standardizations
|
||||
|
||||
# If the repo is Uniglot...
|
||||
if git config remote.origin.url | grep -q AniNIX/Uniglot; then
|
||||
# Set the hooks to the local directory
|
||||
git config core.hooksPath $PWD/Hooks
|
||||
else
|
||||
# Otherwise set it to the global hooks
|
||||
git config core.hooksPath /opt/aninix/Uniglot/Hooks
|
||||
fi
|
||||
fi
|
|
@ -0,0 +1,15 @@
|
|||
using AniNIX.Shared;
|
||||
|
||||
namespace AniNIX.Uniglot {
|
||||
|
||||
/// Test class
|
||||
public class Test {
|
||||
|
||||
/// <summary>
|
||||
/// The default function
|
||||
/// </summary>
|
||||
static int Main(string[] args) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
import os
|
||||
import pytest
|
||||
|
||||
def test_hooks_exec():
|
||||
fh = os.popen("find Hooks -type f -exec ls -l {} \\; | grep -E ^-rw-")
|
||||
output = fh.read()
|
||||
retcode = fh.close()
|
||||
assert retcode == 256 and output == ''
|
|
@ -0,0 +1,26 @@
|
|||
import os
|
||||
import pytest
|
||||
|
||||
def test_bash_import():
|
||||
fh = os.popen("/bin/bash -c 'source Bash/header; [ `declare -F | wc -l` -eq `grep -E -c ^function\\ Bash/header` ]'", mode='r', buffering=-1)
|
||||
output = fh.read()
|
||||
retcode = fh.close()
|
||||
assert retcode == None
|
||||
|
||||
def test_c_import():
|
||||
fh = os.popen("gcc -o tests/c.out C/ll.h", mode='r', buffering=-1)
|
||||
output = fh.read()
|
||||
retcode = fh.close()
|
||||
assert retcode == None and os.path.isfile('tests/c.out')
|
||||
|
||||
def test_csharp_import():
|
||||
fh = os.popen("/bin/bash -c 'mcs -out:tests/csharp.out CSharp/*.csharp tests/test.csharp'", mode='r', buffering=-1)
|
||||
output = fh.read()
|
||||
retcode = fh.close()
|
||||
assert retcode == None and os.path.isfile('tests/csharp.out')
|
||||
|
||||
def test_remove_outs():
|
||||
fh = os.popen("/bin/bash -c 'rm -Rf tests/*.out'", mode='r', buffering=-1)
|
||||
output = fh.read()
|
||||
retcode = fh.close()
|
||||
assert retcode == None
|
Loading…
Reference in New Issue