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 # if $1 == "compressed", check that we have compressed indexes, otherwise
34 if [ "$1" = "compressed" ]; then
35 ! test -e var
/lib
/apt
/lists
/*_Packages
|| F
=1
36 ! test -e var
/lib
/apt
/lists
/*_Sources
|| F
=1
37 test -e var
/lib
/apt
/lists
/*_Packages.gz
|| F
=1
38 test -e var
/lib
/apt
/lists
/*_Sources.gz
|| F
=1
40 test -e var
/lib
/apt
/lists
/*_Packages
|| F
=1
41 test -e var
/lib
/apt
/lists
/*_Sources
|| F
=1
42 ! test -e var
/lib
/apt
/lists
/*_Packages.gz
|| F
=1
43 ! test -e var
/lib
/apt
/lists
/*_Sources.gz
|| F
=1
47 ls -l var
/lib
/apt
/lists
/
52 echo "---- building sandbox----"
54 trap "cd /; rm -rf $WORKDIR" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
60 mkdir -p etc
/apt
/preferences.d etc
/apt
/trusted.gpg.d var
/cache
/apt
/archives
/partial var
/lib
/apt
/lists
/partial var
/lib
/dpkg
61 cp /etc
/apt
/trusted.gpg etc
/apt
62 touch var
/lib
/dpkg
/status
63 echo "deb $TEST_SOURCE" > etc
/apt
/sources.list
64 echo "deb-src $TEST_SOURCE" >> etc
/apt
/sources.list
66 echo "---- uncompressed update ----"
67 # first attempt should fail, no trusted GPG key
68 out
=$($APT_GET update 2>&1)
69 echo "$out" | grep -q NO_PUBKEY
70 key
=$(echo "$out" | sed -n '/NO_PUBKEY/ { s/^.*NO_PUBKEY \([[:alnum:]]\+\)$
/\
1/; p
}')
72 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
76 echo "---- uncompressed cache ----"
77 $APT_CACHE show $TEST_PKG | grep -q ^Version:
79 $APT_CACHE show $TEST_PKG | grep -q ^Version:
80 rm var/cache/apt/*.bin
81 $APT_CACHE policy $TEST_PKG | grep -q '500 http
://'
83 $APT_CACHE policy $TEST_PKG | grep -q '500 http
://'
85 TEST_SRC=`$APT_CACHE show $TEST_PKG | grep ^Source: | awk '{print
$2}'`
86 rm var/cache/apt/*.bin
87 $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary:
89 $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary:
91 echo "---- uncompressed install ----"
92 $APT_GET install -d $TEST_PKG
93 test -e var/cache/apt/archives/$TEST_PKG*.deb
95 ! test -e var/cache/apt/archives/$TEST_PKG*.deb
97 echo "---- uncompressed get source ----"
98 $APT_GET source $TEST_PKG
99 test -f $TEST_SRC_*.dsc
103 echo "----- uncompressed update with preexisting indexes, no pdiff ----"
104 $APT_GET -o Acquire::PDiffs=false update
107 echo "----- uncompressed update with preexisting indexes, with pdiff ----"
108 $APT_GET -o Acquire::PDiffs=true update
111 echo "----- compressed update ----"
112 find var/lib/apt/lists/ -type f | xargs -r rm
113 $APT_GET -o Acquire::GzipIndexes=true update
114 check_indexes compressed
116 echo "---- compressed cache ----"
117 $APT_CACHE show $TEST_PKG | grep -q ^Version:
119 $APT_CACHE show $TEST_PKG | grep -q ^Version:
120 rm var/cache/apt/*.bin
121 $APT_CACHE policy $TEST_PKG | grep -q '500 http
://'
123 $APT_CACHE policy $TEST_PKG | grep -q '500 http
://'
125 TEST_SRC=`$APT_CACHE show $TEST_PKG | grep ^Source: | awk '{print
$2}'`
126 rm var/cache/apt/*.bin
127 $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary:
129 $APT_CACHE showsrc $TEST_SRC | grep -q ^Binary:
131 echo "---- compressed install ----"
132 $APT_GET install -d $TEST_PKG
133 ! test -e var/cache/apt/archives/$TEST_PKG*.deb
135 echo "---- compressed get source ----"
136 $APT_GET source $TEST_PKG
137 test -f $TEST_SRC_*.dsc
141 echo "----- compressed update with preexisting indexes, no pdiff ----"
142 $APT_GET -o Acquire::PDiffs=false -o Acquire::GzipIndexes=true update
143 check_indexes compressed
145 echo "----- compressed update with preexisting indexes, with pdiff ----"
146 $APT_GET -o Acquire::PDiffs=true -o Acquire::GzipIndexes=true update
147 check_indexes compressed
149 echo "---- ALL TESTS PASSED ----"