File: build

package info (click to toggle)
eximdoc4 4.99-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,884 kB
  • sloc: perl: 935; javascript: 182; makefile: 180; sh: 88; xml: 68
file content (52 lines) | stat: -rwxr-xr-x 1,391 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Usage: [TARGET=…] $0 [ref]
# - Build from either the ref (or refs/heads/master) or from the current working directory
# - Can be used as a post-update hook

set -eu
shopt -s extglob

tmp=$(mktemp -d)
trap "rm -rf '$tmp'" EXIT INT

staging="$tmp/staging"                          # the temporary build dir
pubdir=${TARGET:-/srv/www/vhosts/www.exim.org}  # publish here

if [[ $(git rev-parse --is-inside-work-tree) != true ]]
then
  workdir=$tmp/workdir
  install -d "$workdir"
  git --work-tree="$workdir" checkout -f refs/heads/master	# FIXME: use the receiving branch
  cd "$workdir"
fi

if ! test -d "$pubdir"
then
	echo "Warning: $pubdir does not exist. Did you forget to set the TARGET env in \"local\" mode?" >&2
	exit 1
fi


if getent group eximdev
then install -m 02775 -g eximdev -d "$staging"
else install -d "$staging"
fi

cp -r --preserve=timestamps "$pubdir"/exim-+(html|pdf)-* "$staging/" ||:

# start working
latest=$(cd docbook && compgen -G '[45].*' | sort -V | tail -n1)

script/gen \
  --web \
  --spec docbook/[45]*/spec.xml \
  --filter  docbook/[45]*/filter.xml \
  --tmpl templates \
  --latest "$latest" \
  --docroot "$staging"

mv "$staging" "$pubdir.$$"              # may take some time (tmp -> data volume)
mv "$pubdir" "$pubdir.$(date -Isecond)" # backup
mv "$pubdir.$$" "$pubdir"               # should be fast

echo "*** updated into $pubdir"