On Sat, Mar 03, 2012 at 11:00:12PM +0100, Michael Biebl wrote: > I only quickly glanced at the patch and my perl is pretty rusty, so > beware, but from what I see, you don't handle .desktop files from > subdirectories. The most prominent one is /usr/share/applications/kde4. > Dunno, if there are other DEs/apps using a subdirectory.
I've fixed this and have attached a patch that recurses into subdirectories. I've confirmed that both evince and amarok are now listed in /etc/mailcap with my patch. -- brian m. carlson / brian with sandals: Houston, Texas, US +1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
diff -ur mime-support.old/debian/debhelper.log mime-support-3.52/debian/debhelper.log --- mime-support.old/debian/debhelper.log 2012-03-01 00:49:14.802827192 +0000 +++ mime-support-3.52/debian/debhelper.log 2012-03-02 00:15:34.186074158 +0000 @@ -10,3 +10,4 @@ dh_md5sums dh_md5sums dh_md5sums +dh_md5sums diff -ur mime-support.old/update-mime mime-support-3.52/update-mime --- mime-support.old/update-mime 2012-03-01 00:49:14.802827192 +0000 +++ mime-support-3.52/update-mime 2012-03-05 00:55:45.312001931 +0000 @@ -24,6 +24,7 @@ $mailcap = "/etc/mailcap"; $mailcapdef = "/usr/lib/mime/mailcap"; $mimedir = "/usr/lib/mime/packages"; +$appsdir = "/usr/share/applications"; $orderfile = "/etc/mailcap.order"; $defpriority = 5; $localgen = 0; @@ -63,14 +64,12 @@ %packages; %priorities; @order; - +$counter=1; sub ReadEntries { - my($pkg,$priority,$counter); - - $counter=1; + my($pkg,$priority); # foreach $file (glob "$mimedir/*") { foreach $file (map { glob $_.'/*' } split ':',$mimedir) { @@ -110,6 +109,67 @@ } } +sub RecurseIntoDirectories +{ + my @files; + foreach my $dir (@_) { + next if ($dir =~ m!(^|/)(\.|\#)|(\~)$!); + my @entries = glob "$dir/*"; + push @files, RecurseIntoDirectories(grep { -d $_ } @entries); + push @files, grep { -f $_ } @entries; + } + return @files; +} + +sub ReadDesktopEntries +{ + my($pkg,$priority); + + foreach $file (RecurseIntoDirectories(split ':',$appsdir)) { + next if ($file =~ m!(^|/)(\.|\#)|(\~)$!); + next unless ($file =~ m/\.desktop$/); + ($pkg) = ($file =~ m|/([^/]*)\.desktop$|); + print STDERR "$pkg:\n" if $debug; + + next if (defined $packages{$pkg}); + $packages{$pkg} = []; + + if (open(FILE,"<$file")) { + my($terminal, $exec, @types) = ("test=test -n \"\$DISPLAY\""); + while (<FILE>) { + chomp; + next if (m/^\s*$|^\s*\#/); + if (m/^Terminal=(\w+)/i) { + $terminal = "needsterminal" if ($1 eq "true"); + } + elsif (m/Exec=(.*)$/i) { + $exec = $1; + $exec =~ s/%[fFuU]/%s/g; + $exec .= " %s" if ($exec !~ m/%s/); + } + elsif (m/MimeType=(.*)/i) { + push @types, split(/;/, $1); + } + } + if (!defined($exec) || !scalar(@types)) { + close(FILE); + next; + } + foreach $type (@types) { + my $entry = "$type; $exec; $terminal"; + $priority=$defpriority; + $entries{$counter} = $entry; + push @{$packages{$pkg}},$counter; + push @{$priorities{$priority}},$counter; + print STDERR "$counter: $entry\n" if $debug; + $counter++; + } + close(FILE); + } else { + print STDERR "Warning: could not open file '$file' -- $!\n"; + } + } +} sub ReadOrder @@ -270,6 +330,7 @@ ReadEntries(); +ReadDesktopEntries(); ReadOrder(); @list = OrderEntries(); UpdateMailcap(@list);
signature.asc
Description: Digital signature