]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | set -e | |
3 | ||
4 | TESTDIR=$(readlink -f $(dirname $0)) | |
5 | . $TESTDIR/framework | |
6 | ||
7 | setupenvironment | |
8 | configarchitecture "i386" | |
9 | ||
10 | buildsimplenativepackage 'apt' 'all' '1.0' 'stable' | |
11 | buildsimplenativepackage 'apt' 'all' '2.0' 'unstable' | |
12 | insertinstalledpackage 'vrms' 'all' '1.0' | |
13 | ||
14 | umask 0027 | |
15 | ||
16 | setupaptarchive | |
17 | ||
18 | # apt-ftparchive knows how to chmod files | |
19 | find aptarchive/dists -name '*Packages*' -type f | while read file; do | |
20 | testaccessrights "$file" '644' | |
21 | done | |
22 | # created by the framework without special care | |
23 | find aptarchive/dists -name '*Release*' -type f | while read file; do | |
24 | testaccessrights "$file" '640' | |
25 | done | |
26 | # all copied files are properly chmodded | |
27 | find rootdir/var/lib/apt/lists -type f | while read file; do | |
28 | testaccessrights "$file" '644' | |
29 | done | |
30 | ||
31 | testdownload() { | |
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" | |
43 | testdownload apt_2.0_all.deb apt | |
44 | ||
45 | # simulate normal user with non-existent root-owned directories | |
46 | rm -rf rootdir/var/cache/apt/archives/ | |
47 | mkdir rootdir/var/cache/apt/archives/ | |
48 | addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/var/cache/apt/archives || true;" | |
49 | chmod -R -w rootdir/var/cache/apt/archives | |
50 | ||
51 | # normal case(es) | |
52 | testdownload apt_1.0_all.deb apt stable | |
53 | testdownload apt_2.0_all.deb apt | |
54 | ||
55 | DEBFILE="$(readlink -f aptarchive)/pool/apt_2.0_all.deb" | |
56 | testequal "'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 | |
59 | testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms | |
60 | ||
61 | # deb:736962 | |
62 | testsuccess aptget download apt | |
63 | testsuccess aptget download apt | |
64 | testsuccess test -s apt_2.0_all.deb | |
65 | ||
66 | rm -f apt_1.0_all.deb apt_2.0_all.deb | |
67 | ||
68 | # deb:738103 | |
69 | testsuccess aptget download apt apt apt/unstable apt=2.0 | |
70 | testsuccess test -s apt_2.0_all.deb | |
71 | ||
72 | # restore "root" rights | |
73 | chmod -f -R +w $PWD/rootdir/var/cache/apt/archives | |
74 | rm -rf rootdir/var/cache/apt/archives/ | |
75 | ||
76 | # file: debs aren't copied to archives, so change to http which obviously are | |
77 | changetowebserver | |
78 | testsuccess aptget update | |
79 | ||
80 | # test with already stored deb | |
81 | testsuccess aptget install -d apt | |
82 | testsuccess test -s rootdir/var/cache/apt/archives/apt_2.0_all.deb | |
83 | testaccessrights 'aptarchive/pool/apt_2.0_all.deb' '644' | |
84 | mv aptarchive/pool/apt_2.0_all.deb aptarchive/pool/apt_2.0_all.deb.gone | |
85 | testdownload apt_2.0_all.deb apt | |
86 | mv aptarchive/pool/apt_2.0_all.deb.gone aptarchive/pool/apt_2.0_all.deb |