]>
Commit | Line | Data |
---|---|---|
42d41ddb DK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
4 | TESTDIR=$(readlink -f $(dirname $0)) | |
5 | . $TESTDIR/framework | |
6 | ||
7 | setupenvironment | |
8 | configarchitecture "i386" | |
c5ede4ca | 9 | confighashes 'SHA512' |
42d41ddb DK |
10 | |
11 | buildsimplenativepackage 'apt' 'all' '1.0' 'stable' | |
12 | buildsimplenativepackage 'apt' 'all' '2.0' 'unstable' | |
567785b9 | 13 | insertinstalledpackage 'vrms' 'all' '1.0' |
42d41ddb | 14 | |
68ba0b7f | 15 | OLD_UMASK="$(umask)" |
5684f71f | 16 | umask 0027 |
68ba0b7f DK |
17 | setupaptarchive --no-update |
18 | umask "$OLD_UMASK" | |
5684f71f | 19 | |
68ba0b7f DK |
20 | # directories should be readable by everyone |
21 | find aptarchive/dists -type d | while read dir; do | |
22 | chmod o+rx "$dir" | |
23 | done | |
5684f71f DK |
24 | # apt-ftparchive knows how to chmod files |
25 | find aptarchive/dists -name '*Packages*' -type f | while read file; do | |
26 | testaccessrights "$file" '644' | |
68ba0b7f | 27 | chmod 640 "$file" |
5684f71f DK |
28 | done |
29 | # created by the framework without special care | |
30 | find aptarchive/dists -name '*Release*' -type f | while read file; do | |
31 | testaccessrights "$file" '640' | |
32 | done | |
68ba0b7f DK |
33 | |
34 | testsuccess aptget update | |
35 | ||
42d41ddb | 36 | testdownload() { |
2aa7df1d DK |
37 | local APT="$2" |
38 | if [ -n "$3" ]; then | |
39 | APT="${APT}/${3}" | |
42d41ddb | 40 | fi |
2aa7df1d | 41 | msgtest "Test download of package file $1 with" "$APT" |
08ea7806 | 42 | testsuccess --nomsg aptget download ${APT} -o Debug::pkgAcquire::Worker=1 -o Debug::pkgAcquire::Auth=1 |
43acd019 DK |
43 | testsuccess test -f "$1" |
44 | rm -f "$1" | |
42d41ddb DK |
45 | } |
46 | ||
43acd019 | 47 | # normal case as "root" |
03aa0847 DK |
48 | OLDPWD="$(pwd)" |
49 | cd downloaded | |
43acd019 | 50 | testdownload apt_2.0_all.deb apt |
03aa0847 | 51 | cd "$OLDPWD" |
43acd019 DK |
52 | |
53 | # simulate normal user with non-existent root-owned directories | |
54 | rm -rf rootdir/var/cache/apt/archives/ | |
55 | mkdir rootdir/var/cache/apt/archives/ | |
56 | addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/var/cache/apt/archives || true;" | |
57 | chmod -R -w rootdir/var/cache/apt/archives | |
58 | ||
03aa0847 DK |
59 | OLDPWD="$(pwd)" |
60 | cd downloaded | |
61 | ||
6ae22905 | 62 | # normal case(es) |
42d41ddb DK |
63 | testdownload apt_1.0_all.deb apt stable |
64 | testdownload apt_2.0_all.deb apt | |
65 | ||
03aa0847 | 66 | DEBFILE="$(readlink -f ../aptarchive)/pool/apt_2.0_all.deb" |
63c71412 | 67 | testequal "'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 |
68 | |
69 | # deb:677887 | |
03aa0847 | 70 | testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms --print-uris |
567785b9 | 71 | testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms |
6ae22905 | 72 | |
e2095426 DK |
73 | # deb:736962 |
74 | testsuccess aptget download apt | |
75 | testsuccess aptget download apt | |
76 | testsuccess test -s apt_2.0_all.deb | |
77 | ||
78 | rm -f apt_1.0_all.deb apt_2.0_all.deb | |
79 | ||
80 | # deb:738103 | |
81 | testsuccess aptget download apt apt apt/unstable apt=2.0 | |
6ae22905 | 82 | testsuccess test -s apt_2.0_all.deb |
8f3594c3 | 83 | |
43acd019 | 84 | # restore "root" rights |
03aa0847 | 85 | cd "$OLDPWD" |
63c71412 | 86 | chmod -f -R +w "$PWD/rootdir/var/cache/apt/archives" |
43acd019 DK |
87 | rm -rf rootdir/var/cache/apt/archives/ |
88 | ||
89 | # file: debs aren't copied to archives, so change to http which obviously are | |
90 | changetowebserver | |
91 | testsuccess aptget update | |
92 | ||
93 | # test with already stored deb | |
94 | testsuccess aptget install -d apt | |
95 | testsuccess test -s rootdir/var/cache/apt/archives/apt_2.0_all.deb | |
5684f71f | 96 | testaccessrights 'aptarchive/pool/apt_2.0_all.deb' '644' |
43acd019 | 97 | mv aptarchive/pool/apt_2.0_all.deb aptarchive/pool/apt_2.0_all.deb.gone |
03aa0847 | 98 | cd downloaded |
43acd019 | 99 | testdownload apt_2.0_all.deb apt |
03aa0847 | 100 | cd "$OLDPWD" |
43acd019 | 101 | mv aptarchive/pool/apt_2.0_all.deb.gone aptarchive/pool/apt_2.0_all.deb |