]> git.saurik.com Git - apt.git/blame - test/test-indexes.sh
test-indexes.sh: Add source related tests, which uncovers two regressions
[apt.git] / test / test-indexes.sh
CommitLineData
31e1187b 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
8BUILDDIR=$(readlink -f $(dirname $0)/../build)
9
f4782b42 10TEST_SOURCE="http://ftp.debian.org/debian unstable contrib"
31e1187b 11TEST_SOURCE_KEYID=55BE302B
12GPG_KEYSERVER=gpg-keyserver.de
13# should be a small package with dependencies satisfiable in TEST_SOURCE, i. e.
14# ideally no depends at all
15TEST_PKG="python-psyco-doc"
16
17export LD_LIBRARY_PATH=$BUILDDIR/bin
18
19OPTS="-o RootDir=. -o Dir::Bin::Methods=$BUILDDIR/bin/methods -o Debug::NoLocking=true"
20DEBUG=""
21#DEBUG="-o Debug::pkgCacheGen=true"
22#DEBUG="-o Debug::pkgAcquire=true"
23APT_GET="$BUILDDIR/bin/apt-get $OPTS $DEBUG"
24APT_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
31echo "---- building sandbox----"
32WORKDIR=$(mktemp -d)
33trap "cd /; rm -rf $WORKDIR" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
34cd $WORKDIR
35
36rm -fr etc var
37rm -f home
38ln -s /home home
39mkdir -p etc/apt/preferences.d etc/apt/trusted.gpg.d var/cache/apt/archives/partial var/lib/apt/lists/partial var/lib/dpkg
40cp /etc/apt/trusted.gpg etc/apt
41touch var/lib/dpkg/status
f4782b42 42echo "deb $TEST_SOURCE" > etc/apt/sources.list
43echo "deb-src $TEST_SOURCE" >> etc/apt/sources.list
31e1187b 44
45# get keyring
46gpg --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
48echo "---- uncompressed update ----"
49$APT_GET update
50test -e var/lib/apt/lists/*_Packages
f4782b42 51test -e var/lib/apt/lists/*_Sources
31e1187b 52! test -e var/lib/apt/lists/*_Packages.gz
f4782b42 53! test -e var/lib/apt/lists/*_Sources.gz
31e1187b 54
55echo "---- uncompressed cache ----"
56$APT_CACHE show $TEST_PKG | grep -q ^Version:
57# again (with cache)
58$APT_CACHE show $TEST_PKG | grep -q ^Version:
59rm 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
f4782b42 64TEST_SRC=`$APT_CACHE show $TEST_PKG | grep ^Source: | awk '{print $2}'`
65rm 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
31e1187b 70echo "---- uncompressed install ----"
71$APT_GET install -d $TEST_PKG
72test -e var/cache/apt/archives/$TEST_PKG*.deb
73$APT_GET clean
74! test -e var/cache/apt/archives/$TEST_PKG*.deb
75
f4782b42 76echo "---- uncompressed get source ----"
77$APT_GET source $TEST_PKG
78test -f $TEST_SRC_*.dsc
79test -d $TEST_SRC-*
80rm -r $TEST_SRC*
81
31e1187b 82echo "----- uncompressed update with preexisting indexes, no pdiff ----"
83$APT_GET -o Acquire::PDiffs=false update
84test -e var/lib/apt/lists/*_Packages
f4782b42 85test -e var/lib/apt/lists/*_Sources
31e1187b 86! test -e var/lib/apt/lists/*_Packages.gz
f4782b42 87! test -e var/lib/apt/lists/*_Sources.gz
31e1187b 88
89echo "----- uncompressed update with preexisting indexes, with pdiff ----"
90$APT_GET -o Acquire::PDiffs=true update
91test -e var/lib/apt/lists/*_Packages
f4782b42 92test -e var/lib/apt/lists/*_Sources
31e1187b 93! test -e var/lib/apt/lists/*_Packages.gz
f4782b42 94! test -e var/lib/apt/lists/*_Sources.gz
31e1187b 95
96echo "----- compressed update ----"
97find 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
f4782b42 100! test -e var/lib/apt/lists/*_Sources
31e1187b 101test -e var/lib/apt/lists/*_Packages.gz
f4782b42 102test -e var/lib/apt/lists/*_Sources.gz
31e1187b 103
104echo "---- compressed cache ----"
105$APT_CACHE show $TEST_PKG | grep -q ^Version:
106# again (with cache)
107$APT_CACHE show $TEST_PKG | grep -q ^Version:
108rm 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
f4782b42 113TEST_SRC=`$APT_CACHE show $TEST_PKG | grep ^Source: | awk '{print $2}'`
114rm 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
31e1187b 119echo "---- compressed install ----"
120$APT_GET install -d $TEST_PKG
121! test -e var/cache/apt/archives/$TEST_PKG*.deb
122
f4782b42 123echo "---- compressed get source ----"
124$APT_GET source $TEST_PKG
125test -f $TEST_SRC_*.dsc
126test -d $TEST_SRC-*
127rm -r $TEST_SRC*
128
31e1187b 129echo "----- 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
f4782b42 132! test -e var/lib/apt/lists/*_Sources
31e1187b 133test -e var/lib/apt/lists/*_Packages.gz
f4782b42 134test -e var/lib/apt/lists/*_Sources.gz
31e1187b 135
136echo "----- 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
f4782b42 139! test -e var/lib/apt/lists/*_Sources
31e1187b 140test -e var/lib/apt/lists/*_Packages.gz
f4782b42 141test -e var/lib/apt/lists/*_Sources.gz
31e1187b 142
143echo "---- ALL TESTS PASSED ----"