summaryrefslogtreecommitdiff
path: root/dh_installwm
blob: e07b7299a4a212b41f59b9d4f5d1563738bc0cd1 (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
112
113
114
115
116
117
#!/usr/bin/perl -w

=head1 NAME

dh_installwm - register a window manager

=cut

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

=head1 SYNOPSIS

B<dh_installwm> [S<I<debhelper options>>] [B<-n>] [B<--priority=>I<n>] [S<I<wm ...>>]

=head1 DESCRIPTION

dh_installwm is a debhelper program that is responsible for
generating the postinst and postrm commands that register a window manager
with L<update-alternatives(8)>. The window manager's man page is also 
registered as a slave symlink (in v6 mode and up), if it is found in 
usr/share/man/man1/ in the package build directory.

Any window manager programs specified as parameters will be registered in
the first package dh_installwm is told to act on. By default, this is the
first binary package in debian/control, but if you use -p, -i, or -a flags,
it will be the first package specified by those flags.

Files named debian/package.wm can list other window manager programs to
register.

=head1 OPTIONS

=over 4

=item B<--priority=>I<n>

Set the priority of the window manager. Default is 20, which is too low for
most window managers; see the Debian Policy document for instructions on
calculating the correct value.

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

Do not modify postinst/postrm scripts. Turns this command into a no-op.

=item I<wm ...>

The commands used to run the window manager or window managers you want to
register.

=back

=head1 NOTES

Note that this command is not idempotent. L<dh_prep(1)> 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();

if (! defined $dh{PRIORITY}) {
        $dh{PRIORITY}=20;
}

if (@ARGV) {
	# This is here for backwards compatibility. If the filename doesn't
	# include a path, assume it's in /usr/bin.
	if ($ARGV[0] !~ m:/:) {
		$ARGV[0]="/usr/bin/$ARGV[0]";
	}
}

foreach my $package (@{$dh{DOPACKAGES}}) {
	my $tmp=tmpdir($package);
	my $file=pkgfile($package,"wm");

	my @wm;
	if ($file) {
		@wm=filearray($file, '.');
	}

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

	if (! $dh{NOSCRIPTS}) {
WM:		foreach my $wm (@wm) {
			autoscript($package,"prerm","prerm-wm","s:#WM#:$wm:");

			my $wmman;
			if (! compat(5)) {
				foreach my $ext (".1", ".1x") {
					$wmman="/usr/share/man/man1/".basename($wm).$ext;
					if (-e "$tmp$wmman" || -e "$tmp$wmman.gz") {
						autoscript($package,"postinst","postinst-wm","s:#WM#:$wm:;s:#WMMAN#:$wmman.gz:;s/#PRIORITY#/$dh{PRIORITY}/",);
						next WM;
					}
				}
			}
			autoscript($package,"postinst","postinst-wm-noman","s:#WM#:$wm:;s/#PRIORITY#/$dh{PRIORITY}/",);
		}
	}
}

=head1 SEE ALSO

L<debhelper(7)>

This program is a part of debhelper.

=head1 AUTHOR

Joey Hess <joeyh@debian.org>

=cut