summaryrefslogtreecommitdiff
path: root/dh_installdocs
blob: fcdedc500fed9cd119d6d1adb7eeaebfd4a0af16 (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
#!/bin/sh -e
#
# Reads debian/docs, installs all files listed there into /usr/doc/$PACKAGE
# Also installs the debian/copyright and debian/README.debian and debian/TODO

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

for PACKAGE in $DH_DOPACKAGES; do
	TMP=`tmpdir $PACKAGE`
	file=`pkgfile $PACKAGE docs`

	if [ ! -d $TMP/usr/doc/$PACKAGE ]; then
		doit "install -d $TMP/usr/doc/$PACKAGE"
	fi

	docs=""

	if [ "$file" ]; then
		docs=`tr "\n" " " < $file`
	fi

	if [ \( "$PACKAGE" = "$DH_FIRSTPACKAGE" -o "$DH_PARAMS_ALL" \) \
	     -a "$*" ]; then
		docs="$* $docs"
	fi

	if [ "$docs" ]; then
		doit "cp -a $docs $TMP/usr/doc/$PACKAGE/"
	fi

	# .Debian is correct, according to policy.
	readme_debian=`pkgfile $PACKAGE README.Debian`
	if [ -z "$readme_debian" ]; then
		readme_debian=`pkgfile $PACKAGE README.debian`
	fi
	if [ "$readme_debian" ]; then
		doit "install -m 644 -p $readme_debian $TMP/usr/doc/$PACKAGE/README.Debian"
	fi

	todo=`pkgfile $PACKAGE TODO`
	if [ "$todo" ]; then
		if isnative; then
			doit "install -m 655 -p $todo $TMP/usr/doc/$PACKAGE/TODO"
		else
			doit "install -m 644 -p $todo $TMP/usr/doc/$PACKAGE/TODO.Debian"
		fi
	fi

	# Support debian/package.copyright, but if not present, fall back
	# on debian/copyright for all packages, not just the main binary
	# package.
	copyright=`pkgfile $PACKAGE copyright`
	if [ ! "$copyright" -a -e debian/copyright ]; then
		copyright=debian/copyright
	fi
	if [ "$copyright" ]; then
			doit "install -m 644 -p $copyright $TMP/usr/doc/$PACKAGE/copyright"
	fi
done