]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-get-download
activate AI_IDN by default to support IDN domains
[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
30c8107e 15addtrap 'prefix' "umask $(umask);"
5684f71f 16umask 0027
68ba0b7f 17setupaptarchive --no-update
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
30c8107e
DK
32if [ "$(id -u)" = '0' ]; then
33 # permission errors an everything
34 testfailure aptget update
35
36 find aptarchive/dists -name '*Packages*' -type f | while read file; do
37 chmod 777 "$file"
38 done
39 # permission errors on Release
40 testwarning aptget update
41fi
42
43#everything (too) permissive
44find aptarchive/ -type f | while read file; do
45 chmod 777 "$file"
46done
47find incoming/ -type f | while read file; do
48 chmod 777 "$file"
49done
68ba0b7f
DK
50testsuccess aptget update
51
42d41ddb 52testdownload() {
30c8107e
DK
53 local DEB="$1"
54 shift
55 msgtest "Test download of package file $DEB with" "$@"
56 testsuccess --nomsg aptget download "$@" -o Debug::pkgAcquire::Worker=1 -o Debug::pkgAcquire::Auth=1
57 testsuccess test -f "$DEB"
58 testaccessrights "$DEB" '644'
59 rm -f "$DEB"
42d41ddb
DK
60}
61
43acd019 62# normal case as "root"
03aa0847
DK
63OLDPWD="$(pwd)"
64cd downloaded
43acd019 65testdownload apt_2.0_all.deb apt
03aa0847 66cd "$OLDPWD"
43acd019
DK
67
68# simulate normal user with non-existent root-owned directories
69rm -rf rootdir/var/cache/apt/archives/
70mkdir rootdir/var/cache/apt/archives/
71addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/var/cache/apt/archives || true;"
72chmod -R -w rootdir/var/cache/apt/archives
73
03aa0847
DK
74OLDPWD="$(pwd)"
75cd downloaded
76
6ae22905 77# normal case(es)
30c8107e 78testdownload apt_1.0_all.deb apt/stable
42d41ddb
DK
79testdownload apt_2.0_all.deb apt
80
03aa0847 81DEBFILE="$(readlink -f ../aptarchive)/pool/apt_2.0_all.deb"
63c71412 82testequal "'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
83
84# deb:677887
03aa0847 85testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms --print-uris
567785b9 86testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms
6ae22905 87
e2095426
DK
88# deb:736962
89testsuccess aptget download apt
30c8107e
DK
90testsuccess test -s apt_2.0_all.deb
91testaccessrights 'apt_2.0_all.deb' '644'
e2095426
DK
92testsuccess aptget download apt
93testsuccess test -s apt_2.0_all.deb
30c8107e 94testaccessrights 'apt_2.0_all.deb' '644'
e2095426
DK
95
96rm -f apt_1.0_all.deb apt_2.0_all.deb
97
98# deb:738103
30c8107e 99testdownload apt_2.0_all.deb apt apt apt/unstable apt=2.0
8f3594c3 100
30c8107e 101# FIXME: pick up already downloaded deb files for real
43acd019 102# restore "root" rights
30c8107e
DK
103#cd "$OLDPWD"
104#chmod -f -R +w "$PWD/rootdir/var/cache/apt/archives"
105#rm -rf rootdir/var/cache/apt/archives/
43acd019
DK
106
107# file: debs aren't copied to archives, so change to http which obviously are
30c8107e
DK
108#changetowebserver
109#testsuccess aptget update
43acd019
DK
110
111# test with already stored deb
30c8107e
DK
112#testsuccess aptget install -d apt
113#testsuccess test -s rootdir/var/cache/apt/archives/apt_2.0_all.deb
114#testaccessrights 'rootdir/var/cache/apt/archives/apt_2.0_all.deb' '644'
115#mv aptarchive/pool/apt_2.0_all.deb aptarchive/pool/apt_2.0_all.deb.gone
116#cd downloaded
117#testdownload apt_2.0_all.deb apt
118#cd "$OLDPWD"
119#mv aptarchive/pool/apt_2.0_all.deb.gone aptarchive/pool/apt_2.0_all.deb