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