]> git.donarmstrong.com Git - debhelper.git/commitdiff
r2010: * dh_icons: New program to update Freedesktop icon caches. Thanks
authorjoeyh <joeyh>
Sun, 8 Jul 2007 22:16:15 +0000 (22:16 +0000)
committerjoeyh <joeyh>
Sun, 8 Jul 2007 22:16:15 +0000 (22:16 +0000)
  to Josselin Mouette, Ross Burton, Jordi Mallach, and Loïc Minier.
Closes: #329460
* Note that as a transitional measure, dh_icons will currently only update
  existing caches, and not create and new caches. Once everything is
  updating the icon caches, this will be changed. See #329460 for the full
  plan.

autoscripts/postinst-icons [new file with mode: 0644]
autoscripts/postrm-icons [new file with mode: 0644]
debian/changelog
dh_icons [new file with mode: 0755]

diff --git a/autoscripts/postinst-icons b/autoscripts/postinst-icons
new file mode 100644 (file)
index 0000000..3c018b3
--- /dev/null
@@ -0,0 +1,7 @@
+if which gtk-update-icon-cache >/dev/null 2>&1; then\r
+       for dir in #DIRLIST#; do\r
+               if [ -f "$dir"/icon-theme.cache ]; then\r
+                       gtk-update-icon-cache --force --quiet "$dir"\r
+               fi\r
+       done\r
+fi\r
diff --git a/autoscripts/postrm-icons b/autoscripts/postrm-icons
new file mode 100644 (file)
index 0000000..3765560
--- /dev/null
@@ -0,0 +1,15 @@
+if [ "$1" = "remove" ]; then\r
+       for dir in #DIRLIST#; do\r
+               if [ -d "$dir" ]; then\r
+                       if [ -f "$dir"/index.theme ] && \\r
+                          [ -f "$dir"/icon-theme.cache ] && \\r
+                          which gtk-update-icon-cache >/dev/null 2>&1\r
+                       then\r
+                               gtk-update-icon-cache --force --quiet "$dir"\r
+                       else\r
+                               rm -f "$dir"/icon-theme.cache\r
+                               rmdir -p --ignore-fail-on-non-empty "$dir"\r
+                       fi\r
+               fi\r
+       done\r
+fi\r
index 9874acd6abb970089e683fbaca6e27ae519f39c7..0462e8afbd127953f6a85a61c1833211436132dc 100644 (file)
@@ -1,10 +1,17 @@
 debhelper (5.0.51) UNRELEASED; urgency=low
 
+  * dh_icons: New program to update Freedesktop icon caches. Thanks
+    to Josselin Mouette, Ross Burton, Jordi Mallach, and Loïc Minier.
+    Closes: #329460
+  * Note that as a transitional measure, dh_icons will currently only update
+    existing caches, and not create and new caches. Once everything is
+    updating the icon caches, this will be changed. See #329460 for the full
+    plan.
   * Remove possibly confusing (though strictly accurate) sentence from
     dh_installdirs.1. Closes: #429318
   * dh_gencontrol: Fix man page typo. Closes: #431232
 
- -- Joey Hess <joeyh@debian.org>  Sat, 30 Jun 2007 17:19:00 -0400
+ -- Joey Hess <joeyh@debian.org>  Sun, 08 Jul 2007 17:54:50 -0400
 
 debhelper (5.0.50) unstable; urgency=low
 
diff --git a/dh_icons b/dh_icons
new file mode 100755 (executable)
index 0000000..aa077e4
--- /dev/null
+++ b/dh_icons
@@ -0,0 +1,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 gtk-update-icon-cache program provided by GTK+2.0.
+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<gtk-update-icon-cache>.
+
+=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 /\.jpg$/);
+                       }, "$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