summarylogtreecommitdiffstats
path: root/update-bamf-index.pl
blob: 6af14ebe2d8fb90b7736e663ea6301904d370bab (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
#!/usr/bin/perl

# This is a copy of the perl script in bamfdaemon.postinst from Ubuntu's bamf
# packaging

use File::Find;

my $dir_name;

sub strip_exec {
  my $f = $_;
  return unless $f =~ /\.desktop$/;
  return unless ("$File::Find::dir" eq "$dir_name");
  my @lines;
  open F, $f;
  @lines = <F>;
  close F;
  my $in_desktop_entry = 0;
  foreach (@lines) {
    if (/^\[\s*(.+)\s*\]/) {
      $in_desktop_entry = ($1 eq "Desktop Entry");
    }
    if (/^Exec=(.+)$/ && $in_desktop_entry) {
      print "$f\t$1\n";
    }
  }
}

$dir_name = $ARGV[-1];
$dir_name = $1 if ($dir_name =~ /(.*)\/$/);
find (\&strip_exec, $dir_name);