summaryrefslogtreecommitdiff
path: root/dh_undocumented
blob: 93328ad05bfbf086b0f0f0db6b75e085f2ec650d (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
#!/usr/bin/perl -w
#
# Passed a list of undocumented man pages, generates symlinks to
# undocumented.7.gz for those man pages.
#
# Also, it looks for debian/undocumented files for more lists of
# undocumented man pages.

use Debian::Debhelper::Dh_Lib;
init();

foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
	$TMP=tmpdir($PACKAGE);
	$undocumented=pkgfile($PACKAGE,"undocumented");

	@undoc=();
	if ($undocumented) {
		@undoc=filearray($undocumented);
	}

	if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
		push @undoc, @ARGV;
	}	

	foreach $file (@undoc) {
		$file=~s/.gz$//; # .gz extension is optional in input.

		# Determine what directory the file belongs in,
		# /usr/share/man, or /usr/X11R6/man, and how the link to
		# the undocuemtned.7 man page will look.
		($section)=$file=~m/^.*\.(\d)/;
		if (!$section) {
			error("\"$file\" does not have an extension.");
		}	
		if ($file=~/.*\.\dx/) {
			$dir="usr/X11R6/man/man$section";
			$reldir="../../../share/man/man7/";
		}
		elsif ($section != 7) {
			$dir="usr/share/man/man$section";
			$reldir="../man7/";
		}
		else {
			$dir="usr/share/man/man$section";
			$reldir="";
		}

		if (! -d "$TMP/$dir") {
			doit("install","-d","$TMP/$dir");
		}
		doit("ln","-sf","${reldir}undocumented.7.gz","$TMP/$dir/$file.gz");
	}
}