]> git.donarmstrong.com Git - debhelper.git/blob - dh_desktop
Merge branch 'master' of ssh://git.debian.org/git/debhelper/debhelper
[debhelper.git] / dh_desktop
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_desktop - Register .desktop files
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_desktop> [S<I<debhelper options>>]
15
16 =head1 DESCRIPTION
17
18 dh_desktop is a debhelper program that registers .desktop files.
19 Currently this program does not handle installation of the files, though it
20 may do so at a later date. It takes care of adding maintainer script
21 fragments to call F<update-desktop-database>.
22
23 Note that since F<update-desktop-database> currently only handles mime
24 types, as an optimisation, desktop files not containing MimeType fields
25 will currently  be ignored by dh_desktop.
26
27 =cut
28
29 init();
30
31 foreach my $package (@{$dh{DOPACKAGES}}) {
32         my $tmp=tmpdir($package);
33
34         if (-d "$tmp/usr/share/applications") {
35                 # Get a list of the desktop files that are in
36                 # usr/share/applications and thus might need
37                 # update-desktop-database be called. Other desktop
38                 # files don't.
39                 my $desktop_files = `find $tmp/usr/share/applications -type f -name \\*.desktop -exec grep -q "^MimeType" '{}' \\; -printf '%p\n'`;
40                 if ($desktop_files && ! $dh{NOSCRIPTS}) {
41                         autoscript($package,"postinst","postinst-desktop");
42                         autoscript($package,"postrm","postrm-desktop");
43                 }
44         }
45 }
46
47 =head1 SEE ALSO
48
49 L<debhelper>
50
51 This program is a part of debhelper.
52
53 =head1 AUTHOR
54
55 Ross Burton <ross@burtonini.com>
56
57 =cut