summaryrefslogtreecommitdiff
path: root/dselect/update
blob: a61086d79fabeb049bce0f217fbc4a35e92b01f3 (plain)
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
#!/bin/sh
set -e

# Get the configuration from /etc/apt/apt.conf
OPTS="-f"
APTGET="/usr/bin/apt-get"
APTCACHE="/usr/bin/apt-cache"
DPKG="/usr/bin/dpkg"
DPKG_OPTS="--admindir=$1"
APT_OPT0="-oDir::State::status=$1/status"
APT_OPT1="-oDPkg::Options::=$DPKG_OPTS"
CACHEDIR="/var/cache/apt"
PROMPT="false"
RES=`apt-config shell OPTS DSelect::UpdateOptions \
      DPKG Dir::Bin::dpkg/f APTGET Dir::Bin::apt-get/f \
      APTCACHE Dir::Bin::apt-cache/f CACHEDIR Dir::Cache/d \
      PROMPT DSelect::PromptAfterUpdate/b`
eval $RES

# It looks slightly ugly to have a double / in the dpkg output
CACHEDIR=`echo $CACHEDIR | sed -e "s|/$||"`

set +e
FAILED=0
$APTGET $OPTS "$APT_OPT0" "$APT_OPT1" update || FAILED=1
set -e

echo "Merging Available information"
rm -f $CACHEDIR/available
$APTCACHE dumpavail > $CACHEDIR/available
$DPKG "$DPKG_OPTS" --update-avail $CACHEDIR/available
rm -f $CACHEDIR/available

if [ x$PROMPT = "xtrue" ]; then
   echo "Press enter to continue." && read RES;
fi

exit $FAILED