]> git.donarmstrong.com Git - debhelper.git/blob - dh_installemacsen
r430: the great pod juggernaught rolls on through the night
[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   dh_installemacsen [debhelper options] [-n] [--priority=n]
15                     [--flavor=foo]
16
17 =head1 DESCRIPTION
18
19 dh_installemacsen is a debhelper program that is responsible for installing
20 files used by the debian emacsen-common package into package build
21 directories.
22
23 It also automatically generates the postinst and prerm commands needed to
24 register a package as an emacs add on package. 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. "dh_clean -k" 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();
63
64 if (! defined $dh{PRIORITY}) {
65         $dh{PRIORITY}=50;
66 }
67 if (! defined $dh{FLAVOR}) {
68         $dh{FLAVOR}='emacs';
69 }
70
71 foreach my $package (@{$dh{DOPACKAGES}}) {
72         my $tmp=tmpdir($package);
73
74         my $emacsen_install=pkgfile($package,"emacsen-install");
75         my $emacsen_remove=pkgfile($package,"emacsen-remove");
76         my $emacsen_startup=pkgfile($package,"emacsen-startup");
77
78         if ($emacsen_install ne '') {
79                 if (! -d "$tmp/usr/lib/emacsen-common/packages/install") {
80                         doit("install","-d","$tmp/usr/lib/emacsen-common/packages/install");
81                 }
82                 doit("install","-m0755",$emacsen_install,"$tmp/usr/lib/emacsen-common/packages/install/$package");
83         }
84
85         if ($emacsen_remove ne '') {
86                 if (! -d "$tmp/usr/lib/emacsen-common/packages/remove") {
87                         doit("install","-d","$tmp/usr/lib/emacsen-common/packages/remove");
88                 }
89                 doit("install","-m0755","$emacsen_remove","$tmp/usr/lib/emacsen-common/packages/remove/$package");
90         }
91         
92         if ($emacsen_startup ne '') {
93                 if (! -d "$tmp/etc/$dh{FLAVOR}/site-start.d/") {
94                         doit("install","-d","$tmp/etc/$dh{FLAVOR}/site-start.d/");
95                 }
96                 doit("install","-m0644",$emacsen_startup,"$tmp/etc/$dh{FLAVOR}/site-start.d/$dh{PRIORITY}$package.el");
97         }
98
99         if ($emacsen_install ne '' || $emacsen_remove ne '') {
100                 if (! $dh{NOSCRIPTS}) {
101                         autoscript($package,"postinst","postinst-emacsen",
102                                 "s/#PACKAGE#/$package/");
103                         autoscript($package,"prerm","prerm-emacsen",
104                                 "s/#PACKAGE#/$package/");
105                 }
106         }
107 }
108
109 =head1 SEE ALSO
110
111 L<debhelper(1)>
112
113 This program is a part of debhelper.
114
115 =head1 AUTHOR
116
117 Joey Hess <joeyh@debian.org>
118
119 =cut