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