]> 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
5684f71f
DK
14umask 0027
15
42d41ddb
DK
16setupaptarchive
17
5684f71f
DK
18# apt-ftparchive knows how to chmod files
19find aptarchive/dists -name '*Packages*' -type f | while read file; do
20 testaccessrights "$file" '644'
21done
22# created by the framework without special care
23find aptarchive/dists -name '*Release*' -type f | while read file; do
24 testaccessrights "$file" '640'
25done
26# all copied files are properly chmodded
27find rootdir/var/lib/apt/lists -type f | while read file; do
28 testaccessrights "$file" '644'
29done
30
42d41ddb 31testdownload() {
2aa7df1d
DK
32 local APT="$2"
33 if [ -n "$3" ]; then
34 APT="${APT}/${3}"
42d41ddb 35 fi
2aa7df1d 36 msgtest "Test download of package file $1 with" "$APT"
0954c58e 37 testsuccess --nomsg aptget download ${APT}
43acd019
DK
38 testsuccess test -f "$1"
39 rm -f "$1"
42d41ddb
DK
40}
41
43acd019
DK
42# normal case as "root"
43testdownload apt_2.0_all.deb apt
44
45# simulate normal user with non-existent root-owned directories
46rm -rf rootdir/var/cache/apt/archives/
47mkdir rootdir/var/cache/apt/archives/
48addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/var/cache/apt/archives || true;"
49chmod -R -w rootdir/var/cache/apt/archives
50
6ae22905 51# normal case(es)
42d41ddb
DK
52testdownload apt_1.0_all.deb apt stable
53testdownload apt_2.0_all.deb apt
54
55DEBFILE="$(readlink -f aptarchive)/pool/apt_2.0_all.deb"
d57f6084 56testequal "'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
57
58# deb:677887
59testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms
6ae22905 60
e2095426
DK
61# deb:736962
62testsuccess aptget download apt
63testsuccess aptget download apt
64testsuccess test -s apt_2.0_all.deb
65
66rm -f apt_1.0_all.deb apt_2.0_all.deb
67
68# deb:738103
69testsuccess aptget download apt apt apt/unstable apt=2.0
6ae22905 70testsuccess test -s apt_2.0_all.deb
8f3594c3 71
43acd019
DK
72# restore "root" rights
73chmod -f -R +w $PWD/rootdir/var/cache/apt/archives
74rm -rf rootdir/var/cache/apt/archives/
75
76# file: debs aren't copied to archives, so change to http which obviously are
77changetowebserver
78testsuccess aptget update
79
80# test with already stored deb
81testsuccess aptget install -d apt
82testsuccess test -s rootdir/var/cache/apt/archives/apt_2.0_all.deb
5684f71f 83testaccessrights 'aptarchive/pool/apt_2.0_all.deb' '644'
43acd019
DK
84mv aptarchive/pool/apt_2.0_all.deb aptarchive/pool/apt_2.0_all.deb.gone
85testdownload apt_2.0_all.deb apt
86mv aptarchive/pool/apt_2.0_all.deb.gone aptarchive/pool/apt_2.0_all.deb