File: preinst

package info (click to toggle)
apt 0.6.46.4-0.1%2Betch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 8,112 kB
  • ctags: 3,425
  • sloc: cpp: 29,961; xml: 9,133; sh: 3,027; makefile: 673; perl: 209
file content (30 lines) | stat: -rwxr-xr-x 1,119 bytes parent folder | download | duplicates (4)
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
#! /bin/sh

# dpkg does this for us while we are upgrading..
#if [ "$1" = "upgrade" -a -L /var/state/apt -a -e /var/lib/apt -a ! -L /var/state/apt ] && dpkg --compare-versions "$2" ">=" "0.4.10"; then
#  rm /var/state/apt
#fi

if [ "$1" = "upgrade" -o "$1" = "install" -a "$2" != "" ]; then
  if [ ! -e /var/lib/apt -a -e /var/state/apt ]; then
    # upgrading from /var/state/apt using apt.
    # it's probably running now so we want to ensure /var/state/apt
    # is still valid afterwards. and since we're upgrading

    if [ -x /usr/bin/perl -a -d /var/state/apt -a ! -L /var/state/apt ] &&
      perl -e 'exit 1 if ((stat("/var/lib"))[0] != (stat("/var/state/apt"))[0])'
    then
      # same fs, we can mv it
      mv /var/state/apt /var/lib/apt
      ln -s ../lib/apt /var/state/apt
      # note that this symlink (/var/state/apt) will be removed when
      # dpkg finishes unpacking the apt we're about to install; this is okay
    else
      # scary, let's just symlink it and hope
      ln -s /var/state/apt /var/lib/apt
    fi
  fi
  touch /var/lib/apt/lists/partial/.delete-me-later || true
fi

#DEBHELPER#