preinst 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. #! /bin/sh
  2. set -e
  3. # dpkg does this for us while we are upgrading..
  4. #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
  5. # rm /var/state/apt
  6. #fi
  7. if [ "$1" = "upgrade" -o "$1" = "install" -a "$2" != "" ]; then
  8. if [ ! -e /var/lib/apt -a -e /var/state/apt ]; then
  9. # upgrading from /var/state/apt using apt.
  10. # it's probably running now so we want to ensure /var/state/apt
  11. # is still valid afterwards. and since we're upgrading
  12. if [ -x /usr/bin/perl -a -d /var/state/apt -a ! -L /var/state/apt ] &&
  13. perl -e 'exit 1 if ((stat("/var/lib"))[0] != (stat("/var/state/apt"))[0])'
  14. then
  15. # same fs, we can mv it
  16. mv /var/state/apt /var/lib/apt
  17. ln -s ../lib/apt /var/state/apt
  18. # note that this symlink (/var/state/apt) will be removed when
  19. # dpkg finishes unpacking the apt we're about to install; this is okay
  20. else
  21. # scary, let's just symlink it and hope
  22. ln -s /var/state/apt /var/lib/apt
  23. fi
  24. fi
  25. touch /var/lib/apt/lists/partial/.delete-me-later || true
  26. fi
  27. #DEBHELPER#