]>
Commit | Line | Data |
---|---|---|
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 | ||
8 | BUILDDIR=$(readlink -f $(dirname $0)/../build) | |
9 | ||
f4782b42 | 10 | TEST_SOURCE="http://ftp.debian.org/debian unstable contrib" |
31e1187b | 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 | |
f4782b42 | 42 | echo "deb $TEST_SOURCE" > etc/apt/sources.list |
43 | echo "deb-src $TEST_SOURCE" >> etc/apt/sources.list | |
31e1187b | 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 | |
f4782b42 | 51 | test -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 | |
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 | ||
f4782b42 | 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 | ||
31e1187b | 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 | ||
f4782b42 | 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 | ||
31e1187b | 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 | |
f4782b42 | 85 | test -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 | |
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 | |
f4782b42 | 92 | test -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 | |
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 | |
f4782b42 | 100 | ! test -e var/lib/apt/lists/*_Sources |
31e1187b | 101 | test -e var/lib/apt/lists/*_Packages.gz |
f4782b42 | 102 | test -e var/lib/apt/lists/*_Sources.gz |
31e1187b | 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 | ||
f4782b42 | 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 | ||
31e1187b | 119 | echo "---- compressed install ----" |
120 | $APT_GET install -d $TEST_PKG | |
121 | ! test -e var/cache/apt/archives/$TEST_PKG*.deb | |
122 | ||
f4782b42 | 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 | ||
31e1187b | 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 | |
f4782b42 | 132 | ! test -e var/lib/apt/lists/*_Sources |
31e1187b | 133 | test -e var/lib/apt/lists/*_Packages.gz |
f4782b42 | 134 | test -e var/lib/apt/lists/*_Sources.gz |
31e1187b | 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 | |
f4782b42 | 139 | ! test -e var/lib/apt/lists/*_Sources |
31e1187b | 140 | test -e var/lib/apt/lists/*_Packages.gz |
f4782b42 | 141 | test -e var/lib/apt/lists/*_Sources.gz |
31e1187b | 142 | |
143 | echo "---- ALL TESTS PASSED ----" |