update 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. set -e
  3. # Set the textdomain for the translations using $"..."
  4. TEXTDOMAIN="apt"
  5. # Get the configuration from /etc/apt/apt.conf
  6. CLEAN="prompt"
  7. OPTS=""
  8. APTGET="/usr/bin/apt-get"
  9. APTCACHE="/usr/bin/apt-cache"
  10. DPKG="/usr/bin/dpkg"
  11. DPKG_OPTS="--admindir=$1"
  12. APT_OPT0="-oDir::State::status=$1/status"
  13. APT_OPT1="-oDPkg::Options::=$DPKG_OPTS"
  14. CACHEDIR="/var/cache/apt"
  15. PROMPT="false"
  16. RES=`apt-config shell CLEAN DSelect::Clean OPTS DSelect::UpdateOptions \
  17. DPKG Dir::Bin::dpkg/f APTGET Dir::Bin::apt-get/f \
  18. APTCACHE Dir::Bin::apt-cache/f CACHEDIR Dir::Cache/d \
  19. PROMPT DSelect::PromptAfterUpdate/b`
  20. eval $RES
  21. # It looks slightly ugly to have a double / in the dpkg output
  22. CACHEDIR=`echo $CACHEDIR | sed -e "s|/$||"`
  23. STATUS=1
  24. if $APTGET $OPTS "$APT_OPT0" "$APT_OPT1" update
  25. then
  26. echo $"Merging available information"
  27. rm -f $CACHEDIR/available
  28. $APTCACHE dumpavail > $CACHEDIR/available
  29. $DPKG "$DPKG_OPTS" --update-avail $CACHEDIR/available
  30. rm -f $CACHEDIR/available
  31. case "$CLEAN" in
  32. Pre-Auto|PreAuto|pre-auto)
  33. $APTGET "$APT_OPT0" "$APT_OPT1" autoclean;;
  34. esac
  35. STATUS=0
  36. fi
  37. if [ x$PROMPT = "xtrue" ]; then
  38. echo $"Press [Enter] to continue." && read RES;
  39. fi
  40. exit $STATUS