summary refs log tree commit diff
path: root/www/they.causal.agency/post-update.sh
blob: db2d593604ea04fd019773264ef9a2bb15995d4f (plain) (blame)
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
#!/bin/sh
set -eu

do_tree() {
	tree=$1
	manpath=$2
	echo "Copying manuals for ${tree}..."
	git ls-tree $tree | while read -r mode type hash name; do
		if [ $type != blob ]; then
			continue
		fi
		case "$name" in
			(README.7)
				continue
				;;
			(*.[1-9])
				section=${name##*.}
				mkdir -p /var/www/man/${manpath}/man${section}
				git cat-file $type $hash \
					>/var/www/man/${manpath}/man${section}/${name}
				;;
		esac
	done
	if test -d /var/www/man/${manpath}; then
		makewhatis /var/www/man/${manpath}
		if ! fgrep -q ${manpath} /var/www/man/manpath.conf; then
			echo $manpath >>/var/www/man/manpath.conf
			sort -o /var/www/man/manpath.conf /var/www/man/manpath.conf
		fi
	fi
}

do_tree HEAD HEAD

repo=${PWD##*/}
for tag in $(git tag); do
	manpath=${repo%.git}-${tag}
	if ! test -d /var/www/man/${manpath}; then
		do_tree $tag $manpath
	fi
done