]> git.saurik.com Git - apt.git/blame_incremental - test/integration/test-apt-update-transactions
tests: support spaces in path and TMPDIR
[apt.git] / test / integration / test-apt-update-transactions
... / ...
CommitLineData
1#!/bin/sh
2set -e
3
4# ensure that an update will only succeed entirely or not at all
5
6TESTDIR="$(readlink -f "$(dirname "$0")")"
7. "$TESTDIR/framework"
8
9setupenvironment
10configarchitecture 'i386'
11configcompression '.' 'gz'
12
13insertpackage 'unstable' 'foo' 'i386' '1.0'
14insertsource 'unstable' 'foo' 'i386' '1.0'
15
16setupaptarchive --no-update
17
18breakfile() {
19 mv "${1}" "${1}.bak"
20 mv "${1}.gz" "${1}.gz.bak"
21 cat > "$1" <<EOF
22Package: bar
23EOF
24 compressfile "$1"
25}
26restorefile() {
27 mv "${1}.bak" "$1"
28 mv "${1}.gz.bak" "${1}.gz"
29}
30
31testrun() {
32 rm -rf aptarchive/dists.good
33 cp -a aptarchive/dists aptarchive/dists.good
34 insertpackage 'unstable' 'bar' 'i386' '1.0'
35 insertsource 'unstable' 'bar' 'i386' '1.0'
36 buildaptarchivefromfiles '+1 hour'
37
38 # produce an unsigned repository
39 find aptarchive \( -name 'Release.gpg' -o -name 'InRelease' \) -delete
40 testfailure aptget update --no-allow-insecure-repositories
41 testfileequal "$1" "$(listcurrentlistsdirectory)"
42
43 # signed but broken
44 signreleasefiles
45
46 onehashbroken() {
47 testfailure aptget update
48 # each file generates two messages with this string
49 testequal '2' grep --count 'Hash Sum mismatch' rootdir/tmp/testfailure.output
50 testfileequal "$1" "$(listcurrentlistsdirectory)"
51 }
52
53 breakfile aptarchive/dists/unstable/main/binary-i386/Packages
54 onehashbroken "$1"
55 restorefile aptarchive/dists/unstable/main/binary-i386/Packages
56
57 breakfile aptarchive/dists/unstable/main/source/Sources
58 onehashbroken "$1"
59 restorefile aptarchive/dists/unstable/main/source/Sources
60
61 rm -rf aptarchive/dists
62 cp -a aptarchive/dists.good aptarchive/dists
63}
64
65testsetup() {
66 msgmsg 'Test with no initial data over' "$1"
67 rm -rf rootdir/var/lib/apt/lists
68 mkdir -p rootdir/var/lib/apt/lists/partial
69 listcurrentlistsdirectory > listsdir.lst
70 testrun 'listsdir.lst'
71
72 msgmsg 'Test with initial data over' "$1"
73 rm -rf rootdir/var/lib/apt/lists
74 testsuccess aptget update -o Debug::pkgAcquire::Worker=1
75 listcurrentlistsdirectory > listsdir.lst
76 testrun 'listsdir.lst'
77}
78
79testsetup 'file'
80
81changetowebserver
82webserverconfig 'aptwebserver::support::modified-since' 'false' "$1"
83webserverconfig 'aptwebserver::support::last-modified' 'false' "$1" # curl is clever and sees hits here also
84webserverconfig 'aptwebserver::support::range' 'false' "$1"
85
86testsetup 'http'
87
88changetohttpswebserver
89
90testsetup 'https'