]> git.saurik.com Git - apt.git/blame_incremental - test/integration/test-apt-get-download
deduplicate main methods
[apt.git] / test / integration / test-apt-get-download
... / ...
CommitLineData
1#!/bin/sh
2set -e
3
4TESTDIR=$(readlink -f $(dirname $0))
5. $TESTDIR/framework
6
7setupenvironment
8configarchitecture "i386"
9confighashes 'SHA512'
10
11buildsimplenativepackage 'apt' 'all' '1.0' 'stable'
12buildsimplenativepackage 'apt' 'all' '2.0' 'unstable'
13insertinstalledpackage 'vrms' 'all' '1.0'
14
15OLD_UMASK="$(umask)"
16umask 0027
17setupaptarchive --no-update
18umask "$OLD_UMASK"
19
20# directories should be readable by everyone
21find aptarchive/dists -type d | while read dir; do
22 chmod o+rx "$dir"
23done
24# apt-ftparchive knows how to chmod files
25find aptarchive/dists -name '*Packages*' -type f | while read file; do
26 testaccessrights "$file" '644'
27 chmod 640 "$file"
28done
29# created by the framework without special care
30find aptarchive/dists -name '*Release*' -type f | while read file; do
31 testaccessrights "$file" '640'
32done
33
34testsuccess aptget update
35
36testdownload() {
37 local APT="$2"
38 if [ -n "$3" ]; then
39 APT="${APT}/${3}"
40 fi
41 msgtest "Test download of package file $1 with" "$APT"
42 testsuccess --nomsg aptget download ${APT} -o Debug::pkgAcquire::Worker=1 -o Debug::pkgAcquire::Auth=1
43 testsuccess test -f "$1"
44 rm -f "$1"
45}
46
47# normal case as "root"
48OLDPWD="$(pwd)"
49cd downloaded
50testdownload apt_2.0_all.deb apt
51cd "$OLDPWD"
52
53# simulate normal user with non-existent root-owned directories
54rm -rf rootdir/var/cache/apt/archives/
55mkdir rootdir/var/cache/apt/archives/
56addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/var/cache/apt/archives || true;"
57chmod -R -w rootdir/var/cache/apt/archives
58
59OLDPWD="$(pwd)"
60cd downloaded
61
62# normal case(es)
63testdownload apt_1.0_all.deb apt stable
64testdownload apt_2.0_all.deb apt
65
66DEBFILE="$(readlink -f ../aptarchive)/pool/apt_2.0_all.deb"
67testequal "'file://${DEBFILE}' apt_2.0_all.deb $(stat -c%s "$DEBFILE") SHA512:$(sha512sum "$DEBFILE" | cut -d' ' -f 1)" aptget download apt --print-uris
68
69# deb:677887
70testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms --print-uris
71testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms
72
73# deb:736962
74testsuccess aptget download apt
75testsuccess aptget download apt
76testsuccess test -s apt_2.0_all.deb
77
78rm -f apt_1.0_all.deb apt_2.0_all.deb
79
80# deb:738103
81testsuccess aptget download apt apt apt/unstable apt=2.0
82testsuccess test -s apt_2.0_all.deb
83
84# restore "root" rights
85cd "$OLDPWD"
86chmod -f -R +w "$PWD/rootdir/var/cache/apt/archives"
87rm -rf rootdir/var/cache/apt/archives/
88
89# file: debs aren't copied to archives, so change to http which obviously are
90changetowebserver
91testsuccess aptget update
92
93# test with already stored deb
94testsuccess aptget install -d apt
95testsuccess test -s rootdir/var/cache/apt/archives/apt_2.0_all.deb
96testaccessrights 'aptarchive/pool/apt_2.0_all.deb' '644'
97mv aptarchive/pool/apt_2.0_all.deb aptarchive/pool/apt_2.0_all.deb.gone
98cd downloaded
99testdownload apt_2.0_all.deb apt
100cd "$OLDPWD"
101mv aptarchive/pool/apt_2.0_all.deb.gone aptarchive/pool/apt_2.0_all.deb