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 | 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" |
15 | |
16 | export LD_LIBRARY_PATH=$BUILDDIR/bin |
17 | |
18 | OPTS="-o RootDir=. -o Dir::Bin::Methods=$BUILDDIR/bin/methods -o Debug::NoLocking=true" |
19 | DEBUG="" |
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" |
24 | |
25 | [ -x "$BUILDDIR/bin/apt-get" ] || { |
26 | echo "please build the tree first" >&2 |
27 | exit 1 |
28 | } |
29 | |
30 | echo "---- building sandbox----" |
31 | WORKDIR=$(mktemp -d) |
32 | trap "cd /; rm -rf $WORKDIR" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM |
33 | cd $WORKDIR |
34 | |
35 | rm -fr etc var |
36 | rm -f home |
37 | ln -s /home home |
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 |
f4782b42 |
41 | echo "deb $TEST_SOURCE" > etc/apt/sources.list |
42 | echo "deb-src $TEST_SOURCE" >> etc/apt/sources.list |
31e1187b |
43 | |
31e1187b |
44 | echo "---- uncompressed update ----" |
8d48388e |
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}') |
49 | # get keyring |
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 |
31e1187b |
51 | $APT_GET update |
8d48388e |
52 | |
31e1187b |
53 | test -e var/lib/apt/lists/*_Packages |
f4782b42 |
54 | test -e var/lib/apt/lists/*_Sources |
31e1187b |
55 | ! test -e var/lib/apt/lists/*_Packages.gz |
f4782b42 |
56 | ! test -e var/lib/apt/lists/*_Sources.gz |
31e1187b |
57 | |
58 | echo "---- uncompressed cache ----" |
59 | $APT_CACHE show $TEST_PKG | grep -q ^Version: |
60 | # again (with cache) |
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://' |
64 | # again (with cache) |
65 | $APT_CACHE policy $TEST_PKG | grep -q '500 http://' |
66 | |
f4782b42 |
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: |
70 | # again (with cache) |
71 | $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary: |
72 | |
31e1187b |
73 | echo "---- uncompressed install ----" |
74 | $APT_GET install -d $TEST_PKG |
75 | test -e var/cache/apt/archives/$TEST_PKG*.deb |
76 | $APT_GET clean |
77 | ! test -e var/cache/apt/archives/$TEST_PKG*.deb |
78 | |
f4782b42 |
79 | echo "---- uncompressed get source ----" |
80 | $APT_GET source $TEST_PKG |
81 | test -f $TEST_SRC_*.dsc |
82 | test -d $TEST_SRC-* |
83 | rm -r $TEST_SRC* |
84 | |
31e1187b |
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 |
f4782b42 |
88 | test -e var/lib/apt/lists/*_Sources |
31e1187b |
89 | ! test -e var/lib/apt/lists/*_Packages.gz |
f4782b42 |
90 | ! test -e var/lib/apt/lists/*_Sources.gz |
31e1187b |
91 | |
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 |
f4782b42 |
95 | test -e var/lib/apt/lists/*_Sources |
31e1187b |
96 | ! test -e var/lib/apt/lists/*_Packages.gz |
f4782b42 |
97 | ! test -e var/lib/apt/lists/*_Sources.gz |
31e1187b |
98 | |
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 |
f4782b42 |
103 | ! test -e var/lib/apt/lists/*_Sources |
31e1187b |
104 | test -e var/lib/apt/lists/*_Packages.gz |
f4782b42 |
105 | test -e var/lib/apt/lists/*_Sources.gz |
31e1187b |
106 | |
107 | echo "---- compressed cache ----" |
108 | $APT_CACHE show $TEST_PKG | grep -q ^Version: |
109 | # again (with cache) |
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://' |
113 | # again (with cache) |
114 | $APT_CACHE policy $TEST_PKG | grep -q '500 http://' |
115 | |
f4782b42 |
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: |
119 | # again (with cache) |
120 | $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary: |
121 | |
31e1187b |
122 | echo "---- compressed install ----" |
123 | $APT_GET install -d $TEST_PKG |
124 | ! test -e var/cache/apt/archives/$TEST_PKG*.deb |
125 | |
f4782b42 |
126 | echo "---- compressed get source ----" |
127 | $APT_GET source $TEST_PKG |
128 | test -f $TEST_SRC_*.dsc |
129 | test -d $TEST_SRC-* |
130 | rm -r $TEST_SRC* |
131 | |
31e1187b |
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 |
f4782b42 |
135 | ! test -e var/lib/apt/lists/*_Sources |
31e1187b |
136 | test -e var/lib/apt/lists/*_Packages.gz |
f4782b42 |
137 | test -e var/lib/apt/lists/*_Sources.gz |
31e1187b |
138 | |
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 |
f4782b42 |
142 | ! test -e var/lib/apt/lists/*_Sources |
31e1187b |
143 | test -e var/lib/apt/lists/*_Packages.gz |
f4782b42 |
144 | test -e var/lib/apt/lists/*_Sources.gz |
31e1187b |
145 | |
146 | echo "---- ALL TESTS PASSED ----" |