This file is indexed.

prerm is in dpkg 1.16.1.2ubuntu7.7.

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
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/bin/sh -e
# This script can be called in the following ways:
#
# Before the package is removed:
#      <prerm> remove
#
# Before an upgrade:
#      <old-prerm> upgrade <new-version>
# if that fails:
#      <new-prerm> failed-upgrade <old-version>
#
#
# Before package is deconfigured while dependency is replaced due to conflict:
#      <prerm> deconfigure in-favour <new-package> <version>
#              removing <old-package> <version>
#
# Before the package is replaced due to conflict:
#      <prerm> remove in-favour <new-package> <version>

downgrade_multiarch_infodb()
{
    admindir=${DPKG_ADMINDIR:-/var/lib/dpkg}
    pkgadmindir=$admindir/info

    coinst_pkgs="`ls "$pkgadmindir" | \
        sed -n -e 's/^\([^:]\+:[^.]\+\)\..*$/\1/p' | sort -u | \
        cut -d: -f1 | uniq -d`"

    # Abort if we cannot possibly downgrade
    if [ -n "$coinst_pkgs" ]; then
        cat <<- MSG
	dpkg: error: You have more than one architecture instance for some
	installed 'Multi-Arch: same' packages, to be able to downgrade dpkg
	you will need to have only one instance installed per package.

	List of co-installed packages:

	$coinst_pkgs
	MSG
        exit 1
    fi

    bad_dep_pkgs=$(dpkg-query -f'${Package} ${Depends} ${Recommends} ${Suggests} ${Enhances} ${Conflicts} ${Replaces} ${Breaks}\n' -W | \
	grep ":any" | cut -d" " -f1 | sort -u)
    if [ -n "$bad_dep_pkgs" ]; then
        cat <<- MSG
	dpkg: error: Some installed packages have multiarch dependencies
	that the old dpkg won't parse. You should get rid of them
	(or downgrade them to versions without those dependencies) before
	proceeding with dpkg's downgrade.

	List of affected packages:

	$bad_dep_pkgs
	MSG
	exit 1
    fi

    for dep in Depends Recommends Suggests Enhances \
	       Conflicts Replaces Breaks; do
	if grep -qE "^$dep:.*:any" $admindir/available; then
		cat <<- MSG
		dpkg: error: $admindir/available references packages with
		multiarch dependencies that the old dpkg won't parse. You
		should clear this file with "dpkg --clear-avail" before
		proceeding with dpkg's downgrade.
		MSG
		exit 1
	fi
    done

    echo "Downgrading the multiarch dpkg control files database ..."
    ls $pkgadmindir | grep : | while read oldfile; do
        # We first do a round of hardlinks to the new names, so that the db
        # will never be unusable for either of the dpkg versions.
        newfile=$(echo $oldfile | sed -e 's/:[^.]\+//')
        ln "$pkgadmindir/$oldfile" "$pkgadmindir/$newfile"
    done
    echo -n "1" >$admindir/format
}

ensure_no_triggers_noawait()
{
    admindir=${DPKG_ADMINDIR:-/var/lib/dpkg}
    pkgadmindir=$admindir/info

    trig_noawait=$(find "$pkgadmindir" -name "*.triggers" -type f | \
                   xargs -r grep -El "^(interest|activate)-(no)?await" | \
		   sed -e 's,^.*/\([^/.:]\+\)[^/]\+$,\1,')

    # Abort if we cannot possibly downgrade
    if [ -n "$trig_noawait" ]; then
        cat <<- MSG
	dpkg: error: You have packages using the "interest-noawait" and/or
	"activate-noawait" trigger directives but the dpkg version that
	you're trying to downgrade to doesn't support them. Aborting
	downgrade.

	List of affected packages:

	$trig_noawait
	MSG
        exit 1
    fi

    bad_triggers_files=$(find "$admindir/triggers" -type f | \
                         xargs -r grep -l "/noawait$" || true)
    if [ -n "$bad_triggers_files" ]; then
        cat <<- MSG
	dpkg: error: Some internal trigger files unexpectedly reference
	packages tagged with "/noawait" while their corresponding
	infodb files doesn't seem to contain any "interest-noawait"
	directive. Aborting the downgrade as those tags are not supported
	by the version you're trying to downgrade to.

	List of internal trigger files that are affected:

	$bad_triggers_files
	MSG
	exit 1
    fi
}

case "$1" in
    upgrade)
        # Downgrade the multiarch db to a “monoarch” db layout
        if dpkg --compare-versions "$2" lt 1.16.0~ubuntu4; then
	    if dpkg --compare-versions "$2" ge 1.16.0~ubuntu1; then
		# this version had provisional multiarch support with
		# a different layout.
		infodir="/var/lib/dpkg/info/$(dpkg --print-architecture)"
		# since this version of dpkg may have been configured using
		# the old version, the directory might have been recreated
		# under us - so handle this case by removing and converting
		# to a symlink.
		if [ -d "$infodir" ] && ! [ -L "$infodir" ]; then
		    # if this fails, it's because it has contents, so
		    # downgrading will corrupt the dpkg database.  let it fail
		    # before things get out of hand!
		    rmdir "$infodir"
		fi
		if [ ! -d "$infodir" ]; then
		    ln -sf . "$infodir"
		fi
	    fi
            downgrade_multiarch_infodb
        fi

        # Allow the downgrade only if no package is using the
	# (interest|activate)-noawait trigger directives
        if dpkg --compare-versions "$2" lt 1.16.1~; then
            ensure_no_triggers_noawait
        fi
        ;;

    remove|failed-upgrade|deconfigure)
        ;;

    *)
        echo "$0 called with unknown argument \`$1'" 1>&2
        exit 1
        ;;
esac


exit 0