Package: debhelper Version: 7.0.14 Severity: wishlist Following the discussion on debian-devel about hardcoding paths to binaries in desktop files, here is a patch to dh_desktop which will do that automatically if the file is located in the same package.
Cheers, -- .''`. : :' : We are debian.org. Lower your prices, surrender your code. `. `' We will add your hardware and software distinctiveness to `- our own. Resistance is futile.
--- /usr/bin/dh_desktop 2008-07-05 14:24:31.000000000 +0200
+++ dh_desktop 2008-07-23 12:09:54.177650163 +0200
@@ -17,12 +17,14 @@
dh_desktop is a debhelper program that registers .desktop files.
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-desktop-database>.
+may do so at a later date.
-Note that since F<update-desktop-database> currently only handles mime
-types, as an optimisation, desktop files not containing MimeType fields
-will currently be ignored by dh_desktop.
+This program takes care of adding maintainer script fragments to call
+F<update-desktop-database> when there are desktop files containing the
+MimeType field.
+
+It will also modify files to hardcode the path to the executable if it
+can be found in the same package.
=cut
@@ -30,17 +32,40 @@
foreach my $package (@{$dh{DOPACKAGES}}) {
my $tmp=tmpdir($package);
+ my $need_script=0;
- if (-d "$tmp/usr/share/applications") {
- # Get a list of the desktop files that are in
- # usr/share/applications and thus might need
- # update-desktop-database be called. Other desktop
- # files don't.
- my $desktop_files = `find $tmp/usr/share/applications -type f -name \\*.desktop -execdir grep -q "^MimeType" '{}' \\; -printf '%p\n'`;
- if ($desktop_files && ! $dh{NOSCRIPTS}) {
- autoscript($package,"postinst","postinst-desktop");
- autoscript($package,"postrm","postrm-desktop");
+ # Get a list of desktop files in /usr/share/applications
+ foreach my $desktop_file (glob("$tmp/usr/share/applications/*.desktop")) {
+ next if excludefile ($desktop_file);
+ open (ORIG, $desktop_file) || error("cannot read $desktop_file: $!\n");
+ open (NEW, "> $desktop_file.new") || error ("cannot write $desktop_file: $!\n");
+ while (<ORIG>) {
+ # Only files specifying MIME types need a call to update-desktop-database
+ if (/^MimeType\=/) {
+ $need_script=1;
+ }
+ if (/^Exec\=(\S+)(.*)$/) {
+ my $execname = $1;
+ # Look for the executable's absolute path in the same package
+ foreach my $bindir ("/usr/bin", "/usr/sbin", "/usr/games") {
+ if (-f "$tmp$bindir/$1") {
+ $execname = "$bindir/$1";
+ last;
+ }
+ }
+ print NEW "Exec=$execname$2\n";
+ } else {
+ print NEW $_;
+ }
}
+ close (ORIG);
+ close (NEW);
+ rename "$desktop_file.new", $desktop_file;
+ }
+
+ if ($need_script && ! $dh{NOSCRIPTS}) {
+ autoscript($package,"postinst","postinst-desktop");
+ autoscript($package,"postrm","postrm-desktop");
}
}
@@ -53,5 +78,6 @@
=head1 AUTHOR
Ross Burton <[EMAIL PROTECTED]>
+Josselin Mouette <[EMAIL PROTECTED]>
=cut
signature.asc
Description: Ceci est une partie de message numériquement signée

