]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-get-download
drop privileges in copy:// method as we do for file://
[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 addtrap 'prefix' "umask $(umask);"
16 umask 0027
17 setupaptarchive --no-update
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 if [ "$(id -u)" = '0' ]; then
33 # permission errors an everything
34 testfailure aptget update
35
36 find aptarchive/dists -name '*Packages*' -type f | while read file; do
37 chmod 777 "$file"
38 done
39 # permission errors on Release
40 testwarning aptget update
41 fi
42
43 #everything (too) permissive
44 find aptarchive/ -type f | while read file; do
45 chmod 777 "$file"
46 done
47 find incoming/ -type f | while read file; do
48 chmod 777 "$file"
49 done
50 testsuccess aptget update
51
52 testdownload() {
53 local DEB="$1"
54 shift
55 msgtest "Test download of package file $DEB with" "$@"
56 testsuccess --nomsg aptget download "$@" -o Debug::pkgAcquire::Worker=1 -o Debug::pkgAcquire::Auth=1
57 testsuccess test -f "$DEB"
58 testaccessrights "$DEB" '644'
59 rm -f "$DEB"
60 }
61
62 # normal case as "root"
63 OLDPWD="$(pwd)"
64 cd downloaded
65 testdownload apt_2.0_all.deb apt
66 cd "$OLDPWD"
67
68 # simulate normal user with non-existent root-owned directories
69 rm -rf rootdir/var/cache/apt/archives/
70 mkdir rootdir/var/cache/apt/archives/
71 addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/var/cache/apt/archives || true;"
72 chmod -R -w rootdir/var/cache/apt/archives
73
74 OLDPWD="$(pwd)"
75 cd downloaded
76
77 # normal case(es)
78 testdownload apt_1.0_all.deb apt/stable
79 testdownload apt_2.0_all.deb apt
80
81 DEBFILE="$(readlink -f ../aptarchive)/pool/apt_2.0_all.deb"
82 testequal "'file://${DEBFILE}' apt_2.0_all.deb $(stat -c%s "$DEBFILE") SHA512:$(sha512sum "$DEBFILE" | cut -d' ' -f 1)" aptget download apt --print-uris
83
84 # deb:677887
85 testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms --print-uris
86 testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms
87
88 # deb:736962
89 testsuccess aptget download apt
90 testsuccess test -s apt_2.0_all.deb
91 testaccessrights 'apt_2.0_all.deb' '644'
92 testsuccess aptget download apt
93 testsuccess test -s apt_2.0_all.deb
94 testaccessrights 'apt_2.0_all.deb' '644'
95
96 rm -f apt_1.0_all.deb apt_2.0_all.deb
97
98 # deb:738103
99 testdownload apt_2.0_all.deb apt apt apt/unstable apt=2.0
100
101 # FIXME: pick up already downloaded deb files for real
102 # restore "root" rights
103 #cd "$OLDPWD"
104 #chmod -f -R +w "$PWD/rootdir/var/cache/apt/archives"
105 #rm -rf rootdir/var/cache/apt/archives/
106
107 # file: debs aren't copied to archives, so change to http which obviously are
108 #changetowebserver
109 #testsuccess aptget update
110
111 # test with already stored deb
112 #testsuccess aptget install -d apt
113 #testsuccess test -s rootdir/var/cache/apt/archives/apt_2.0_all.deb
114 #testaccessrights 'rootdir/var/cache/apt/archives/apt_2.0_all.deb' '644'
115 #mv aptarchive/pool/apt_2.0_all.deb aptarchive/pool/apt_2.0_all.deb.gone
116 #cd downloaded
117 #testdownload apt_2.0_all.deb apt
118 #cd "$OLDPWD"
119 #mv aptarchive/pool/apt_2.0_all.deb.gone aptarchive/pool/apt_2.0_all.deb