]> git.saurik.com Git - apt.git/blob - test/test-indexes.sh
test-indexes.sh: Add source related tests, which uncovers two regressions
[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="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 "deb $TEST_SOURCE" > etc/apt/sources.list
43 echo "deb-src $TEST_SOURCE" >> etc/apt/sources.list
44
45 # get keyring
46 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
47
48 echo "---- uncompressed update ----"
49 $APT_GET update
50 test -e var/lib/apt/lists/*_Packages
51 test -e var/lib/apt/lists/*_Sources
52 ! test -e var/lib/apt/lists/*_Packages.gz
53 ! test -e var/lib/apt/lists/*_Sources.gz
54
55 echo "---- uncompressed cache ----"
56 $APT_CACHE show $TEST_PKG | grep -q ^Version:
57 # again (with cache)
58 $APT_CACHE show $TEST_PKG | grep -q ^Version:
59 rm var/cache/apt/*.bin
60 $APT_CACHE policy $TEST_PKG | grep -q '500 http://'
61 # again (with cache)
62 $APT_CACHE policy $TEST_PKG | grep -q '500 http://'
63
64 TEST_SRC=`$APT_CACHE show $TEST_PKG | grep ^Source: | awk '{print $2}'`
65 rm var/cache/apt/*.bin
66 $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary:
67 # again (with cache)
68 $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary:
69
70 echo "---- uncompressed install ----"
71 $APT_GET install -d $TEST_PKG
72 test -e var/cache/apt/archives/$TEST_PKG*.deb
73 $APT_GET clean
74 ! test -e var/cache/apt/archives/$TEST_PKG*.deb
75
76 echo "---- uncompressed get source ----"
77 $APT_GET source $TEST_PKG
78 test -f $TEST_SRC_*.dsc
79 test -d $TEST_SRC-*
80 rm -r $TEST_SRC*
81
82 echo "----- uncompressed update with preexisting indexes, no pdiff ----"
83 $APT_GET -o Acquire::PDiffs=false update
84 test -e var/lib/apt/lists/*_Packages
85 test -e var/lib/apt/lists/*_Sources
86 ! test -e var/lib/apt/lists/*_Packages.gz
87 ! test -e var/lib/apt/lists/*_Sources.gz
88
89 echo "----- uncompressed update with preexisting indexes, with pdiff ----"
90 $APT_GET -o Acquire::PDiffs=true update
91 test -e var/lib/apt/lists/*_Packages
92 test -e var/lib/apt/lists/*_Sources
93 ! test -e var/lib/apt/lists/*_Packages.gz
94 ! test -e var/lib/apt/lists/*_Sources.gz
95
96 echo "----- compressed update ----"
97 find var/lib/apt/lists/ -type f | xargs -r rm
98 $APT_GET -o Acquire::GzipIndexes=true update
99 ! test -e var/lib/apt/lists/*_Packages
100 ! test -e var/lib/apt/lists/*_Sources
101 test -e var/lib/apt/lists/*_Packages.gz
102 test -e var/lib/apt/lists/*_Sources.gz
103
104 echo "---- compressed cache ----"
105 $APT_CACHE show $TEST_PKG | grep -q ^Version:
106 # again (with cache)
107 $APT_CACHE show $TEST_PKG | grep -q ^Version:
108 rm var/cache/apt/*.bin
109 $APT_CACHE policy $TEST_PKG | grep -q '500 http://'
110 # again (with cache)
111 $APT_CACHE policy $TEST_PKG | grep -q '500 http://'
112
113 TEST_SRC=`$APT_CACHE show $TEST_PKG | grep ^Source: | awk '{print $2}'`
114 rm var/cache/apt/*.bin
115 $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary:
116 # again (with cache)
117 $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary:
118
119 echo "---- compressed install ----"
120 $APT_GET install -d $TEST_PKG
121 ! test -e var/cache/apt/archives/$TEST_PKG*.deb
122
123 echo "---- compressed get source ----"
124 $APT_GET source $TEST_PKG
125 test -f $TEST_SRC_*.dsc
126 test -d $TEST_SRC-*
127 rm -r $TEST_SRC*
128
129 echo "----- compressed update with preexisting indexes, no pdiff ----"
130 $APT_GET -o Acquire::PDiffs=false -o Acquire::GzipIndexes=true update
131 ! test -e var/lib/apt/lists/*_Packages
132 ! test -e var/lib/apt/lists/*_Sources
133 test -e var/lib/apt/lists/*_Packages.gz
134 test -e var/lib/apt/lists/*_Sources.gz
135
136 echo "----- compressed update with preexisting indexes, with pdiff ----"
137 $APT_GET -o Acquire::PDiffs=true -o Acquire::GzipIndexes=true update
138 ! test -e var/lib/apt/lists/*_Packages
139 ! test -e var/lib/apt/lists/*_Sources
140 test -e var/lib/apt/lists/*_Packages.gz
141 test -e var/lib/apt/lists/*_Sources.gz
142
143 echo "---- ALL TESTS PASSED ----"