4 TESTDIR
=$(readlink -f $(dirname $0))
8 configarchitecture
'i386'
14 PKGFILE
="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')"
17 msgtest 'Test for successful execution of' "$
*"
18 local OUTPUT=$(mktemp)
20 if aptget update "$@
" >${OUTPUT} 2>&1; then
28 msgtest 'No intermediate patch files' 'still exist'
29 local EDS="$(find rootdir/var/lib/apt/lists -name '*.ed' -o -name '*.ed.*')"
30 if [ -z "$EDS" ]; then
38 msgtest 'Check if the right pdiff merger was used'
39 if grep -q '^pkgAcqIndexMergeDiffs::Done(): rred' $OUTPUT; then
40 if echo "$
*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
43 msgfail "Merge shouldn
't have been used, but was"
45 elif echo "$*" | grep -q -- '-o Acquire
::PDiffs
::Merge
=1'; then
46 msgfail "Merge should have been used, but wasn't
"
53 msgmsg "Testcase
: setup the base with
: $
*"
54 find aptarchive -name 'Packages*' -type f -delete
55 cp ${PKGFILE} aptarchive/Packages
56 compressfile 'aptarchive/Packages'
59 rm -rf aptarchive/Packages.diff rootdir/var/lib/apt/lists
60 testsuccess aptget update "$@
"
61 cp -a rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists-bak
62 testnopackage newstuff
63 testequal "$(cat ${PKGFILE})
64 " aptcache show apt oldstuff
66 msgmsg "Testcase
: apply with one
patch: $
*"
67 cp ${PKGFILE}-new aptarchive/Packages
68 compressfile 'aptarchive/Packages'
69 mkdir -p aptarchive/Packages.diff
70 PATCHFILE="aptarchive
/Packages.diff
/$(date +%Y-%m-%d-%H%M.%S)"
71 diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
72 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
73 PATCHINDEX='aptarchive/Packages.diff/Index'
74 echo "SHA1
-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
76 9f4148e06d7faa37062994ff10d0c842d7017513
33053002 2010-08-18-2013.28
77 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
79 7651fc0ac57cd83d41c63195a9342e2db5650257
19722 2010-08-18-0814.28
80 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
81 generatereleasefiles '+1hour'
83 find aptarchive -name 'Packages*' -type f -delete
85 testnopackage oldstuff
86 testequal "$(cat ${PKGFILE}-new)
87 " aptcache show apt newstuff
89 msgmsg "Testcase
: index is already up
-to-date: $
*"
90 find rootdir/var/lib/apt/lists -name '*.IndexDiff' -type f -delete
91 testsuccess aptget update "$@
"
92 testequal "$(cat ${PKGFILE}-new)
93 " aptcache show apt newstuff
95 msgmsg "Testcase
: apply with two patches
: $
*"
96 cp ${PKGFILE}-new aptarchive/Packages
101 Maintainer: Joe Sixpack <joe@example.org>
103 Filename: pool/futurestuff_1.0_i386.deb
105 MD5sum: 311aeeaaae5ba33aff1ceaf3e1f76671
106 SHA1: 3c695e028f7a1ae324deeaae5ba332desa81088c
107 SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
108 Description: some cool and shiny future stuff
109 This package will appear in the next next mirror update
110 Description-md5: d5f89fbbc2ce34c455dfee9b67d82b6b' >> aptarchive/Packages
112 compressfile 'aptarchive/Packages'
113 PATCHFILE2="aptarchive
/Packages.diff
/$(date -d 'now + 1hour' '+%Y-%m-%d-%H%M.%S')"
114 diff -e ${PKGFILE}-new aptarchive/Packages > ${PATCHFILE2} || true
115 cat $PATCHFILE2 | gzip > ${PATCHFILE2}.gz
116 echo "SHA1
-Current: $(sha1sum aptarchive/Packages | cut -d' ' -f 1) $(stat -c%s aptarchive/Packages)
118 9f4148e06d7faa37062994ff10d0c842d7017513
33053002 2010-08-18-2013.28
119 $(sha1sum ${PKGFILE} | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}) $(basename ${PATCHFILE})
120 $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new) $(basename ${PATCHFILE2})
122 7651fc0ac57cd83d41c63195a9342e2db5650257
19722 2010-08-18-0814.28
123 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
124 $(sha1sum ${PATCHFILE2} | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE2}) $(basename ${PATCHFILE2})" > $PATCHINDEX
125 generatereleasefiles '+2hour'
127 cp -a aptarchive/Packages Packages-future
128 find aptarchive -name 'Packages*' -type f -delete
129 rm -rf rootdir/var/lib/apt/lists
130 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
132 testnopackage oldstuff
133 testequal "$(cat Packages-future)
134 " aptcache show apt newstuff futurestuff
136 msgmsg "Testcase
: patch applying fails
, but successful fallback
: $
*"
137 rm -rf rootdir/var/lib/apt/lists
138 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
139 cp ${PKGFILE}-new aptarchive/Packages
140 compressfile 'aptarchive/Packages'
141 mkdir -p aptarchive/Packages.diff
142 PATCHFILE="aptarchive
/Packages.diff
/$(date +%Y-%m-%d-%H%M.%S)"
143 diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
144 PATCHINDEX='aptarchive/Packages.diff/Index'
145 echo "SHA1
-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
147 9f4148e06d7faa37062994ff10d0c842d7017513
33053002 2010-08-18-2013.28
148 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
150 7651fc0ac57cd83d41c63195a9342e2db5650257
19722 2010-08-18-0814.28
151 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
152 echo 'I am Mallory and I change files' >> $PATCHFILE
153 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
154 generatereleasefiles '+1hour'
156 testsuccess aptget update "$@
"
157 testnopackage oldstuff
158 testequal "$(cat ${PKGFILE}-new)
159 " aptcache show apt newstuff
161 echo 'Debug::pkgAcquire::Diffs "true
";
162 Debug::Acquire::Transaction "true
";
163 Debug::pkgAcquire::rred "true
";' > rootdir/etc/apt/apt.conf.d/rreddebug.conf
165 testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=1
166 testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=1
167 testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=0
168 testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=0