]> git.saurik.com Git - apt.git/blame_incremental - test/integration/test-apt-get-download
Merge remote-tracking branch 'upstream/debian/experimental' into feature/acq-trans
[apt.git] / test / integration / test-apt-get-download
... / ...
CommitLineData
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'
12insertinstalledpackage 'vrms' 'all' '1.0'
13
14umask 0027
15
16setupaptarchive
17
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
31testdownload() {
32 local APT="$2"
33 if [ -n "$3" ]; then
34 APT="${APT}/${3}"
35 fi
36 msgtest "Test download of package file $1 with" "$APT"
37 testsuccess --nomsg aptget download ${APT}
38 testsuccess test -f "$1"
39 rm -f "$1"
40}
41
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
51# normal case(es)
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"
56testequal "'file://${DEBFILE}' apt_2.0_all.deb $(stat -c%s $DEBFILE) SHA512:$(sha512sum $DEBFILE | cut -d' ' -f 1)" aptget download apt --print-uris
57
58# deb:677887
59testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms
60
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
70testsuccess test -s apt_2.0_all.deb
71
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
83testaccessrights 'aptarchive/pool/apt_2.0_all.deb' '644'
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