summaryrefslogtreecommitdiff
path: root/dh_installxaw
blob: 3bda1fa0589f88306629f22832fec3ea946c7699 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/perl -w

=head1 NAME

dh_installxaw - install xaw wrappers config files into package build directories

=cut

use strict;
use Debian::Debhelper::Dh_Lib;

=head1 SYNOPSIS

  dh_installxaw [debhelper options] [-n]

=head1 DESCRIPTION

dh_installxaw is a debhelper program that is responsible for installing
xaw wrappers config files into package build directories.

It also automatically generates the postinst, prerm, and postrm commands
needed to interface with the debian xaw-wrappers package. See
L<dh_installdeb(1)> for an explanation of how this works.

If a file named debian/package.xaw exists, then it is installed into
usr/lib/xaw-wrappers/config/package in the package build directory.

=head1 OPTIONS

=over 4

=item B<-n>, B<--noscripts>

Do not modify postinst/prerm/postrm scripts.

=back

=head1 NOTES

Note that this command is not idempotent. "dh_clean -k" should be called
between invocations of this command. Otherwise, it may cause multiple
instances of the same text to be added to maintainer scripts.

=cut

init();

foreach my $package (@{$dh{DOPACKAGES}}) {
	my $tmp=tmpdir($package);
	my $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");
		}
	}
}

=head1 SEE ALSO

L<debhelper(1)>

This program is a part of debhelper.

=head1 AUTHOR

Joey Hess <joeyh@debian.org>

=cut