summaryrefslogtreecommitdiff
path: root/dh_installmanpages
blob: a8fb1e992dfda7eaa80f81644540e690efb5601b (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh -e
#
# Automatically find and install man pages. However, do not install any man 
# pages listed on the command line.
# Also change man pages with .so commands in them into symlinks.
#
# This is a little bit (hah!) DWIMish, but still very handy.

PATH=debian:$PATH:/usr/lib/debhelper
. dh_lib

for PACKAGE in $DH_DOPACKAGES; do
        TMP=`tmpdir $PACKAGE`

	# Find all filenames that look like man pages.
	# .ex files are examples installed by deb-make, we don't want those, or
	# .in files, which are from configure.
	# We also need to exclude all debian/tmp type dirs.
	EXCLUDE=`grep ^Package: debian/control | \
		cut -d " " -f 2 | tr "\n" "|"`
	for file in `find * -type f -name "*.[1-9]*" ! -name "*.ex" \
		! -name "*.in" | egrep -v "^debian/(${EXCLUDE}tmp)/"`
	do
		# Make sure file thinks they are man pages.
		if file -L $file|grep -q roff; then
			if echo $file|grep -q /; then
				NAME=`expr $file : '.*/\(.*\)'`
			else
				NAME=$file
			fi
			# Look at the command line and check if we should
			# install the file.
			install=1
			for notinstall in $@; do
				if [ "$NAME" = "$notinstall" -o \
				     "$file" = "$notinstall" ]; then
					install=""
				fi
			done
			if [ "$install" ]; then
				SECTION=man`expr $NAME : '.*\.\([123456789]\)'`
				# Test to see if the filename ends with 'x',
				# if so, this is an X man page.
				if expr $NAME : '.*\.[123456789]x' >/dev/null; then
					EXTDIR="X11R6"
				else
					EXTDIR=""
				fi
				if [ ! -e $TMP/usr/man/$SECTION/$NAME -a \
				     ! -e $TMP/usr/X11*/man/$SECTION/$NAME ]; then
					if [ ! -d $TMP/usr/$EXTDIR/man/$SECTION ]; then
						doit "install -d $TMP/usr/$EXTDIR/man/$SECTION"
					fi
					doit "install -p -m644 $file $TMP/usr/$EXTDIR/man/$SECTION/$NAME"
				fi
			fi
		fi
	done

	# Now the .so conversion.
	for file in `find $TMP/usr/man $TMP/usr/X11*/man -type f -size -256c 2>/dev/null`
	do
		solink=`expr "\`head -1 $file\`" : '\.so \(.*\)'`
		if [ "$solink" ]; then
			doit "rm -f $file"
			# The .so links include the subdir the page is in, 
			# thus the ../
			doit "ln -s ../$solink $file"
		fi
	done
done