This file is indexed.

preinst is in libmtp9 1.1.10-2ubuntu1.

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
#!/bin/sh
# preinst script for libmtp

set -e

PACKAGE=libmtp9

# Prepare to move a conffile without triggering a dpkg question
prep_mv_conffile() {
    PKGNAME="$1"
    CONFFILE="$2"
    if [ -e "$CONFFILE" ]; then
        md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
        old_md5sum="`dpkg-query -W -f='${Conffiles}' $PKGNAME | sed -n -e \"\\\\' $CONFFILE '{s/ obsolete$//;s/.* //p}\"`"
        if [ "$md5sum" = "$old_md5sum" ]; then
            rm -f "$CONFFILE"
        fi
    fi
}

case "$1" in
install|upgrade)
    # PART B: Check if file /etc/udev/libmtp.rules exists
    # Do not mix with package-default rules file: /lib/udev/rules.d/libmtp8.rules
    if [ -e "/etc/udev/libmtp.rules" ]; then
        # Check if libmtp5 or early libmtp6 (<< 0.2.1-2) are installed (and not purged)
        # Default: Remove /etc/udev/libmtp.rules
        removeit="1"
        # Get libmtp* package list in the format '${Package} ${Version}'
        listpkgs="`dpkg-query -W -f '${Package} ${Version}\n' 'libmtp*' | grep '^libmtp[0-9]\+\ '`"
        # Separate by new line
        IFS=$(printf "\n")
        for ipkg in $listpkgs; do
            name="`echo $ipkg | cut -d' ' -f1`"
            version="`echo $ipkg | cut -d' ' -f2`"
            # Exception: Do not remove if libmtp5 is installed
            if [ "$name" = "libmtp5" -a ! "$version" = "" ]; then
                removeit="0"
            fi
            # Exception: Do not remove if libmtp6 (<< 0.2.1-2) is installed
            if [ "$name" = "libmtp6" -a ! "$version" = ""]; then
                if dpkg --compare-versions "$version" lt-nl "0.2.1-2"; then
                    removeit="0"
                fi
            fi
        done
        unset IFS
        # If not installed, remove the old libmtp.rules
        [ "$removeit" = "1" ] && rm -f /etc/udev/libmtp.rules
        # Its symlink, /etc/udev/rules.d/libmtp.rules, is checked in postinst
    fi

    # PART C:
    # Disabled until the package libmtp-common is made.
    # /lib/udev/rules.d/libmtp8.rules is rules file installed by default.
    # Do not mix with user-modified file: /etc/udev/rules.d/libmtp8.rules
    # Will be replaced by unversioned /lib/udev/rules.d/45-libmtp.rules
    #rm_conffile $PACKAGE /lib/udev/rules.d/45-libmtp8.rules
    
    # PART D:
    # Remove ancient /etc/udev/rules.d/65-libmtp.rules
    if [ -e /etc/udev/rules.d/65-libmtp.rules ]; then
        dpkg-maintscript-helper rm_conffile \
            /etc/udev/rules.d/65-libmtp.rules -- "$@"
    fi

esac



exit 0