File: bamfdaemon.postinst

package info (click to toggle)
bamf 0.5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,732 kB
  • sloc: ansic: 14,574; sh: 4,238; makefile: 423; xml: 249; python: 46
file content (91 lines) | stat: -rw-r--r-- 2,326 bytes parent folder | download | duplicates (5)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#! /bin/sh
set -e

BAMF_INDEX_NAME="bamf-2.index"

if [ "$1" = "configure" ] || [ "$1" = "triggered" ]; then
	if [ -d /usr/share/applications ]; then
		# remove deprecated index files
		if [ -f /usr/share/applications/bamf.index ]; then
			rm -f /usr/share/applications/bamf.index
		fi
		# rebuild index
		I=/usr/share/applications/$BAMF_INDEX_NAME
		echo "Rebuilding $I..."
		rm -f $I
		perl -e '
		    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;
		        my $exec = "";
		        my $class = "";
		        my $no_display = "false";
		        my $only_show_in = "";

		        foreach (@lines)
		        {
		            if (/^\[\s*(.+)\s*\]/)
		            {
		                $was_in_desktop = $in_desktop_entry;
		                $in_desktop_entry = ($1 eq "Desktop Entry");

		                if ($was_in_desktop and !$in_desktop_entry)
		                {
		                    last;
		                }
		            }

		            if ($in_desktop_entry)
		            {
		                if (/^Exec=(.+)$/)
		                {
		                    $exec = $1;
		                    $exec =~ s/^\s+|\s+$//g;
		                }

		                if (/^NoDisplay=(.+)$/)
		                {
		                    $no_display = $1;
		                    $no_display =~ s/^\s+|\s+$//g;
		                }

		                if (/^OnlyShowIn=(.+)$/)
		                {
		                    $only_show_in = $1;
		                    $only_show_in =~ s/^\s+|\s+$//g;
		                }

		                if (/^StartupWMClass=(.+)$/)
		                {
		                    $class = $1;
		                    $class =~ s/^\s+|\s+$//g;
		                }
		            }
		        }

		        if ($exec ne "")
		        {
		            print "$f\t$exec\t$class\t$only_show_in\t$no_display\n";
		        }
		    };

		    $dir_name = $ARGV[-1];
		    $dir_name = $1 if($dir_name=~/(.*)\/$/);
		    find(\&strip_exec, $dir_name);' /usr/share/applications \
		> $I.new || rm -f $I.new

		[ -e $I.new ] && mv $I.new $I || true
	fi
fi

#DEBHELPER#