Commit e5c3f5f

Daniel Axtens <dja@axtens.net>
2026-11-15 14:53:20
better compress script
1 parent de210c8
Changed files (2)
scripts/compress.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+set -e -u -o pipefail
+#set -v -x
+
+ORIGSIZE=`stat -f%z $1`
+
+brotli --best $1
+BRSIZE=`stat -f%z $1.br`
+if [ $ORIGSIZE -le $BRSIZE ]; then
+    rm $1.br
+fi
+
+gzip --best --keep $1
+GZSIZE=`stat -f%z $1.gz`
+if [ $ORIGSIZE -le $GZSIZE ]; then
+    rm $1.gz
+fi
+
+zstd -9 --quiet $1
+ZSTDSIZE=`stat -f%z $1.zst`
+if [ $ORIGSIZE -le $ZSTDSIZE ]; then
+    rm $1.zst
+fi
+
+echo "$1: $ORIGSIZE ($BRSIZE) ($GZSIZE) ($ZSTDSIZE)"
build.sh
@@ -91,7 +91,7 @@ generate_etags "/git"
 popd
 
 # compress the files
-find root/usr/local/www -type f -exec brotli --squash --best \{\} \; -exec gzip --best --keep \{\} \; -exec zstd -9 \{\} \;
+find root/usr/local/www -type f -exec $SRCDIR/scripts/compress.sh \{\} \;
 
 # copy in cgi-bin last so it doesn't get compressed
 cp -r $SRCDIR/cgi-bin root/usr/local/www/