summaryrefslogtreecommitdiff
path: root/dh_installinfo
blob: 2983d28f993c90397c6f6005cb0e33638ecfc505 (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
#!/usr/bin/perl -w
#
# Reads debian/info, installs all files listed there into /usr/info
# and puts appropriate commands into the postinst.

BEGIN { push @INC, "debian", "/usr/share/debhelper" }
use Dh_Lib;
init();

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

	undef @info;
	
	if ($file) {
		@info=filearray($file);
	}

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

	if (@info) {
		if ( ! -d "$TMP/usr/info") {
			doit("install","-d","$TMP/usr/info");
		}
		doit("cp",@info,"$TMP/usr/info");
		doit("chmod","-R", "go=rX","$TMP/usr/info/");
		doit("chmod","-R", "u+rw","$TMP/usr/info/");
	}

	foreach $file (@info) {
		# Only register with install-info if this is a head file in
		# a tree of info files.
		if ($file=~/\.info$/ && ! $dh{NOSCRIPTS}) {
			# Figure out what section this file goes in.
			my $section='';
			open (IN, "<$file") || die "$file: $!";
			while (<IN>) {
				if (/INFO-DIR-SECTION\s+(.*)/) {
					$section=$1;
					last;
				}
			}
			close IN;
			
			my $fn="/usr/info/".Dh_Lib::basename($file);
			
			if ($section ne '') {
				autoscript($PACKAGE,"postinst","postinst-info",
					"s/#SECTION#/$section/g;s:#FILE#:$fn:");
			}
			else {
				autoscript($PACKAGE,"postinst","postinst-info-nosection",
					"s:#FILE#:$fn:");
			}
			autoscript($PACKAGE,"prerm","prerm-info", "s:#FILE#:$fn:");
		}
	}
}