summaryrefslogtreecommitdiff
path: root/dh_icons
blob: 355a85bc04dac4038f489d66915c404203ad9b2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/perl -w

=head1 NAME

dh_icons - Update Freedesktop icon caches

=cut

use strict;
use File::Find;
use Debian::Debhelper::Dh_Lib;

=head1 SYNOPSIS

B<dh_icons> [S<I<debhelper options>>] [B<-n>]

=head1 DESCRIPTION

dh_icons is a debhelper program that updates Freedesktop icon caches
when needed, using the update-icon-caches program provided by GTK+2.12.
Currently this program does not handle installation of the files, though it
may do so at a later date. It takes care of adding maintainer script
fragments to call F<update-icon-caches>.

=head1 OPTIONS

=over 4

=item B<-n>, B<--noscripts>

Do not modify maintainer scripts.

=cut

init();

my $baseicondir="/usr/share/icons";

foreach my $package (@{$dh{DOPACKAGES}}) {
	my $tmp=tmpdir($package);
	my $icondir="$tmp$baseicondir";
	if (-d $icondir) {
		my @dirlist;
		opendir(DIRHANDLE, $icondir);
		while (my $subdir = readdir(DIRHANDLE)) {
			next if $subdir =~ /^\./;
			my $needs_cache = 0;
			find sub {
				$needs_cache = 1 if -f and (/\.png$/ or /\.svg$/ or /\.xpm$/ or /\.icon$/);
			}, "$icondir/$subdir" ;
			push @dirlist, "$baseicondir/$subdir" if $needs_cache;
		}
		if (@dirlist and ! $dh{NOSCRIPTS}) {
			my $list=join(" ", @dirlist);
			autoscript($package,"postinst","postinst-icons","s%#DIRLIST#%$list%");
			autoscript($package,"postrm","postrm-icons","s%#DIRLIST#%$list%");
		}
	}
}

=head1 SEE ALSO

L<debhelper>

This program is a part of debhelper.

=head1 AUTHOR

Ross Burton <ross@burtonini.com>
Jordi Mallach <jordi@debian.org>
Josselin Mouette <joss@debian.org>

=cut