#!/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 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