]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-get-download
add --sha512 option + documentation for apt-ftparchive
[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
42d41ddb 35testdownload() {
2aa7df1d
DK
36 local APT="$2"
37 if [ -n "$3" ]; then
38 APT="${APT}/${3}"
42d41ddb 39 fi
2aa7df1d 40 msgtest "Test download of package file $1 with" "$APT"
08ea7806 41 testsuccess --nomsg aptget download ${APT} -o Debug::pkgAcquire::Worker=1 -o Debug::pkgAcquire::Auth=1
43acd019
DK
42 testsuccess test -f "$1"
43 rm -f "$1"
42d41ddb
DK
44}
45
43acd019 46# normal case as "root"
03aa0847
DK
47OLDPWD="$(pwd)"
48cd downloaded
43acd019 49testdownload apt_2.0_all.deb apt
03aa0847 50cd "$OLDPWD"
43acd019
DK
51
52# simulate normal user with non-existent root-owned directories
53rm -rf rootdir/var/cache/apt/archives/
54mkdir rootdir/var/cache/apt/archives/
55addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/var/cache/apt/archives || true;"
56chmod -R -w rootdir/var/cache/apt/archives
57
03aa0847
DK
58OLDPWD="$(pwd)"
59cd downloaded
60
6ae22905 61# normal case(es)
42d41ddb
DK
62testdownload apt_1.0_all.deb apt stable
63testdownload apt_2.0_all.deb apt
64
03aa0847 65DEBFILE="$(readlink -f ../aptarchive)/pool/apt_2.0_all.deb"
d57f6084 66testequal "'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
67
68# deb:677887
03aa0847 69testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms --print-uris
567785b9 70testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms
6ae22905 71
e2095426
DK
72# deb:736962
73testsuccess aptget download apt
74testsuccess aptget download apt
75testsuccess test -s apt_2.0_all.deb
76
77rm -f apt_1.0_all.deb apt_2.0_all.deb
78
79# deb:738103
80testsuccess aptget download apt apt apt/unstable apt=2.0
6ae22905 81testsuccess test -s apt_2.0_all.deb
8f3594c3 82
43acd019 83# restore "root" rights
03aa0847 84cd "$OLDPWD"
43acd019
DK
85chmod -f -R +w $PWD/rootdir/var/cache/apt/archives
86rm -rf rootdir/var/cache/apt/archives/
87
88# file: debs aren't copied to archives, so change to http which obviously are
89changetowebserver
90testsuccess aptget update
91
92# test with already stored deb
93testsuccess aptget install -d apt
94testsuccess test -s rootdir/var/cache/apt/archives/apt_2.0_all.deb
5684f71f 95testaccessrights 'aptarchive/pool/apt_2.0_all.deb' '644'
43acd019 96mv aptarchive/pool/apt_2.0_all.deb aptarchive/pool/apt_2.0_all.deb.gone
03aa0847 97cd downloaded
43acd019 98testdownload apt_2.0_all.deb apt
03aa0847 99cd "$OLDPWD"
43acd019 100mv aptarchive/pool/apt_2.0_all.deb.gone aptarchive/pool/apt_2.0_all.deb