build.sh (1965B)
1 #!/bin/bash 2 3 # Build the handbook for every version branch with sphinx-multiversion, 4 # using the toolchain from .buildbot/Dockerfile. The result goes to _build/. 5 # 6 # Uses docker, or podman if there is no docker; set CONTAINER_ENGINE to 7 # choose. 8 9 set -o pipefail 10 11 cd "$(dirname "$0")/.." || exit 1 12 13 git branch -r \ 14 | grep -v '\->' \ 15 | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" \ 16 | while read remote; do \ 17 git branch --track "${remote#origin/}" "$remote"; \ 18 done 19 20 git tag --delete latest || echo "Deleting tag can fail" 21 # Get latest version branch 22 latest=$(git for-each-ref --format "%(refname)" | grep -i '^refs/remotes/origin/v[0-9]*\.[0-9]*\.x$' | sort -r | head -n1) 23 echo $latest" is latest ref" 24 git tag latest $latest 25 26 CONTAINER_ENGINE=podman 27 image=gnunet-handbook-build 28 29 "$CONTAINER_ENGINE" build -t "$image" .buildbot || exit 1 30 31 # The checkout is mounted read-only at the same path as on the host, and 32 # sphinx-multiversion reads the branches and the tag set up above from its 33 # .git. The output comes back as a tar stream on stdout (so Sphinx's own 34 # output goes to stderr) and is unpacked here, so that _build/ belongs to 35 # the user running this script whichever user the container runs as. 36 # 37 # SPHINX_MULTIVERSION is the conditional extension switch in conf.py. 38 # GNUNET_VERSION (read by conf.py) and SOURCE_DATE_EPOCH (read by Sphinx) 39 # are passed on if they are set. conf.py also puts the current year into 40 # the copyright notice, so the container gets the host's time zone, or the 41 # two would disagree about the year around New Year. 42 tz=() 43 if [ -e /etc/localtime ]; then 44 tz=(--volume /etc/localtime:/etc/localtime:ro) 45 fi 46 mkdir -p _build 47 "$CONTAINER_ENGINE" run --rm --network=none \ 48 --volume "$PWD:$PWD:ro" --workdir "$PWD" "${tz[@]}" \ 49 --env SPHINX_MULTIVERSION=1 \ 50 --env GNUNET_VERSION \ 51 --env SOURCE_DATE_EPOCH \ 52 "$image" \ 53 sh -c 'sphinx-multiversion . /tmp/_build >&2 && tar -C /tmp/_build -cf - .' \ 54 | tar -C _build -xf -