Compare commits
9 Commits
Author | SHA1 | Date |
---|---|---|
DarkFeather | 1976a88e0b | |
DarkFeather | e4b0c55cd8 | |
DarkFeather | 5a28cc9b52 | |
DarkFeather | 0e42f49f1f | |
DarkFeather | 723996aa8e | |
DarkFeather | 07fec4262e | |
DarkFeather | fb9de15de0 | |
DarkFeather | d53fd90185 | |
DarkFeather | b1b92be47b |
|
@ -1,10 +1,9 @@
|
|||
# Testing outputs
|
||||
src/HelloWorld
|
||||
src/HelloWorld/**
|
||||
src/ascii-invaders
|
||||
src/ascii-invaders/**
|
||||
src/ascii-invaders**
|
||||
src/HelloWorld**
|
||||
pkg/
|
||||
testing.log
|
||||
wiki/
|
||||
|
||||
# Packaging outputs
|
||||
*.pkg.tar.zst
|
||||
|
|
58
LICENSE
58
LICENSE
|
@ -1,27 +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 Pending 2017 (https://aninix.net/irc/)
|
||||
|
||||
The "AniNIX" name and |> logo is trademark-pending as of 2017. All
|
||||
AniNIX materials can be reproduced and re-used, though you must
|
||||
contact the admins of the network to get written permission to use
|
||||
the AniNIX name.
|
||||
|
||||
Attribution is appreciated for other materials but not legally
|
||||
required or necessary.
|
||||
# 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
|
||||
|
|
29
Makefile
29
Makefile
|
@ -21,7 +21,7 @@ install: ${list} MaatIcon.png
|
|||
for i in ${systemdList}; do install -m 0644 -o root $$i ${pkgdir}/usr/lib/systemd/system; done
|
||||
|
||||
clean:
|
||||
cat .gitignore | sudo xargs rm -Rf
|
||||
git clean -fdX
|
||||
|
||||
uninstall:
|
||||
for i in ${list}; do rm -Rf ${installDir}/$$i; done
|
||||
|
@ -29,7 +29,21 @@ uninstall:
|
|||
rmdir -p ${pkgdir}${serverRoot}/src
|
||||
rmdir -p ${pkgdir}${serverRoot}/pkg
|
||||
|
||||
test: clean
|
||||
test:
|
||||
./maat -h | grep -c Usage 1>/dev/null
|
||||
|
||||
checkperm:
|
||||
chown -R ${owner}: ${pkgdir}${serverRoot}/src
|
||||
chown -R ${owner}: ${pkgdir}${serverRoot}/pkg
|
||||
for i in ${list}; do chown -R ${owner}: "${installDir}/$$i"; sudo chmod ${perms} "${installDir}/$$i"; done
|
||||
|
||||
diff:
|
||||
for i in ${list}; do if [ -f ${installDir}/$$i ]; then diff "$$i" "${installDir}/$$i"; fi done
|
||||
|
||||
reverse:
|
||||
for i in ${list}; do if [ -f ${installDir}/$$i ]; then cp "${installDir}/$$i" "$$i"; fi done
|
||||
|
||||
extendedtest: clean
|
||||
sudo ./maat -u $$USER -T
|
||||
test -d src
|
||||
test -d src/ascii-invaders
|
||||
|
@ -48,14 +62,3 @@ test: clean
|
|||
make clean
|
||||
@echo
|
||||
@echo Tests passed successfully.
|
||||
|
||||
diff:
|
||||
for i in ${list}; do if [ -f ${installDir}/$$i ]; then diff "$$i" "${installDir}/$$i"; fi done
|
||||
|
||||
reverse:
|
||||
for i in ${list}; do if [ -f ${installDir}/$$i ]; then cp "${installDir}/$$i" "$$i"; fi done
|
||||
|
||||
checkperm:
|
||||
chown -R ${owner}: ${pkgdir}${serverRoot}/src
|
||||
chown -R ${owner}: ${pkgdir}${serverRoot}/pkg
|
||||
for i in ${list}; do chown -R ${owner}: "${installDir}/$$i"; sudo chmod ${perms} "${installDir}/$$i"; done
|
||||
|
|
8
PKGBUILD
8
PKGBUILD
|
@ -9,14 +9,14 @@ pkgrel() {
|
|||
echo $(( `git log "$(git describe --tag --abbrev=0)"..HEAD | grep -c commit` + 1 ))
|
||||
}
|
||||
epoch="$(git log | grep -c commit)"
|
||||
pkgdesc="$(head -n 1 README)"
|
||||
pkgdesc="$(head -n 1 README.md)"
|
||||
arch=("x86_64")
|
||||
url="https://aninix.net/foundation/${pkgname}"
|
||||
url="$(git config remote.origin.url | sed 's/.git$//')"
|
||||
license=('custom')
|
||||
groups=()
|
||||
provides=("${pkgname}")
|
||||
conflicts=()
|
||||
replaces=("${pkgname,,}", "aninix-${pkgname,,}")
|
||||
replaces=("${pkgname,,}" "aninix-${pkgname,,}")
|
||||
backup=(usr/local/etc/Maat/aur.list)
|
||||
options=()
|
||||
install=installscript
|
||||
|
@ -28,7 +28,7 @@ validpgpkeys=()
|
|||
|
||||
prepare() {
|
||||
git pull
|
||||
make -C .. test && make -C .. clean
|
||||
make -C .. test
|
||||
}
|
||||
|
||||
build() {
|
||||
|
|
2
README
2
README
|
@ -1,2 +0,0 @@
|
|||
AniNIX::Maat \\ Quality Assurance and Reporting Framework
|
||||
This package allows automation around code packaging and deployment. It will pull from both AniNIX::Foundation and ArchLinux AUR.
|
|
@ -0,0 +1,19 @@
|
|||
Continuous integration and continuous delivery (CI/CD) are integral to current DevOps mentality -- a step further is GitOps, wherein developers only need to interact with Git and their artifacts are magically available downstream. AniNIX/Maat is intended to provide this for AniNIX and [ArchLinux AUR](https://wiki.archlinux.org/title/Arch_User_Repository) packages.
|
||||
|
||||
# Etymology
|
||||
Maat is named for [the Egyptian goddess of truth and order](https://en.wikipedia.org/wiki/Maat) -- Maat was deeply tied into the idea of honorable contribution to community and the flow of the Nile, from which came the lifeblood of Egypt. Truth is reflected in the Maat service's use of testing and GPG signing prior to delivering packages, and the communal aspect is that Maat is how we deliver AniNIX and AUR packages for the world to use.
|
||||
|
||||
# Relevant Files and Software
|
||||
|
||||
Maat runs as a [systemd.timer](https://man.archlinux.org/man/systemd.timer.5) nightly, invoking our build script. Ad hoc builds can be requested from admins. Output gets published on the [landing page](https://maat.aninix.net) from our build pipeline -- there you can download packages, view build logs, see testing status, etc.
|
||||
|
||||
Our CI/CD pipeline attempts to pull directly from Git sources, either from the AniNIX or the curated AUR, build those packages, and make the available to systems downstream. The `/usr/local/etc/Maat/aur.list` file allows the admin to control which AUR packages are pulled and built -- output files from builds can help identify issues like missing public GPG keys or dependency issues.
|
||||
|
||||
Maat also consumes a GPG key. The admin will need to set up this key and publish it. You will need to add [our GPG key](https://aninix.net/AniNIX/ShadowArch/src/branch/main/EtcFiles/aninix.gpg) to use the AniNIX's CI/CD.
|
||||
|
||||
# Available Clients
|
||||
As Maat is a pipeline for ArchLinux systems, the primary client is [Pacman](https://wiki.archlinux.org/title/Pacman). You can see how to subscribe your host to Maat in [this configuration snippet](https://aninix.net/AniNIX/Ubiqtorate/src/branch/main/roles/ShadowArch/files/pacman.conf#L103).
|
||||
|
||||
# Equivalents or Competition
|
||||
|
||||
General equivalents are Jenkins or GitLab CI/CD Runners. We chose to write our own because these are resource-intensive and often insecure. AniNIX/Maat enacts exactly the steps as detailed by Arch and only offers a noninteractive dashboard -- users are only able to see the artifacts and all changes must be done in upstream.
|
47
maat
47
maat
|
@ -16,7 +16,7 @@ pkgExt=".pkg.tar.zst"
|
|||
deprivuser="maat"
|
||||
|
||||
### Printing defaults
|
||||
passCell="<td style='color:green;'>PASS</td>";
|
||||
passCell="<td style='color:#72ff72;'>PASS</td>";
|
||||
failCell="<td style='color:red;'>FAIL</td>";
|
||||
warnCell="<td style='color:yellow;'>N/A</td>";
|
||||
tableHead="<table style='text-align: left;'>\n<tr><th>Package</th><th>Testing Status</th><th>Build Status</th><th>Latest Build</th><th>Time and Log of Run</th></tr>";
|
||||
|
@ -34,7 +34,7 @@ function Usage() {
|
|||
|
||||
### Put the initial content in the webfile
|
||||
function SeedWebFile() {
|
||||
printf '<html>\n<head>\n<title>AniNIX/Maat -- Build Results</title>\n<link rel="icon" type="image/png" href="/MaatIcon.png" />\n<link rel="icon" type="image/png" href="/MaatIcon.png">\n<meta name="apple-mobile-web-app-capable" content="yes" />\n<link rel="stylesheet" type="text/css" href="https://aninix.net/assets/css/theme-aninix.css">\n<link rel="apple-touch-icon" sizes="180x180" href="/MaatIcon.png" />\n</head>\n<body>\n<h1>AniNIX/Maat -- Build Status</h1>\nWEBSTATSGOHERE\n<h2>AnINIX Packages</h2>\n<p>These are packages written by the AniNIX. Their source is in <a href="https://aninix.net/" alt=AniNIX/Foundation>AniNIX/Foundation</a>.</p>\n' > "$webfile"
|
||||
printf '<html lang="en">\n<head>\n<title>AniNIX/Maat -- Build Results</title>\n<link rel="icon" type="image/png" href="/MaatIcon.png" />\n<link rel="icon" type="image/png" href="/MaatIcon.png">\n<meta name="apple-mobile-web-app-capable" content="yes" />\n<link rel="stylesheet" type="text/css" href="https://aninix.net/assets/css/theme-aninix.css">\n<link rel="apple-touch-icon" sizes="180x180" href="/MaatIcon.png" />\n</head>\n<body>\n<h1>AniNIX/Maat -- Build Status</h1>\nWEBSTATSGOHERE\n<h2>AnINIX Packages</h2>\n<p>These are packages written by the AniNIX. Their source is in <a href="https://aninix.net/" alt=AniNIX/Foundation>AniNIX/Foundation</a>.</p>\n' > "$webfile"
|
||||
printf "$tableHead" >> "$webfile"
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ function BuildPackage() {
|
|||
for pkg in `find . -type f | grep -E "${pkgExt}""\$"`; do
|
||||
printf "<a href=\"/$suffix/$pkg\">$pkg</a><br/>" >> "$webfile"
|
||||
pkgname="$(basename "$pkg" | cut -f 1 -d '.' | sed 's/-[[:digit:]]\+$//')"
|
||||
# Remove old copies
|
||||
find "${pkgdir}/${suffix}/" -name "${pkgname}-[0-9]*" -exec rm {} \;
|
||||
mv "$pkg" "$pkgdir"/"$suffix";
|
||||
mv "$pkg"".sig" "$pkgdir"/"$suffix";
|
||||
|
@ -83,7 +84,7 @@ function BuildRepo() {
|
|||
git clone "$repo"
|
||||
fi
|
||||
cd "$repodir"
|
||||
git reset --hard origin &>/dev/null
|
||||
git clean -fdX
|
||||
output="$(git pull 2>&1)"
|
||||
if [ -n "$incremental" ] && [ $( echo "$output" | grep -c 'Already up to date.' ) -eq 1 ]; then
|
||||
return;
|
||||
|
@ -95,11 +96,11 @@ function BuildRepo() {
|
|||
for pkgbuild in `find . -type f -name PKGBUILD`; do
|
||||
cd "$(dirname "$pkgbuild")"
|
||||
# Tell the status file about it.
|
||||
printf '<tr style="border: 1px solid #FFF;"><td>'"<a href='$repo'>$repodir</a> -- $pkgbuild"'</td>' >> "$webfile"
|
||||
printf '<tr style="border: 1px solid #FFF;"><td>'"<a href='$(echo "$repo" | sed 's#aur.archlinux.org#aur.archlinux.org/packages#' | sed 's/.git//')'>$repodir</a> -- $pkgbuild"'</td>' >> "$webfile"
|
||||
if [ -f Makefile ] && [ `grep -E -c '^test:' Makefile` -ge 1 ]; then
|
||||
# Have to try to install dependencies first
|
||||
for dep in $(grep makedepends PKGBUILD | cut -f 2 -d '(' | cut -f 1 -d ')' | sed "s/'//g"); do
|
||||
pacman -Sy "$dep" --noconfirm --needed
|
||||
pacman -S "$dep" --noconfirm --needed
|
||||
done
|
||||
# Check test status.
|
||||
timeout --preserve-status "$timeout" sudo -u "$deprivuser" /bin/bash -l -c "cd $PWD; make test" &>> "$pkgdir"/"$repodir".txt
|
||||
|
@ -129,7 +130,6 @@ function UpdateLocalRepo() {
|
|||
set -x
|
||||
cd "$pkgdir"
|
||||
chown -R "$deprivuser": .
|
||||
# TODO Add deduplication of updated files -- keep latest 3 versions.
|
||||
rm -Rf AniNIX.[db,files]*
|
||||
sudo -u "$deprivuser" repo-add --sign ./AniNIX.db.tar.zst `ls -1 *"${pkgExt}"`
|
||||
cd aur/
|
||||
|
@ -138,6 +138,20 @@ function UpdateLocalRepo() {
|
|||
set +x
|
||||
}
|
||||
|
||||
### Clean source tracking
|
||||
function CleanSrcTracking() {
|
||||
searchbase="${homedir}/src"
|
||||
for path in `find "$searchbase" -maxdepth 1 -mindepth 1 -type d`; do
|
||||
cd "$path"
|
||||
giturl="$(git config remote.origin.url)"
|
||||
if ! grep "$giturl" "$aurconf"; then
|
||||
cd "$searchbase"
|
||||
rm -Rf "$path"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# Clear variables
|
||||
aurconf='/usr/local/etc/Maat/aur.list'
|
||||
baseurl='https://aninix.net/AniNIX'
|
||||
|
@ -150,12 +164,26 @@ timeout="90s"
|
|||
# Stat tracking
|
||||
starttime=`date +%s`
|
||||
|
||||
function usage() {
|
||||
### Show helptext
|
||||
# param retcode: what to exit
|
||||
retcode="$1"
|
||||
cat <<EOM
|
||||
Usage: $0
|
||||
$0 -T # Extended testing
|
||||
$0 -b homedir -c aurconf -u user -t timeout
|
||||
Add -s to skip patching or -v for verbosity.
|
||||
EOM
|
||||
exit $retcode
|
||||
}
|
||||
|
||||
|
||||
# Parse arguments
|
||||
while getopts 'b:c:hil:st:Tu:v' OPTION; do
|
||||
case "${OPTION}" in
|
||||
b) homedir="${OPTARG}" ;;
|
||||
c) aurconf="${OPTARG}" ;;
|
||||
h) Usage; exit 0 ;;
|
||||
h) usage; exit 0 ;;
|
||||
i) incremental=1 ;;
|
||||
l) cmdstring="$0"; for arg in $@; do if [ "$arg" != "-l" ] && [ "$arg" != "${OPTARG}" ]; then cmdstring="$cmdstring \"${arg}\""; fi; done; exec /bin/bash -c "$cmdstring | tee -a \"${OPTARG}\""; ;;
|
||||
s) skipPatching=1 ;;
|
||||
|
@ -163,7 +191,7 @@ while getopts 'b:c:hil:st:Tu:v' OPTION; do
|
|||
T) export MAATTESTINGVAR=1; exec $0 -l ./testing.log -u "$deprivuser" -v -s -c <(echo https://aur.archlinux.org/ascii-invaders.git) -b . ;;
|
||||
u) deprivuser="${OPTARG}" ;;
|
||||
v) set -x ;;
|
||||
*) usage; exit 1 ;;
|
||||
*) echo "Internal GitOps CI/CD Pipeline"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
@ -196,7 +224,8 @@ SeedWebFile
|
|||
if [ -n "$MAATTESTINGVAR" ]; then
|
||||
BuildRepo "$baseurl"/HelloWorld
|
||||
else
|
||||
for AniNIXrepo in `curl -s "$baseurl" | grep 'class="name"' | cut -f 4 -d \" | sed "s#^#https://$(echo "$baseurl" | cut -f 3 -d /)#" | sed 's/$/.git/'`; do
|
||||
CleanSrcTracking
|
||||
for AniNIXrepo in `curl -s "$baseurl" | grep 'class="text primary name"' | cut -f 4 -d \" | sed "s#^#https://$(echo "$baseurl" | cut -f 3 -d /)#" | sed 's/$/.git/'`; do
|
||||
BuildRepo "$AniNIXrepo" '.'
|
||||
done
|
||||
fi
|
||||
|
|
|
@ -6,7 +6,7 @@ ConditionPathExists=|!/srv/maat/pkg/.lock
|
|||
ExecStartPre=/usr/sbin/mkdir /srv/maat/pkg/.lock
|
||||
ExecStart=/usr/local/bin/maat
|
||||
ExecStopPost=/usr/sbin/rmdir /srv/maat/pkg/.lock
|
||||
Type=oneshot
|
||||
Type=simple
|
||||
RemainAfterExit=no
|
||||
User=root
|
||||
Group=root
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
make extendedtest
|
Loading…
Reference in New Issue