]>
git.saurik.com Git - apt.git/blob - test/test-indexes.sh
3 # Test behaviour of index retrieval and usage, in particular with uncompressed
4 # and gzip compressed indexes.
5 # Author: Martin Pitt <martin.pitt@ubuntu.com>
6 # (C) 2010 Canonical Ltd.
8 BUILDDIR
=$(readlink -f $(dirname $0)/..
/build
)
10 TEST_SOURCE
="http://ftp.debian.org/debian unstable contrib"
11 GPG_KEYSERVER
=gpg
-keyserver.de
12 # should be a small package with dependencies satisfiable in TEST_SOURCE, i. e.
13 # ideally no depends at all
14 TEST_PKG
="python-psyco-doc"
16 export LD_LIBRARY_PATH
=$BUILDDIR/bin
18 OPTS
="-qq -o Dir::Bin::Methods=$BUILDDIR/bin/methods -o Debug::NoLocking=true"
20 #DEBUG="-o Debug::pkgCacheGen=true"
21 #DEBUG="-o Debug::pkgAcquire=true"
22 APT_GET
="$BUILDDIR/bin/apt-get $OPTS $DEBUG"
23 APT_CACHE
="$BUILDDIR/bin/apt-cache $OPTS $DEBUG"
25 [ -x "$BUILDDIR/bin/apt-get" ] || {
26 echo "please build the tree first" >&2
31 echo "--- apt-get update $@ (no trusted keys)"
33 rm -f etc
/apt
/trusted.gpg etc
/apt
/secring.gpg
34 touch etc
/apt
/trusted.gpg etc
/apt
/secring.gpg
35 find var
/lib
/apt
/lists
/ -type f
| xargs -r rm
37 # first attempt should fail, no trusted GPG key
38 out
=$($APT_GET "$@" update 2>&1)
39 echo "$out" | grep -q NO_PUBKEY
40 key
=$(echo "$out" | sed -n '/NO_PUBKEY/ { s/^.*NO_PUBKEY \([[:alnum:]]\+\)$
/\
1/; p
}')
43 gpg -q --no-options --no-default-keyring --secret-keyring etc/apt/secring.gpg --trustdb-name etc/apt/trustdb.gpg --keyring etc/apt/trusted.gpg --primary-keyring etc/apt/trusted.gpg --keyserver $GPG_KEYSERVER --recv-keys $key
46 echo "--- apt-get update $@ (with trusted keys)"
47 find var/lib/apt/lists/ -type f | xargs -r rm
51 # if $1 == "compressed", check that we have compressed indexes, otherwise
54 echo "--- only ${1:-uncompressed} index files present"
56 if [ "$1" = "compressed" ]; then
57 ! test -e var/lib/apt/lists/*_Packages || F=1
58 ! test -e var/lib/apt/lists/*_Sources || F=1
59 test -e var/lib/apt/lists/*_Packages.gz || F=1
60 test -e var/lib/apt/lists/*_Sources.gz || F=1
62 test -e var/lib/apt/lists/*_Packages || F=1
63 test -e var/lib/apt/lists/*_Sources || F=1
64 ! test -e var/lib/apt/lists/*_Packages.gz || F=1
65 ! test -e var/lib/apt/lists/*_Sources.gz || F=1
69 ls -laR var/lib/apt/lists/
74 # test apt-cache commands
76 echo "--- apt-cache commands"
78 $APT_CACHE show $TEST_PKG | grep -q ^Version:
80 $APT_CACHE show $TEST_PKG | grep -q ^Version:
81 rm var/cache/apt/*.bin
82 $APT_CACHE policy $TEST_PKG | grep -q '500 http
://'
84 $APT_CACHE policy $TEST_PKG | grep -q '500 http
://'
86 TEST_SRC=`$APT_CACHE show $TEST_PKG | grep ^Source: | awk '{print
$2}'`
87 rm var/cache/apt/*.bin
88 $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary:
90 $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary:
93 # test apt-get install
95 echo "--- apt-get install"
97 $APT_GET install -d $TEST_PKG
98 test -e var/cache/apt/archives/$TEST_PKG*.deb
100 ! test -e var/cache/apt/archives/$TEST_PKG*.deb
103 # test apt-get source
105 echo "--- apt-get source"
106 $APT_GET source $TEST_PKG
107 test -f $TEST_SRC_*.dsc
112 ############################################################################
114 ############################################################################
116 echo "===== building sandbox ====="
118 trap "cd /; rm -rf $WORKDIR" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
124 mkdir -p etc/apt/preferences.d etc/apt/trusted.gpg.d etc/apt/apt.conf.d var/cache/apt/archives/partial var/lib/apt/lists/partial var/lib/dpkg
125 cp /etc/apt/trusted.gpg etc/apt
126 touch var/lib/dpkg/status
127 echo "deb $TEST_SOURCE" > etc/apt/sources.list
128 echo "deb-src $TEST_SOURCE" >> etc/apt/sources.list
130 # specifying -o RootDir at the command line does not work for
131 # etc/apt/apt.conf.d/ since it is parsed after pkgInitConfig(); $APT_CONFIG is
132 # checked first, so this works
133 echo 'RootDir
".";' > apt_config
134 export APT_CONFIG=`pwd`/apt_config
136 echo "===== uncompressed indexes ====="
143 echo "--- apt-get update with preexisting indexes"
148 echo "--- apt-get update with preexisting indexes and pdiff mode"
149 $APT_GET -o Acquire::PDiffs=true update
153 echo "===== compressed indexes (CLI option) ====="
154 check_update -o Acquire::GzipIndexes=true
155 check_indexes compressed
160 echo "--- apt-get update with preexisting indexes"
161 $APT_GET -o Acquire::GzipIndexes=true update
162 check_indexes compressed
165 echo "--- apt-get update with preexisting indexes and pdiff mode"
166 $APT_GET -o Acquire::GzipIndexes=true -o Acquire::PDiffs=true update
167 check_indexes compressed
170 echo "===== compressed indexes (apt.conf.d option) ====="
171 cat <<EOF > etc/apt/apt.conf.d/02compress-indexes
172 Acquire::GzipIndexes "true";
173 Acquire::CompressionTypes::Order:: "gz";
177 check_indexes compressed
182 echo "--- apt-get update with preexisting indexes"
184 check_indexes compressed
187 echo "--- apt-get update with preexisting indexes and pdiff mode"
188 $APT_GET -o Acquire::PDiffs=true update
189 check_indexes compressed
192 echo "===== ALL TESTS PASSED ====="