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 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"
17 export LD_LIBRARY_PATH
=$BUILDDIR/bin
19 OPTS
="-o RootDir=. -o Dir::Bin::Methods=$BUILDDIR/bin/methods -o Debug::NoLocking=true"
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"
26 [ -x "$BUILDDIR/bin/apt-get" ] || {
27 echo "please build the tree first" >&2
31 echo "---- building sandbox----"
33 trap "cd /; rm -rf $WORKDIR" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
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
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
48 echo "---- uncompressed 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
55 echo "---- uncompressed cache ----"
56 $APT_CACHE show
$TEST_PKG | grep -q ^Version
:
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://'
62 $APT_CACHE policy
$TEST_PKG | grep -q '500 http://'
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
:
68 $APT_CACHE showsrc
$TEST_SRC | grep -q ^Binary
:
70 echo "---- uncompressed install ----"
71 $APT_GET install -d $TEST_PKG
72 test -e var
/cache
/apt
/archives
/$TEST_PKG*.deb
74 ! test -e var
/cache
/apt
/archives
/$TEST_PKG*.deb
76 echo "---- uncompressed get source ----"
77 $APT_GET source $TEST_PKG
78 test -f $TEST_SRC_*.dsc
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
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
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
104 echo "---- compressed cache ----"
105 $APT_CACHE show
$TEST_PKG | grep -q ^Version
:
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://'
111 $APT_CACHE policy
$TEST_PKG | grep -q '500 http://'
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
:
117 $APT_CACHE showsrc
$TEST_SRC | grep -q ^Binary
:
119 echo "---- compressed install ----"
120 $APT_GET install -d $TEST_PKG
121 ! test -e var
/cache
/apt
/archives
/$TEST_PKG*.deb
123 echo "---- compressed get source ----"
124 $APT_GET source $TEST_PKG
125 test -f $TEST_SRC_*.dsc
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
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
143 echo "---- ALL TESTS PASSED ----"