This file is indexed.

postinst is in bamfdaemon 0.5.3+18.04.20180207.2-0ubuntu1.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

 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
#! /bin/sh
set -e

BAMF_INDEX_NAME="bamf-2.index"

if [ "$1" = "configure" ] || [ "$1" = "triggered" ]; then
    if [ -d /usr/share/applications ]; then
        # 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