#!/usr/bin/perl -w

=head1 NAME

dh_iconcache - Updates the Icon Cache for icons in /usr/share/icons

=cut

use strict;
use Debian::Debhelper::Dh_Lib;

=head1 SYNOPSIS

B<dh_iconcache> [S<I<debhelper options>>] [B<-p<package>>]

=head1 DESCRIPTION

dh_iconcache is a debhelper program that updates the GTK icon cache.
This is necessary, if packages install icons into /usr/share/icons/B<package>.
Currently this program does not handle installation of icons, though 
may do so at a later date. It takes care of adding maintainer script
fragments to call F<gtk-update-icon-cache>.

=cut

init();

foreach my $package (@{$dh{DOPACKAGES}}) {
	my $tmp=tmpdir($package);

	if (-d "$tmp/usr/share/icons/") {
		my @icon_dirs = `find $tmp/usr/share/icons -mindepth 1 -maxdepth 1 -type d -printf '/usr/share/icons/%P\n'`;
		if (@icon_dirs && ! $dh{NOSCRIPTS}) {
			foreach my $dir (@icon_dirs) {
				chomp($dir);
				if ($dir ne '') {
					autoscript($package,"postinst","postinst-iconcache","s:#ICONDIR#:$dir:g");
					autoscript($package,"postrm","postrm-iconcache","s:#ICONDIR#:$dir:g");
				}
			}
			# not used, because KDE people might not be happy with it
			# addsubstvar($package, "misc:Depends", "libgtk2.0-bin");
		}
	}
}

=head1 SEE ALSO

L<debhelper>

This program is a part of debhelper.

=head1 AUTHOR

Daniel Holbach <daniel.holbach@ubuntu.com>

=cut
