update 1.1 KB

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