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