summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-09-30 20:27:09 +0000
committerJune McEnroe <june@causal.agency>2021-09-30 22:57:04 +0000
commit957c7fdb0bd1c0a504d39808c92b47dafcd55b12 (patch)
tree8fb401be2060e4966b617e367197e0798c304315
parentSilence owner-info error (diff)
downloadsrc-957c7fdb0bd1c0a504d39808c92b47dafcd55b12.tar.gz
src-957c7fdb0bd1c0a504d39808c92b47dafcd55b12.zip
Build and copy static binaries to /var/www
Ideally these wouldn't require sh, cat, rm, mktemp.
-rw-r--r--www/git.causal.agency/.gitignore9
-rw-r--r--www/git.causal.agency/Makefile52
-rw-r--r--www/git.causal.agency/about-filter.sh7
-rw-r--r--www/git.causal.agency/cgitrc11
-rw-r--r--www/git.causal.agency/email-filter.sh6
-rw-r--r--www/git.causal.agency/owner-filter.sh4
-rw-r--r--www/git.causal.agency/source-filter.sh17
7 files changed, 73 insertions, 33 deletions
diff --git a/www/git.causal.agency/.gitignore b/www/git.causal.agency/.gitignore
index a0ae074c..40b3dcbf 100644
--- a/www/git.causal.agency/.gitignore
+++ b/www/git.causal.agency/.gitignore
@@ -1,6 +1,15 @@
 about-filter
+cat
+compress
+ctags
+email-filter
+gzip
 hilex
 htagml
+mandoc
+mktemp
 mtags
 owner-filter
+rm
+sh
 source-filter
diff --git a/www/git.causal.agency/Makefile b/www/git.causal.agency/Makefile
index 638c21e7..76c93d3a 100644
--- a/www/git.causal.agency/Makefile
+++ b/www/git.causal.agency/Makefile
@@ -1,20 +1,48 @@
-ETC = /usr/local/etc
-WWW = /usr/local/www/cgit
-LIBEXEC = /usr/local/libexec
+PREFIX = /var/www
+CONFDIR = ${PREFIX}/conf
+DATADIR = ${PREFIX}/cgit
+BINDIR = ${PREFIX}/bin
 
-BIN = ../../bin
-BINS = about-filter source-filter owner-filter hilex htagml mtags
+BINS += about-filter
+BINS += cat
+BINS += compress
+BINS += ctags
+BINS += email-filter
+BINS += gzip
+BINS += hilex
+BINS += htagml
+BINS += mandoc
+BINS += mktemp
+BINS += mtags
+BINS += owner-filter
+BINS += rm
+BINS += sh
+BINS += source-filter
 
 all: ${BINS}
 
-install: cgitrc custom.css ${BINS}
-	install -m 644 cgitrc ${ETC}
-	install -m 644 custom.css ${WWW}
-	install ${BINS} ${LIBEXEC}
+cat rm sh:
+	cp /bin/$@ $@
+
+compress ctags mandoc mktemp:
+	${MAKE} -C /usr/src/usr.bin/$@ LDFLAGS='-static -pie'
+	mv /usr/src/usr.bin/$@/$@ $@
+	${MAKE} -C /usr/src/usr.bin/$@ clean
+
+gzip: compress
+	cp compress $@
 
-hilex htagml mtags::
-	${MAKE} -C ${BIN} $@
-	ln -f ${BIN}/$@ $@
+hilex htagml mtags:
+	rm -f ../../bin/$@
+	${MAKE} -C ../../bin $@ LDFLAGS='-static -pie'
+	mv ../../bin/$@ $@
+
+install: cgitrc custom.css ${BINS}
+	install -m 644 cgitrc ${CONFDIR}
+	install -m 644 custom.css ${DATADIR}
+	install -d -o www -g daemon ${PREFIX}/cache/cgit
+	install -d -m 1700 -o www -g daemon ${PREFIX}/tmp
+	install ${BINS} ${BINDIR}
 
 clean:
 	rm -f ${BINS}
diff --git a/www/git.causal.agency/about-filter.sh b/www/git.causal.agency/about-filter.sh
index 2ff645e2..7a93d471 100644
--- a/www/git.causal.agency/about-filter.sh
+++ b/www/git.causal.agency/about-filter.sh
@@ -1,15 +1,16 @@
 #!/bin/sh
+set -eu
 
 options=fragment,man=%N.%S,includes=../tree/%I
 
 case "$1" in
 	(README.[1-9])
-		exec /usr/bin/mandoc -T html -O $options
+		exec mandoc -T html -O $options
 		;;
 	(*.[1-9])
-		exec /usr/bin/mandoc -T html -O $options,toc
+		exec mandoc -T html -O $options,toc
 		;;
 	(*)
-		exec /usr/local/libexec/hilex -l text -f html -o pre
+		exec hilex -l text -f html -o pre
 		;;
 esac
diff --git a/www/git.causal.agency/cgitrc b/www/git.causal.agency/cgitrc
index 8ccd7c72..b85f6fbb 100644
--- a/www/git.causal.agency/cgitrc
+++ b/www/git.causal.agency/cgitrc
@@ -14,16 +14,17 @@ repository-sort=age
 branch-sort=age
 
 css=/custom.css
-email-filter=/usr/local/libexec/cgit-email
-about-filter=/usr/local/libexec/about-filter
-source-filter=/usr/local/libexec/source-filter
-owner-filter=/usr/local/libexec/owner-filter
+about-filter=/bin/about-filter
+source-filter=/bin/source-filter
+owner-filter=/bin/owner-filter
+email-filter=/bin/email-filter
 
 readme=:README.7
 readme=:README
 
 remove-suffix=1
 enable-git-config=1
-scan-path=/home/june/pub
+scan-path=/git.causal.agency
 
+cache-root=/cache/cgit
 cache-size=1024
diff --git a/www/git.causal.agency/email-filter.sh b/www/git.causal.agency/email-filter.sh
new file mode 100644
index 00000000..ca778d69
--- /dev/null
+++ b/www/git.causal.agency/email-filter.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -eu
+
+read -r first rest || :
+[ "${first}" != "${first#C}" ] && first='C.'
+echo "${first}" "${rest}"
diff --git a/www/git.causal.agency/owner-filter.sh b/www/git.causal.agency/owner-filter.sh
index 18e74cf1..1997e97b 100644
--- a/www/git.causal.agency/owner-filter.sh
+++ b/www/git.causal.agency/owner-filter.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 set -eu
 
-cat <<EOF
+echo '
 <a href="https://liberapay.com/june/donate"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a>
-EOF
+'
diff --git a/www/git.causal.agency/source-filter.sh b/www/git.causal.agency/source-filter.sh
index 514272db..8782e266 100644
--- a/www/git.causal.agency/source-filter.sh
+++ b/www/git.causal.agency/source-filter.sh
@@ -1,25 +1,20 @@
 #!/bin/sh
 set -eu
 
-ctags=/usr/bin/ctags
-mtags=/usr/local/libexec/mtags
-hilex=/usr/local/libexec/hilex
-htagml=/usr/local/libexec/htagml
-
 case "$1" in
 	(*.[chlmy]|Makefile|*.mk|*.[1-9]|.profile|.shrc|*.sh)
-		tmp=$(mktemp -d -t source-filter)
+		tmp=$(mktemp -d)
 		trap 'rm -fr "${tmp}"' EXIT
 		cd "${tmp}"
 		cat >"$1"
-		touch tags
+		: >tags
 		case "$1" in
-			(*.[chlmy]) $ctags -w "$1";;
-			(*) $mtags "$1";;
+			(*.[chlmy]) ctags -w "$1";;
+			(*) mtags "$1";;
 		esac
-		$hilex -f html "$1" | $htagml -i "$1"
+		hilex -f html "$1" | htagml -i "$1"
 		;;
 	(*)
-		exec $hilex -t -n "$1" -f html
+		exec hilex -t -n "$1" -f html
 		;;
 esac