]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-get-download
autorun permission tests for all apt-get update calls
[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 testdownload() {
36 local APT="$2"
37 if [ -n "$3" ]; then
38 APT="${APT}/${3}"
39 fi
40 msgtest "Test download of package file $1 with" "$APT"
41 testsuccess --nomsg aptget download ${APT}
42 testsuccess test -f "$1"
43 rm -f "$1"
44 }
45
46 # normal case as "root"
47 testdownload apt_2.0_all.deb apt
48
49 # simulate normal user with non-existent root-owned directories
50 rm -rf rootdir/var/cache/apt/archives/
51 mkdir rootdir/var/cache/apt/archives/
52 addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/var/cache/apt/archives || true;"
53 chmod -R -w rootdir/var/cache/apt/archives
54
55 # normal case(es)
56 testdownload apt_1.0_all.deb apt stable
57 testdownload apt_2.0_all.deb apt
58
59 DEBFILE="$(readlink -f aptarchive)/pool/apt_2.0_all.deb"
60 testequal "'file://${DEBFILE}' apt_2.0_all.deb $(stat -c%s $DEBFILE) SHA512:$(sha512sum $DEBFILE | cut -d' ' -f 1)" aptget download apt --print-uris
61
62 # deb:677887
63 testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms
64
65 # deb:736962
66 testsuccess aptget download apt
67 testsuccess aptget download apt
68 testsuccess test -s apt_2.0_all.deb
69
70 rm -f apt_1.0_all.deb apt_2.0_all.deb
71
72 # deb:738103
73 testsuccess aptget download apt apt apt/unstable apt=2.0
74 testsuccess test -s apt_2.0_all.deb
75
76 # restore "root" rights
77 chmod -f -R +w $PWD/rootdir/var/cache/apt/archives
78 rm -rf rootdir/var/cache/apt/archives/
79
80 # file: debs aren't copied to archives, so change to http which obviously are
81 changetowebserver
82 testsuccess aptget update
83
84 # test with already stored deb
85 testsuccess aptget install -d apt
86 testsuccess test -s rootdir/var/cache/apt/archives/apt_2.0_all.deb
87 testaccessrights 'aptarchive/pool/apt_2.0_all.deb' '644'
88 mv aptarchive/pool/apt_2.0_all.deb aptarchive/pool/apt_2.0_all.deb.gone
89 testdownload apt_2.0_all.deb apt
90 mv aptarchive/pool/apt_2.0_all.deb.gone aptarchive/pool/apt_2.0_all.deb