diff --git a/latex/build-all.sh b/latex/build-all.sh index ce9ca8b..dfe7e90 100755 --- a/latex/build-all.sh +++ b/latex/build-all.sh @@ -7,3 +7,5 @@ cd full ./build-image.sh git.janishutz.com/registry/latex-build-full cd .. rm ./full/entrypoint.sh +cd fmt +./build-image.sh git.janishutz.com/registry/latex-format diff --git a/latex/fmt/Dockerfile b/latex/fmt/Dockerfile new file mode 100644 index 0000000..55b4dad --- /dev/null +++ b/latex/fmt/Dockerfile @@ -0,0 +1,10 @@ +FROM alpine + +WORKDIR /root + +RUN apk add texlive-binextra perl-file-homedir perl-yaml-tiny + +COPY ./format.sh /root/ +RUN chmod +x /root/format.sh + +CMD [ "/root/format.sh" ] diff --git a/latex/fmt/build-image.sh b/latex/fmt/build-image.sh new file mode 100755 index 0000000..12228ff --- /dev/null +++ b/latex/fmt/build-image.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +set -e + +echo "Build will be tagged with $1" +echo "Build directory is $(pwd)" + +OLD_IMG=$(docker image ls -q "$1") +docker buildx build . -t "$1" + +echo "Build complete, starting upload..." +docker push "$1" + +if [ -n "$OLD_IMG" ]; then + if [ "$OLD_IMG" != "$(docker image ls -q "$1")" ]; then + echo "New build uploaded, removing old image, id: $OLD_IMG" + docker image rmi -f "$OLD_IMG" || true + echo "Exit status: $?" + fi +fi diff --git a/latex/fmt/format.sh b/latex/fmt/format.sh new file mode 100755 index 0000000..5e23010 --- /dev/null +++ b/latex/fmt/format.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ ! "$1" == "" ]; then + cd $1 +fi + +echo "Formatting directory $(pwd)" + +files=$(find . -type f | grep "\.tex") + +idx=1 +total=$(echo "$files" | wc -l) +for file in $files; do + echo "Processing file $idx / $total" + latexindent -s -w $file + ((idx++)) +done