]> git.donarmstrong.com Git - debhelper.git/blob - dh_icons
python distutils buildsystem: When checking if a version of python is installed,...
[debhelper.git] / dh_icons
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_icons - Update Freedesktop icon caches
6
7 =cut
8
9 use strict;
10 use File::Find;
11 use Debian::Debhelper::Dh_Lib;
12
13 =head1 SYNOPSIS
14
15 B<dh_icons> [S<I<debhelper options>>] [B<-n>]
16
17 =head1 DESCRIPTION
18
19 B<dh_icons> is a debhelper program that updates Freedesktop icon caches
20 when needed, using the B<update-icon-caches> program provided by GTK+2.12.
21 Currently this program does not handle installation of the files, though it
22 may do so at a later date, so should be run after icons are installed in
23 the package build directories. 
24
25 It takes care of adding maintainer script fragments to call
26 B<update-icon-caches> for icon directories. (This is not done for gnome and
27 hicolor icons, as those are handled by triggers.)
28 These commands are inserted into the maintainer scripts by L<dh_installdeb(1)>.
29
30 =head1 OPTIONS
31
32 =over 4
33
34 =item B<-n>, B<--noscripts>
35
36 Do not modify maintainer scripts.
37
38 =back
39
40 =cut
41
42 init();
43
44 my $baseicondir="/usr/share/icons";
45
46 foreach my $package (@{$dh{DOPACKAGES}}) {
47         my $tmp=tmpdir($package);
48         my $icondir="$tmp$baseicondir";
49         if (-d $icondir) {
50                 my @dirlist;
51                 opendir(DIRHANDLE, $icondir);
52                 while (my $subdir = readdir(DIRHANDLE)) {
53                         next if $subdir =~ /^\./;
54                         next if $subdir eq "gnome";
55                         next if $subdir eq "hicolor";
56                         my $needs_cache = 0;
57                         find sub {
58                                 $needs_cache = 1 if -f and (/\.png$/ or /\.svg$/ or /\.xpm$/ or /\.icon$/);
59                         }, "$icondir/$subdir" ;
60                         push @dirlist, "$baseicondir/$subdir" if $needs_cache;
61                 }
62                 if (@dirlist and ! $dh{NOSCRIPTS}) {
63                         my $list=join(" ", @dirlist);
64                         autoscript($package,"postinst","postinst-icons","s%#DIRLIST#%$list%");
65                         autoscript($package,"postrm","postrm-icons","s%#DIRLIST#%$list%");
66                 }
67         }
68 }
69
70 =head1 SEE ALSO
71
72 L<debhelper>
73
74 This program is a part of debhelper.
75
76 =head1 AUTHOR
77
78 Ross Burton <ross@burtonini.com>
79 Jordi Mallach <jordi@debian.org>
80 Josselin Mouette <joss@debian.org>
81
82 =cut