]> git.saurik.com Git - apt.git/blob - test/test-indexes.sh
changelog: clarify abi break, it's not external
[apt.git] / test / test-indexes.sh
1 #!/bin/sh -e
2
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.
7
8 BUILDDIR=$(readlink -f $(dirname $0)/../build)
9
10 TEST_SOURCE="deb http://ftp.debian.org/debian unstable contrib"
11 TEST_SOURCE_KEYID=55BE302B
12 GPG_KEYSERVER=gpg-keyserver.de
13 # should be a small package with dependencies satisfiable in TEST_SOURCE, i. e.
14 # ideally no depends at all
15 TEST_PKG="python-psyco-doc"
16
17 export LD_LIBRARY_PATH=$BUILDDIR/bin
18
19 OPTS="-o RootDir=. -o Dir::Bin::Methods=$BUILDDIR/bin/methods -o Debug::NoLocking=true"
20 DEBUG=""
21 #DEBUG="-o Debug::pkgCacheGen=true"
22 #DEBUG="-o Debug::pkgAcquire=true"
23 APT_GET="$BUILDDIR/bin/apt-get $OPTS $DEBUG"
24 APT_CACHE="$BUILDDIR/bin/apt-cache $OPTS $DEBUG"
25
26 [ -x "$BUILDDIR/bin/apt-get" ] || {
27 echo "please build the tree first" >&2
28 exit 1
29 }
30
31 echo "---- building sandbox----"
32 WORKDIR=$(mktemp -d)
33 trap "cd /; rm -rf $WORKDIR" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
34 cd $WORKDIR
35
36 rm -fr etc var
37 rm -f home
38 ln -s /home home
39 mkdir -p etc/apt/preferences.d etc/apt/trusted.gpg.d var/cache/apt/archives/partial var/lib/apt/lists/partial var/lib/dpkg
40 cp /etc/apt/trusted.gpg etc/apt
41 touch var/lib/dpkg/status
42 echo "$TEST_SOURCE" > etc/apt/sources.list
43
44 # get keyring
45 gpg --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 $TEST_SOURCE_KEYID
46
47 echo "---- uncompressed update ----"
48 $APT_GET update
49 test -e var/lib/apt/lists/*_Packages
50 ! test -e var/lib/apt/lists/*_Packages.gz
51
52 echo "---- uncompressed cache ----"
53 $APT_CACHE show $TEST_PKG | grep -q ^Version:
54 # again (with cache)
55 $APT_CACHE show $TEST_PKG | grep -q ^Version:
56 rm var/cache/apt/*.bin
57 $APT_CACHE policy $TEST_PKG | grep -q '500 http://'
58 # again (with cache)
59 $APT_CACHE policy $TEST_PKG | grep -q '500 http://'
60
61 echo "---- uncompressed install ----"
62 $APT_GET install -d $TEST_PKG
63 test -e var/cache/apt/archives/$TEST_PKG*.deb
64 $APT_GET clean
65 ! test -e var/cache/apt/archives/$TEST_PKG*.deb
66
67 echo "----- uncompressed update with preexisting indexes, no pdiff ----"
68 $APT_GET -o Acquire::PDiffs=false update
69 test -e var/lib/apt/lists/*_Packages
70 ! test -e var/lib/apt/lists/*_Packages.gz
71
72 echo "----- uncompressed update with preexisting indexes, with pdiff ----"
73 $APT_GET -o Acquire::PDiffs=true update
74 test -e var/lib/apt/lists/*_Packages
75 ! test -e var/lib/apt/lists/*_Packages.gz
76
77 echo "----- compressed update ----"
78 find var/lib/apt/lists/ -type f | xargs -r rm
79 $APT_GET -o Acquire::GzipIndexes=true update
80 ! test -e var/lib/apt/lists/*_Packages
81 test -e var/lib/apt/lists/*_Packages.gz
82
83 echo "---- compressed cache ----"
84 $APT_CACHE show $TEST_PKG | grep -q ^Version:
85 # again (with cache)
86 $APT_CACHE show $TEST_PKG | grep -q ^Version:
87 rm var/cache/apt/*.bin
88 $APT_CACHE policy $TEST_PKG | grep -q '500 http://'
89 # again (with cache)
90 $APT_CACHE policy $TEST_PKG | grep -q '500 http://'
91
92 echo "---- compressed install ----"
93 $APT_GET install -d $TEST_PKG
94 ! test -e var/cache/apt/archives/$TEST_PKG*.deb
95
96 echo "----- compressed update with preexisting indexes, no pdiff ----"
97 $APT_GET -o Acquire::PDiffs=false -o Acquire::GzipIndexes=true update
98 ! test -e var/lib/apt/lists/*_Packages
99 test -e var/lib/apt/lists/*_Packages.gz
100
101 echo "----- compressed update with preexisting indexes, with pdiff ----"
102 $APT_GET -o Acquire::PDiffs=true -o Acquire::GzipIndexes=true update
103 ! test -e var/lib/apt/lists/*_Packages
104 test -e var/lib/apt/lists/*_Packages.gz
105
106 echo "---- ALL TESTS PASSED ----"