]> git.donarmstrong.com Git - debhelper.git/blob - dh_installemacsen
Merge branch 'dh_overrides'
[debhelper.git] / dh_installemacsen
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_installemacsen - register an emacs add on package
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_installemacsen> [S<I<debhelper options>>] [B<-n>] [B<--priority=>I<n>] [B<--flavor=>I<foo>]
15
16 =head1 DESCRIPTION
17
18 dh_installemacsen is a debhelper program that is responsible for installing
19 files used by the debian emacsen-common package into package build
20 directories.
21
22 It also automatically generates the postinst and prerm commands needed to
23 register a package as an emacs add on package. The commands are added to
24 the maintainer scripts by dh_installdeb. See L<dh_installdeb(1)>
25 for an explanation of how this works.
26
27 If a file named debian/package.emacsen-install exists, then it is installed
28 into
29 usr/lib/emacsen-common/packages/install/package in the package build
30 directory. Similarly, debian/package.emacsen-remove is installed into
31 usr/lib/emacsen-common/packages/remove/package . And similarly,
32 debian/package.emacsen-startup is installed into
33 etc/emacs/site-start.d/50<package>.el (by default).
34
35 =head1 OPTIONS
36
37 =over 4
38
39 =item B<-n>, B<--noscripts>
40
41 Do not modify postinst/prerm scripts.
42
43 =item B<--priority=>I<n>
44
45 Sets the priority number of a site-start.d file. Default is 50.
46
47 =item B<--flavor=>I<foo>
48
49 Sets the flavor a site-start.d file will be installed in. Default is
50 "emacs", alternatives include "xemacs" and "emacs20".
51
52 =back
53
54 =head1 NOTES
55
56 Note that this command is not idempotent. L<dh_prep(1)> should be called
57 between invocations of this command. Otherwise, it may cause multiple
58 instances of the same text to be added to maintainer scripts.
59
60 =cut
61
62 init(options => {
63         "flavor=s" => \$dh{FLAVOR},
64 });
65
66 if (! defined $dh{PRIORITY}) {
67         $dh{PRIORITY}=50;
68 }
69 if (! defined $dh{FLAVOR}) {
70         $dh{FLAVOR}='emacs';
71 }
72
73 foreach my $package (@{$dh{DOPACKAGES}}) {
74         my $tmp=tmpdir($package);
75
76         my $emacsen_install=pkgfile($package,"emacsen-install");
77         my $emacsen_remove=pkgfile($package,"emacsen-remove");
78         my $emacsen_startup=pkgfile($package,"emacsen-startup");
79
80         if ($emacsen_install ne '') {
81                 if (! -d "$tmp/usr/lib/emacsen-common/packages/install") {
82                         doit("install","-d","$tmp/usr/lib/emacsen-common/packages/install");
83                 }
84                 doit("install","-m0755",$emacsen_install,"$tmp/usr/lib/emacsen-common/packages/install/$package");
85         }
86
87         if ($emacsen_remove ne '') {
88                 if (! -d "$tmp/usr/lib/emacsen-common/packages/remove") {
89                         doit("install","-d","$tmp/usr/lib/emacsen-common/packages/remove");
90                 }
91                 doit("install","-m0755","$emacsen_remove","$tmp/usr/lib/emacsen-common/packages/remove/$package");
92         }
93         
94         if ($emacsen_startup ne '') {
95                 if (! -d "$tmp/etc/$dh{FLAVOR}/site-start.d/") {
96                         doit("install","-d","$tmp/etc/$dh{FLAVOR}/site-start.d/");
97                 }
98                 doit("install","-m0644",$emacsen_startup,"$tmp/etc/$dh{FLAVOR}/site-start.d/$dh{PRIORITY}$package.el");
99         }
100
101         if ($emacsen_install ne '' || $emacsen_remove ne '') {
102                 if (! $dh{NOSCRIPTS}) {
103                         autoscript($package,"postinst","postinst-emacsen",
104                                 "s/#PACKAGE#/$package/");
105                         autoscript($package,"prerm","prerm-emacsen",
106                                 "s/#PACKAGE#/$package/");
107                 }
108         }
109 }
110
111 =head1 SEE ALSO
112
113 L<debhelper(7)>
114
115 This program is a part of debhelper.
116
117 =head1 AUTHOR
118
119 Joey Hess <joeyh@debian.org>
120
121 =cut