summaryrefslogtreecommitdiff
path: root/dh_installxaw
blob: bee971091c459efab64e748c8214ba3fa7a9648a (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
#!/usr/bin/perl -w
#
# Integration with xaw-wrappers
#
# If debian/xaw-wrappers file exists, save it to 
# $TMP/usr/share/xaw-wrappers/config/$PACKAGE
#
# Also, add calls to postinst and postrm.

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

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

	if ($xaw ne '') {
		if (! -d "$TMP/usr/share/xaw-wrappers/config") {
			doit("install","-d","$TMP/usr/share/xaw-wrappers/config");
		}
		doit("install","-p","-m644",$xaw,
			"$TMP/usr/share/xaw-wrappers/config/$PACKAGE");

		if (! $dh{NOSCRIPTS}) {
			# Parse the xaw conf file to figure out what programs
			# and link names are present in it. Have to pass
			# those into the scripts.
			my %data;
			my $install_opts='';
			my $remove_opts='';
			my $stanza='';
			
			open (IN,$xaw);
			while (<IN>) {
				chomp;
				s/\s+/ /g;
				if (/^#/ eq '') {
					if (/(.*?):\s?(.*)/) {
						$data{lc($1)}=$2;
						$stanza=1;
					}
					elsif ($stanza) {
						$install_opts.="'$data{program} $data{'link-name'} $data{wrapped}' ";
						$remove_opts.="'$data{'link-name'} $data{wrapped}' ";
						undef %data;
						$stanza='';
					}
				}
			}
			close IN;

			if ($stanza) {
				$install_opts.="'$data{program} $data{'link-name'} $data{wrapped}'";
				$remove_opts.="'$data{'link-name'} $data{wrapped}'";
			}
			
			autoscript($PACKAGE,"postinst","postinst-xaw",
				"s:#OPTS#:$install_opts:");
			autoscript($PACKAGE,"prerm","prerm-xaw",
				"s:#OPTS#:$remove_opts:");
			autoscript($PACKAGE,"postrm","postrm-xaw");
		}
	}
}