Adding initial files
This commit is contained in:
		
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| src/ | ||||
| web/ | ||||
| pkg/ | ||||
							
								
								
									
										27
									
								
								LICENSE
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								LICENSE
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| # 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. | ||||
							
								
								
									
										37
									
								
								Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								Makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| INSTALLDIR = ${pkgdir}/usr/local/bin | ||||
| INSTALLLIST = ./maat-builder | ||||
| OWNER=root | ||||
| PERMS=0755 | ||||
|  | ||||
|  | ||||
| compile: /bin/bash | ||||
| 	@echo Nothing to compile. | ||||
|  | ||||
| install: ${INSTALLLIST} | ||||
| 	mkdir -p ${INSTALLDIR} | ||||
| 	for i in ${INSTALLLIST}; do install -m ${PERMS} -o ${OWNER} $$i ${INSTALLDIR}; done | ||||
|  | ||||
| clean: | ||||
| 	cat .gitignore | xargs rm -Rf | ||||
|  | ||||
| uninstall: | ||||
| 	for i in ${INSTALLLIST}; do rm -Rf ${INSTALLDIR}/$$i; done | ||||
|  | ||||
| test: | ||||
| 	for i in ${LIST}; do $$i -h; done | ||||
|  | ||||
| test-run: | ||||
| 	bash ./maat -v -d ./repo -b ./build -w ./web -c /dev/null | ||||
|  | ||||
| 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: | ||||
| 	for i in ${list}; do chown ${OWNER}: "${INSTALLDIR}/$$i"; chmod ${PERMS} "${INSTALLDIR}/$$i"; done | ||||
| 	chmod 0644 ${SUPPORTDIR}/maat.html | ||||
| 	chown ${OWNER}: ${SUPPORTDIR}/maat.html | ||||
| 	chmod 0644 ${pkgdir}/etc/lighttpd/conf.d/maat.conf | ||||
| 	chown http: ${pkgdir}/etc/lighttpd/conf.d/maat.conf | ||||
							
								
								
									
										43
									
								
								PKGBUILD
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								PKGBUILD
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,43 @@ | ||||
| # Maintainer: Shikoba Kage <darkfeather@aninix.net> | ||||
| pkgname=maat | ||||
| pkgver=0.1."$(git rev-parse HEAD)" | ||||
| pkgrel=1 | ||||
| epoch= | ||||
| pkgdesc="AniNIX::Maat \\\\ Quality Assurance and Reporting Framework" | ||||
| arch=("x86_64") | ||||
| url="https://aninix.net/wiki/Maat" | ||||
| license=('custom') | ||||
| groups=() | ||||
| depends=('bash>=4.4' 'wget' 'grep' 'make' 'git') | ||||
| makedepends=('make>=4.2') | ||||
| checkdepends=() | ||||
| optdepends=() | ||||
| provides=('maat') | ||||
| conflicts=() | ||||
| replaces=() | ||||
| backup=() | ||||
| options=() | ||||
| install= | ||||
| changelog= | ||||
| source=() | ||||
| noextract=() | ||||
| md5sums=() | ||||
| validpgpkeys=() | ||||
|  | ||||
| prepare() { | ||||
|     git pull | ||||
| } | ||||
|  | ||||
| build() { | ||||
|     make -C .. | ||||
| } | ||||
|  | ||||
| check() { | ||||
| 	make -C "${srcdir}/.." test | ||||
| } | ||||
|  | ||||
| package() { | ||||
|     export pkgdir="${pkgdir}" | ||||
| 	make -C .. install | ||||
|     install -D -m644 ../LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" | ||||
| } | ||||
							
								
								
									
										160
									
								
								maat-builder
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										160
									
								
								maat-builder
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,160 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| # File: maat-builder | ||||
| # | ||||
| # Description: This file allows a Maat host to build source packages | ||||
| #              and optionally upload to the AniNIX::Foundation | ||||
| # | ||||
| # Package: ConfigPackages/Maat | ||||
| # Copyright: WTFPL | ||||
| # | ||||
| # Author: darkfeather@aninix.net | ||||
| #  | ||||
|  | ||||
| ### Printing defaults | ||||
| passCell="<td style='color:green;'>PASS<td>"; | ||||
| failCell="<td style='color:red;'>FAIL<td>"; | ||||
| warnCell="<td style='color:yellow;'>N/A<td>"; | ||||
|  | ||||
| ### Add helptext. | ||||
| function Usage() { | ||||
|     echo "Usage: $0" | ||||
|     echo "       $0 [ -b basedir ] [ -c AUR.git.list ] [ -T ] [ -u https://base.url/ ]" | ||||
|     echo "       $0 -h" | ||||
|     echo | ||||
|     echo 'Add -v to increase verbosity or -h for help. Add the -l LOGFILE flags to log to a file' | ||||
| } | ||||
|  | ||||
| ### 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=https://aninix.net/mediawiki/images/9/90/MaatIcon.png" />\n<link rel="icon" type="image/png" href="/mediawiki/images/9/90/MaatIcon.png">\n<meta name="apple-mobile-web-app-capable" content="yes" />\n<link rel="stylesheet" type="text/css" href="/style.css">\n<link rel="apple-touch-icon" sizes="180x180" href="mediawiki/images/9/90/MaatIcon.png" />\n</head>\n<body>\n<h1>AniNIX::Maat \\\\ Build Status</h1>\nWEBSTATSGOHERE\n' > "$webfile" | ||||
| } | ||||
|  | ||||
| ### Update the webfile to close up table tags and add stats.  | ||||
| function UpdateWebFile() { | ||||
|     sed -i "s#WEBSTATSGOHERE#<p>These are the AniNIX testing results. We found $passcount passing and $failcount failing packages, with $warncount warnings. It took $runtime seconds to finish.</p><table><tr><th>Package</th><th>Testing Status</th><th>Build Status</th><th>Latest Build</th><th>Time of Run</th></tr>#" "$webfile" | ||||
|     echo '</table></body></html>' >> "$webfile" | ||||
|  | ||||
| } | ||||
|  | ||||
| ### Build the package. Assumes a PKGBUILD is resent in the repo. | ||||
| function BuildPackage() {  | ||||
|     makepkg &>/dev/null | ||||
|     if [ $? -ne 0 ]; then | ||||
|         # Build failed. | ||||
|         printf "$failCell""$warnCell"  >> "$webfile"  | ||||
|     else | ||||
|         # Build passed. | ||||
|         printf "$passCell""<td>"  >> "$webfile" | ||||
|         # List passing versions | ||||
|         ls -1 *.pkg.tar.xz | tr '\n' '`' | sed 's#`#<br/>#g' >> "$webfile"  | ||||
|         printf "</td>" >> "$webfile" | ||||
|     fi | ||||
|     for pkg in `find . -type f | egrep '.tar.xz$'`; do mv "$pkg" "$pkgdir"; done | ||||
| } | ||||
|  | ||||
| ### Build the repo passed as argument | ||||
| # param repo: the repo to build. | ||||
| function BuildRepo() { | ||||
|     repo="$1" | ||||
|     cd "$srcdir" | ||||
|     if [ -z "$repo" ]; then continue; fi | ||||
|     repodir="$(echo $repo | rev | cut -f 1 -d '/' | rev | sed 's/\.git$//')" | ||||
|     #Set up the checkout | ||||
|     if [ ! -d "$repodir" ]; then | ||||
|         git clone "$repo" | ||||
|     fi | ||||
|     cd "$repodir"  | ||||
|     git pull | ||||
|     # Find the PKGBuilds in the repo | ||||
|     for pkgbuild in `find . -type f -name PKGBUILD`; do | ||||
|         cd "$(dirname "$pkgbuild")" | ||||
|         # Tell the status file about it. | ||||
|         printf '<tr><td>'"<a href='$repo'>$repodir</a> -- $pkgbuild"'</td>' >> "$webfile" | ||||
|         if [ -f Makefile ] && [ `egrep -c '^test:' Makefile` -ge 1 ]; then | ||||
|             # Check test status. | ||||
|             timeout --preserve-status 30s /bin/bash -c 'make test' &>/dev/null | ||||
|             if [ $? -ne 0 ]; then | ||||
|                 # Testing failed. | ||||
|                 printf "$failCell""$warnCell""$warnCell" >> "$webfile" | ||||
|             else | ||||
|                 # Testing passed. | ||||
|                 printf "$passCell" >> "$webfile" | ||||
|                 BuildPackage  | ||||
|             fi | ||||
|         else  | ||||
|             # Can't test -- usually from non-AniNIX repos. | ||||
|             printf "$warnCell" >> "$webfile" | ||||
|             BuildPackage | ||||
|         fi | ||||
|         # Timestamp | ||||
|         printf "<td>$(date +%F-%R)</td>\n" >> "$webfile" | ||||
|         cd "$cwd" | ||||
|         if [ ! -z "$testing" ]; then break; fi | ||||
|     done | ||||
|     cd "$cwd"  | ||||
| } | ||||
|  | ||||
| ### Update the local repo  | ||||
| function UpdateLocalRepo() {  | ||||
|     cd "$pkgdir"  | ||||
|     # TODO Add deduplication of updated files -- keep latest 3 versions. | ||||
|     repo-add --new ./AniNIX::Maat.db.tar.xz `ls -1 *.tar.xz` | ||||
| } | ||||
|  | ||||
| # Production defaults | ||||
| baseurl='https://aninix.net/foundation/' | ||||
| aurconf='/usr/local/etc/Maat/aur.list' | ||||
| homedir=/srv/maat/ | ||||
| unset upload | ||||
| unset testing | ||||
|  | ||||
| # Stat tracking | ||||
| starttime=`date +%s` | ||||
|  | ||||
| # Parse arguments | ||||
| while getopts 'b:c:hl:Tu:Uv' OPTION; do | ||||
|     case "${OPTION}" in | ||||
|         b) homedir="${OPTARG}" ;; | ||||
|         c) aurconf="${OPTARG}" ;; | ||||
|         h) Usage; exit 0 ;; | ||||
|         l) cmdstring="$0"; for arg in $@; do if [ "$arg" != "-l" ] && [ "$arg" != "${OPTARG}" ]; then cmdstring="$cmdstring \"${arg}\""; fi; done; exec /bin/bash -c "$0 $cmdstring | tee -a \"${OPTARG}\"" ;; | ||||
|         T) homedir='.'; testing=1 ;; | ||||
|         u) baseurl="${OPTARG}" ;; | ||||
|         v) set -x ;; | ||||
|         *) usage; exit 1 ;; | ||||
|     esac | ||||
| done | ||||
|  | ||||
| # Ensure work directories live | ||||
| if [ $( echo "$homedir" | egrep -c '^/') -ne 1 ]; then  | ||||
|     homedir="${PWD}/${homedir}" | ||||
| fi | ||||
| srcdir="${homedir}/src" && mkdir -p "${srcdir}" | ||||
| pkgdir="${homedir}/pkg" && mkdir -p "${pkgdir}" | ||||
| webdir="${homedir}/web" && mkdir -p "${webdir}" | ||||
| webfile="$webdir"/index.php | ||||
|  | ||||
| # For each repo listed at the CGIT URL and conf file | ||||
| cwd="$(pwd)" | ||||
| SeedWebFile | ||||
| for aninixrepo in `wget -q -O - "$baseurl" | grep toplevel-repo | cut -f 4 -d \' | sed "s#^#$baseurl#"`; do | ||||
|     BuildRepo "$aninixrepo" | ||||
|     if [ ! -z "$testing" ]; then break; fi | ||||
| done | ||||
| for repo in `cat "$aurconf"`; do | ||||
|     BuildRepo repo; | ||||
|     if [ ! -z "$testing" ]; then break; fi | ||||
| done | ||||
|  | ||||
| UpdateLocalRepo | ||||
|  | ||||
| runtime=$(( `date +%s` - $starttime )) | ||||
|  | ||||
| # Update stats | ||||
| failcount=$(grep -c "$failCell" "$webfile") | ||||
| warncount=$(grep -c "$warnCell" "$webfile") | ||||
| passcount=$( grep -v "$failCell" "$webfile" | grep -c "$passCell" ) | ||||
| UpdateWebFile | ||||
|  | ||||
| # Exit | ||||
		Reference in New Issue
	
	Block a user
	 DarkFeather
					DarkFeather