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