]> git.saurik.com Git - apt.git/blame_incremental - test/integration/test-apt-get-download
use +0000 instead of UTC by default as timezone in output
[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"
9confighashes 'SHA512'
10
11buildsimplenativepackage 'apt' 'all' '1.0' 'stable'
12buildsimplenativepackage 'apt' 'all' '2.0' 'unstable'
13insertinstalledpackage 'vrms' 'all' '1.0'
14
15addtrap 'prefix' "umask $(umask);"
16umask 0027
17setupaptarchive --no-update
18
19# directories should be readable by everyone
20find aptarchive/dists -type d | while read dir; do
21 chmod o+rx "$dir"
22done
23# apt-ftparchive knows how to chmod files
24find aptarchive/dists -name '*Packages*' -type f | while read file; do
25 testaccessrights "$file" '644'
26 chmod 640 "$file"
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
32if [ "$(id -u)" = '0' ]; then
33 # Release file can't be accessed by _apt
34 testsuccesswithnotice aptget update
35fi
36
37#everything (too) permissive
38find aptarchive/ -type f | while read file; do
39 chmod 777 "$file"
40done
41find incoming/ -type f | while read file; do
42 chmod 777 "$file"
43done
44testsuccess aptget update
45
46testdownload() {
47 local DEB="$1"
48 shift
49 msgtest "Test download of package file $DEB with" "$@"
50 testsuccess --nomsg aptget download "$@" -o Debug::pkgAcquire::Worker=1 -o Debug::pkgAcquire::Auth=1
51 testsuccess test -f "$DEB"
52 testaccessrights "$DEB" '644'
53 rm -f "$DEB"
54}
55
56# normal case as "root"
57OLDPWD="$(pwd)"
58cd downloaded
59testdownload apt_2.0_all.deb apt
60cd "$OLDPWD"
61
62# simulate normal user with non-existent root-owned directories
63rm -rf rootdir/var/cache/apt/archives/
64mkdir rootdir/var/cache/apt/archives/
65addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/var/cache/apt/archives || true;"
66chmod -R -w rootdir/var/cache/apt/archives
67
68OLDPWD="$(pwd)"
69cd downloaded
70
71# normal case(es)
72testdownload apt_1.0_all.deb apt/stable
73testdownload apt_2.0_all.deb apt
74
75DEBFILE="$(readlink -f ../aptarchive)/pool/apt_2.0_all.deb"
76testequal "'file://${DEBFILE}' apt_2.0_all.deb $(stat -c%s "$DEBFILE") SHA512:$(sha512sum "$DEBFILE" | cut -d' ' -f 1)" aptget download apt --print-uris
77
78# deb:677887
79testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms --print-uris
80testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms
81
82# deb:736962
83testsuccess aptget download apt
84testsuccess test -s apt_2.0_all.deb
85testaccessrights 'apt_2.0_all.deb' '644'
86testsuccess aptget download apt
87testsuccess test -s apt_2.0_all.deb
88testaccessrights 'apt_2.0_all.deb' '644'
89
90rm -f apt_1.0_all.deb apt_2.0_all.deb
91
92# deb:738103
93testdownload apt_2.0_all.deb apt apt apt/unstable apt=2.0
94
95# FIXME: pick up already downloaded deb files for real
96# restore "root" rights
97#cd "$OLDPWD"
98#chmod -f -R +w "$PWD/rootdir/var/cache/apt/archives"
99#rm -rf rootdir/var/cache/apt/archives/
100
101# file: debs aren't copied to archives, so change to http which obviously are
102#changetowebserver
103#testsuccess aptget update
104
105# test with already stored deb
106#testsuccess aptget install -d apt
107#testsuccess test -s rootdir/var/cache/apt/archives/apt_2.0_all.deb
108#testaccessrights 'rootdir/var/cache/apt/archives/apt_2.0_all.deb' '644'
109#mv aptarchive/pool/apt_2.0_all.deb aptarchive/pool/apt_2.0_all.deb.gone
110#cd downloaded
111#testdownload apt_2.0_all.deb apt
112#cd "$OLDPWD"
113#mv aptarchive/pool/apt_2.0_all.deb.gone aptarchive/pool/apt_2.0_all.deb