]> git.donarmstrong.com Git - debhelper.git/blob - dh_icons
r2010: * dh_icons: New program to update Freedesktop icon caches. Thanks
[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 dh_icons is a debhelper program that updates Freedesktop icon caches
20 when needed, using the gtk-update-icon-cache program provided by GTK+2.0.
21 Currently this program does not handle installation of the files, though it
22 may do so at a later date. It takes care of adding maintainer script
23 fragments to call F<gtk-update-icon-cache>.
24
25 =head1 OPTIONS
26
27 =over 4
28
29 =item B<-n>, B<--noscripts>
30
31 Do not modify maintainer scripts.
32
33 =cut
34
35 init();
36
37 my $baseicondir="/usr/share/icons";
38
39 foreach my $package (@{$dh{DOPACKAGES}}) {
40         my $tmp=tmpdir($package);
41         my $icondir="$tmp$baseicondir";
42         if (-d $icondir) {
43                 my @dirlist;
44                 opendir(DIRHANDLE, $icondir);
45                 while (my $subdir = readdir(DIRHANDLE)) {
46                         next if $subdir =~ /^\./;
47                         my $needs_cache = 0;
48                         find sub {
49                                 $needs_cache = 1 if -f and (/\.png$/ or /\.svg$/ or /\.jpg$/);
50                         }, "$icondir/$subdir" ;
51                         push @dirlist, "$baseicondir/$subdir" if $needs_cache;
52                 }
53                 if (@dirlist and ! $dh{NOSCRIPTS}) {
54                         my $list=join(" ", @dirlist);
55                         autoscript($package,"postinst","postinst-icons","s%#DIRLIST#%$list%");
56                         autoscript($package,"postrm","postrm-icons","s%#DIRLIST#%$list%");
57                 }
58         }
59 }
60
61 =head1 SEE ALSO
62
63 L<debhelper>
64
65 This program is a part of debhelper.
66
67 =head1 AUTHOR
68
69 Ross Burton <ross@burtonini.com>
70 Jordi Mallach <jordi@debian.org>
71 Josselin Mouette <joss@debian.org>
72
73 =cut