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
="-o RootDir=. -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
30 echo "---- building sandbox----"
32 trap "cd /; rm -rf $WORKDIR" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
38 mkdir -p etc
/apt
/preferences.d etc
/apt
/trusted.gpg.d var
/cache
/apt
/archives
/partial var
/lib
/apt
/lists
/partial var
/lib
/dpkg
39 cp /etc
/apt
/trusted.gpg etc
/apt
40 touch var
/lib
/dpkg
/status
41 echo "deb $TEST_SOURCE" > etc
/apt
/sources.list
42 echo "deb-src $TEST_SOURCE" >> etc
/apt
/sources.list
44 echo "---- uncompressed update ----"
45 # first attempt should fail, no trusted GPG key
46 out
=$($APT_GET update 2>&1)
47 echo "$out" | grep -q NO_PUBKEY
48 key
=$(echo "$out" | sed -n '/NO_PUBKEY/ { s/^.*NO_PUBKEY \([[:alnum:]]\+\)$
/\
1/; p
}')
50 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 $key
53 test -e var/lib/apt/lists/*_Packages
54 test -e var/lib/apt/lists/*_Sources
55 ! test -e var/lib/apt/lists/*_Packages.gz
56 ! test -e var/lib/apt/lists/*_Sources.gz
58 echo "---- uncompressed cache ----"
59 $APT_CACHE show $TEST_PKG | grep -q ^Version:
61 $APT_CACHE show $TEST_PKG | grep -q ^Version:
62 rm var/cache/apt/*.bin
63 $APT_CACHE policy $TEST_PKG | grep -q '500 http
://'
65 $APT_CACHE policy $TEST_PKG | grep -q '500 http
://'
67 TEST_SRC=`$APT_CACHE show $TEST_PKG | grep ^Source: | awk '{print
$2}'`
68 rm var/cache/apt/*.bin
69 $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary:
71 $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary:
73 echo "---- uncompressed install ----"
74 $APT_GET install -d $TEST_PKG
75 test -e var/cache/apt/archives/$TEST_PKG*.deb
77 ! test -e var/cache/apt/archives/$TEST_PKG*.deb
79 echo "---- uncompressed get source ----"
80 $APT_GET source $TEST_PKG
81 test -f $TEST_SRC_*.dsc
85 echo "----- uncompressed update with preexisting indexes, no pdiff ----"
86 $APT_GET -o Acquire::PDiffs=false update
87 test -e var/lib/apt/lists/*_Packages
88 test -e var/lib/apt/lists/*_Sources
89 ! test -e var/lib/apt/lists/*_Packages.gz
90 ! test -e var/lib/apt/lists/*_Sources.gz
92 echo "----- uncompressed update with preexisting indexes, with pdiff ----"
93 $APT_GET -o Acquire::PDiffs=true update
94 test -e var/lib/apt/lists/*_Packages
95 test -e var/lib/apt/lists/*_Sources
96 ! test -e var/lib/apt/lists/*_Packages.gz
97 ! test -e var/lib/apt/lists/*_Sources.gz
99 echo "----- compressed update ----"
100 find var/lib/apt/lists/ -type f | xargs -r rm
101 $APT_GET -o Acquire::GzipIndexes=true update
102 ! test -e var/lib/apt/lists/*_Packages
103 ! test -e var/lib/apt/lists/*_Sources
104 test -e var/lib/apt/lists/*_Packages.gz
105 test -e var/lib/apt/lists/*_Sources.gz
107 echo "---- compressed cache ----"
108 $APT_CACHE show $TEST_PKG | grep -q ^Version:
110 $APT_CACHE show $TEST_PKG | grep -q ^Version:
111 rm var/cache/apt/*.bin
112 $APT_CACHE policy $TEST_PKG | grep -q '500 http
://'
114 $APT_CACHE policy $TEST_PKG | grep -q '500 http
://'
116 TEST_SRC=`$APT_CACHE show $TEST_PKG | grep ^Source: | awk '{print
$2}'`
117 rm var/cache/apt/*.bin
118 $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary:
120 $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary:
122 echo "---- compressed install ----"
123 $APT_GET install -d $TEST_PKG
124 ! test -e var/cache/apt/archives/$TEST_PKG*.deb
126 echo "---- compressed get source ----"
127 $APT_GET source $TEST_PKG
128 test -f $TEST_SRC_*.dsc
132 echo "----- compressed update with preexisting indexes, no pdiff ----"
133 $APT_GET -o Acquire::PDiffs=false -o Acquire::GzipIndexes=true update
134 ! test -e var/lib/apt/lists/*_Packages
135 ! test -e var/lib/apt/lists/*_Sources
136 test -e var/lib/apt/lists/*_Packages.gz
137 test -e var/lib/apt/lists/*_Sources.gz
139 echo "----- compressed update with preexisting indexes, with pdiff ----"
140 $APT_GET -o Acquire::PDiffs=true -o Acquire::GzipIndexes=true update
141 ! test -e var/lib/apt/lists/*_Packages
142 ! test -e var/lib/apt/lists/*_Sources
143 test -e var/lib/apt/lists/*_Packages.gz
144 test -e var/lib/apt/lists/*_Sources.gz
146 echo "---- ALL TESTS PASSED ----"