]> git.saurik.com Git - apt.git/blame - test/integration/skip-acquire-same-repository-multiple-times
reset HOME, USER(NAME), TMPDIR & SHELL in DropPrivileges
[apt.git] / test / integration / skip-acquire-same-repository-multiple-times
CommitLineData
9d2a8a73
DK
1#!/bin/sh
2set -e
3
3abb6a6a
DK
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
9d2a8a73
DK
6setupenvironment
7configarchitecture 'amd64'
8
9TESTFILE="$TESTDIR/framework"
3abb6a6a 10cp "$TESTFILE" aptarchive/foo
9d2a8a73
DK
11APTARCHIVE="$(readlink -f ./aptarchive)"
12
13getcodenamefromsuite() { echo "jessie"; }
14buildsimplenativepackage 'foo' 'all' '1.0' 'stable'
15setupaptarchive --no-update
16ln -s "${APTARCHIVE}/dists/stable" "${APTARCHIVE}/dists/jessie"
17for FILE in rootdir/etc/apt/sources.list.d/*-stable-* ; do
18 sed 's#stable#jessie#g' $FILE > $(echo "$FILE" | sed 's#stable#jessie#g')
19done
20
21# install a slowed down file: otherwise its to fast to reproduce combining
22NEWMETHODS="$(readlink -f rootdir)/usr/lib/apt/methods"
23OLDMETHODS="$(readlink -f rootdir/usr/lib/apt/methods)"
63c71412
DK
24rm "$NEWMETHODS"
25mkdir "$NEWMETHODS"
26backupIFS="$IFS"
27IFS="$(printf "\n\b")"
28for METH in $(find "$OLDMETHODS" ! -type d); do
29 ln -s "$OLDMETHODS/$(basename "$METH")" "$NEWMETHODS"
9d2a8a73 30done
63c71412 31IFS="$backupIFS"
d2b7b130
DK
32rm "${NEWMETHODS}/file" "${NEWMETHODS}/http"
33cat >"${NEWMETHODS}/file" <<EOF
9d2a8a73
DK
34#!/bin/sh
35while read line; do
36 echo "\$line"
37 if [ -z "\$line" ]; then
533fe3d1 38 sleep 0.5
9d2a8a73 39 fi
3abb6a6a 40done | '$OLDMETHODS/'"\${0##*/}"
9d2a8a73 41EOF
d2b7b130
DK
42chmod +x "${NEWMETHODS}/file"
43ln -s "${NEWMETHODS}/file" "${NEWMETHODS}/http"
9d2a8a73
DK
44
45tworepos() {
46 msgtest "Downloading the same repository twice over $1" "$3"
47 testsuccess --nomsg aptget update -o Debug::pkgAcquire::Worker=1
48 cp rootdir/tmp/testsuccess.output download.log
49 #cat download.log
c2a4a8dd 50 aptget indextargets --format '$(FILENAME)' --no-release-info | sort > file.lst
63c71412 51 testequal "$(find "$(readlink -f ./rootdir/var/lib/apt/lists)" -name '*_dists_*' \( ! -name '*InRelease' \) -type f | sort)" cat file.lst
9d2a8a73
DK
52 testsuccess aptcache policy
53 testequal "foo:
54 Installed: (none)
55 Candidate: 1.0
56 Version table:
76b004d1 57 1.0 500
1dd20368
DK
58 500 $1:$2 jessie/main all Packages
59 500 $1:$2 stable/main all Packages" aptcache policy foo
9d2a8a73
DK
60 testfailure aptcache show foo/unstable
61 testsuccess aptcache show foo/stable
62 testsuccess aptcache show foo/jessie
63}
64
65tworepos 'file' "$APTARCHIVE" 'no partial'
1dd20368
DK
66testequal '14' grep -c '200%20URI%20Start' ./download.log
67testequal '14' grep -c '201%20URI%20Done' ./download.log
68testequal '8' grep -c '^ @ Queue: Action combined' ./download.log
9d2a8a73
DK
69tworepos 'file' "$APTARCHIVE" 'hit'
70testequal '6' grep -c '200%20URI%20Start' ./download.log
71testequal '6' grep -c '201%20URI%20Done' ./download.log
72testequal '0' grep -c '^ @ Queue: Action combined' ./download.log
73rm -rf rootdir/var/lib/apt/lists
74
75changetowebserver
76
6c0765c0 77tworepos 'http' "//localhost:${APTHTTPPORT}" 'no partial'
1dd20368
DK
78testequal '12' grep -c '200%20URI%20Start' ./download.log
79testequal '12' grep -c '201%20URI%20Done' ./download.log
80testequal '8' grep -c '^ @ Queue: Action combined' ./download.log
6c0765c0 81tworepos 'http' "//localhost:${APTHTTPPORT}" 'hit'
9d2a8a73
DK
82testequal '2' grep -c '200%20URI%20Start' ./download.log
83testequal '4' grep -c '201%20URI%20Done' ./download.log
84testequal '0' grep -c '^ @ Queue: Action combined' ./download.log
85rm -rf rootdir/var/lib/apt/lists