]> git.donarmstrong.com Git - debhelper.git/blob - dh_installmime
r1737: releasing version 4.2.30
[debhelper.git] / dh_installmime
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_installmime - install mime files into package build directories
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_installmime> [S<I<debhelper options>>] [B<-n>]
15
16 =head1 DESCRIPTION
17
18 dh_installmime is a debhelper program that is responsible for installing
19 mime files into package build directories.
20
21 It also automatically generates the postinst and postrm commands needed to
22 interface with the debian mime-support and shared-mime-info packages.  See
23 L<dh_installdeb(1)> for an explanation of how this works.
24
25 If files named debian/package.mime or debian/package.sharedmimeinfo exist, then
26 they are installed into usr/lib/mime/packages/package and
27 /usr/share/mime/packages/package.xml (respectively) in the package build
28 directory.
29
30 =head1 OPTIONS
31
32 =over 4
33
34 =item B<-n>, B<--noscripts>
35
36 Do not modify postinst/postrm scripts.
37
38 =back
39
40 =head1 NOTES
41
42 Note that this command is not idempotent. "dh_clean -k" should be called
43 between invocations of this command. Otherwise, it may cause multiple
44 instances of the same text to be added to maintainer scripts.
45
46 =cut
47
48 init();
49
50 foreach my $package (@{$dh{DOPACKAGES}}) {
51         my $tmp=tmpdir($package);
52         my $mime=pkgfile($package,"mime");
53         
54         if ($mime ne '') {
55                 if (! -d "$tmp/usr/lib/mime/packages") {
56                         doit("install","-d","$tmp/usr/lib/mime/packages");
57                 }
58                 doit("install","-p","-m644",$mime,"$tmp/usr/lib/mime/packages/$package");
59         }
60         # Check wether we have to call update-mime (either upstream already
61         # installs a MIME information file or Debian provides one)
62         if ((! $dh{NOSCRIPTS}) && (-d "$tmp/usr/lib/mime/packages")) {
63                 autoscript($package,"postinst","postinst-mime");
64                 autoscript($package,"postrm","postrm-mime")
65         }
66         
67         my $sharedmimeinfo=pkgfile($package,"sharedmimeinfo");
68         
69         if ($sharedmimeinfo ne '') {
70                 if (! -d "$tmp/usr/share/mime/packages") {
71                         doit("install", "-d", "$tmp/usr/share/mime/packages");
72                 }
73                 doit("install", "-p", "-m644", $sharedmimeinfo, "$tmp/usr/share/mime/packages/$package.xml");
74         }
75         # check wether we have to call update-mime-database (either upstream
76         # already installs a shared MIME information file or Debian provides
77         # one)
78         if ((! $dh{NOSCRIPTS}) && (-d "$tmp/usr/share/mime/packages")) {
79                 autoscript($package, "postinst", "postinst-sharedmimeinfo");
80                 autoscript($package, "postrm", "postrm-sharedmimeinfo")
81         }
82 }
83
84 =head1 SEE ALSO
85
86 L<debhelper(7)>
87
88 This program is a part of debhelper.
89
90 =head1 AUTHOR
91
92 Joey Hess <joeyh@debian.org>
93
94 =cut