summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am62
-rw-r--r--tests/atoms.test180
-rwxr-xr-xtests/basic.sh425
-rwxr-xr-xtests/brokenuncompressor.sh13
-rw-r--r--tests/buildinfo.test656
-rw-r--r--tests/buildneeding.test631
-rw-r--r--tests/check.test225
-rw-r--r--tests/copy.test210
-rw-r--r--tests/descriptions.test143
-rw-r--r--tests/diffgeneration.test271
-rw-r--r--tests/easyupdate.test142
-rw-r--r--tests/evil.key18
-rw-r--r--tests/expired.key19
-rw-r--r--tests/expiredwithsubkey-working.key52
-rw-r--r--tests/expiredwithsubkey.key52
-rw-r--r--tests/export.test79
-rw-r--r--tests/exporthooks.test79
-rw-r--r--tests/flat.test518
-rw-r--r--tests/flood.test744
-rwxr-xr-xtests/genpackage.sh106
-rw-r--r--tests/good.key18
-rw-r--r--tests/includeasc.test221
-rw-r--r--tests/includeextra.test857
-rw-r--r--tests/layeredupdate.test684
-rw-r--r--tests/layeredupdate2.test683
-rw-r--r--tests/listcodenames.test41
-rw-r--r--tests/morgue.test276
-rwxr-xr-xtests/multiversion.sh353
-rw-r--r--tests/old-database/conf/distributions5
-rw-r--r--tests/old-database/db/checksums.dbbin0 -> 16384 bytes
-rw-r--r--tests/old-database/db/contents.cache.dbbin0 -> 16384 bytes
-rw-r--r--tests/old-database/db/packages.dbbin0 -> 57344 bytes
-rw-r--r--tests/old-database/db/references.dbbin0 -> 16384 bytes
-rw-r--r--tests/old-database/db/release.caches.dbbin0 -> 20480 bytes
-rw-r--r--tests/old-database/db/version4
-rw-r--r--tests/onlysmalldeletes.test142
-rw-r--r--tests/override.test172
-rw-r--r--tests/packagediff.test287
-rw-r--r--tests/revoked.keybin0 -> 624 bytes
-rw-r--r--tests/revoked.pkeybin0 -> 690 bytes
-rw-r--r--tests/shunit2-helper-functions.sh68
-rw-r--r--tests/signatures.test286
-rw-r--r--tests/signed.test68
-rw-r--r--tests/snapshotcopyrestore.test597
-rw-r--r--tests/srcfilterlist.test221
-rw-r--r--tests/subcomponents.test502
-rw-r--r--tests/template.test4
-rw-r--r--tests/test.inc237
-rwxr-xr-xtests/test.sh271
-rw-r--r--tests/trackingcorruption.test79
-rw-r--r--tests/uncompress.test514
-rw-r--r--tests/updatecorners.test176
-rw-r--r--tests/updatepullreject.test555
-rw-r--r--tests/uploaders.test253
-rw-r--r--tests/valgrind.supp128
-rw-r--r--tests/various1.test1430
-rw-r--r--tests/various2.test2462
-rw-r--r--tests/various3.test982
-rw-r--r--tests/verify.test437
-rw-r--r--tests/withsubkeys-works.key52
-rw-r--r--tests/withsubkeys.key52
-rw-r--r--tests/wrongarch.test86
62 files changed, 17828 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..709e79f
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,62 @@
+EXTRA_DIST = \
+brokenuncompressor.sh \
+genpackage.sh \
+test.inc \
+test.sh \
+atoms.test \
+buildinfo.test \
+buildneeding.test \
+check.test \
+copy.test \
+descriptions.test \
+diffgeneration.test \
+easyupdate.test \
+export.test \
+exporthooks.test \
+flat.test \
+flood.test \
+includeasc.test \
+includeextra.test \
+layeredupdate.test \
+layeredupdate2.test \
+listcodenames.test \
+morgue.test \
+onlysmalldeletes.test \
+override.test \
+packagediff.test \
+signatures.test \
+signed.test \
+snapshotcopyrestore.test \
+srcfilterlist.test \
+subcomponents.test \
+template.test \
+trackingcorruption.test \
+uncompress.test \
+updatecorners.test \
+updatepullreject.test \
+uploaders.test \
+various1.test \
+various2.test \
+various3.test \
+verify.test \
+wrongarch.test \
+evil.key \
+expired.key \
+expiredwithsubkey.key \
+expiredwithsubkey-working.key \
+good.key \
+revoked.key \
+revoked.pkey \
+withsubkeys.key \
+withsubkeys-works.key \
+basic.sh \
+multiversion.sh \
+shunit2-helper-functions.sh
+MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
+
+check:
+ ./basic.sh
+ ./multiversion.sh
+
+clean-local:
+ rm -rf testrepo testpkgs
diff --git a/tests/atoms.test b/tests/atoms.test
new file mode 100644
index 0000000..c57a53d
--- /dev/null
+++ b/tests/atoms.test
@@ -0,0 +1,180 @@
+. "$TESTSDIR"/test.inc
+
+# different tests to check the error messages when accessing
+# architectures components or packagetypes...
+
+mkdir conf
+cat > conf/options <<EOF
+export silent-never
+EOF
+
+cat > conf/distributions <<EOF
+Codename: codename
+Architectures: te/st all source
+Components: component
+EOF
+
+testrun - -b . update 3<<EOF
+*=Error parsing ./conf/distributions, line 2, column 16: Malformed Architectures element 'te/st': '/' is not allowed
+-v0*=There have been errors!
+return 255
+EOF
+
+sed -i -e 's#te/st#test#' conf/distributions
+
+testrun - -b . update 3<<EOF
+*=Error: Distribution codename contains an architecture called 'all'.
+-v0*=There have been errors!
+return 255
+EOF
+
+sed -i -e 's#\<all\>#a|l#' conf/distributions
+
+testrun - -b . update 3<<EOF
+*=Error parsing ./conf/distributions, line 2, column 21: Malformed Architectures element 'a|l': '|' is not allowed
+-v0*=There have been errors!
+return 255
+EOF
+
+sed -i -e 's#\<a|l\>##' -e 's#component#compo|nent#' conf/distributions
+
+testrun - -b . update 3<<EOF
+*=Error parsing ./conf/distributions, line 3, column 13: Malformed Components element 'compo|nent': '|' is not allowed
+-v0*=There have been errors!
+return 255
+EOF
+
+sed -i -e 's#compo|nent#.#' conf/distributions
+
+testrun - -b . update 3<<EOF
+*=Error parsing ./conf/distributions, line 3, column 13: Malformed Components element '.': '.' is not allowed as directory part
+-v0*=There have been errors!
+return 255
+EOF
+
+sed -i -e 's# .$# ./test#' conf/distributions
+
+testrun - -b . update 3<<EOF
+*=Error parsing ./conf/distributions, line 3, column 13: Malformed Components element './test': '.' is not allowed as directory part
+-v0*=There have been errors!
+return 255
+EOF
+
+sed -i -e 's# ./test$# bla/./test#' conf/distributions
+
+testrun - -b . update 3<<EOF
+*=Error parsing ./conf/distributions, line 3, column 13: Malformed Components element 'bla/./test': '.' is not allowed as directory part
+-v0*=There have been errors!
+return 255
+EOF
+
+sed -i -e 's# bla/./test$# bla/../test#' conf/distributions
+
+testrun - -b . update 3<<EOF
+*=Error parsing ./conf/distributions, line 3, column 13: Malformed Components element 'bla/../test': '..' is not allowed as directory part
+-v0*=There have been errors!
+return 255
+EOF
+
+sed -i -e 's#/test$##' conf/distributions
+
+testrun - -b . update 3<<EOF
+*=Error parsing ./conf/distributions, line 3, column 13: Malformed Components element 'bla/..': '..' is not allowed as directory part
+-v0*=There have been errors!
+return 255
+EOF
+
+sed -i -e 's#bla/##' conf/distributions
+
+testrun - -b . update 3<<EOF
+*=Error parsing ./conf/distributions, line 3, column 13: Malformed Components element '..': '..' is not allowed as directory part
+-v0*=There have been errors!
+return 255
+EOF
+
+sed -i -e 's#\.\.#component#' -e 's#Components#UdebComponents#' conf/distributions
+
+testrun - -b . update 3<<EOF
+*=Error parsing ./conf/distributions, line 3, column 16:
+*= A 'UDebComponents'-field is only allowed after a 'Components'-field.
+-v0*=There have been errors!
+return 255
+EOF
+
+ed -s conf/distributions <<EOF
+/Codename/a
+Components: test
+.
+w
+q
+EOF
+
+testrun - -b . update 3<<EOF
+*=Error parsing ./conf/distributions, line 4, column 17: 'component' not allowed in UDebComponents as it was not in Components.
+-v0*=There have been errors!
+return 255
+EOF
+
+sed -i -e 's#test$#test component#' conf/distributions
+cat >> conf/distributions <<EOF
+ContentsArchitectures: bla
+EOF
+
+testrun - -b . update 3<<EOF
+*=Error parsing ./conf/distributions, line 5, column 24: 'bla' not allowed in ContentsArchitectures as it was not in Architectures.
+-v0*=There have been errors!
+return 255
+EOF
+
+sed -i -e 's#ContentsArchitectures#ContentsComponents#' conf/distributions
+
+testrun - -b . update 3<<EOF
+*=Error parsing ./conf/distributions, line 5, column 21: 'bla' not allowed in ContentsComponents as it was not in Components.
+-v0*=There have been errors!
+return 255
+EOF
+
+sed -i -e 's#ContentsComponents: bla#ContentsUComponents: test#' conf/distributions
+
+testrun - -b . update 3<<EOF
+*=Error parsing ./conf/distributions, line 5, column 22: 'test' not allowed in ContentsUComponents as it was not in UDebComponents.
+-v0*=There have been errors!
+return 255
+EOF
+
+sed -i -e 's#ContentsUComponents: test#ContentsUComponents: component#' conf/distributions
+
+testrun - -b . -A test export 3<<EOF
+*=Action 'export' cannot be restricted to an architecture!
+*=neither --archiecture nor -A make sense here.
+*=To ignore use --ignore=unusedoption.
+-v0*=There have been errors!
+return 255
+EOF
+testrun - -b . -C test export 3<<EOF
+*=Action 'export' cannot be restricted to a component!
+*=neither --component nor -C make sense here.
+*=To ignore use --ignore=unusedoption.
+-v0*=There have been errors!
+return 255
+EOF
+testrun - -b . -T dsc export 3<<EOF
+*=Action 'export' cannot be restricted to a packagetype!
+*=neither --packagetype nor -T make sense here.
+*=To ignore use --ignore=unusedoption.
+-v0*=There have been errors!
+return 255
+EOF
+mkdir db
+testrun - -b . -A test remove codename nothing 3<<EOF
+-v0*=Not removed as not found: nothing
+EOF
+testrun - -b . -A bla remove codename nothing 3<<EOF
+*=Error: Architecture 'bla' as given to --architecture is not know.
+*=(it does not appear as architecture in ./conf/distributions (did you mistype?))
+-v0*=There have been errors!
+returns 255
+EOF
+
+rm -r conf db
+testsuccess
diff --git a/tests/basic.sh b/tests/basic.sh
new file mode 100755
index 0000000..867c489
--- /dev/null
+++ b/tests/basic.sh
@@ -0,0 +1,425 @@
+#!/bin/sh
+set -u
+
+# Copyright (C) 2017, Benjamin Drung <benjamin.drung@profitbricks.com>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+. "${0%/*}/shunit2-helper-functions.sh"
+
+setUp() {
+ create_repo
+}
+
+tearDown() {
+ check_db
+}
+
+test_empty() {
+ $REPREPRO -b $REPO export
+ call $REPREPRO -b $REPO list buster
+ assertEquals "" "$($REPREPRO -b $REPO list buster)"
+}
+
+test_list() {
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=1.0 REVISION=-1 ../genpackage.sh)
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_1.0-1_${ARCH}.deb
+ assertEquals "buster|main|$ARCH: hello 1.0-1" "$($REPREPRO -b $REPO list buster)"
+}
+
+test_ls() {
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster EPOCH="1:" VERSION=2.5 REVISION=-3 ../genpackage.sh)
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.5-3_${ARCH}.deb
+ assertEquals "hello | 1:2.5-3 | buster | $ARCH" "$($REPREPRO -b $REPO ls hello)"
+}
+
+test_copy() {
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster EPOCH="1:" VERSION=2.5 REVISION=-3 ../genpackage.sh)
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.5-3_${ARCH}.deb
+ assertEquals "hello | 1:2.5-3 | buster | $ARCH" "$($REPREPRO -b $REPO ls hello)"
+ add_distro bullseye
+ call $REPREPRO $VERBOSE_ARGS -b $REPO copy bullseye buster hello
+ assertEquals "bullseye|main|$ARCH: hello 1:2.5-3" "$($REPREPRO -b $REPO list bullseye)"
+}
+
+test_copy_existing() {
+ add_distro bullseye
+ (cd $PKGS && PACKAGE=sl SECTION=main DISTRI=buster EPOCH="" VERSION=3.03 REVISION=-1 ../genpackage.sh)
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/sl_3.03-1_${ARCH}.deb
+ assertEquals "sl | 3.03-1 | buster | $ARCH" "$($REPREPRO -b $REPO ls sl)"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO copy bullseye buster sl
+ assertEquals "\
+sl | 3.03-1 | buster | $ARCH
+sl | 3.03-1 | bullseye | $ARCH" "$($REPREPRO -b $REPO ls sl)"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO copy bullseye buster sl
+ assertEquals "\
+sl | 3.03-1 | buster | $ARCH
+sl | 3.03-1 | bullseye | $ARCH" "$($REPREPRO -b $REPO ls sl)"
+}
+
+test_include_changes() {
+ (cd $PKGS && PACKAGE=sl SECTION=main DISTRI=buster EPOCH="" VERSION=3.03 REVISION=-1 ../genpackage.sh)
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main include buster $PKGS/sl_3.03-1_${ARCH}.changes
+ assertEquals "\
+buster|main|$ARCH: sl 3.03-1
+buster|main|$ARCH: sl-addons 3.03-1
+buster|main|source: sl 3.03-1" "$($REPREPRO -b $REPO list buster)"
+}
+
+test_include_old() {
+ # Test including an old package version. Expected output:
+ # Skipping inclusion of 'hello' '2.9-1' in 'buster|main|$ARCH', as it has already '2.9-2'.
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-1 ../genpackage.sh)
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-2 ../genpackage.sh)
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-2_${ARCH}.deb
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-1_${ARCH}.deb
+ assertEquals "buster|main|$ARCH: hello 2.9-2" "$($REPREPRO -b $REPO list buster)"
+}
+
+test_limit() {
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-1 ../genpackage.sh)
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-2 ../genpackage.sh)
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-1_${ARCH}.deb
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-2_${ARCH}.deb
+ assertEquals "buster|main|$ARCH: hello 2.9-2" "$($REPREPRO -b $REPO list buster)"
+}
+
+test_older_version() {
+ cat >> $REPO/conf/incoming <<EOF
+Name: buster-upload
+IncomingDir: incoming
+TempDir: tmp
+Allow: buster
+Permit: older_version
+EOF
+ echo "Limit: 3" >> $REPO/conf/distributions
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-1 ../genpackage.sh)
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-2 ../genpackage.sh)
+ mkdir -p "$REPO/incoming"
+ cp "$PKGS/hello_2.9-2_${ARCH}.changes" "$PKGS/hello-addons_2.9-2_all.deb" "$PKGS/hello_2.9-2_${ARCH}.deb" "$PKGS/hello_2.9-2.dsc" "$PKGS/hello_2.9.orig.tar.gz" "$PKGS/hello_2.9-2.debian.tar.xz" "$REPO/incoming"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO processincoming buster-upload hello_2.9-2_${ARCH}.changes
+ assertEquals "hello | 2.9-2 | buster | $ARCH, source" "$($REPREPRO -b $REPO ls hello)"
+ cp "$PKGS/hello_2.9-1_${ARCH}.changes" "$PKGS/hello-addons_2.9-1_all.deb" "$PKGS/hello_2.9-1_${ARCH}.deb" "$PKGS/hello_2.9-1.dsc" "$PKGS/hello_2.9.orig.tar.gz" "$PKGS/hello_2.9-1.debian.tar.xz" "$REPO/incoming"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO processincoming buster-upload hello_2.9-1_${ARCH}.changes
+ assertEquals "\
+hello | 2.9-2 | buster | $ARCH, source
+hello | 2.9-1 | buster | $ARCH, source" "$($REPREPRO -b $REPO ls hello)"
+}
+
+test_too_old_version() {
+ # Allow only one version per package in the archive
+ # Test if uploading an older version will not replace the newer version
+ # in the archive.
+ cat >> $REPO/conf/incoming <<EOF
+Name: buster-upload
+IncomingDir: incoming
+TempDir: tmp
+Allow: buster
+Permit: older_version
+EOF
+ echo "Limit: 1" >> $REPO/conf/distributions
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-1 ../genpackage.sh)
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-2 ../genpackage.sh)
+ mkdir -p "$REPO/incoming"
+ cp "$PKGS/hello_2.9-2_${ARCH}.changes" "$PKGS/hello-addons_2.9-2_all.deb" "$PKGS/hello_2.9-2_${ARCH}.deb" "$PKGS/hello_2.9-2.dsc" "$PKGS/hello_2.9.orig.tar.gz" "$PKGS/hello_2.9-2.debian.tar.xz" "$REPO/incoming"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO processincoming buster-upload hello_2.9-2_${ARCH}.changes
+ assertEquals "hello | 2.9-2 | buster | $ARCH, source" "$($REPREPRO -b $REPO ls hello)"
+ cp "$PKGS/hello_2.9-1_${ARCH}.changes" "$PKGS/hello-addons_2.9-1_all.deb" "$PKGS/hello_2.9-1_${ARCH}.deb" "$PKGS/hello_2.9-1.dsc" "$PKGS/hello_2.9.orig.tar.gz" "$PKGS/hello_2.9-1.debian.tar.xz" "$REPO/incoming"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO processincoming buster-upload hello_2.9-1_${ARCH}.changes
+ assertEquals "hello | 2.9-2 | buster | $ARCH, source" "$($REPREPRO -b $REPO ls hello)"
+}
+
+test_remove() {
+ (cd $PKGS && PACKAGE=sl SECTION=main DISTRI=buster EPOCH="" VERSION=3.03 REVISION=-1 ../genpackage.sh)
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main include buster $PKGS/sl_3.03-1_${ARCH}.changes
+ assertEquals "\
+buster|main|$ARCH: sl 3.03-1
+buster|main|$ARCH: sl-addons 3.03-1
+buster|main|source: sl 3.03-1" "$($REPREPRO -b $REPO list buster)"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO remove buster sl
+ assertEquals "buster|main|$ARCH: sl-addons 3.03-1" "$($REPREPRO -b $REPO list buster)"
+}
+
+test_listcodenames() {
+ assertEquals "buster" "$($REPREPRO -b $REPO _listcodenames)"
+ add_distro bullseye
+ assertEquals "\
+buster
+bullseye" "$($REPREPRO -b $REPO _listcodenames)"
+}
+
+test_copysrc() {
+ (cd $PKGS && PACKAGE=sl SECTION=main DISTRI=buster EPOCH="" VERSION=3.03 REVISION=-1 ../genpackage.sh)
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main include buster $PKGS/sl_3.03-1_${ARCH}.changes
+ add_distro bullseye
+ call $REPREPRO $VERBOSE_ARGS -b $REPO copysrc bullseye buster sl
+ assertEquals "\
+bullseye|main|$ARCH: sl 3.03-1
+bullseye|main|$ARCH: sl-addons 3.03-1
+bullseye|main|source: sl 3.03-1" "$($REPREPRO -b $REPO list bullseye)"
+ assertEquals "\
+buster|main|$ARCH: sl 3.03-1
+buster|main|$ARCH: sl-addons 3.03-1
+buster|main|source: sl 3.03-1" "$($REPREPRO -b $REPO list buster)"
+}
+
+test_copymatched() {
+ (cd $PKGS && PACKAGE=sl SECTION=main DISTRI=buster EPOCH="" VERSION=3.03 REVISION=-1 ../genpackage.sh)
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main include buster $PKGS/sl_3.03-1_${ARCH}.changes
+ add_distro bullseye
+ call $REPREPRO $VERBOSE_ARGS -b $REPO copymatched bullseye buster "sl-a*on?"
+ assertEquals "bullseye|main|$ARCH: sl-addons 3.03-1" "$($REPREPRO -b $REPO list bullseye)"
+ assertEquals "\
+buster|main|$ARCH: sl 3.03-1
+buster|main|$ARCH: sl-addons 3.03-1
+buster|main|source: sl 3.03-1" "$($REPREPRO -b $REPO list buster)"
+}
+
+test_move() {
+ (cd $PKGS && PACKAGE=sl SECTION=main DISTRI=buster EPOCH="" VERSION=3.03 REVISION=-1 ../genpackage.sh)
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedsc buster $PKGS/sl_3.03-1.dsc
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/sl_3.03-1_$ARCH.deb $PKGS/sl-addons_3.03-1_all.deb
+ add_distro bullseye
+ call $REPREPRO $VERBOSE_ARGS -b $REPO move bullseye buster sl
+ assertEquals "\
+bullseye|main|$ARCH: sl 3.03-1
+bullseye|main|source: sl 3.03-1" "$($REPREPRO -b $REPO list bullseye)"
+ assertEquals "buster|main|$ARCH: sl-addons 3.03-1" "$($REPREPRO -b $REPO list buster)"
+ assertEquals "\
+Distribution: buster
+Source: sl
+Version: 3.03-1
+Files:
+ pool/main/s/sl/sl_3.03-1.dsc s 0
+ pool/main/s/sl/sl_3.03.orig.tar.gz s 0
+ pool/main/s/sl/sl_3.03-1.debian.tar.xz s 0
+ pool/main/s/sl/sl_3.03-1_$ARCH.deb b 0
+ pool/main/s/sl/sl-addons_3.03-1_all.deb a 1
+
+Distribution: bullseye
+Source: sl
+Version: 3.03-1
+Files:
+ pool/main/s/sl/sl_3.03-1_$ARCH.deb b 1
+ pool/main/s/sl/sl_3.03-1.dsc s 1
+ pool/main/s/sl/sl_3.03.orig.tar.gz s 1
+ pool/main/s/sl/sl_3.03-1.debian.tar.xz s 1" "$($REPREPRO -b $REPO dumptracks)"
+}
+
+test_movesrc() {
+ (cd $PKGS && PACKAGE=sl SECTION=main DISTRI=buster EPOCH="" VERSION=3.03 REVISION=-1 ../genpackage.sh)
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main include buster $PKGS/sl_3.03-1_${ARCH}.changes
+ add_distro bullseye
+ call $REPREPRO $VERBOSE_ARGS -b $REPO movesrc bullseye buster sl
+ assertEquals "\
+bullseye|main|$ARCH: sl 3.03-1
+bullseye|main|$ARCH: sl-addons 3.03-1
+bullseye|main|source: sl 3.03-1" "$($REPREPRO -b $REPO list bullseye)"
+ assertEquals "" "$($REPREPRO -b $REPO list buster)"
+}
+
+test_movematched() {
+ (cd $PKGS && PACKAGE=sl SECTION=main DISTRI=buster EPOCH="" VERSION=3.03 REVISION=-1 ../genpackage.sh)
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main include buster $PKGS/sl_3.03-1_${ARCH}.changes
+ add_distro bullseye
+ call $REPREPRO $VERBOSE_ARGS -b $REPO movematched bullseye buster "sl-a*on?"
+ assertEquals "bullseye|main|$ARCH: sl-addons 3.03-1" "$($REPREPRO -b $REPO list bullseye)"
+ assertEquals "\
+buster|main|$ARCH: sl 3.03-1
+buster|main|source: sl 3.03-1" "$($REPREPRO -b $REPO list buster)"
+}
+
+test_archive() {
+ clear_distro
+ add_distro buster-archive
+ add_distro buster "Limit: 1\nArchive: buster-archive"
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-1 ../genpackage.sh)
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-2 ../genpackage.sh)
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-1_${ARCH}.deb
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-2_${ARCH}.deb
+ assertEquals "\
+hello | 2.9-1 | buster-archive | $ARCH
+hello | 2.9-2 | buster | $ARCH" "$($REPREPRO -b $REPO ls hello)"
+ assertEquals "\
+Distribution: buster-archive
+Source: hello
+Version: 2.9-1
+Files:
+ pool/main/h/hello/hello_2.9-1_$ARCH.deb b 1
+
+Distribution: buster
+Source: hello
+Version: 2.9-2
+Files:
+ pool/main/h/hello/hello_2.9-2_$ARCH.deb b 1" "$($REPREPRO -b $REPO dumptracks)"
+}
+
+test_archive_downgrade() {
+ clear_distro
+ add_distro buster-archive
+ add_distro buster "Limit: 1\nArchive: buster-archive"
+ add_distro buster-proposed
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-1 ../genpackage.sh)
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-2 ../genpackage.sh)
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-2_${ARCH}.deb
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster-proposed $PKGS/hello_2.9-1_${ARCH}.deb
+ call $REPREPRO $VERBOSE_ARGS -b $REPO move buster buster-proposed hello=2.9-1
+ assertEquals "\
+hello | 2.9-2 | buster-archive | $ARCH
+hello | 2.9-1 | buster | $ARCH" "$($REPREPRO -b $REPO ls hello)"
+ assertEquals "\
+Distribution: buster-archive
+Source: hello
+Version: 2.9-2
+Files:
+ pool/main/h/hello/hello_2.9-2_$ARCH.deb b 1
+
+Distribution: buster
+Source: hello
+Version: 2.9-1
+Files:
+ pool/main/h/hello/hello_2.9-1_$ARCH.deb b 1" "$($REPREPRO -b $REPO dumptracks)"
+}
+
+test_archive_move() {
+ clear_distro
+ add_distro buster-archive "Limit: -1"
+ add_distro buster "Limit: 1\nArchive: buster-archive"
+ add_distro buster-proposed "Limit: -1"
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-1 ../genpackage.sh)
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-2 ../genpackage.sh)
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-3 ../genpackage.sh)
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster-proposed $PKGS/hello_2.9-1_${ARCH}.deb
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster-proposed $PKGS/hello_2.9-2_${ARCH}.deb
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster-proposed $PKGS/hello_2.9-3_${ARCH}.deb
+ assertEquals "\
+hello | 2.9-3 | buster-proposed | $ARCH
+hello | 2.9-2 | buster-proposed | $ARCH
+hello | 2.9-1 | buster-proposed | $ARCH" "$($REPREPRO -b $REPO ls hello)"
+ assertEquals "\
+Distribution: buster-proposed
+Source: hello
+Version: 2.9-1
+Files:
+ pool/main/h/hello/hello_2.9-1_$ARCH.deb b 1
+
+Distribution: buster-proposed
+Source: hello
+Version: 2.9-2
+Files:
+ pool/main/h/hello/hello_2.9-2_$ARCH.deb b 1
+
+Distribution: buster-proposed
+Source: hello
+Version: 2.9-3
+Files:
+ pool/main/h/hello/hello_2.9-3_$ARCH.deb b 1" "$($REPREPRO -b $REPO dumptracks)"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main move buster buster-proposed hello=2.9-1
+ assertEquals "\
+hello | 2.9-1 | buster | $ARCH
+hello | 2.9-3 | buster-proposed | $ARCH
+hello | 2.9-2 | buster-proposed | $ARCH" "$($REPREPRO -b $REPO ls hello)"
+ assertEquals "\
+Distribution: buster
+Source: hello
+Version: 2.9-1
+Files:
+ pool/main/h/hello/hello_2.9-1_$ARCH.deb b 1
+
+Distribution: buster-proposed
+Source: hello
+Version: 2.9-2
+Files:
+ pool/main/h/hello/hello_2.9-2_$ARCH.deb b 1
+
+Distribution: buster-proposed
+Source: hello
+Version: 2.9-3
+Files:
+ pool/main/h/hello/hello_2.9-3_$ARCH.deb b 1" "$($REPREPRO -b $REPO dumptracks)"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main move buster buster-proposed hello=2.9-2
+ assertEquals "\
+hello | 2.9-1 | buster-archive | $ARCH
+hello | 2.9-2 | buster | $ARCH
+hello | 2.9-3 | buster-proposed | $ARCH" "$($REPREPRO -b $REPO ls hello)"
+ assertEquals "\
+Distribution: buster-archive
+Source: hello
+Version: 2.9-1
+Files:
+ pool/main/h/hello/hello_2.9-1_$ARCH.deb b 1
+
+Distribution: buster
+Source: hello
+Version: 2.9-2
+Files:
+ pool/main/h/hello/hello_2.9-2_$ARCH.deb b 1
+
+Distribution: buster-proposed
+Source: hello
+Version: 2.9-3
+Files:
+ pool/main/h/hello/hello_2.9-3_$ARCH.deb b 1" "$($REPREPRO -b $REPO dumptracks)"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main move buster buster-proposed hello
+ assertEquals "\
+hello | 2.9-2 | buster-archive | $ARCH
+hello | 2.9-1 | buster-archive | $ARCH
+hello | 2.9-3 | buster | $ARCH" "$($REPREPRO -b $REPO ls hello)"
+ assertEquals "\
+Distribution: buster-archive
+Source: hello
+Version: 2.9-1
+Files:
+ pool/main/h/hello/hello_2.9-1_$ARCH.deb b 1
+
+Distribution: buster-archive
+Source: hello
+Version: 2.9-2
+Files:
+ pool/main/h/hello/hello_2.9-2_$ARCH.deb b 1
+
+Distribution: buster
+Source: hello
+Version: 2.9-3
+Files:
+ pool/main/h/hello/hello_2.9-3_$ARCH.deb b 1" "$($REPREPRO -b $REPO dumptracks)"
+}
+
+test_archive_move_back() {
+ clear_distro
+ add_distro buster-archive "Limit: -1"
+ add_distro buster "Limit: 1\nArchive: buster-archive"
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-1 ../genpackage.sh)
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-2 ../genpackage.sh)
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-1_${ARCH}.deb
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster-archive $PKGS/hello_2.9-2_${ARCH}.deb
+ assertEquals "\
+hello | 2.9-2 | buster-archive | $ARCH
+hello | 2.9-1 | buster | $ARCH" "$($REPREPRO -b $REPO ls hello)"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main move buster buster-archive hello=2.9-2
+ assertEquals "\
+hello | 2.9-1 | buster-archive | $ARCH
+hello | 2.9-2 | buster | $ARCH" "$($REPREPRO -b $REPO ls hello)"
+}
+
+test_ddeb() {
+ clear_distro
+ add_distro buster "DDebComponents: main non-free"
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster VERSION=2.9 REVISION=-1 DDEB=1 ../genpackage.sh)
+ #mv $PKGS/hello_2.9-1_${ARCH}.deb $PKGS/hello_2.9-1_${ARCH}.ddeb
+ #sed -i "s/hello_2.9-1_${ARCH}.deb/hello_2.9-1_${ARCH}.ddeb/g" $PKGS/hello_2.9-1_${ARCH}.changes
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main include buster $PKGS/hello_2.9-1_${ARCH}.changes
+ assertEquals "hello | 2.9-1 | buster | $ARCH, source" "$($REPREPRO -b $REPO ls hello)"
+}
+
+. shunit2
diff --git a/tests/brokenuncompressor.sh b/tests/brokenuncompressor.sh
new file mode 100755
index 0000000..42ea32a
--- /dev/null
+++ b/tests/brokenuncompressor.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+if [ $# -ne 0 ] ; then
+ echo "brokenuncompressor.sh: Wrong number of arguments: $#" >&2
+ exit 17
+fi
+$uncompressor
+if test -f breakon2nd ; then
+ rm breakon2nd
+ exit 0;
+fi
+# Breaking an .lzma stream is hard, faking it is more reproduceable...
+echo "brokenuncompressor.sh: claiming broken archive" >&2
+exit 1
diff --git a/tests/buildinfo.test b/tests/buildinfo.test
new file mode 100644
index 0000000..e3d4c7a
--- /dev/null
+++ b/tests/buildinfo.test
@@ -0,0 +1,656 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+
+gensource() {
+ srcname="$1"
+ version="$2"
+ build="$3"
+ mkdir "${srcname}-${version}"
+ cd "${srcname}-${version}"
+ mkdir debian
+ cat > debian/rules <<'EOF'
+#!/usr/bin/make -f
+tmp = $(CURDIR)/debian/tmp
+build-indep build-arch:
+binary-indep binary-arch:
+ rm -f debian/files # prep
+ # wrong directory, but not relevant for the test
+ install -m 755 -d $(tmp)/DEBIAN $(tmp)/usr/share/doc/documentation
+ echo "I have told you so" > $(tmp)/usr/share/doc/documentation/NEWS
+ gzip -c9 debian/changelog > $(tmp)/usr/share/doc/documentation/changelog.gz
+ chown -R root.root $(tmp) && chmod -R go=rX $(tmp)
+ dpkg-gencontrol -isp
+ dpkg --build $(tmp) ..
+clean:
+ rm -f debian/files
+.PHONY: clean binary-arch binary-indep binary build build-indep buil-arch
+EOF
+ chmod a+x debian/rules
+ cat > debian/changelog <<EOF
+${srcname} (${version}) test; urgency=low
+
+ * everything fixed
+
+ -- Sky.NET <nowhere@example.com> Sat, 15 Jan 2011 17:12:05 +2700
+EOF
+
+ cat > debian/control <<EOF
+Source: ${srcname}
+Section: doc
+Priority: standard
+Maintainer: Sky.NET <nowhere@example.com>
+Standards-Version: Aleph_17
+
+EOF
+ cat >> debian/control
+ # sadly dpkg-buildinfo does not allow faking the architecture, so this gets more ugly:
+ echo simulating: dpkg-buildpackage -rfakeroot -us -uc -S
+ fakeroot debian/rules clean
+ (cd .. && dpkg-source -b "${srcname}-${version}")
+ dpkg-genchanges --build=source > "../${srcname}_${version}_source.changes"
+ dpkg-genbuildinfo --build=source
+ dpkg-genchanges --build=source > "../${srcname}_${version}_sourceandbuild.changes"
+ if ! grep buildinfo "../${srcname}_${version}_sourceandbuild.changes" ; then
+ ed -s "../${srcname}_${version}_sourceandbuild.changes" <<EOF
+/^Checksums-Sha1:/a
+ $(sha1andsize "../${srcname}_${version}_source.buildinfo") ${srcname}_${version}_source.buildinfo
+.
+/^Checksums-Sha256:/a
+ $(sha2andsize "../${srcname}_${version}_source.buildinfo") ${srcname}_${version}_source.buildinfo
+.
+/^Files:/a
+ $(mdandsize "../${srcname}_${version}_source.buildinfo") doc standard ${srcname}_${version}_source.buildinfo
+.
+w
+q
+EOF
+ fi
+ echo simulating dpkg-buildpackage -rfakeroot -us -uc --build="$build"
+ fakeroot debian/rules clean
+ case $build in
+ any) debian/rules build-arch ; fakeroot debian/rules binary-arch ;;
+ all) debian/rules build-indep ; fakeroot debian/rules binary-indep ;;
+ *) echo "unknown build type" ; exit 1 ;;
+ esac
+ dpkg-genbuildinfo --build="$build"
+ dpkg-genchanges --build="$build" > "../${srcname}_${version}_binary.changes"
+ cd ..
+}
+
+gensource 'source-a' '1' all << EOF
+Package: onlyall
+Architecture: all
+Description: documentation
+ documentation
+EOF
+gensource 'source-b' '2' any << EOF
+Package: onlyany
+Architecture: any
+Description: binaries
+ binaries
+EOF
+
+mkdir "source-c-3"
+cd "source-c-3"
+mkdir debian
+cat > debian/rules <<'EOF'
+#!/usr/bin/make -f
+build-indep build-arch:
+binary-indep binary-arch: binary-%:
+ rm -rf debian/tmp #prep
+ install -m 755 -d debian/tmp/DEBIAN debian/tmp/usr/share/doc/some$*
+ echo "I have told you so" > debian/tmp/usr/share/doc/some$*/NEWS
+ gzip -c9 debian/changelog > debian/tmp/usr/share/doc/some$*/changelog.gz
+ chown -R root.root debian/tmp && chmod -R go=rX debian/tmp
+ dpkg-gencontrol -isp -psome$* -Pdebian/tmp
+ dpkg --build debian/tmp ..
+clean:
+ rm -f debian/files -r debian/tmp
+.PHONY: clean binary-arch binary-indep binary build build-indep buil-arch
+EOF
+chmod a+x debian/rules
+cat > debian/changelog <<EOF
+source-c (3) test; urgency=low
+
+ * everything fixed
+
+ -- Sky.NET <nowhere@example.com> Sat, 15 Jan 2011 17:12:05 +2700
+EOF
+
+cat > debian/control <<EOF
+Source: source-c
+Section: shells
+Priority: required
+Maintainer: Sky.NET <nowhere@example.com>
+Standards-Version: Aleph_17
+
+Package: somearch
+Architecture: any
+Description: binaries
+ binaries
+
+Package: someindep
+Architecture: all
+Description: scripts
+ scripts
+EOF
+# sadly dpkg-buildinfo does not allow faking the architecture, so this gets more ugly:
+echo simulating dpkg-buildpackage -rfakeroot -us -uc --build="full"
+fakeroot debian/rules clean
+(cd .. && dpkg-source -b source-c-3)
+debian/rules build-arch ; debian/rules build-indep
+fakeroot debian/rules binary-arch
+fakeroot debian/rules binary-indep
+dpkg-genbuildinfo --build=full
+dpkg-genchanges --build=full > "../source-c_3_full.changes"
+cd ..
+
+rm -r source-a-1 source-b-2 source-c-3
+
+# first check include:
+mkdir conf
+cat > conf/options <<EOF
+export silent-never
+EOF
+cat > conf/distributions <<EOF
+Codename: test
+Architectures: coal source
+Components: main
+EOF
+
+mkdir -p pool/main/s/source-a pool/main/s/source-b
+
+echo Check that include properly ignores a .buildinfo file
+testrun - include test source-a_1_binary.changes 3<<EOF
+stderr
+-v3*=Ignoring buildinfo file: 'source-a_1_all.buildinfo'!
+stdout
+$(odb)
+$(ofa 'pool/main/s/source-a/onlyall_1_all.deb')
+$(opa 'onlyall' '1' 'test' 'main' 'coal' 'deb')
+EOF
+rm -r pool db
+
+mkdir pool
+testrun - -A coal include test source-b_2_binary.changes 3<<EOF
+stderr
+-v3*=Ignoring buildinfo file: 'source-b_2_abacus.buildinfo'!
+-v1*=Skipping 'onlyany_2_abacus.deb' as architecture is not in the requested set.
+*=source-b_2_binary.changes: Not enough files in .changes!
+-v0*=There have been errors!
+returns 255
+stdout
+$(odb)
+EOF
+rm -r pool db
+
+mkdir pool
+testrun - -A coal include test source-b_2_source.changes 3<<EOF
+stderr
+-v1*=Skipping 'source-b_2.dsc' as architecture 'source' is not in the requested set.
+-v1*=Skipping 'source-b_2.tar.gz' as architecture 'source' is not in the requested set.
+*=source-b_2_source.changes: Not enough files in .changes!
+-v0*=There have been errors!
+returns 255
+stdout
+$(odb)
+EOF
+rm -r pool db
+
+mkdir pool
+testrun - -A coal include test source-b_2_sourceandbuild.changes 3<<EOF
+stderr
+-v3*=Ignoring buildinfo file: 'source-b_2_source.buildinfo'!
+-v1*=Skipping 'source-b_2.dsc' as architecture 'source' is not in the requested set.
+-v1*=Skipping 'source-b_2.tar.gz' as architecture 'source' is not in the requested set.
+*=source-b_2_sourceandbuild.changes: Not enough files in .changes!
+-v0*=There have been errors!
+returns 255
+stdout
+$(odb)
+EOF
+rm -r pool db
+
+mkdir -p pool/main/s/source-a pool/main/s/source-b
+testrun - include test source-b_2_sourceandbuild.changes 3<<EOF
+stderr
+-v3*=Ignoring buildinfo file: 'source-b_2_source.buildinfo'!
+stdout
+$(odb)
+$(ofa 'pool/main/s/source-b/source-b_2.dsc')
+$(ofa 'pool/main/s/source-b/source-b_2.tar.gz')
+$(opa 'source-b' '2' 'test' 'main' 'source' 'dsc')
+EOF
+rm -r pool db
+
+cat > conf/distributions <<EOF
+Codename: test
+Architectures: abacus source
+Components: main
+EOF
+
+mkdir -p pool/main/s/source-a pool/main/s/source-b pool/main/s/source-c
+
+echo Check that include properly ignores a .buildinfo file
+testrun - include test source-a_1_binary.changes 3<<EOF
+stderr
+-v3*=Ignoring buildinfo file: 'source-a_1_all.buildinfo'!
+stdout
+$(odb)
+$(ofa 'pool/main/s/source-a/onlyall_1_all.deb')
+$(opa 'onlyall' '1' 'test' 'main' 'abacus' 'deb')
+EOF
+
+testrun - include test source-b_2_binary.changes 3<<EOF
+stderr
+-v3*=Ignoring buildinfo file: 'source-b_2_abacus.buildinfo'!
+stdout
+$(ofa 'pool/main/s/source-b/onlyany_2_abacus.deb')
+$(opa 'onlyany' '2' 'test' 'main' 'abacus' 'deb')
+EOF
+
+testrun - include test source-b_2_sourceandbuild.changes 3<<EOF
+stderr
+-v3*=Ignoring buildinfo file: 'source-b_2_source.buildinfo'!
+stdout
+$(ofa 'pool/main/s/source-b/source-b_2.dsc')
+$(ofa 'pool/main/s/source-b/source-b_2.tar.gz')
+$(opa 'source-b' '2' 'test' 'main' 'source' 'dsc')
+EOF
+
+testrun - include test source-c_3_full.changes 3<<EOF
+stderr
+-v3*=Ignoring buildinfo file: 'source-c_3_abacus.buildinfo'!
+stdout
+$(ofa 'pool/main/s/source-c/source-c_3.dsc')
+$(ofa 'pool/main/s/source-c/source-c_3.tar.gz')
+$(ofa 'pool/main/s/source-c/somearch_3_abacus.deb')
+$(ofa 'pool/main/s/source-c/someindep_3_all.deb')
+$(opa 'source-c' '3' 'test' 'main' 'source' 'dsc')
+$(opa 'somearch' '3' 'test' 'main' 'abacus' 'deb')
+$(opa 'someindep' '3' 'test' 'main' 'abacus' 'deb')
+EOF
+rm -r pool db
+
+echo now the same with tracking information:
+
+cat > conf/distributions <<EOF
+Codename: test
+Architectures: coal source
+Components: main
+Tracking: minimal includebuildinfos
+EOF
+
+mkdir -p pool/main/s/source-a pool/main/s/source-b
+
+echo Check that include properly ignores a .buildinfo file
+testrun - include test source-a_1_binary.changes 3<<EOF
+stderr
+stdout
+$(odb)
+$(ofa 'pool/main/s/source-a/onlyall_1_all.deb')
+$(ofa 'pool/main/s/source-a/source-a_1_all.buildinfo')
+$(opa 'onlyall' '1' 'test' 'main' 'coal' 'deb')
+$(ota 'test' 'source-a')
+EOF
+rm -r pool db
+
+mkdir pool
+testrun - -A coal include test source-b_2_binary.changes 3<<EOF
+stderr
+-v1*=Skipping 'source-b_2_abacus.buildinfo' as architecture is not in the requested set.
+-v1*=Skipping 'onlyany_2_abacus.deb' as architecture is not in the requested set.
+*=source-b_2_binary.changes: Not enough files in .changes!
+-v0*=There have been errors!
+returns 255
+stdout
+$(odb)
+EOF
+rm -r pool db
+
+mkdir pool
+testrun - -A coal include test source-b_2_source.changes 3<<EOF
+stderr
+-v1*=Skipping 'source-b_2.dsc' as architecture 'source' is not in the requested set.
+-v1*=Skipping 'source-b_2.tar.gz' as architecture 'source' is not in the requested set.
+*=source-b_2_source.changes: Not enough files in .changes!
+-v0*=There have been errors!
+returns 255
+stdout
+$(odb)
+EOF
+rm -r pool db
+
+mkdir pool
+testrun - -A coal include test source-b_2_sourceandbuild.changes 3<<EOF
+stderr
+-v1*=Skipping 'source-b_2_source.buildinfo' as architecture 'source' is not in the requested set.
+-v1*=Skipping 'source-b_2.dsc' as architecture 'source' is not in the requested set.
+-v1*=Skipping 'source-b_2.tar.gz' as architecture 'source' is not in the requested set.
+*=source-b_2_sourceandbuild.changes: Not enough files in .changes!
+-v0*=There have been errors!
+returns 255
+stdout
+$(odb)
+EOF
+rm -r pool db
+
+mkdir -p pool/main/s/source-a pool/main/s/source-b
+testrun - include test source-b_2_sourceandbuild.changes 3<<EOF
+stderr
+stdout
+$(odb)
+$(ofa 'pool/main/s/source-b/source-b_2_source.buildinfo')
+$(ofa 'pool/main/s/source-b/source-b_2.dsc')
+$(ofa 'pool/main/s/source-b/source-b_2.tar.gz')
+$(opa 'source-b' '2' 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'source-b')
+EOF
+rm -r pool db
+
+cat > conf/distributions <<EOF
+Codename: test
+Architectures: abacus source
+Components: main
+Tracking: minimal includebuildinfos
+EOF
+
+mkdir -p pool/main/s/source-a pool/main/s/source-b pool/main/s/source-c
+
+echo Check that include properly ignores a .buildinfo file
+testrun - include test source-a_1_binary.changes 3<<EOF
+stderr
+stdout
+$(odb)
+$(ofa 'pool/main/s/source-a/source-a_1_all.buildinfo')
+$(ofa 'pool/main/s/source-a/onlyall_1_all.deb')
+$(opa 'onlyall' '1' 'test' 'main' 'abacus' 'deb')
+$(ota 'test' 'source-a')
+EOF
+
+testrun - include test source-b_2_binary.changes 3<<EOF
+stderr
+stdout
+$(ofa 'pool/main/s/source-b/source-b_2_abacus.buildinfo')
+$(ofa 'pool/main/s/source-b/onlyany_2_abacus.deb')
+$(opa 'onlyany' '2' 'test' 'main' 'abacus' 'deb')
+$(ota 'test' 'source-b')
+EOF
+
+testrun - include test source-b_2_sourceandbuild.changes 3<<EOF
+stderr
+stdout
+$(ofa 'pool/main/s/source-b/source-b_2_source.buildinfo')
+$(ofa 'pool/main/s/source-b/source-b_2.dsc')
+$(ofa 'pool/main/s/source-b/source-b_2.tar.gz')
+$(opa 'source-b' '2' 'test' 'main' 'source' 'dsc')
+EOF
+
+testrun - include test source-c_3_full.changes 3<<EOF
+stderr
+stdout
+$(ofa 'pool/main/s/source-c/source-c_3_abacus.buildinfo')
+$(ofa 'pool/main/s/source-c/source-c_3.dsc')
+$(ofa 'pool/main/s/source-c/source-c_3.tar.gz')
+$(ofa 'pool/main/s/source-c/somearch_3_abacus.deb')
+$(ofa 'pool/main/s/source-c/someindep_3_all.deb')
+$(opa 'source-c' '3' 'test' 'main' 'source' 'dsc')
+$(opa 'somearch' '3' 'test' 'main' 'abacus' 'deb')
+$(opa 'someindep' '3' 'test' 'main' 'abacus' 'deb')
+$(ota 'test' 'source-c')
+EOF
+rm -r pool db
+
+mkdir -p pool/main/s/source-a pool/main/s/source-b pool/main/s/source-c
+mkdir i j tmp
+mv source-?_* *.deb j/
+cp j/* i/
+cat > conf/incoming <<EOF
+Name: foo
+IncomingDir: i
+TempDir: tmp
+Default: test
+EOF
+
+# avoid problems with the order of files:
+rm './i/source-b_2_source.changes'
+rm './i/source-a_1_source.changes'
+
+echo check to process all .changes at the same time with tracking:
+testrun - processincoming foo 3<<EOF
+stderr
+stdout
+$(odb)
+$(ofa 'pool/main/s/source-a/source-a_1_all.buildinfo')
+$(ofa 'pool/main/s/source-a/onlyall_1_all.deb')
+$(opa 'onlyall' '1' 'test' 'main' 'abacus' 'deb')
+$(ofa 'pool/main/s/source-a/source-a_1_source.buildinfo')
+$(ofa 'pool/main/s/source-a/source-a_1.dsc')
+$(ofa 'pool/main/s/source-a/source-a_1.tar.gz')
+$(opa 'source-a' '1' 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'source-a')
+$(ofa 'pool/main/s/source-b/source-b_2_abacus.buildinfo')
+$(ofa 'pool/main/s/source-b/onlyany_2_abacus.deb')
+$(opa 'onlyany' '2' 'test' 'main' 'abacus' 'deb')
+$(ofa 'pool/main/s/source-b/source-b_2_source.buildinfo')
+$(ofa 'pool/main/s/source-b/source-b_2.dsc')
+$(ofa 'pool/main/s/source-b/source-b_2.tar.gz')
+$(opa 'source-b' '2' 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'source-b')
+$(ofa 'pool/main/s/source-c/source-c_3_abacus.buildinfo')
+$(ofa 'pool/main/s/source-c/source-c_3.dsc')
+$(ofa 'pool/main/s/source-c/source-c_3.tar.gz')
+$(ofa 'pool/main/s/source-c/somearch_3_abacus.deb')
+$(ofa 'pool/main/s/source-c/someindep_3_all.deb')
+$(opa 'source-c' '3' 'test' 'main' 'source' 'dsc')
+$(opa 'somearch' '3' 'test' 'main' 'abacus' 'deb')
+$(opa 'someindep' '3' 'test' 'main' 'abacus' 'deb')
+$(ota 'test' 'source-c')
+-v3*=deleting './i/onlyall_1_all.deb'...
+-v3*=deleting './i/onlyany_2_abacus.deb'...
+-v3*=deleting './i/somearch_3_abacus.deb'...
+-v3*=deleting './i/someindep_3_all.deb'...
+-v3*=deleting './i/source-a_1.dsc'...
+-v3*=deleting './i/source-a_1.tar.gz'...
+-v3*=deleting './i/source-a_1_all.buildinfo'...
+-v3*=deleting './i/source-a_1_binary.changes'...
+-v3*=deleting './i/source-a_1_source.buildinfo'...
+-v3*=deleting './i/source-a_1_sourceandbuild.changes'...
+-v3*=deleting './i/source-b_2.dsc'...
+-v3*=deleting './i/source-b_2.tar.gz'...
+-v3*=deleting './i/source-b_2_abacus.buildinfo'...
+-v3*=deleting './i/source-b_2_binary.changes'...
+-v3*=deleting './i/source-b_2_source.buildinfo'...
+-v3*=deleting './i/source-b_2_sourceandbuild.changes'...
+-v3*=deleting './i/source-c_3.dsc'...
+-v3*=deleting './i/source-c_3.tar.gz'...
+-v3*=deleting './i/source-c_3_abacus.buildinfo'...
+-v3*=deleting './i/source-c_3_full.changes'...
+EOF
+
+rm -r db pool
+mkdir -p pool/main/s/source-a pool/main/s/source-b pool/main/s/source-c
+
+cp j/* i/
+rm './i/source-b_2_source.changes'
+rm './i/source-a_1_source.changes'
+ed -s conf/distributions <<EOF
+g/^Tracking: /s/include[^ ]*//g
+w
+q
+EOF
+
+echo check to process all .changes at the same time without storing buildinfo:
+testrun - processincoming foo 3<<EOF
+stderr
+stdout
+$(odb)
+$(ofa 'pool/main/s/source-a/onlyall_1_all.deb')
+$(opa 'onlyall' '1' 'test' 'main' 'abacus' 'deb')
+$(ofa 'pool/main/s/source-a/source-a_1.dsc')
+$(ofa 'pool/main/s/source-a/source-a_1.tar.gz')
+$(opa 'source-a' '1' 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'source-a')
+$(ofa 'pool/main/s/source-b/onlyany_2_abacus.deb')
+$(opa 'onlyany' '2' 'test' 'main' 'abacus' 'deb')
+$(ofa 'pool/main/s/source-b/source-b_2.dsc')
+$(ofa 'pool/main/s/source-b/source-b_2.tar.gz')
+$(opa 'source-b' '2' 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'source-b')
+$(ofa 'pool/main/s/source-c/source-c_3.dsc')
+$(ofa 'pool/main/s/source-c/source-c_3.tar.gz')
+$(ofa 'pool/main/s/source-c/somearch_3_abacus.deb')
+$(ofa 'pool/main/s/source-c/someindep_3_all.deb')
+$(opa 'source-c' '3' 'test' 'main' 'source' 'dsc')
+$(opa 'somearch' '3' 'test' 'main' 'abacus' 'deb')
+$(opa 'someindep' '3' 'test' 'main' 'abacus' 'deb')
+$(ota 'test' 'source-c')
+-v3*=deleting './i/onlyall_1_all.deb'...
+-v3*=deleting './i/onlyany_2_abacus.deb'...
+-v3*=deleting './i/somearch_3_abacus.deb'...
+-v3*=deleting './i/someindep_3_all.deb'...
+-v3*=deleting './i/source-a_1.dsc'...
+-v3*=deleting './i/source-a_1.tar.gz'...
+-v3*=deleting './i/source-a_1_binary.changes'...
+-v3*=deleting './i/source-a_1_sourceandbuild.changes'...
+-v3*=deleting './i/source-b_2.dsc'...
+-v3*=deleting './i/source-b_2.tar.gz'...
+-v3*=deleting './i/source-b_2_binary.changes'...
+-v3*=deleting './i/source-b_2_sourceandbuild.changes'...
+-v3*=deleting './i/source-c_3.dsc'...
+-v3*=deleting './i/source-c_3.tar.gz'...
+-v3*=deleting './i/source-c_3_full.changes'...
+EOF
+
+echo check to process all .changes at the same time without storing buildinfo but deleting them:
+cat >> conf/incoming <<EOF
+Cleanup: unused_buildinfo_files
+EOF
+
+rm -r db pool
+mkdir -p pool/main/s/source-a pool/main/s/source-b pool/main/s/source-c
+
+rm -r i
+mkdir i
+cp j/* i/
+rm './i/source-b_2_source.changes'
+rm './i/source-a_1_source.changes'
+
+testrun - processincoming foo 3<<EOF
+stderr
+stdout
+$(odb)
+$(ofa 'pool/main/s/source-a/onlyall_1_all.deb')
+$(opa 'onlyall' '1' 'test' 'main' 'abacus' 'deb')
+$(ofa 'pool/main/s/source-a/source-a_1.dsc')
+$(ofa 'pool/main/s/source-a/source-a_1.tar.gz')
+$(opa 'source-a' '1' 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'source-a')
+$(ofa 'pool/main/s/source-b/onlyany_2_abacus.deb')
+$(opa 'onlyany' '2' 'test' 'main' 'abacus' 'deb')
+$(ofa 'pool/main/s/source-b/source-b_2.dsc')
+$(ofa 'pool/main/s/source-b/source-b_2.tar.gz')
+$(opa 'source-b' '2' 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'source-b')
+$(ofa 'pool/main/s/source-c/source-c_3.dsc')
+$(ofa 'pool/main/s/source-c/source-c_3.tar.gz')
+$(ofa 'pool/main/s/source-c/somearch_3_abacus.deb')
+$(ofa 'pool/main/s/source-c/someindep_3_all.deb')
+$(opa 'source-c' '3' 'test' 'main' 'source' 'dsc')
+$(opa 'somearch' '3' 'test' 'main' 'abacus' 'deb')
+$(opa 'someindep' '3' 'test' 'main' 'abacus' 'deb')
+$(ota 'test' 'source-c')
+-v3*=deleting './i/onlyall_1_all.deb'...
+-v3*=deleting './i/onlyany_2_abacus.deb'...
+-v3*=deleting './i/somearch_3_abacus.deb'...
+-v3*=deleting './i/someindep_3_all.deb'...
+-v3*=deleting './i/source-a_1.dsc'...
+-v3*=deleting './i/source-a_1.tar.gz'...
+-v3*=deleting './i/source-a_1_all.buildinfo'...
+-v3*=deleting './i/source-a_1_binary.changes'...
+-v3*=deleting './i/source-a_1_source.buildinfo'...
+-v3*=deleting './i/source-a_1_sourceandbuild.changes'...
+-v3*=deleting './i/source-b_2.dsc'...
+-v3*=deleting './i/source-b_2.tar.gz'...
+-v3*=deleting './i/source-b_2_abacus.buildinfo'...
+-v3*=deleting './i/source-b_2_binary.changes'...
+-v3*=deleting './i/source-b_2_source.buildinfo'...
+-v3*=deleting './i/source-b_2_sourceandbuild.changes'...
+-v3*=deleting './i/source-c_3.dsc'...
+-v3*=deleting './i/source-c_3.tar.gz'...
+-v3*=deleting './i/source-c_3_abacus.buildinfo'...
+-v3*=deleting './i/source-c_3_full.changes'...
+EOF
+
+echo Now check storing the .buildinfo files in a logdir:
+sed -e 's/^Cleanup:.*/LogDir: log/' -i conf/incoming
+mkdir log
+
+rm -r db pool
+mkdir -p pool/main/s/source-a pool/main/s/source-b pool/main/s/source-c
+
+rm -r i
+mkdir i
+cp j/* i/
+rm './i/source-b_2_source.changes'
+rm './i/source-a_1_source.changes'
+
+testrun - processincoming foo 3<<EOF
+stderr
+stdout
+$(odb)
+$(ofa 'pool/main/s/source-a/onlyall_1_all.deb')
+$(opa 'onlyall' '1' 'test' 'main' 'abacus' 'deb')
+$(ofa 'pool/main/s/source-a/source-a_1.dsc')
+$(ofa 'pool/main/s/source-a/source-a_1.tar.gz')
+$(opa 'source-a' '1' 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'source-a')
+$(ofa 'pool/main/s/source-b/onlyany_2_abacus.deb')
+$(opa 'onlyany' '2' 'test' 'main' 'abacus' 'deb')
+$(ofa 'pool/main/s/source-b/source-b_2.dsc')
+$(ofa 'pool/main/s/source-b/source-b_2.tar.gz')
+$(opa 'source-b' '2' 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'source-b')
+$(ofa 'pool/main/s/source-c/source-c_3.dsc')
+$(ofa 'pool/main/s/source-c/source-c_3.tar.gz')
+$(ofa 'pool/main/s/source-c/somearch_3_abacus.deb')
+$(ofa 'pool/main/s/source-c/someindep_3_all.deb')
+$(opa 'source-c' '3' 'test' 'main' 'source' 'dsc')
+$(opa 'somearch' '3' 'test' 'main' 'abacus' 'deb')
+$(opa 'someindep' '3' 'test' 'main' 'abacus' 'deb')
+$(ota 'test' 'source-c')
+-v2*=Created directory "./log/source-c_3_source+abacus+all.0000000"
+-v2*=Created directory "./log/source-b_2_source.0000000"
+-v2*=Created directory "./log/source-b_2_abacus.0000000"
+-v2*=Created directory "./log/source-a_1_all.0000000"
+-v2*=Created directory "./log/source-a_1_source.0000000"
+-v3*=deleting './i/onlyall_1_all.deb'...
+-v3*=deleting './i/onlyany_2_abacus.deb'...
+-v3*=deleting './i/somearch_3_abacus.deb'...
+-v3*=deleting './i/someindep_3_all.deb'...
+-v3*=deleting './i/source-a_1.dsc'...
+-v3*=deleting './i/source-a_1.tar.gz'...
+-v3*=deleting './i/source-a_1_all.buildinfo'...
+-v3*=deleting './i/source-a_1_binary.changes'...
+-v3*=deleting './i/source-a_1_source.buildinfo'...
+-v3*=deleting './i/source-a_1_sourceandbuild.changes'...
+-v3*=deleting './i/source-b_2.dsc'...
+-v3*=deleting './i/source-b_2.tar.gz'...
+-v3*=deleting './i/source-b_2_abacus.buildinfo'...
+-v3*=deleting './i/source-b_2_binary.changes'...
+-v3*=deleting './i/source-b_2_source.buildinfo'...
+-v3*=deleting './i/source-b_2_sourceandbuild.changes'...
+-v3*=deleting './i/source-c_3.dsc'...
+-v3*=deleting './i/source-c_3.tar.gz'...
+-v3*=deleting './i/source-c_3_abacus.buildinfo'...
+-v3*=deleting './i/source-c_3_full.changes'...
+EOF
+
+dodiff log/source-a_1_all.0000000/source-a_1_all.buildinfo j/source-a_1_all.buildinfo
+dodiff log/source-a_1_source.0000000/source-a_1_source.buildinfo j/source-a_1_source.buildinfo
+dodiff log/source-b_2_abacus.0000000/source-b_2_abacus.buildinfo j/source-b_2_abacus.buildinfo
+dodiff log/source-b_2_source.0000000/source-b_2_source.buildinfo j/source-b_2_source.buildinfo
+dodiff log/source-c_3_source+abacus+all.0000000/source-c_3_abacus.buildinfo j/source-c_3_abacus.buildinfo
+
+testsuccess
diff --git a/tests/buildneeding.test b/tests/buildneeding.test
new file mode 100644
index 0000000..4d0b587
--- /dev/null
+++ b/tests/buildneeding.test
@@ -0,0 +1,631 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+mkdir conf
+mkdir package-1.0
+mkdir package-1.0/debian
+cat >package-1.0/debian/control <<END
+Source: package
+Section: sound
+Priority: extra
+Maintainer: me <me@example.org>
+Standards-Version: 0.0
+
+Package: rumsrumsrums
+Architecture: all
+Description: a package
+ .
+
+Package: dumdidum
+Architecture: another
+Description: a package not build
+ .
+
+Package: troettroet
+Architecture: abacus
+Description: some test-package
+ .
+END
+cat >package-1.0/debian/changelog <<END
+package (1.0-1) test; urgency=critical
+
+ * first version
+
+ -- me <me@example.orgguess@who> Mon, 01 Jan 1980 01:02:02 +0000
+END
+
+dpkg-source -b package-1.0
+
+cat > conf/distributions <<EOF
+Codename: bla
+Suite: test
+Components: main
+Architectures: source abacus another
+Tracking: all
+
+Codename: blub
+Components: main
+Architectures: notinbla
+
+Codename: oses
+Components: main
+Architectures: source abacus kfreebsd-abacus hurd-abacus
+Tracking: all
+EOF
+cat >> conf/options <<EOF
+export silent-never
+EOF
+
+# to get databases:
+testrun - rereference 3<<EOF
+stdout
+$(odb)
+-v1*=Referencing oses...
+-v3*=Unlocking dependencies of oses|main|abacus...
+-v3*=Referencing oses|main|abacus...
+-v2=Rereferencing oses|main|abacus...
+-v3*=Unlocking dependencies of oses|main|kfreebsd-abacus...
+-v3*=Referencing oses|main|kfreebsd-abacus...
+-v2=Rereferencing oses|main|kfreebsd-abacus...
+-v3*=Unlocking dependencies of oses|main|hurd-abacus...
+-v3*=Referencing oses|main|hurd-abacus...
+-v2=Rereferencing oses|main|hurd-abacus...
+-v3*=Unlocking dependencies of oses|main|source...
+-v3*=Referencing oses|main|source...
+-v2=Rereferencing oses|main|source...
+-v1*=Referencing bla...
+-v3*=Unlocking dependencies of bla|main|abacus...
+-v3*=Referencing bla|main|abacus...
+-v2=Rereferencing bla|main|abacus...
+-v3*=Unlocking dependencies of bla|main|another...
+-v3*=Referencing bla|main|another...
+-v2=Rereferencing bla|main|another...
+-v3*=Unlocking dependencies of bla|main|source...
+-v3*=Referencing bla|main|source...
+-v2=Rereferencing bla|main|source...
+-v1*=Referencing blub...
+-v3*=Unlocking dependencies of blub|main|notinbla...
+-v3*=Referencing blub|main|notinbla...
+-v2=Rereferencing blub|main|notinbla...
+EOF
+
+testrun empty build-needing test abacus
+testrun empty build-needing test all
+testrun empty build-needing test any
+
+testrun - includedsc test package_1.0-1.dsc 3<<EOF
+stderr
+-v1*=package_1.0-1.dsc: component guessed as 'main'
+stdout
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/p"
+-v2*=Created directory "./pool/main/p/package"
+$(ofa 'pool/main/p/package/package_1.0-1.dsc')
+$(ofa 'pool/main/p/package/package_1.0-1.tar.gz')
+$(opa 'package' '1.0-1' 'bla' 'main' 'source' 'dsc')
+$(ota 'bla' 'package')
+EOF
+rm package_1.0*
+
+testrun - build-needing test another 3<<EOF
+stdout
+*=package 1.0-1 pool/main/p/package/package_1.0-1.dsc
+EOF
+testrun - build-needing test abacus 3<<EOF
+stdout
+*=package 1.0-1 pool/main/p/package/package_1.0-1.dsc
+EOF
+testrun - build-needing test all 3<<EOF
+stdout
+*=package 1.0-1 pool/main/p/package/package_1.0-1.dsc
+EOF
+testrun - build-needing test any 3<<EOF
+stdout
+*=package 1.0-1 pool/main/p/package/package_1.0-1.dsc all
+*=package 1.0-1 pool/main/p/package/package_1.0-1.dsc another
+*=package 1.0-1 pool/main/p/package/package_1.0-1.dsc abacus
+EOF
+testrun - build-needing test source 3<<EOF
+stderr
+*=Error: Architecture 'source' makes no sense for build-needing!
+-v0*=There have been errors!
+returns 255
+EOF
+testrun - build-needing test mistake 3<<EOF
+stderr
+*=Error: Architecture 'mistake' is not known!
+-v0*=There have been errors!
+returns 255
+EOF
+testrun - build-needing test notinbla 3<<EOF
+stderr
+*=Error: Architecture 'notinbla' not found in distribution 'bla'!
+-v0*=There have been errors!
+returns 255
+EOF
+
+mkdir package-1.0/debian/tmp
+mkdir package-1.0/debian/tmp/DEBIAN
+mkdir -p package-1.0/debian/tmp/usr/share/sounds
+touch package-1.0/debian/tmp/usr/share/sounds/krach.wav
+cd package-1.0
+dpkg-gencontrol -prumsrumsrums
+dpkg --build debian/tmp ..
+cd ..
+
+testrun - -C main includedeb test rumsrumsrums_1.0-1_all.deb 3<<EOF
+stderr
+stdout
+$(ofa 'pool/main/p/package/rumsrumsrums_1.0-1_all.deb')
+$(opa 'rumsrumsrums' '1.0-1' 'bla' 'main' 'abacus' 'deb')
+$(opa 'rumsrumsrums' x 'bla' 'main' 'another' 'deb')
+EOF
+
+testrun - build-needing test another 3<<EOF
+stdout
+*=package 1.0-1 pool/main/p/package/package_1.0-1.dsc
+EOF
+testrun - build-needing test abacus 3<<EOF
+stdout
+*=package 1.0-1 pool/main/p/package/package_1.0-1.dsc
+EOF
+testrun - build-needing test any 3<<EOF
+stdout
+*=package 1.0-1 pool/main/p/package/package_1.0-1.dsc another
+*=package 1.0-1 pool/main/p/package/package_1.0-1.dsc abacus
+EOF
+testrun empty build-needing test all
+
+cd package-1.0
+dpkg-gencontrol -ptroettroet
+dpkg --build debian/tmp ..
+cd ..
+
+testrun - -C main includedeb test troettroet_1.0-1_abacus.deb 3<<EOF
+stderr
+stdout
+$(ofa 'pool/main/p/package/troettroet_1.0-1_abacus.deb')
+$(opa 'troettroet' x 'bla' 'main' 'abacus' 'deb')
+EOF
+
+testrun - build-needing test another 3<<EOF
+stdout
+*=package 1.0-1 pool/main/p/package/package_1.0-1.dsc
+EOF
+testrun - build-needing test abacus 3<<EOF
+stdout
+EOF
+
+# Include a fake .log file to tell reprepro that architecture is done:
+
+echo "There was nothing to do on this architecture!" > package_1.0-1_another.log
+echo "package_1.0-1_another.log - -" > package-1.0/debian/files
+cd package-1.0
+dpkg-genchanges -B > ../package_1.0-1_another.changes
+cd ..
+
+# work around dpkg-dev 1.18.15+ no longer adding Architectures of log files:
+if ! grep -q -s '^Architecture:' package_1.0-1_another.changes ; then
+ sed -e 's/^Version:/Architecture: another\n&/' -i package_1.0-1_another.changes
+fi
+
+testrun - -C main include test package_1.0-1_another.changes 3<<EOF
+stderr
+*=Ignoring log file: 'package_1.0-1_another.log'!
+*=package_1.0-1_another.changes: Not enough files in .changes!
+-v0*=There have been errors!
+returns 255
+EOF
+
+sed -i -e 's/Tracking: all/Tracking: all includelogs/' conf/distributions
+
+testrun - -C main include test package_1.0-1_another.changes 3<<EOF
+stderr
+stdout
+$(ofa 'pool/main/p/package/package_1.0-1_another.log')
+EOF
+
+testrun empty build-needing test another
+testrun empty build-needing test abacus
+
+# TODO: add a new version of that package...
+rm -r package-1.0
+
+mkdir onlyonearch-1.0
+mkdir onlyonearch-1.0/debian
+cat >onlyonearch-1.0/debian/control <<END
+Source: onlyonearch
+Section: something
+Priority: extra
+Maintainer: me <me@example.org>
+Standards-Version: 0.0
+
+Package: onearch
+Architecture: abacus
+Description: some test-onlyonearch
+ .
+END
+cat >onlyonearch-1.0/debian/changelog <<END
+onlyonearch (1.0-1) test; urgency=critical
+
+ * first version
+
+ -- me <me@example.orgguess@who> Mon, 01 Jan 1980 01:02:02 +0000
+END
+dpkg-source -b onlyonearch-1.0
+mkdir onlyonearch-1.0/debian/tmp
+mkdir onlyonearch-1.0/debian/tmp/DEBIAN
+mkdir -p onlyonearch-1.0/debian/tmp/usr/bin
+touch onlyonearch-1.0/debian/tmp/usr/bin/program
+cd onlyonearch-1.0
+dpkg-gencontrol -ponearch
+dpkg --build debian/tmp ..
+cd ..
+rm -r onlyonearch-1.0
+
+testrun - --delete includedsc test onlyonearch_1.0-1.dsc 3<<EOF
+stderr
+-v1*=onlyonearch_1.0-1.dsc: component guessed as 'main'
+stdout
+-v2*=Created directory "./pool/main/o"
+-v2*=Created directory "./pool/main/o/onlyonearch"
+$(ofa 'pool/main/o/onlyonearch/onlyonearch_1.0-1.dsc')
+$(ofa 'pool/main/o/onlyonearch/onlyonearch_1.0-1.tar.gz')
+$(opa 'onlyonearch' x 'bla' 'main' 'source' 'dsc')
+$(ota 'bla' 'onlyonearch')
+EOF
+
+testrun empty build-needing test another
+testrun empty build-needing test all
+testrun - build-needing test abacus 3<<EOF
+stdout
+*=onlyonearch 1.0-1 pool/main/o/onlyonearch/onlyonearch_1.0-1.dsc
+EOF
+
+testrun - build-needing test any 3<<EOF
+stdout
+*=onlyonearch 1.0-1 pool/main/o/onlyonearch/onlyonearch_1.0-1.dsc abacus
+EOF
+
+testrun - --delete -C main includedeb test onearch_1.0-1_abacus.deb 3<<EOF
+stderr
+stdout
+$(ofa 'pool/main/o/onlyonearch/onearch_1.0-1_abacus.deb')
+$(opa 'onearch' x 'bla' 'main' 'abacus' 'deb')
+EOF
+
+testrun empty build-needing test another
+testrun empty build-needing test abacus
+testrun empty build-needing test all
+testrun empty build-needing test any
+
+mkdir onlyarchall-1.0
+mkdir onlyarchall-1.0/debian
+cat >onlyarchall-1.0/debian/control <<END
+Source: onlyarchall
+Section: something
+Priority: extra
+Maintainer: me <me@example.org>
+Standards-Version: 0.0
+
+Package: archall
+Architecture: all
+Description: some test-arch all package
+ .
+END
+cat >onlyarchall-1.0/debian/changelog <<END
+onlyarchall (1.0-1) test; urgency=critical
+
+ * first version
+
+ -- me <me@example.orgguess@who> Mon, 01 Jan 1980 01:02:02 +0000
+END
+dpkg-source -b onlyarchall-1.0
+mkdir onlyarchall-1.0/debian/tmp
+mkdir onlyarchall-1.0/debian/tmp/DEBIAN
+mkdir -p onlyarchall-1.0/debian/tmp/usr/bin
+touch onlyarchall-1.0/debian/tmp/usr/bin/program
+cd onlyarchall-1.0
+dpkg-gencontrol -parchall
+dpkg --build debian/tmp ..
+cd ..
+rm -r onlyarchall-1.0
+
+testrun - --delete includedsc test onlyarchall_1.0-1.dsc 3<<EOF
+stderr
+-v1*=onlyarchall_1.0-1.dsc: component guessed as 'main'
+stdout
+-v2*=Created directory "./pool/main/o/onlyarchall"
+$(ofa 'pool/main/o/onlyarchall/onlyarchall_1.0-1.dsc')
+$(ofa 'pool/main/o/onlyarchall/onlyarchall_1.0-1.tar.gz')
+$(opa 'onlyarchall' x 'bla' 'main' 'source' 'dsc')
+$(ota 'bla' 'onlyarchall')
+EOF
+
+testrun empty build-needing test another
+testrun empty build-needing test abacus
+testrun - build-needing test all 3<<EOF
+stdout
+*=onlyarchall 1.0-1 pool/main/o/onlyarchall/onlyarchall_1.0-1.dsc
+EOF
+testrun - build-needing test any 3<<EOF
+stdout
+*=onlyarchall 1.0-1 pool/main/o/onlyarchall/onlyarchall_1.0-1.dsc all
+EOF
+
+testrun - --delete -C main includedeb test archall_1.0-1_all.deb 3<<EOF
+stderr
+stdout
+$(ofa 'pool/main/o/onlyarchall/archall_1.0-1_all.deb')
+$(opa 'archall' x 'bla' 'main' 'abacus' 'deb')
+$(opa 'archall' x 'bla' 'main' 'another' 'deb')
+EOF
+
+testrun empty build-needing test another
+testrun empty build-needing test abacus
+testrun empty build-needing test any
+
+mkdir allandany-1.0
+mkdir allandany-1.0/debian
+cat >allandany-1.0/debian/control <<END
+Source: allandany
+Section: something
+Priority: extra
+Maintainer: me <me@example.org>
+Standards-Version: 0.0
+
+Package: allpart
+Architecture: all
+Description: some test-arch all package
+ .
+
+Package: anypart
+Architecture: any
+Description: some test-arch any package
+ .
+END
+cat >allandany-1.0/debian/changelog <<END
+allandany (1.0-1) test; urgency=critical
+
+ * first version
+
+ -- me <me@example.org> Mon, 01 Jan 1980 01:02:02 +0000
+END
+dpkg-source -b allandany-1.0
+mkdir allandany-1.0/debian/tmp
+mkdir allandany-1.0/debian/tmp/DEBIAN
+mkdir -p allandany-1.0/debian/tmp/usr/bin
+touch allandany-1.0/debian/tmp/usr/bin/program
+cd allandany-1.0
+dpkg-gencontrol -panypart
+dpkg --build debian/tmp ..
+cd ..
+rm -r allandany-1.0/debian/tmp
+mkdir allandany-1.0/debian/tmp
+mkdir allandany-1.0/debian/tmp/DEBIAN
+mkdir -p allandany-1.0/debian/tmp/usr/share
+touch allandany-1.0/debian/tmp/usr/share/data
+cd allandany-1.0
+dpkg-gencontrol -pallpart
+dpkg --build debian/tmp ..
+cd ..
+echo "There was nothing to do on this architecture!" > allandany_1.0-1_another.log
+echo "allandany_1.0-1_another.log - -" > allandany-1.0/debian/files
+cd allandany-1.0
+dpkg-genchanges -B > ../allandany_1.0-1_another.changes
+cd ..
+rm -r allandany-1.0
+
+# work around dpkg-dev 1.18.15+ no longer adding Architectures of log files:
+if ! grep -q -s '^Architecture:' allandany_1.0-1_another.changes ; then
+ sed -e 's/^Version:/Architecture: another\n&/' -i allandany_1.0-1_another.changes
+fi
+
+testrun - --delete includedsc test allandany_1.0-1.dsc 3<<EOF
+stderr
+-v1*=allandany_1.0-1.dsc: component guessed as 'main'
+stdout
+-v2*=Created directory "./pool/main/a"
+-v2*=Created directory "./pool/main/a/allandany"
+$(ofa 'pool/main/a/allandany/allandany_1.0-1.dsc')
+$(ofa 'pool/main/a/allandany/allandany_1.0-1.tar.gz')
+$(opa 'allandany' x 'bla' 'main' 'source' 'dsc')
+$(ota 'bla' 'allandany')
+EOF
+
+testrun - build-needing test another 3<<EOF
+stdout
+*=allandany 1.0-1 pool/main/a/allandany/allandany_1.0-1.dsc
+EOF
+testrun - build-needing test abacus 3<<EOF
+stdout
+*=allandany 1.0-1 pool/main/a/allandany/allandany_1.0-1.dsc
+EOF
+testrun - build-needing test all 3<<EOF
+stdout
+*=allandany 1.0-1 pool/main/a/allandany/allandany_1.0-1.dsc
+EOF
+testrun - build-needing test any 3<<EOF
+stdout
+*=allandany 1.0-1 pool/main/a/allandany/allandany_1.0-1.dsc abacus
+*=allandany 1.0-1 pool/main/a/allandany/allandany_1.0-1.dsc another
+*=allandany 1.0-1 pool/main/a/allandany/allandany_1.0-1.dsc all
+EOF
+
+testrun - --delete -C main includedeb test anypart_1.0-1_abacus.deb 3<<EOF
+stderr
+stdout
+$(ofa 'pool/main/a/allandany/anypart_1.0-1_abacus.deb')
+$(opa 'anypart' x 'bla' 'main' 'abacus' 'deb')
+EOF
+
+testrun empty build-needing test abacus
+testrun - build-needing test all 3<<EOF
+stdout
+*=allandany 1.0-1 pool/main/a/allandany/allandany_1.0-1.dsc
+EOF
+testrun - build-needing test any 3<<EOF
+stdout
+*=allandany 1.0-1 pool/main/a/allandany/allandany_1.0-1.dsc another
+*=allandany 1.0-1 pool/main/a/allandany/allandany_1.0-1.dsc all
+EOF
+
+testrun - --delete -C main includedeb test allpart_1.0-1_all.deb 3<<EOF
+stderr
+stdout
+$(ofa 'pool/main/a/allandany/allpart_1.0-1_all.deb')
+$(opa 'allpart' x 'bla' 'main' 'abacus' 'deb')
+$(opa 'allpart' x 'bla' 'main' 'another' 'deb')
+EOF
+
+testrun empty build-needing test abacus
+testrun empty build-needing test all
+testrun - build-needing test any 3<<EOF
+stdout
+*=allandany 1.0-1 pool/main/a/allandany/allandany_1.0-1.dsc another
+EOF
+
+testrun - -C main include test allandany_1.0-1_another.changes 3<<EOF
+stderr
+stdout
+$(ofa 'pool/main/a/allandany/allandany_1.0-1_another.log')
+EOF
+
+testrun empty build-needing test any
+
+mkdir anyonly-1.0
+mkdir anyonly-1.0/debian
+cat >anyonly-1.0/debian/control <<END
+Source: anyonly
+Section: something
+Priority: extra
+Maintainer: me <me@example.org>
+Standards-Version: 0.0
+
+Package: anyonly
+Architecture: any
+Description: some test-arch any package
+ .
+END
+cat >anyonly-1.0/debian/changelog <<END
+anyonly (1.0-1) test; urgency=critical
+
+ * first version
+
+ -- me <me@example.org> Mon, 01 Jan 1980 01:02:02 +0000
+END
+dpkg-source -b anyonly-1.0
+mkdir anyonly-1.0/debian/tmp
+mkdir anyonly-1.0/debian/tmp/DEBIAN
+mkdir -p anyonly-1.0/debian/tmp/usr/bin
+touch anyonly-1.0/debian/tmp/usr/bin/program
+cd anyonly-1.0
+dpkg-gencontrol -panyonly
+dpkg --build debian/tmp ..
+cd ..
+rm -r anyonly-1.0
+
+testrun - --delete includedsc test anyonly_1.0-1.dsc 3<<EOF
+stderr
+-v1*=anyonly_1.0-1.dsc: component guessed as 'main'
+stdout
+-v2*=Created directory "./pool/main/a/anyonly"
+$(ofa 'pool/main/a/anyonly/anyonly_1.0-1.dsc')
+$(ofa 'pool/main/a/anyonly/anyonly_1.0-1.tar.gz')
+$(opa 'anyonly' x 'bla' 'main' 'source' 'dsc')
+$(ota 'bla' 'anyonly')
+EOF
+
+testrun empty build-needing test all
+testrun - build-needing test any 3<<EOF
+stdout
+*=anyonly 1.0-1 pool/main/a/anyonly/anyonly_1.0-1.dsc another
+*=anyonly 1.0-1 pool/main/a/anyonly/anyonly_1.0-1.dsc abacus
+EOF
+
+mkdir linuxwildcard-1.0
+mkdir linuxwildcard-1.0/debian
+cat >linuxwildcard-1.0/debian/control <<END
+Source: linuxwildcard
+Section: something
+Priority: extra
+Maintainer: me <me@example.org>
+Standards-Version: 0.0
+
+Package: linuxwildcard
+Architecture: linux-any
+Description: some test-arch any package
+ .
+END
+cat >linuxwildcard-1.0/debian/changelog <<END
+linuxwildcard (1.0-1) test; urgency=critical
+
+ * first version
+
+ -- me <me@example.org> Mon, 01 Jan 1980 01:02:02 +0000
+END
+dpkg-source -b linuxwildcard-1.0
+rm -r linuxwildcard-1.0
+
+mkdir kfreebsdwildcard-1.0
+mkdir kfreebsdwildcard-1.0/debian
+cat >kfreebsdwildcard-1.0/debian/control <<END
+Source: kfreebsdwildcard
+Section: something
+Priority: extra
+Maintainer: me <me@example.org>
+Standards-Version: 0.0
+
+Package: kfreebsdwildcard
+Architecture: kfreebsd-any
+Description: some test-arch any package
+ .
+END
+cat >kfreebsdwildcard-1.0/debian/changelog <<END
+kfreebsdwildcard (1.0-1) test; urgency=critical
+
+ * first version
+
+ -- me <me@example.org> Mon, 01 Jan 1980 01:02:02 +0000
+END
+dpkg-source -b kfreebsdwildcard-1.0
+rm -r kfreebsdwildcard-1.0
+
+testrun - includedsc oses linuxwildcard_1.0-1.dsc 3<<EOF
+stderr
+-v1*=linuxwildcard_1.0-1.dsc: component guessed as 'main'
+stdout
+-v2*=Created directory "./pool/main/l"
+-v2*=Created directory "./pool/main/l/linuxwildcard"
+$(ofa 'pool/main/l/linuxwildcard/linuxwildcard_1.0-1.dsc')
+$(ofa 'pool/main/l/linuxwildcard/linuxwildcard_1.0-1.tar.gz')
+$(opa 'linuxwildcard' x 'oses' 'main' 'source' 'dsc')
+$(ota 'oses' 'linuxwildcard')
+EOF
+
+testrun - includedsc oses kfreebsdwildcard_1.0-1.dsc 3<<EOF
+stderr
+-v1*=kfreebsdwildcard_1.0-1.dsc: component guessed as 'main'
+stdout
+-v2*=Created directory "./pool/main/k"
+-v2*=Created directory "./pool/main/k/kfreebsdwildcard"
+$(ofa 'pool/main/k/kfreebsdwildcard/kfreebsdwildcard_1.0-1.dsc')
+$(ofa 'pool/main/k/kfreebsdwildcard/kfreebsdwildcard_1.0-1.tar.gz')
+$(opa 'kfreebsdwildcard' x 'oses' 'main' 'source' 'dsc')
+$(ota 'oses' 'kfreebsdwildcard')
+EOF
+
+testrun empty build-needing oses all
+testrun empty build-needing oses hurd-abacus
+testrun - build-needing oses abacus 3<<EOF
+stdout
+*=linuxwildcard 1.0-1 pool/main/l/linuxwildcard/linuxwildcard_1.0-1.dsc
+EOF
+testrun - build-needing oses kfreebsd-abacus 3<<EOF
+stdout
+*=kfreebsdwildcard 1.0-1 pool/main/k/kfreebsdwildcard/kfreebsdwildcard_1.0-1.dsc
+EOF
+
+rm -r pool conf db *.deb *.log *.changes
+testsuccess
diff --git a/tests/check.test b/tests/check.test
new file mode 100644
index 0000000..b9d160a
--- /dev/null
+++ b/tests/check.test
@@ -0,0 +1,225 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+dodo test ! -d db
+mkdir -p conf db pool
+cat > conf/distributions <<EOF
+Codename: n
+Components: c
+Architectures: a
+EOF
+cat > conf/options <<EOF
+export silent-never
+EOF
+
+echo "fake-deb1" > fake1.deb
+echo "fake-deb2" > fake2.deb
+echo "fake-deb3" > fake3.deb
+
+fakedeb1md="$(md5 fake1.deb)"
+fakedeb2md="$(md5 fake2.deb)"
+fakedeb3md="$(md5 fake3.deb)"
+fakedeb1sha1="$(sha1 fake1.deb)"
+fakedeb2sha1="$(sha1 fake2.deb)"
+fakedeb3sha1="$(sha1 fake3.deb)"
+fakedeb1sha2="$(sha256 fake1.deb)"
+fakedeb2sha2="$(sha256 fake2.deb)"
+fakedeb3sha2="$(sha256 fake3.deb)"
+fakesize=10
+
+cat > fakeindex <<EOF
+Package: fake
+Version: 0
+Source: pseudo (9999)
+Architecture: all
+Filename: pool/c/p/pseudo/fake_0_all.deb
+Section: base
+Priority: extra
+Description: test
+ test
+Size: $fakesize
+MD5Sum: $fakedeb1md
+EOF
+
+testrun - -b . -C c -A a -T deb _addpackage n fakeindex fake 3<<EOF
+returns 249
+stderr
+*=Error: package fake version 0 lists file pool/c/p/pseudo/fake_0_all.deb not yet in the pool!
+-v0*=There have been errors!
+stdout
+EOF
+
+mkdir -p pool/c/p/pseudo
+cp fake2.deb pool/c/p/pseudo/fake_0_all.deb
+
+testrun - -b . _detect pool/c/p/pseudo/fake_0_all.deb 3<<EOF
+stderr
+stdout
+$(ofa 'pool/c/p/pseudo/fake_0_all.deb')
+-v0*=1 files were added but not used.
+-v0*=The next deleteunreferenced call will delete them.
+EOF
+
+testrun - -b . -C c -A a -T deb _addpackage n fakeindex fake 3<<EOF
+returns 254
+stderr
+*=File "pool/c/p/pseudo/fake_0_all.deb" is already registered with different checksums!
+*=md5 expected: $fakedeb2md, got: $fakedeb1md
+*=Error: package fake version 0 lists different checksums than in the pool!
+-v0*=There have been errors!
+stdout
+EOF
+
+testrun - -b . _forget pool/c/p/pseudo/fake_0_all.deb 3<<EOF
+stderr
+stdout
+$(ofd 'pool/c/p/pseudo/fake_0_all.deb' false)
+EOF
+
+cp fake1.deb pool/c/p/pseudo/fake_0_all.deb
+
+testrun - -b . _detect pool/c/p/pseudo/fake_0_all.deb 3<<EOF
+stderr
+stdout
+$(ofa 'pool/c/p/pseudo/fake_0_all.deb')
+-v0*=1 files were added but not used.
+-v0*=The next deleteunreferenced call will delete them.
+EOF
+
+testrun - -b . -C c -A a -T deb _addpackage n fakeindex fake 3<<EOF
+stdout
+$(opa 'fake' '0' 'n' 'c' 'a' 'deb')
+-v1*=Adding 'fake' '0' to 'n|c|a'.
+EOF
+
+testrun - -b . checkpool 3<<EOF
+stderr
+stdout
+EOF
+
+testrun - -b . check 3<<EOF
+stderr
+stdout
+-v1*=Checking n...
+EOF
+
+cp fake3.deb pool/c/p/pseudo/fake_0_all.deb
+
+testrun - -b . check 3<<EOF
+stderr
+stdout
+-v1*=Checking n...
+EOF
+
+testrun - -b . checkpool 3<<EOF
+return 254
+stderr
+*=WRONG CHECKSUMS of './pool/c/p/pseudo/fake_0_all.deb':
+*=md5 expected: $fakedeb1md, got: $fakedeb3md
+*=sha1 expected: $fakedeb1sha1, got: $fakedeb3sha1
+*=sha256 expected: $fakedeb1sha2, got: $fakedeb3sha2
+-v0*=There have been errors!
+stdout
+EOF
+
+testrun - -b . _forget pool/c/p/pseudo/fake_0_all.deb 3<<EOF
+stderr
+stdout
+$(ofd 'pool/c/p/pseudo/fake_0_all.deb' false)
+EOF
+
+testrun - -b . _detect pool/c/p/pseudo/fake_0_all.deb 3<<EOF
+stderr
+stdout
+$(ofa 'pool/c/p/pseudo/fake_0_all.deb')
+EOF
+
+testrun - -b . checkpool 3<<EOF
+stderr
+stdout
+EOF
+
+testrun - -b . check 3<<EOF
+stdout
+-v1*=Checking n...
+stderr
+*=File "pool/c/p/pseudo/fake_0_all.deb" is already registered with different checksums!
+*=md5 expected: $fakedeb3md, got: $fakedeb1md
+*=Files are missing for 'fake'!
+-v0*=There have been errors!
+returns 254
+EOF
+
+testrun - -b . _forget pool/c/p/pseudo/fake_0_all.deb 3<<EOF
+stderr
+stdout
+$(ofd 'pool/c/p/pseudo/fake_0_all.deb' false)
+EOF
+
+# Correct size but wrong checksum:
+testrun - -b . check 3<<EOF
+stdout
+-v1*=Checking n...
+stderr
+*=Deleting unexpected file './pool/c/p/pseudo/fake_0_all.deb'!
+*=(not in database and wrong in pool)
+*= Missing file pool/c/p/pseudo/fake_0_all.deb
+*=Files are missing for 'fake'!
+-v0*=There have been errors!
+returns 249
+EOF
+# Wrong size:
+echo "Tooo long......" > pool/c/p/pseudo/fake_0_all.deb
+testrun - -b . check 3<<EOF
+stdout
+-v1*=Checking n...
+stderr
+*=Deleting unexpected file './pool/c/p/pseudo/fake_0_all.deb'!
+*=(not in database and wrong in pool)
+*= Missing file pool/c/p/pseudo/fake_0_all.deb
+*=Files are missing for 'fake'!
+-v0*=There have been errors!
+returns 249
+EOF
+
+cp fake1.deb pool/c/p/pseudo/fake_0_all.deb
+
+testrun - -b . check 3<<EOF
+stderr
+-v0*=Warning: readded existing file 'pool/c/p/pseudo/fake_0_all.deb' mysteriously missing from the checksum database.
+stdout
+-v1*=Checking n...
+$(ofa 'pool/c/p/pseudo/fake_0_all.deb')
+stderr
+EOF
+
+testout - -b . _dumpcontents 'n|c|a' 3<<EOF
+EOF
+
+cat >results.expected << EOF
+'fake' -> 'Package: fake
+Version: 0
+Source: pseudo (9999)
+Architecture: all
+Filename: pool/c/p/pseudo/fake_0_all.deb
+Section: base
+Priority: extra
+Description: test
+ test
+Size: $fakesize
+MD5Sum: $fakedeb1md
+'
+EOF
+dodiff results.expected results
+cat results
+
+testrun - -b . _listchecksums 3<<EOF
+stdout
+*=pool/c/p/pseudo/fake_0_all.deb :1:$fakedeb1sha1 :2:$fakedeb1sha2 $fakedeb1md $fakesize
+stderr
+EOF
+
+dodo test ! -e dists
+
+rm -r -f db conf pool fake*.deb fakeindex
+testsuccess
diff --git a/tests/copy.test b/tests/copy.test
new file mode 100644
index 0000000..73908b6
--- /dev/null
+++ b/tests/copy.test
@@ -0,0 +1,210 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+dodo test ! -e dists
+mkdir conf db logs lists
+
+cat >> conf/distributions <<EOF
+Codename: a
+Architectures: abacus source
+Components: one two three
+
+Codename: b
+Architectures: abacus
+Components: one two four
+EOF
+
+DISTRI=a PACKAGE=aa EPOCH="" VERSION=1 REVISION="-1" FAKEVER="4-2" SECTION="one" genpackage.sh
+
+testrun - -b . --export=never --delete --delete include a test.changes 3<<EOF
+*=Warning: database 'a|one|abacus' was modified but no index file was exported.
+*=Warning: database 'a|one|source' was modified but no index file was exported.
+*=Changes will only be visible after the next 'export'!
+stdout
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/one"
+-v2*=Created directory "./pool/one/a"
+-v2*=Created directory "./pool/one/a/aa"
+$(ofa 'pool/one/a/aa/aa-addons_4-2_all.deb')
+$(ofa 'pool/one/a/aa/aa_1-1_abacus.deb')
+$(ofa 'pool/one/a/aa/aa_1-1.tar.gz')
+$(ofa 'pool/one/a/aa/aa_1-1.dsc')
+$(opa 'aa-addons' '4-2' 'a' 'one' 'abacus' 'deb')
+$(opa 'aa' '1-1' 'a' 'one' 'abacus' 'deb')
+$(opa 'aa' '1-1' 'a' 'one' 'source' 'dsc')
+$(otta 'a' 'aa')
+-v5*=Deleting 'test.changes'.
+EOF
+
+DISTRI=a PACKAGE=aa EPOCH="" VERSION=1 REVISION="-2" FAKEVER="3-2" SECTION="two" genpackage.sh
+testrun - -b . --export=never --delete --delete include a test.changes 3<<EOF
+*=Warning: database 'a|two|abacus' was modified but no index file was exported.
+*=Warning: database 'a|two|source' was modified but no index file was exported.
+*=Changes will only be visible after the next 'export'!
+stdout
+-v2*=Created directory "./pool/two"
+-v2*=Created directory "./pool/two/a"
+-v2*=Created directory "./pool/two/a/aa"
+$(ofa 'pool/two/a/aa/aa-addons_3-2_all.deb')
+$(ofa 'pool/two/a/aa/aa_1-2_abacus.deb')
+$(ofa 'pool/two/a/aa/aa_1-2.tar.gz')
+$(ofa 'pool/two/a/aa/aa_1-2.dsc')
+$(opa 'aa-addons' '3-2' 'a' 'two' 'abacus' 'deb')
+$(opa 'aa' 1-2 'a' 'two' 'abacus' 'deb')
+$(opa 'aa' 1-2 'a' 'two' 'source' 'dsc')
+$(otta 'a' 'aa')
+-v5*=Deleting 'test.changes'.
+EOF
+
+testrun - -b . ls aa 3<<EOF
+stdout
+*=aa | 1-1 | a | abacus, source
+*=aa | 1-2 | a | abacus, source
+returns 0
+EOF
+testrun - -b . ls aa-addons 3<<EOF
+stdout
+*=aa-addons | 4-2 | a | abacus
+*=aa-addons | 3-2 | a | abacus
+returns 0
+EOF
+
+testrun - -b . list a 3<<EOF
+stdout
+*=a|one|abacus: aa 1-1
+*=a|one|abacus: aa-addons 4-2
+*=a|one|source: aa 1-1
+*=a|two|abacus: aa 1-2
+*=a|two|abacus: aa-addons 3-2
+*=a|two|source: aa 1-2
+returns 0
+EOF
+
+testrun - -b . --export=never copy b a bb cc 3<<EOF
+stderr
+-v0*=Will not copy as not found: bb, cc.
+stdout
+-v3*=Not looking into 'a|one|source' as no matching target in 'b'!
+-v3*=Not looking into 'a|two|source' as no matching target in 'b'!
+-v3*=Not looking into 'a|three|abacus' as no matching target in 'b'!
+-v3*=Not looking into 'a|three|source' as no matching target in 'b'!
+EOF
+
+
+testrun - -b . --export=never copy b a aa-addons 3<<EOF
+stdout
+-v3*=Not looking into 'a|one|source' as no matching target in 'b'!
+-v3*=Not looking into 'a|two|source' as no matching target in 'b'!
+-v3*=Not looking into 'a|three|abacus' as no matching target in 'b'!
+-v3*=Not looking into 'a|three|source' as no matching target in 'b'!
+-v1*=Adding 'aa-addons' '4-2' to 'b|one|abacus'.
+$(opa 'aa-addons' '4-2' 'b' 'one' 'abacus' 'deb')
+-v1*=Adding 'aa-addons' '3-2' to 'b|two|abacus'.
+$(opa 'aa-addons' '3-2' 'b' 'two' 'abacus' 'deb')
+stderr
+*=Warning: database 'b|one|abacus' was modified but no index file was exported.
+*=Warning: database 'b|two|abacus' was modified but no index file was exported.
+*=Changes will only be visible after the next 'export'!
+EOF
+
+testrun - -b . list b 3<<EOF
+stdout
+*=b|one|abacus: aa-addons 4-2
+*=b|two|abacus: aa-addons 3-2
+returns 0
+EOF
+
+testrun - -b . ls aa 3<<EOF
+stdout
+*=aa | 1-1 | a | abacus, source
+*=aa | 1-2 | a | abacus, source
+returns 0
+EOF
+testrun - -b . ls aa-addons 3<<EOF
+stdout
+*=aa-addons | 4-2 | a | abacus
+*=aa-addons | 3-2 | a | abacus
+*=aa-addons | 4-2 | b | abacus
+*=aa-addons | 3-2 | b | abacus
+returns 0
+EOF
+
+testrun - -b . --export=never remove b aa-addons 3<<EOF
+stdout
+$(opd 'aa-addons' unset b one abacus deb)
+$(opd 'aa-addons' unset b two abacus deb)
+stderr
+*=Warning: database 'b|one|abacus' was modified but no index file was exported.
+*=Warning: database 'b|two|abacus' was modified but no index file was exported.
+*=Changes will only be visible after the next 'export'!
+EOF
+
+testrun - -b . ls aa-addons 3<<EOF
+stdout
+*=aa-addons | 4-2 | a | abacus
+*=aa-addons | 3-2 | a | abacus
+returns 0
+EOF
+
+testrun - -b . --export=never copysrc b a aa-addons 3<<EOF
+stdout
+-v3*=Not looking into 'a|one|source' as no matching target in 'b'!
+-v3*=Not looking into 'a|two|source' as no matching target in 'b'!
+-v3*=Not looking into 'a|three|abacus' as no matching target in 'b'!
+-v3*=Not looking into 'a|three|source' as no matching target in 'b'!
+stderr
+-v0*=Nothing to do as no package with source 'aa-addons' found!
+EOF
+
+testrun - -b . --export=never copysrc b a aa 4-2 3-2 3<<EOF
+stdout
+-v3*=Not looking into 'a|one|source' as no matching target in 'b'!
+-v3*=Not looking into 'a|two|source' as no matching target in 'b'!
+-v3*=Not looking into 'a|three|abacus' as no matching target in 'b'!
+-v3*=Not looking into 'a|three|source' as no matching target in 'b'!
+stderr
+-v0*=Nothing to do as no packages with source 'aa' and a requested source version found!
+EOF
+
+testrun - -b . --export=never copysrc b a aa 1-1 2-2 3<<EOF
+stdout
+-v3*=Not looking into 'a|one|source' as no matching target in 'b'!
+-v3*=Not looking into 'a|two|source' as no matching target in 'b'!
+-v3*=Not looking into 'a|three|abacus' as no matching target in 'b'!
+-v3*=Not looking into 'a|three|source' as no matching target in 'b'!
+-v1*=Adding 'aa-addons' '4-2' to 'b|one|abacus'.
+$(opa 'aa-addons' 4-2 'b' 'one' 'abacus' 'deb')
+-v1*=Adding 'aa' '1-1' to 'b|one|abacus'.
+$(opa 'aa' 1-1 'b' 'one' 'abacus' 'deb')
+stderr
+-v0*=Will not copy as not found: 2-2.
+-v6*=Found versions are: 1-1.
+*=Warning: database 'b|one|abacus' was modified but no index file was exported.
+*=Changes will only be visible after the next 'export'!
+EOF
+
+testrun - -b . --export=never copysrc b a aa 1-1 1-2 3<<EOF
+stdout
+-v3*=Not looking into 'a|one|source' as no matching target in 'b'!
+-v3*=Not looking into 'a|two|source' as no matching target in 'b'!
+-v3*=Not looking into 'a|three|abacus' as no matching target in 'b'!
+-v3*=Not looking into 'a|three|source' as no matching target in 'b'!
+-v1*=Adding 'aa-addons' '4-2' to 'b|one|abacus'.
+$(opu 'aa-addons' 4-2 4-2 'b' 'one' 'abacus' 'deb')
+-v1*=Adding 'aa' '1-1' to 'b|one|abacus'.
+$(opu 'aa' 1-1 1-1 'b' 'one' 'abacus' 'deb')
+-v1*=Adding 'aa-addons' '3-2' to 'b|two|abacus'.
+$(opa 'aa-addons' 3-2 'b' 'two' 'abacus' 'deb')
+-v1*=Adding 'aa' '1-2' to 'b|two|abacus'.
+$(opa 'aa' 1-2 'b' 'two' 'abacus' 'deb')
+stderr
+-v6*=Found versions are: 1-1, 1-2.
+*=Warning: replacing 'aa-addons' version '4-2' with equal version '4-2' in 'b|one|abacus'!
+*=Warning: replacing 'aa' version '1-1' with equal version '1-1' in 'b|one|abacus'!
+*=Warning: database 'b|one|abacus' was modified but no index file was exported.
+*=Warning: database 'b|two|abacus' was modified but no index file was exported.
+*=Changes will only be visible after the next 'export'!
+EOF
+
+rm -r db conf pool logs lists
+testsuccess
diff --git a/tests/descriptions.test b/tests/descriptions.test
new file mode 100644
index 0000000..d751375
--- /dev/null
+++ b/tests/descriptions.test
@@ -0,0 +1,143 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+dodo test ! -d db
+mkdir -p conf
+cat > conf/distributions <<EOF
+Codename: 1234
+Components: a
+UDebComponents: a
+Architectures: abacus source
+UDebIndices: Packages .
+DebIndices: Packages .
+DscIndices: Sources .
+
+Codename: 4321
+Components: a
+UDebComponents: a
+Architectures: abacus source
+UDebIndices: Packages .
+DebIndices: Packages .
+DscIndices: Sources .
+EOF
+
+testrun - -b . export 3<<EOF
+stderr
+stdout
+$(odb)
+-v1*=Exporting 1234...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/1234"
+-v2*=Created directory "./dists/1234/a"
+-v2*=Created directory "./dists/1234/a/binary-abacus"
+-v6*= exporting '1234|a|abacus'...
+-v6*= creating './dists/1234/a/binary-abacus/Packages' (uncompressed)
+-v2*=Created directory "./dists/1234/a/debian-installer"
+-v2*=Created directory "./dists/1234/a/debian-installer/binary-abacus"
+-v6*= exporting 'u|1234|a|abacus'...
+-v6*= creating './dists/1234/a/debian-installer/binary-abacus/Packages' (uncompressed)
+-v2*=Created directory "./dists/1234/a/source"
+-v6*= exporting '1234|a|source'...
+-v6*= creating './dists/1234/a/source/Sources' (uncompressed)
+-v1*=Exporting 4321...
+-v2*=Created directory "./dists/4321"
+-v2*=Created directory "./dists/4321/a"
+-v2*=Created directory "./dists/4321/a/binary-abacus"
+-v6*= exporting '4321|a|abacus'...
+-v6*= creating './dists/4321/a/binary-abacus/Packages' (uncompressed)
+-v2*=Created directory "./dists/4321/a/debian-installer"
+-v2*=Created directory "./dists/4321/a/debian-installer/binary-abacus"
+-v6*= exporting 'u|4321|a|abacus'...
+-v6*= creating './dists/4321/a/debian-installer/binary-abacus/Packages' (uncompressed)
+-v2*=Created directory "./dists/4321/a/source"
+-v6*= exporting '4321|a|source'...
+-v6*= creating './dists/4321/a/source/Sources' (uncompressed)
+EOF
+
+mkdir i
+(cd i ; PACKAGE=hello EPOCH="" VERSION=1 REVISION="" SECTION="base" genpackage.sh)
+
+testrun - -b . -C a includedeb 1234 i/hello_1_abacus.deb 3<<EOF
+stdout
+-v9*=Adding reference to 'pool/a/h/hello/hello_1_abacus.deb' by '1234|a|abacus'
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/a"
+-v2*=Created directory "./pool/a/h"
+-v2*=Created directory "./pool/a/h/hello"
+$(ofa 'pool/a/h/hello/hello_1_abacus.deb')
+$(opa 'hello' 1 '1234' 'a' 'abacus' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in '1234|a|abacus'...
+-v6*= replacing './dists/1234/a/binary-abacus/Packages' (uncompressed)
+-v6*= looking for changes in '1234|a|source'...
+-v6*= looking for changes in 'u|1234|a|abacus'...
+EOF
+
+cp dists/1234/a/binary-abacus/Packages i/mangled
+sed -i -e "s/^ blub/Description-md5: 29e34048cfd56bbec39e6997af9c7057/" i/mangled
+
+testrun - -b . -T deb -A abacus -C a _addpackage 4321 i/mangled hello 3<<EOF
+stdout
+-v1*=Adding 'hello' '1' to '4321|a|abacus'.
+-v9*=Adding reference to 'pool/a/h/hello/hello_1_abacus.deb' by '4321|a|abacus'
+$(opa 'hello' 1 '4321' 'a' 'abacus' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in '4321|a|abacus'...
+-v6*= replacing './dists/4321/a/binary-abacus/Packages' (uncompressed)
+-v6*= looking for changes in '4321|a|source'...
+-v6*= looking for changes in 'u|4321|a|abacus'...
+EOF
+
+dbversion="$(sed -n -e 's/^b\(db[0-9]\+\.[0-9]\+\)\.0$/\1/p;T;q' db/version)"
+
+dodo ${dbversion}_dump -p -f db/packages.dump db/packages.db
+dodo sed -e 's/\\0a blub\\0a/\\0aDescription-md5: 29e34048cfd56bbec39e6997af9c7057\\0a/' -i db/packages.dump
+dodo ${dbversion}_load -f db/packages.dump db/packages.db
+
+testrun - -b . export 4321 3<<EOF
+stdout
+-v0*=Exporting 4321...
+-v6*= exporting '4321|a|abacus'...
+-v6*= replacing './dists/4321/a/binary-abacus/Packages' (uncompressed)
+-v6*= exporting '4321|a|source'...
+-v6*= replacing './dists/4321/a/source/Sources' (uncompressed)
+-v6*= exporting 'u|4321|a|abacus'...
+-v6*= replacing './dists/4321/a/debian-installer/binary-abacus/Packages' (uncompressed)
+EOF
+
+if diff dists/1234/a/binary-abacus/Packages dists/4321/a/binary-abacus/Packages ; then
+ echo "Failed to include Description-md5 for test" 2>&1
+ exit 1
+fi
+
+testrun - -b . repairdescriptions 4321 3<<EOF
+stdout
+-v1*=Looking for 'Description's to repair in 4321...
+-v3*=Redoing checksum information for packages in '4321|a|abacus'...
+-v3*=Redoing checksum information for packages in 'u|4321|a|abacus'...
+-v0*=Fixing description for 'hello'...
+-v0*=Exporting indices...
+-v6*= looking for changes in '4321|a|abacus'...
+-v6*= replacing './dists/4321/a/binary-abacus/Packages' (uncompressed)
+-v6*= looking for changes in '4321|a|source'...
+-v6*= looking for changes in 'u|4321|a|abacus'...
+EOF
+
+dodiff dists/1234/a/binary-abacus/Packages dists/4321/a/binary-abacus/Packages
+
+dodo ${dbversion}_load -f db/packages.dump db/packages.db
+
+rm pool/a/h/hello/hello_1_abacus.deb
+
+testrun - -b . repairdescriptions 4321 3<<EOF
+stdout
+-v1*=Looking for 'Description's to repair in 4321...
+-v3*=Redoing checksum information for packages in '4321|a|abacus'...
+-v3*=Redoing checksum information for packages in 'u|4321|a|abacus'...
+stderr
+*=Error 2 opening ./pool/a/h/hello/hello_1_abacus.deb: No such file or directory
+*=Cannot retrieve long description for package 'hello' out of package's files!
+EOF
+
+rm -r -f db conf dists pool i
+testsuccess
diff --git a/tests/diffgeneration.test b/tests/diffgeneration.test
new file mode 100644
index 0000000..8594659
--- /dev/null
+++ b/tests/diffgeneration.test
@@ -0,0 +1,271 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+# testing with Sources, as they are easier to generate...
+
+if ! test -e "$RREDTOOL" ; then
+ echo "SKIPPED: rredtool not found, '$RREDTOOL' tried."
+ exit 0
+fi
+
+mkdir conf
+cat > conf/distributions <<EOF
+Codename: test
+Architectures: source
+Components: main
+DscIndices: Sources Release . .gz $RREDTOOL
+EOF
+
+# Section and Priority in .dsc are a reprepro extension...
+
+echo "Dummy file" > test_1.tar.gz
+cat > test_1.dsc <<EOF
+Format: 1.0
+Source: test
+Binary: more or less
+Architecture: who knows what
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Guess Who <its@me>
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaa some lines to make it long enough aaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+X-Data: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+Files:
+ $(mdandsize test_1.tar.gz) test_1.tar.gz
+EOF
+echo "Dummy file" > pre_1.tar.gz
+cat > pre_1.dsc <<EOF
+Format: 1.0
+Source: pre
+Binary: pre
+Architecture: all
+Version: 1
+Maintainer: Guess Who <its@me>
+Section: pre
+Priority: extra
+Files:
+ $(mdandsize pre_1.tar.gz) pre_1.tar.gz
+EOF
+echo "New file" > pre_2.tar.gz
+cat > pre_2.dsc <<EOF
+Format: 1.0
+Source: pre
+Binary: pre
+Architecture: all
+Version: 2
+Maintainer: Guess Who <its@me>
+Section: pre
+Priority: extra
+Files:
+ $(mdandsize pre_2.tar.gz) pre_2.tar.gz
+EOF
+echo "Even newer" > pre_3.tar.gz
+cat > pre_3.dsc <<EOF
+Format: 1.0
+Source: pre
+Binary: pre
+Architecture: all
+Version: 3
+Maintainer: Guess Who <its@me>
+Section: pre
+Priority: extra
+Files:
+ $(mdandsize pre_3.tar.gz) pre_3.tar.gz
+EOF
+
+mkdir old
+testrun - includedsc test test_1.dsc 3<<EOF
+-v1*=test_1.dsc: component guessed as 'main'
+stdout
+$(odb)
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/t"
+-v2*=Created directory "./pool/main/t/test"
+$(ofa 'pool/main/t/test/test_1.dsc')
+$(ofa 'pool/main/t/test/test_1.tar.gz')
+$(opa 'test' 1 'test' 'main' 'source' 'dsc')
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/test"
+-v2*=Created directory "./dists/test/main"
+-v2*=Created directory "./dists/test/main/source"
+-v6*= looking for changes in 'test|main|source'...
+-v6*= creating './dists/test/main/source/Sources' (uncompressed,gzipped,script: rredtool)
+EOF
+dodo cp dists/test/main/source/Sources old/0
+dodo test "!" -e dists/test/main/source/Sources.diff
+testrun - includedsc test pre_1.dsc 3<<EOF
+-v1*=pre_1.dsc: component guessed as 'main'
+stdout
+-v2*=Created directory "./pool/main/p"
+-v2*=Created directory "./pool/main/p/pre"
+$(ofa 'pool/main/p/pre/pre_1.dsc')
+$(ofa 'pool/main/p/pre/pre_1.tar.gz')
+$(opa 'pre' 1 'test' 'main' 'source' 'dsc')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test|main|source'...
+-v6*= replacing './dists/test/main/source/Sources' (uncompressed,gzipped,script: rredtool)
+EOF
+dodo cp dists/test/main/source/Sources old/1
+dodo test -f dists/test/main/source/Sources.diff/Index
+testrun - includedsc test pre_2.dsc 3<<EOF
+-v1*=pre_2.dsc: component guessed as 'main'
+stdout
+$(ofa 'pool/main/p/pre/pre_2.dsc')
+$(ofa 'pool/main/p/pre/pre_2.tar.gz')
+$(opu 'pre' 1 2 'test' 'main' 'source' 'dsc')
+-v0*=Exporting indices...
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/main/p/pre/pre_1.dsc')
+$(ofd 'pool/main/p/pre/pre_1.tar.gz')
+-v6*= looking for changes in 'test|main|source'...
+-v6*= replacing './dists/test/main/source/Sources' (uncompressed,gzipped,script: rredtool)
+EOF
+dodo cp dists/test/main/source/Sources old/2
+dodo test -f dists/test/main/source/Sources.diff/Index
+testrun - includedsc test pre_3.dsc 3<<EOF
+-v1*=pre_3.dsc: component guessed as 'main'
+stdout
+$(ofa 'pool/main/p/pre/pre_3.dsc')
+$(ofa 'pool/main/p/pre/pre_3.tar.gz')
+$(opu 'pre' 2 3 'test' 'main' 'source' 'dsc')
+-v0*=Exporting indices...
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/main/p/pre/pre_2.dsc')
+$(ofd 'pool/main/p/pre/pre_2.tar.gz')
+-v6*= looking for changes in 'test|main|source'...
+-v6*= replacing './dists/test/main/source/Sources' (uncompressed,gzipped,script: rredtool)
+EOF
+dodo cp dists/test/main/source/Sources old/3
+dodo test -f dists/test/main/source/Sources.diff/Index
+
+(cd dists/test/main/source/Sources.diff/ && ls *.gz) | sort |sed -e 's/\.gz$//' > patches
+
+cat > results.expected <<EOF
+SHA1-Current: $(sha1andsize old/3)
+SHA1-History:
+EOF
+i=0
+for p in $(cat patches) ; do
+cat >> results.expected <<EOF
+ $(sha1and7size old/$i) ${p}
+EOF
+i=$((i+1))
+done
+cat >> results.expected <<EOF
+SHA1-Patches:
+EOF
+for p in $(cat patches) ; do
+ dodo gunzip dists/test/main/source/Sources.diff/${p}.gz
+cat >> results.expected <<EOF
+ $(sha1and7size dists/test/main/source/Sources.diff/${p}) ${p}
+EOF
+done
+cat >> results.expected <<EOF
+X-Patch-Precedence: merged
+EOF
+
+dodiff results.expected dists/test/main/source/Sources.diff/Index
+
+i=1
+for p in $(cat patches) ; do
+ cp dists/test/main/source/Sources.diff/$p $i.diff
+ i=$((i+1))
+done
+cat > results.expected << EOF
+1c
+Package: pre
+Format: 1.0
+Binary: pre
+Architecture: all
+Version: 3
+Maintainer: Guess Who <its@me>
+Priority: extra
+Section: pre
+Directory: pool/main/p/pre
+Files:
+ $(mdandsize pre_3.dsc) pre_3.dsc
+ $(mdandsize pre_3.tar.gz) pre_3.tar.gz
+Checksums-Sha1:
+ $(sha1andsize pre_3.dsc) pre_3.dsc
+ $(sha1andsize pre_3.tar.gz) pre_3.tar.gz
+Checksums-Sha256:
+ $(sha2andsize pre_3.dsc) pre_3.dsc
+ $(sha2andsize pre_3.tar.gz) pre_3.tar.gz
+
+Package: test
+.
+EOF
+dodiff results.expected 1.diff
+rm 1.diff
+cat > results.expected << EOF
+17,18c
+ $(sha2andsize pre_3.dsc) pre_3.dsc
+ $(sha2andsize pre_3.tar.gz) pre_3.tar.gz
+.
+14,15c
+ $(sha1andsize pre_3.dsc) pre_3.dsc
+ $(sha1andsize pre_3.tar.gz) pre_3.tar.gz
+.
+11,12c
+ $(mdandsize pre_3.dsc) pre_3.dsc
+ $(mdandsize pre_3.tar.gz) pre_3.tar.gz
+.
+5c
+Version: 3
+.
+EOF
+dodiff results.expected 2.diff
+rm 2.diff
+dodiff results.expected 3.diff
+rm 3.diff
+cat > results.expected << EOF
+1c
+Package: pre
+.
+EOF
+dodiff results.expected 4.diff
+rm 4.diff
+
+rm -r old db pool conf dists pre_*.dsc pre_*.tar.gz test_1.dsc test_1.tar.gz results.expected patches
+
+testsuccess
diff --git a/tests/easyupdate.test b/tests/easyupdate.test
new file mode 100644
index 0000000..4801c9a
--- /dev/null
+++ b/tests/easyupdate.test
@@ -0,0 +1,142 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+mkdir -p test/a test/dists/name/comp/source
+mkdir bla
+tar -czf test/a/a.tar.gz bla
+rmdir bla
+
+cat > test/a/a.dsc <<EOF
+Format: 3.0 (native)
+Source: apackage
+Version: 0-1
+Maintainer: noone <noone@nowhere.tld>
+Checksums-Sha1:
+ $(sha1andsize test/a/a.tar.gz) a.tar.gz
+EOF
+
+cat > test/dists/name/comp/source/Sources <<EOF
+Package: apackage
+Version: 0-1
+Priority: extra
+Section: devel
+Maintainer: noone <noone@nowhere.tld>
+Directory: a
+Files:
+ $(mdandsize test/a/a.dsc) a.dsc
+ $(mdandsize test/a/a.tar.gz) a.tar.gz
+Checksums-Sha1:
+ $(sha1andsize test/a/a.dsc) a.dsc
+ $(sha1andsize test/a/a.tar.gz) a.tar.gz
+EOF
+
+mkdir conf
+
+cat > conf/distributions <<EOF
+Codename: test1
+Architectures: source
+Components: everything
+Update: u
+
+Codename: test2
+Architectures: source
+Components: everything
+Update: - u
+EOF
+cat > conf/updates <<EOF
+Name: u
+Method: file:${WORKDIR}/test
+Suite: name
+Components: comp>everything
+IgnoreRelease: Yes
+DownloadListsAs: .
+EOF
+
+testrun - update test1 3<<EOF
+-v6=aptmethod start 'file:${WORKDIR}/test/dists/name/comp/source/Sources'
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/name/comp/source/Sources'
+-v2*=Copy file '${WORKDIR}/test/dists/name/comp/source/Sources' to './lists/u_name_comp_Sources'...
+-v6=aptmethod start 'file:${WORKDIR}/test/a/a.dsc'
+-v1*=aptmethod got 'file:${WORKDIR}/test/a/a.dsc'
+-v2*=Linking file '${WORKDIR}/test/a/a.dsc' to './pool/everything/a/apackage/a.dsc'...
+-v6=aptmethod start 'file:${WORKDIR}/test/a/a.tar.gz'
+-v1*=aptmethod got 'file:${WORKDIR}/test/a/a.tar.gz'
+-v2*=Linking file '${WORKDIR}/test/a/a.tar.gz' to './pool/everything/a/apackage/a.tar.gz'...
+stdout
+$(odb)
+-v2*=Created directory "./lists"
+-v0*=Calculating packages to get...
+-v3*= processing updates for 'test1|everything|source'
+-v5*= reading './lists/u_name_comp_Sources'
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/everything"
+-v2*=Created directory "./pool/everything/a"
+-v2*=Created directory "./pool/everything/a/apackage"
+-v0*=Getting packages...
+$(ofa pool/everything/a/apackage/a.dsc)
+$(ofa pool/everything/a/apackage/a.tar.gz)
+-v1*=Shutting down aptmethods...
+-v0*=Installing (and possibly deleting) packages...
+$(opa apackage 0-1 test1 everything source dsc)
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/test1"
+-v2*=Created directory "./dists/test1/everything"
+-v2*=Created directory "./dists/test1/everything/source"
+-v6*= looking for changes in 'test1|everything|source'...
+-v6*= creating './dists/test1/everything/source/Sources' (gzipped)
+EOF
+
+testrun - update test2 3<<EOF
+-v6=aptmethod start 'file:${WORKDIR}/test/dists/name/comp/source/Sources'
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/name/comp/source/Sources'
+-v2*=Copy file '${WORKDIR}/test/dists/name/comp/source/Sources' to './lists/u_name_comp_Sources'...
+stdout
+-v0*=Calculating packages to get...
+-v3*= processing updates for 'test2|everything|source'
+-v5*= marking everything to be deleted
+-v5*= reading './lists/u_name_comp_Sources'
+-v0*=Getting packages...
+-v1*=Shutting down aptmethods...
+-v0*=Installing (and possibly deleting) packages...
+$(opa apackage 0-1 test2 everything source dsc)
+-v0*=Exporting indices...
+-v2*=Created directory "./dists/test2"
+-v2*=Created directory "./dists/test2/everything"
+-v2*=Created directory "./dists/test2/everything/source"
+-v6*= looking for changes in 'test2|everything|source'...
+-v6*= creating './dists/test2/everything/source/Sources' (gzipped)
+EOF
+
+testrun - update test2 3<<EOF
+-v6=aptmethod start 'file:${WORKDIR}/test/dists/name/comp/source/Sources'
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/name/comp/source/Sources'
+-v2*=Copy file '${WORKDIR}/test/dists/name/comp/source/Sources' to './lists/u_name_comp_Sources'...
+stdout
+-v0*=Calculating packages to get...
+-v3*= processing updates for 'test2|everything|source'
+-v5*= marking everything to be deleted
+-v5*= reading './lists/u_name_comp_Sources'
+EOF
+
+true > test/dists/name/comp/source/Sources
+
+testrun - update test2 3<<EOF
+-v6=aptmethod start 'file:${WORKDIR}/test/dists/name/comp/source/Sources'
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/name/comp/source/Sources'
+-v2*=Copy file '${WORKDIR}/test/dists/name/comp/source/Sources' to './lists/u_name_comp_Sources'...
+stdout
+-v0*=Calculating packages to get...
+-v3*= processing updates for 'test2|everything|source'
+-v5*= marking everything to be deleted
+-v5*= reading './lists/u_name_comp_Sources'
+-v0*=Getting packages...
+-v1*=Shutting down aptmethods...
+-v0*=Installing (and possibly deleting) packages...
+$(opd apackage 0-1 test2 everything source dsc)
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test2|everything|source'...
+-v6*= replacing './dists/test2/everything/source/Sources' (gzipped)
+EOF
+
+testsuccess
diff --git a/tests/evil.key b/tests/evil.key
new file mode 100644
index 0000000..31d8f84
--- /dev/null
+++ b/tests/evil.key
@@ -0,0 +1,18 @@
+-----BEGIN PGP PRIVATE KEY BLOCK-----
+Version: GnuPG v1.4.6 (GNU/Linux)
+
+lQG7BEgsP4sRBADBpZrNGxOgGusSQPOO7B2KV3IBPQAg+Ywu4EaGBK4TvIJIqY0K
+5kSAt4oSCwC0jd6cKsG1IqDomcB7fUplJP10XyH438Px7t/4yAUvX4v2MwNnA75W
+X63/JJq0OPQ97KIQHF+Vpz3tLL7jPQxnCR5149bB94BYtaOFxOcfpqYJawCggpza
+MuTTV+xhc+UIPNtOJY9AZu8EAJGPH+WdBxHjeqO8Ao/QECwjqItxx8rxcWjkYN9z
+D4KaiQ1kUFHpU2tql/NCH/+FtvS1l6Cm+90TJO116CCo/+qh9j6+QcQqS6Wz2eJK
+vKMa2IjdIGNcSxgE7/k46g0KQ7uYC2NdzMmRu7ot+NGrFDwN3gt92mmR7MQpc5rI
+ksdbA/9k91cy9ZwbxSQdnTujlekpqiICwC99aotJ7qRSVelgVaU2ueLZpC1BoFA6
+QafyCzSGppkPm0RomLpUl77j5F6wkwJ+8oRchGB0kthsnOA/WW/wK+M0fh/SBpfK
+uFkuXUqKfJxqtOo99H4FuXbsaCWvLjq9y8XmI6Wf6aF/Q6WKPgAAnA7amgto7UZm
+wGVgYLdfn3B4vboQCjO0S1JlcHJlcHJvIFRlc3RzdWl0ZSBLZXkgMiAoRk9SIFVT
+RSBXSVRISU4gVEVTVFNVSVRFIE9OTFkpIDxldmlsQG5vd2hlcmUudGxkPohgBBMR
+AgAgBQJILD+LAhsDBgsJCAcDAgQVAggDBBYCAwECHgECF4AACgkQn6lDZwxnKkrT
+gQCfYJG25Z9MNlOj/F9WzJ2NahZC+NUAn0Qrfs9w8s1Rnw39EYqmVWTG9qSG
+=7arY
+-----END PGP PRIVATE KEY BLOCK-----
diff --git a/tests/expired.key b/tests/expired.key
new file mode 100644
index 0000000..8d5cf67
--- /dev/null
+++ b/tests/expired.key
@@ -0,0 +1,19 @@
+-----BEGIN PGP PRIVATE KEY BLOCK-----
+Version: GnuPG v1.4.6 (GNU/Linux)
+
+lQG6BEgsQCURBAC+SMbS3n9hnYIYf3YoKWHqEsrrjX6UXgb9io3VtHy4ljr2cJbF
+pABjIEWh0z7kLXXJVeR6bAc4lgR8cR6T2TsuRkx0lT2BtFI+iNz8oeLRjM4TQbJQ
+erxl4m67PXPxLXmbhBmO2HSQ/6NlQIE9AfAE5Bf5JTb630aJolrgWF4phwCguqfK
+EcqgotFEErPvwCF9bqv+UHsEAJCNVCJ1wyabrnSykkE+7H8cgB9wkE255ussB0pD
+pX3IKcquwShQFgLUjgCmlVnBqFE5K/K8dBSf+TAYI6a3zV5SzKTWUy2b3cZljMwO
+jUxd5CMVSK4c8IeTxPvWdcx0hzjAngeKNkGbzWaQqUes49Mr9ItxEXViVvaJLcay
+RhnEA/46soa9a7YI+XWJF0UQUSKSbuie5iwGzXC7KCosyNsPcu2G15dL7YelkGAo
+B+rV8yWMVg0+2fY68nmrkilfR32jG3rMPPS5ZPYO8vAQFv1VSJUjuIjerV0+fVsv
+W3udbXFDmURpw8LhZMI5bKmJtcKdGhXd1sZ/vhZSZAFs0LchDwAAl0NwAPemPbcK
+PBEqqXFxSe0lkSIH9bROUmVwcmVwcm8gVGVzdHN1aXRlIEtleSA0IChGT1IgVVNF
+IFdJVEhJTiBURVNUU1VJVEUgT05MWSkgPGV4cGlyZWRAbm93aGVyZS50bGQ+iGYE
+ExECACYFAkgsQCUCGwMFCQABUYAGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRCJ
+T6Kd0E3T1go2AJ4lg1614/jYIy5m7NCCPXUpCOhrVQCfUMuczWp32ddKY4aDqiHX
+t/QBoI4=
+=Q+dU
+-----END PGP PRIVATE KEY BLOCK-----
diff --git a/tests/expiredwithsubkey-working.key b/tests/expiredwithsubkey-working.key
new file mode 100644
index 0000000..1eb14bc
--- /dev/null
+++ b/tests/expiredwithsubkey-working.key
@@ -0,0 +1,52 @@
+-----BEGIN PGP PRIVATE KEY BLOCK-----
+Version: GnuPG v1.4.9 (GNU/Linux)
+
+lQHYBEnjBlUBBAC3SCzchwyhCXrSItaqHZSbp/d+s1zaD7Ui75GY67lgZ92aHPrd
+sXr9+/cCneIFyxyDbG20mLkFNrvOmNIsfDikZGtHhCXlgXMHlv/FqMxw/mvxfFmu
+iEbQwaGIfUqQq1HvrvdaWgbnge9EUxF7qAGFv1Sw+1YYY5qNy2xVF3yxGQARAQAB
+AAP7BxCKAyOU++mTwYEMhXDfsyrDpk93VSPtG1hA5FQ0uGe0gd3bWRt/1kWlqSUJ
+Cuhf9Fxj86W93vqzvUREeKi+nZ3agp7W6xHfWMGDGkLj5uN/3Y9MRZRxzJOnJ02j
+H5v5BMRCJPNMFnNHD8v8eZT2nMholqLCE2ek4A1kqUcu68ECANW1xsnNyHJbu1i8
+LZqGfsQaAGSdEMQlYqi7zM9EoWNcPloN//2KZ978NfybSBWZTNRj/ToFjZ5TUZrz
+JN2/a0ECANuM9NeGxw3ooUUbMc2tWV1r8UDl9o6SS+MJYl5wnyyIttbgsUeeb3YA
+5OjlsemQ5gGKJzxvZYSoXPvkzs1MB9kB/0lGrW6bJk59sjjcMjRmirbjdRk0LvRD
+NAPGrWgPS2zbT2/Y6HzCdlJ+NLSSwAB+tr0AmTZDPsrN/1VIIoF6QiqndbRYUmVw
+cmVwcm8gVGVzdHN1aXRlIEtleSA1IChGT1IgVVNFIFdJVEhJTiBURVNUU1VJVEUg
+T05MWSkgPGV4cGlyZWR3aXRoc3Via2V5QG5vd2hlcmUudGxkPoi2BBMBAgAgBQJJ
+4wZVAhsDBgsJCAcDAgQVAggDBBYCAwECHgECF4AACgkQLxqbMqJgRJotAAP/UAiW
+KlcESGUen7/mfY2pl2rBrq6gTYPh/ElHZKiDrixeJNBEhDub9u7PCg9G8kKrJ+Yq
+Kh9l1yWBVoWq29w/ru2MXSNOgwfZfFMZpfQ0iHxwKreroAXkhHBpF4aG1Q3xwKEB
+nF+8UrA+ajhm2lYhVtw39yDzoH1eF4JdFERkgm+dAbsESeMGwREEANTZPc2YyIzY
+HYYPORodlyu8hSPX0weNh3McidVBZWs4eQfg57lqfXQrKZxfhAOWkS5o3CmU+Qzk
+si5Axkvl6hYt4OKnt9cOSS3IpeB4SCgF/ey1MeLu9pSxqmxvPR2ddZvJuYKrMgiZ
++QF3sgzeOPfYGgrRJOKO2iRx/17R4wy3AKDEhuFBX+ViClYkyvpjzx6J7fxQtQP/
+a6uhhB8AyV9VjjWbupAGZbG1YnrgzJJBUN81BEU9iNqNXNNE464slGI0Ey3KV04w
+5m4/N1heZ25T4BtdM2dTpbU0TEaUhRuqcoCSMhPBpcAPuYNT7NNeinr4Xq681iex
+WW5+LQnNuCEmr2tXPW4Ewy/Z3pmr9+nlZjEGuz+4T6gD/RKSRPccoLKE8Hk57wJM
+6+6tA1dXsLzDYrJLM6t8oQWa++GhPppsxr4r1i16SYTc0Uv/2rblUQlTfmmCE5wB
+vlg6cWb9ly+BhlMCdRCXHgmUeKndB3gaplEGt8R1iZJBW3y17BXf2LPMPti5YoQz
+JwgGLhrgSy0UOvX7eNhX7CUfAACgnc6LCcEXRxIJeM4glyt+hwPCki0IiojnBBgB
+AgAJBQJJ4wbBAhsCAFIJEC8amzKiYESaRyAEGRECAAYFAknjBsEACgkQHSzFxlz9
+b75NRQCgnYR3NtV9F8DuMFCecnRQfR2yPvMAn080v7py3eE1i+UnYJE65wrCB53N
+77AEAIeZLJ1Q26Sdop0r5WZrW98aL9weuWzShkDjuMYiLR1S3kuOCrucVzikrqV/
+JtjLZTAOgU8tGkxY0ORPZS33z3wLZQW4L1EWJWAeG0kbpaSj49GBnCeRs6zP7yu9
+dX3pNWi6ZYHNZ7FDR0hSxLPABeNRuKOhy3/0uLkoC9+Lo+0SnQHYBEnjBtABBADb
+Xlr92Lq288cqkouYZtOOM93zMALoSMoV1ciUf5C03fDaFGJX2l8omQvCsWRjUYTH
+4RgVg+eP3F0nlZnyCkuGM0mS096BheKD6bXpG2aVFnFahwm/3C2GJi7Jd7ajhYFR
+9sDRVfEUi5wTScwKcMmdjEutqmHr3Uuo5MaFCz20oQARAQABAAP8C5FFGWzE0z4F
+dQPtXSHictWetPq1k4m3kMlRMm3r27K2lyxTH3x0Dz4rQ+biYxeWyaqvoD5QbwpE
+5gAGMjB7aREh4ufQKPf5mBwEICluJpogQrTtrHrWprYUWxqkCkuwCDTh6QnH/UwO
+X3m7jaV2vTvFO9zTl/C9YdsKNNXxzxECAObR5GTKe50A/MxtpU7LCMi6MzMmkl+g
+zUJOae6DnTeRYTSJEEiHfbGYzKzrofWCH4qvMpoO0g9x0ON9PMYTP7ECAPNMqY/3
++kA7n6diK3OBa1PcNt2Od4gDSQBRRetG++9mCux/m0IlDn0uK1lPhAYA7D9ncLFn
+8qlbg9lMSqvRb/EB/A7UDEZAXnd4aZ0mhaJJmWLsU9emwspoQlpG50m4ovc6cvHH
+MXVe3WCU+YZYHjfJRdf85py1hKrvcupwkoIIaaGhV4kBPQQYAQIACQUCSeMG0AIb
+AgCoCRAvGpsyomBEmp0gBBkBAgAGBQJJ4wbQAAoJEKVz/rFg3e1bd5oD/RtJlbC6
+yRatjRG+O8AZg33lsKonJpKXtLaXr3seTbff1ODRUVfpm8hI0OuRcm9XJ7Uv9PDe
+rEtDvCokjm/oDUyymlRLLU4MfoUKMNlIs4Wg1jHKM0GZnbxPf5PZWTUmVRFEX+Tz
+/3Sgf5i5l68h8hRzA86UT3UWEPa8T4PsXsHdsl4D/R0+chNjUl9TmyVpyp+7OCEG
+NOpqOdwHdR78VEE7LLahyg/8XehGtHzqvx2Vv58Bt+EV//gGfwSmn2u0brOcdMgF
+w7OXHtqRM0NguAz3PQS3dgoYqShxjf6OSIGg9Q0Y109OF2iEslQ5uFb2p/FjA3wz
+f81KSrTWYPMlXQJlULb0
+=OXP5
+-----END PGP PRIVATE KEY BLOCK-----
diff --git a/tests/expiredwithsubkey.key b/tests/expiredwithsubkey.key
new file mode 100644
index 0000000..85f33e1
--- /dev/null
+++ b/tests/expiredwithsubkey.key
@@ -0,0 +1,52 @@
+-----BEGIN PGP PRIVATE KEY BLOCK-----
+Version: GnuPG v1.4.9 (GNU/Linux)
+
+lQHYBEnjBlUBBAC3SCzchwyhCXrSItaqHZSbp/d+s1zaD7Ui75GY67lgZ92aHPrd
+sXr9+/cCneIFyxyDbG20mLkFNrvOmNIsfDikZGtHhCXlgXMHlv/FqMxw/mvxfFmu
+iEbQwaGIfUqQq1HvrvdaWgbnge9EUxF7qAGFv1Sw+1YYY5qNy2xVF3yxGQARAQAB
+AAP7BxCKAyOU++mTwYEMhXDfsyrDpk93VSPtG1hA5FQ0uGe0gd3bWRt/1kWlqSUJ
+Cuhf9Fxj86W93vqzvUREeKi+nZ3agp7W6xHfWMGDGkLj5uN/3Y9MRZRxzJOnJ02j
+H5v5BMRCJPNMFnNHD8v8eZT2nMholqLCE2ek4A1kqUcu68ECANW1xsnNyHJbu1i8
+LZqGfsQaAGSdEMQlYqi7zM9EoWNcPloN//2KZ978NfybSBWZTNRj/ToFjZ5TUZrz
+JN2/a0ECANuM9NeGxw3ooUUbMc2tWV1r8UDl9o6SS+MJYl5wnyyIttbgsUeeb3YA
+5OjlsemQ5gGKJzxvZYSoXPvkzs1MB9kB/0lGrW6bJk59sjjcMjRmirbjdRk0LvRD
+NAPGrWgPS2zbT2/Y6HzCdlJ+NLSSwAB+tr0AmTZDPsrN/1VIIoF6QiqndbRYUmVw
+cmVwcm8gVGVzdHN1aXRlIEtleSA1IChGT1IgVVNFIFdJVEhJTiBURVNUU1VJVEUg
+T05MWSkgPGV4cGlyZWR3aXRoc3Via2V5QG5vd2hlcmUudGxkPoi8BBMBAgAmAhsD
+BgsJCAcDAgQVAggDBBYCAwECHgECF4AFAknjBwcFCQABUjAACgkQLxqbMqJgRJpK
+jwP8CFRafefR2NTb6C/9JLl6pJzrfs8bz6AZp8Hmq57HWVY9L8TfANNcKqVYhwbd
+f2VWU3Ab8wIYCXUkHeicmaRPvxEw7iVrkhvwg5jVP78Zk3UDKPRJxjq7VFAUc3qy
+WAcmOEv/ombRFFFkh5McEqSw4KVKXPaLXZgVfhpzSw8fIMidAbsESeMGwREEANTZ
+Pc2YyIzYHYYPORodlyu8hSPX0weNh3McidVBZWs4eQfg57lqfXQrKZxfhAOWkS5o
+3CmU+Qzksi5Axkvl6hYt4OKnt9cOSS3IpeB4SCgF/ey1MeLu9pSxqmxvPR2ddZvJ
+uYKrMgiZ+QF3sgzeOPfYGgrRJOKO2iRx/17R4wy3AKDEhuFBX+ViClYkyvpjzx6J
+7fxQtQP/a6uhhB8AyV9VjjWbupAGZbG1YnrgzJJBUN81BEU9iNqNXNNE464slGI0
+Ey3KV04w5m4/N1heZ25T4BtdM2dTpbU0TEaUhRuqcoCSMhPBpcAPuYNT7NNeinr4
+Xq681iexWW5+LQnNuCEmr2tXPW4Ewy/Z3pmr9+nlZjEGuz+4T6gD/RKSRPccoLKE
+8Hk57wJM6+6tA1dXsLzDYrJLM6t8oQWa++GhPppsxr4r1i16SYTc0Uv/2rblUQlT
+fmmCE5wBvlg6cWb9ly+BhlMCdRCXHgmUeKndB3gaplEGt8R1iZJBW3y17BXf2LPM
+Pti5YoQzJwgGLhrgSy0UOvX7eNhX7CUfAACgnc6LCcEXRxIJeM4glyt+hwPCki0I
+iojtBBgBAgAPAhsCBQJJ4wdkBQkAAVIhAFJHIAQZEQIABgUCSeMGwQAKCRAdLMXG
+XP1vvk1FAJ0QB4nk6jWf0Z9+aHBfnkyBF9DlmgCfaBY1cg0GMrZ7sH60IM7/Ym4L
+hP8JEC8amzKiYESas0IEAKmGTzRSawoX0KBTyfOo7AhNz5rhCWTUVo+DZNxC5Am6
+BmD48NEqWrUfG1Ee4vUj+RDzLNXnkG40mZuWFB2mmF+Ss6QuA17icCWxkHYWixOF
+85+Z7sOmS8tPpMrFZuWF48QGFeXfxc1unOQjEPxtOurI+KzeezuyNKQHk9QFCRHT
+nQHYBEnjBtABBADbXlr92Lq288cqkouYZtOOM93zMALoSMoV1ciUf5C03fDaFGJX
+2l8omQvCsWRjUYTH4RgVg+eP3F0nlZnyCkuGM0mS096BheKD6bXpG2aVFnFahwm/
+3C2GJi7Jd7ajhYFR9sDRVfEUi5wTScwKcMmdjEutqmHr3Uuo5MaFCz20oQARAQAB
+AAP8C5FFGWzE0z4FdQPtXSHictWetPq1k4m3kMlRMm3r27K2lyxTH3x0Dz4rQ+bi
+YxeWyaqvoD5QbwpE5gAGMjB7aREh4ufQKPf5mBwEICluJpogQrTtrHrWprYUWxqk
+CkuwCDTh6QnH/UwOX3m7jaV2vTvFO9zTl/C9YdsKNNXxzxECAObR5GTKe50A/Mxt
+pU7LCMi6MzMmkl+gzUJOae6DnTeRYTSJEEiHfbGYzKzrofWCH4qvMpoO0g9x0ON9
+PMYTP7ECAPNMqY/3+kA7n6diK3OBa1PcNt2Od4gDSQBRRetG++9mCux/m0IlDn0u
+K1lPhAYA7D9ncLFn8qlbg9lMSqvRb/EB/A7UDEZAXnd4aZ0mhaJJmWLsU9emwspo
+QlpG50m4ovc6cvHHMXVe3WCU+YZYHjfJRdf85py1hKrvcupwkoIIaaGhV4kBPQQY
+AQIACQUCSeMG0AIbAgCoCRAvGpsyomBEmp0gBBkBAgAGBQJJ4wbQAAoJEKVz/rFg
+3e1bd5oD/RtJlbC6yRatjRG+O8AZg33lsKonJpKXtLaXr3seTbff1ODRUVfpm8hI
+0OuRcm9XJ7Uv9PDerEtDvCokjm/oDUyymlRLLU4MfoUKMNlIs4Wg1jHKM0GZnbxP
+f5PZWTUmVRFEX+Tz/3Sgf5i5l68h8hRzA86UT3UWEPa8T4PsXsHdsl4D/R0+chNj
+Ul9TmyVpyp+7OCEGNOpqOdwHdR78VEE7LLahyg/8XehGtHzqvx2Vv58Bt+EV//gG
+fwSmn2u0brOcdMgFw7OXHtqRM0NguAz3PQS3dgoYqShxjf6OSIGg9Q0Y109OF2iE
+slQ5uFb2p/FjA3wzf81KSrTWYPMlXQJlULb0
+=Hzlj
+-----END PGP PRIVATE KEY BLOCK-----
diff --git a/tests/export.test b/tests/export.test
new file mode 100644
index 0000000..d0a7643
--- /dev/null
+++ b/tests/export.test
@@ -0,0 +1,79 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+mkdir conf
+cat > conf/distributions <<EOF
+Codename: o
+Architectures: a
+Components: e
+DebIndices: Packages .
+EOF
+
+testrun - -b . export o 3<<EOF
+stdout
+$(odb)
+-v1*=Exporting o...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/o"
+-v2*=Created directory "./dists/o/e"
+-v2*=Created directory "./dists/o/e/binary-a"
+-v6*= exporting 'o|e|a'...
+-v6*= creating './dists/o/e/binary-a/Packages' (uncompressed)
+EOF
+
+testrun - -b . remove o nothing 3<<EOF
+stderr
+-v0*=Not removed as not found: nothing
+stdout
+-v0*=Exporting indices...
+-v6*= looking for changes in 'o|e|a'...
+EOF
+
+cat >> conf/distributions <<EOF
+Signed-By: test
+EOF
+
+testrun - -b . export o 3<<EOF
+stdout
+-v1*=Exporting o...
+-v6*= exporting 'o|e|a'...
+-v6*= replacing './dists/o/e/binary-a/Packages' (uncompressed)
+EOF
+
+dodo grep 'Signed-By: test' dists/o/Release
+
+testrun - -b . remove o nothing 3<<EOF
+stderr
+-v0*=Not removed as not found: nothing
+stdout
+-v0*=Exporting indices...
+-v6*= looking for changes in 'o|e|a'...
+EOF
+
+dodo grep 'Signed-By: test' dists/o/Release
+
+cat >> conf/distributions <<EOF
+ValidFor: 100d
+EOF
+
+testrun - -b . export o 3<<EOF
+stdout
+-v1*=Exporting o...
+-v6*= exporting 'o|e|a'...
+-v6*= replacing './dists/o/e/binary-a/Packages' (uncompressed)
+EOF
+
+dodo grep '^Valid-Until:' dists/o/Release
+
+testrun - -b . --export=lookedat remove o nothing 3<<EOF
+stderr
+-v0*=Not removed as not found: nothing
+stdout
+-v0*=Exporting indices...
+-v6*= looking for changes in 'o|e|a'...
+EOF
+
+dodo grep '^Valid-Until:' dists/o/Release
+
+rm -r conf db dists
+testsuccess
diff --git a/tests/exporthooks.test b/tests/exporthooks.test
new file mode 100644
index 0000000..5d7c9c2
--- /dev/null
+++ b/tests/exporthooks.test
@@ -0,0 +1,79 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+mkdir conf
+cat > conf/distributions <<EOF
+Codename: o
+Architectures: a b
+Components: e
+DebIndices: .
+EOF
+
+testrun - -b . export o 3<<EOF
+*=Error parsing ./conf/distributions, line 4, column 13: filename for index files expected!
+-v0*=There have been errors!
+returns 255
+EOF
+
+cat > conf/distributions <<EOF
+Codename: o
+Architectures: a b
+Components: e
+DebIndices: X .gz .bz2 strange.sh
+EOF
+cat > conf/strange.sh <<'EOF'
+#!/bin/sh
+echo hook "$@"
+touch "$1/$3.something.new"
+echo "$3.something.new" >&3
+touch "$1/$3.something.hidden.new"
+echo "$3.something.hidden.new." >&3
+exit 0
+EOF
+chmod a+x conf/strange.sh
+
+testrun - -b . export o 3<<EOF
+stdout
+$(odb)
+-v1*=Exporting o...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/o"
+-v2*=Created directory "./dists/o/e"
+-v2*=Created directory "./dists/o/e/binary-a"
+-v6*= exporting 'o|e|a'...
+-v6*= creating './dists/o/e/binary-a/X' (gzipped,bzip2ed,script: strange.sh)
+*=hook ./dists/o e/binary-a/X.new e/binary-a/X new
+-v2*=Created directory "./dists/o/e/binary-b"
+*=hook ./dists/o e/binary-b/X.new e/binary-b/X new
+-v6*= exporting 'o|e|b'...
+-v6*= creating './dists/o/e/binary-b/X' (gzipped,bzip2ed,script: strange.sh)
+EOF
+
+find dists -type f | sort > results
+cat > results.expected <<EOF
+dists/o/Release
+dists/o/e/binary-a/X.bz2
+dists/o/e/binary-a/X.gz
+dists/o/e/binary-a/X.something
+dists/o/e/binary-a/X.something.hidden
+dists/o/e/binary-b/X.bz2
+dists/o/e/binary-b/X.gz
+dists/o/e/binary-b/X.something
+dists/o/e/binary-b/X.something.hidden
+EOF
+dodiff results.expected results
+
+grep something dists/o/Release > results || true
+cat > results.expected <<EOF
+ $(md5releaseline o e/binary-a/X.something)
+ $(md5releaseline o e/binary-b/X.something)
+ $(sha1releaseline o e/binary-a/X.something)
+ $(sha1releaseline o e/binary-b/X.something)
+ $(sha2releaseline o e/binary-a/X.something)
+ $(sha2releaseline o e/binary-b/X.something)
+EOF
+dodiff results.expected results
+
+rm -r conf db dists
+rm results results.expected
+testsuccess
diff --git a/tests/flat.test b/tests/flat.test
new file mode 100644
index 0000000..48d2eba
--- /dev/null
+++ b/tests/flat.test
@@ -0,0 +1,518 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+dodo test ! -d db
+mkdir -p conf
+cat > conf/distributions <<EOF
+Codename: 1234
+Components: a bb
+UDebComponents: a
+Architectures: x yyyyyyyyyy source
+Update: flattest
+EOF
+cat > conf/updates.base <<EOF
+Name: flattest
+GetInRelease: no
+Flat: a
+VerifyRelease: blindtrust
+Method: file:$WORKDIR
+Suite: flatsource
+EOF
+
+testrun - -b . export 1234 3<<EOF
+stderr
+stdout
+$(odb)
+-v1*=Exporting 1234...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/1234"
+-v2*=Created directory "./dists/1234/a"
+-v2*=Created directory "./dists/1234/a/binary-x"
+-v6*= exporting '1234|a|x'...
+-v6*= creating './dists/1234/a/binary-x/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/1234/a/binary-yyyyyyyyyy"
+-v6*= exporting '1234|a|yyyyyyyyyy'...
+-v6*= creating './dists/1234/a/binary-yyyyyyyyyy/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/1234/a/debian-installer"
+-v2*=Created directory "./dists/1234/a/debian-installer/binary-x"
+-v6*= exporting 'u|1234|a|x'...
+-v6*= creating './dists/1234/a/debian-installer/binary-x/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/1234/a/debian-installer/binary-yyyyyyyyyy"
+-v6*= exporting 'u|1234|a|yyyyyyyyyy'...
+-v6*= creating './dists/1234/a/debian-installer/binary-yyyyyyyyyy/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/1234/a/source"
+-v6*= exporting '1234|a|source'...
+-v6*= creating './dists/1234/a/source/Sources' (gzipped)
+-v2*=Created directory "./dists/1234/bb"
+-v2*=Created directory "./dists/1234/bb/binary-x"
+-v6*= exporting '1234|bb|x'...
+-v6*= creating './dists/1234/bb/binary-x/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/1234/bb/binary-yyyyyyyyyy"
+-v6*= exporting '1234|bb|yyyyyyyyyy'...
+-v6*= creating './dists/1234/bb/binary-yyyyyyyyyy/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/1234/bb/source"
+-v6*= exporting '1234|bb|source'...
+-v6*= creating './dists/1234/bb/source/Sources' (gzipped)
+EOF
+
+mkdir lists
+
+cp conf/updates.base conf/updates
+cat >>conf/updates <<EOF
+Components: a
+EOF
+
+testrun - -b . update 1234 3<<EOF
+returns 255
+stderr
+*=./conf/updates:1 to 8: Update pattern may not contain Components and Flat fields ad the same time.
+-v0*=There have been errors!
+stdout
+EOF
+
+cp conf/updates.base conf/updates
+cat >>conf/updates <<EOF
+UDebComponents: a
+EOF
+
+testrun - -b . update 1234 3<<EOF
+returns 255
+stderr
+*=./conf/updates:1 to 8: Update pattern may not contain UDebComponents and Flat fields ad the same time.
+-v0*=There have been errors!
+stdout
+EOF
+
+mv conf/updates.base conf/updates
+
+testrun - -b . update 1234 3<<EOF
+returns 255
+stderr
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Release'
+*=aptmethod error receiving 'file:$WORKDIR/flatsource/Release':
+='File not found'
+='File not found - $WORKDIR/flatsource/Release (2: No such file or directory)'
+-v0*=There have been errors!
+stdout
+EOF
+
+mkdir flatsource
+touch flatsource/Release
+
+testrun - -b . update 1234 3<<EOF
+returns 255
+stderr
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Release'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Release'
+-v2*=Copy file '$WORKDIR/flatsource/Release' to './lists/flattest_flatsource_flat_Release'...
+*=Missing checksums in Release file './lists/flattest_flatsource_flat_Release'!
+-v0*=There have been errors!
+stdout
+EOF
+
+echo "MD5Sum:" > flatsource/Release
+
+testrun - -b . update 1234 3<<EOF
+returns 254
+stderr
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Release'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Release'
+-v2*=Copy file '$WORKDIR/flatsource/Release' to './lists/flattest_flatsource_flat_Release'...
+*=Could not find 'Packages' within './lists/flattest_flatsource_flat_Release'
+-v0*=There have been errors!
+stdout
+EOF
+
+echo " trash" >> flatsource/Release
+
+testrun - -b . update 1234 3<<EOF
+returns 255
+stderr
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Release'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Release'
+-v2*=Copy file '$WORKDIR/flatsource/Release' to './lists/flattest_flatsource_flat_Release'...
+*=Error parsing md5 checksum line ' trash' within './lists/flattest_flatsource_flat_Release'
+-v0*=There have been errors!
+stdout
+EOF
+
+gzip -c < /dev/null > flatsource/Sources.gz
+gzip -c < /dev/null > flatsource/Packages.gz
+cat > flatsource/Release <<EOF
+MD5Sum:
+ $EMPTYMD5 Sources
+ $(mdandsize flatsource/Sources.gz) Sources.gz
+ $(mdandsize flatsource/Packages.gz) Packages.gz
+EOF
+
+testrun - -b . update 1234 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Release'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Release'
+-v2*=Copy file '$WORKDIR/flatsource/Release' to './lists/flattest_flatsource_flat_Release'...
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Sources.gz'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Sources.gz'
+-v2*=Uncompress '$WORKDIR/flatsource/Sources.gz' into './lists/flattest_flatsource_Sources' using '/bin/gunzip'...
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Packages.gz'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Packages.gz'
+-v2*=Uncompress '$WORKDIR/flatsource/Packages.gz' into './lists/flattest_flatsource_Packages' using '/bin/gunzip'...
+stdout
+-v0*=Calculating packages to get...
+-v4*= nothing to do for '1234|bb|source'
+-v4*= nothing to do for '1234|bb|yyyyyyyyyy'
+-v4*= nothing to do for '1234|bb|x'
+-v3*= processing updates for '1234|a|source'
+-v5*= reading './lists/flattest_flatsource_Sources'
+-v4*= nothing to do for 'u|1234|a|yyyyyyyyyy'
+-v3*= processing updates for '1234|a|yyyyyyyyyy'
+-v5*= reading './lists/flattest_flatsource_Packages'
+-v4*= nothing to do for 'u|1234|a|x'
+-v3*= processing updates for '1234|a|x'
+#-v5*= reading './lists/flattest_flatsource_Packages'
+EOF
+
+cat > flatsource/Packages <<EOF
+
+EOF
+pkgmd="$(mdandsize flatsource/Packages)"
+gzip -f flatsource/Packages
+cat > flatsource/Release <<EOF
+MD5Sum:
+ $EMPTYMD5 Sources
+ $(mdandsize flatsource/Sources.gz) Sources.gz
+ $pkgmd Packages
+ $(mdandsize flatsource/Packages.gz) Packages.gz
+EOF
+
+testrun - -b . update 1234 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Release'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Release'
+-v2*=Copy file '$WORKDIR/flatsource/Release' to './lists/flattest_flatsource_flat_Release'...
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Packages.gz'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Packages.gz'
+-v2*=Uncompress '$WORKDIR/flatsource/Packages.gz' into './lists/flattest_flatsource_Packages' using '/bin/gunzip'...
+stdout
+-v0*=Calculating packages to get...
+-v4*= nothing to do for '1234|bb|source'
+-v4*= nothing to do for '1234|bb|yyyyyyyyyy'
+-v4*= nothing to do for '1234|bb|x'
+-v0*= nothing new for '1234|a|source' (use --noskipold to process anyway)
+-v4*= nothing to do for 'u|1234|a|yyyyyyyyyy'
+-v3*= processing updates for '1234|a|yyyyyyyyyy'
+-v5*= reading './lists/flattest_flatsource_Packages'
+-v4*= nothing to do for 'u|1234|a|x'
+-v3*= processing updates for '1234|a|x'
+#-v5*= reading './lists/flattest_flatsource_Packages'
+EOF
+
+cat > flatsource/Packages <<EOF
+Package: test
+Architecture: all
+Version: 0
+Filename: flatsource/test.deb
+EOF
+pkgmd="$(mdandsize flatsource/Packages)"
+gzip -f flatsource/Packages
+cat > flatsource/Release <<EOF
+MD5Sum:
+ $EMPTYMD5 Sources
+ $(mdandsize flatsource/Sources.gz) Sources.gz
+ $pkgmd Packages
+ $(mdandsize flatsource/Packages.gz) Packages.gz
+EOF
+
+testrun - -b . update 1234 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Release'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Release'
+-v2*=Copy file '$WORKDIR/flatsource/Release' to './lists/flattest_flatsource_flat_Release'...
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Packages.gz'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Packages.gz'
+-v2*=Uncompress '$WORKDIR/flatsource/Packages.gz' into './lists/flattest_flatsource_Packages' using '/bin/gunzip'...
+stdout
+-v0*=Calculating packages to get...
+-v4*= nothing to do for '1234|bb|source'
+-v4*= nothing to do for '1234|bb|yyyyyyyyyy'
+-v4*= nothing to do for '1234|bb|x'
+-v0*= nothing new for '1234|a|source' (use --noskipold to process anyway)
+-v4*= nothing to do for 'u|1234|a|yyyyyyyyyy'
+-v3*= processing updates for '1234|a|yyyyyyyyyy'
+-v5*= reading './lists/flattest_flatsource_Packages'
+stderr
+*=Missing 'Size' line in binary control chunk:
+*=No checksums found in binary control chunk:
+*= 'Package: test
+*=Architecture: all
+*=Version: 0
+*=Filename: flatsource/test.deb'
+-v1*=Stop reading further chunks from './lists/flattest_flatsource_Packages' due to previous errors.
+-v0*=There have been errors!
+return 249
+EOF
+
+cat > flatsource/Packages <<EOF
+Package: test
+Architecture: all
+Version: 0
+Filename: flatsource/test.deb
+Size: 0
+Description: test
+ test
+MD5Sum: $EMPTYMD5ONLY
+EOF
+pkgmd="$(mdandsize flatsource/Packages)"
+gzip -f flatsource/Packages
+cat > flatsource/Release <<EOF
+MD5Sum:
+ $EMPTYMD5 Sources
+ $(mdandsize flatsource/Sources.gz) Sources.gz
+ $pkgmd Packages
+ $(mdandsize flatsource/Packages.gz) Packages.gz
+EOF
+
+testrun - -b . update 1234 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Release'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Release'
+-v2*=Copy file '$WORKDIR/flatsource/Release' to './lists/flattest_flatsource_flat_Release'...
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Packages.gz'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Packages.gz'
+-v2*=Uncompress '$WORKDIR/flatsource/Packages.gz' into './lists/flattest_flatsource_Packages' using '/bin/gunzip'...
+stdout
+-v0*=Calculating packages to get...
+-v4*= nothing to do for '1234|bb|source'
+-v4*= nothing to do for '1234|bb|yyyyyyyyyy'
+-v4*= nothing to do for '1234|bb|x'
+-v0*= nothing new for '1234|a|source' (use --noskipold to process anyway)
+-v4*= nothing to do for 'u|1234|a|yyyyyyyyyy'
+-v3*= processing updates for '1234|a|yyyyyyyyyy'
+-v5*= reading './lists/flattest_flatsource_Packages'
+-v4*= nothing to do for 'u|1234|a|x'
+-v3*= processing updates for '1234|a|x'
+#-v5*= reading './lists/flattest_flatsource_Packages'
+-v2=Created directory "./pool"
+-v2=Created directory "./pool/a"
+-v2=Created directory "./pool/a/t"
+-v2=Created directory "./pool/a/t/test"
+-v0*=Getting packages...
+-v1*=Shutting down aptmethods...
+stderr
+-v6=aptmethod start 'file:$WORKDIR/flatsource/test.deb'
+*=aptmethod error receiving 'file:$WORKDIR/flatsource/test.deb':
+='File not found'
+='File not found - $WORKDIR/flatsource/test.deb (2: No such file or directory)'
+-v0*=There have been errors!
+return 255
+EOF
+
+touch flatsource/test.deb
+
+testrun - -b . update 1234 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Release'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Release'
+-v2*=Copy file '$WORKDIR/flatsource/Release' to './lists/flattest_flatsource_flat_Release'...
+-v6=aptmethod start 'file:$WORKDIR/flatsource/test.deb'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/test.deb'
+-v2*=Linking file '$WORKDIR/flatsource/test.deb' to './pool/a/t/test/test_0_all.deb'...
+stdout
+-v0*=Calculating packages to get...
+-v4*= nothing to do for '1234|bb|source'
+-v4*= nothing to do for '1234|bb|yyyyyyyyyy'
+-v4*= nothing to do for '1234|bb|x'
+-v0*= nothing new for '1234|a|source' (use --noskipold to process anyway)
+-v4*= nothing to do for 'u|1234|a|yyyyyyyyyy'
+-v3*= processing updates for '1234|a|yyyyyyyyyy'
+-v5*= reading './lists/flattest_flatsource_Packages'
+-v4*= nothing to do for 'u|1234|a|x'
+-v3*= processing updates for '1234|a|x'
+#-v5*= reading './lists/flattest_flatsource_Packages'
+-v2=Created directory "./pool"
+-v2=Created directory "./pool/a"
+-v2=Created directory "./pool/a/t"
+-v2=Created directory "./pool/a/t/test"
+-v0*=Getting packages...
+$(ofa 'pool/a/t/test/test_0_all.deb')
+-v1*=Shutting down aptmethods...
+-v0*=Installing (and possibly deleting) packages...
+$(opa 'test' 0 '1234' 'a' 'yyyyyyyyyy' 'deb')
+$(opa 'test' 0 '1234' 'a' 'x' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in '1234|a|x'...
+-v6*= replacing './dists/1234/a/binary-x/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'u|1234|a|x'...
+-v6*= looking for changes in '1234|a|yyyyyyyyyy'...
+-v6*= replacing './dists/1234/a/binary-yyyyyyyyyy/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'u|1234|a|yyyyyyyyyy'...
+-v6*= looking for changes in '1234|a|source'...
+-v6*= looking for changes in '1234|bb|x'...
+-v6*= looking for changes in '1234|bb|yyyyyyyyyy'...
+-v6*= looking for changes in '1234|bb|source'...
+EOF
+
+cat > flatsource/Packages <<EOF
+Package: test
+Architecture: yyyyyyyyyy
+Version: 1
+Description: test
+ test
+Filename: flatsource/test.deb
+Size: 0
+MD5Sum: $EMPTYMD5ONLY
+EOF
+pkgmd="$(mdandsize flatsource/Packages)"
+gzip -f flatsource/Packages
+cat > flatsource/Release <<EOF
+MD5Sum:
+ $EMPTYMD5 Sources
+ $(mdandsize flatsource/Sources.gz) Sources.gz
+ $pkgmd Packages
+ $(mdandsize flatsource/Packages.gz) Packages.gz
+EOF
+
+testrun - -b . update 1234 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Release'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Release'
+-v2*=Copy file '$WORKDIR/flatsource/Release' to './lists/flattest_flatsource_flat_Release'...
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Packages.gz'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Packages.gz'
+-v2*=Uncompress '$WORKDIR/flatsource/Packages.gz' into './lists/flattest_flatsource_Packages' using '/bin/gunzip'...
+-v6=aptmethod start 'file:$WORKDIR/flatsource/test.deb'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/test.deb'
+-v2*=Linking file '$WORKDIR/flatsource/test.deb' to './pool/a/t/test/test_1_yyyyyyyyyy.deb'...
+stdout
+-v0*=Calculating packages to get...
+-v4*= nothing to do for '1234|bb|source'
+-v4*= nothing to do for '1234|bb|yyyyyyyyyy'
+-v4*= nothing to do for '1234|bb|x'
+-v0*= nothing new for '1234|a|source' (use --noskipold to process anyway)
+-v4*= nothing to do for 'u|1234|a|yyyyyyyyyy'
+-v3*= processing updates for '1234|a|yyyyyyyyyy'
+-v5*= reading './lists/flattest_flatsource_Packages'
+-v4*= nothing to do for 'u|1234|a|x'
+-v3*= processing updates for '1234|a|x'
+-v2=Created directory "./pool"
+-v2=Created directory "./pool/a"
+-v2=Created directory "./pool/a/t"
+-v2=Created directory "./pool/a/t/test"
+-v0*=Getting packages...
+$(ofa 'pool/a/t/test/test_1_yyyyyyyyyy.deb')
+-v1*=Shutting down aptmethods...
+-v0*=Installing (and possibly deleting) packages...
+$(opu 'test' unset 1 '1234' 'a' 'yyyyyyyyyy' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in '1234|a|x'...
+-v6*= looking for changes in 'u|1234|a|x'...
+-v6*= looking for changes in '1234|a|yyyyyyyyyy'...
+-v6*= replacing './dists/1234/a/binary-yyyyyyyyyy/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'u|1234|a|yyyyyyyyyy'...
+-v6*= looking for changes in '1234|a|source'...
+-v6*= looking for changes in '1234|bb|x'...
+-v6*= looking for changes in '1234|bb|yyyyyyyyyy'...
+-v6*= looking for changes in '1234|bb|source'...
+EOF
+
+touch fake.dsc
+
+cat > flatsource/Sources <<EOF
+Package: test
+Version: 0
+Description: test
+ test
+Files:
+ $EMPTYMD5 fake.dsc
+EOF
+srcmd="$(mdandsize flatsource/Sources)"
+gzip -f flatsource/Sources
+cat > flatsource/Release <<EOF
+MD5Sum:
+ $srcmd Sources
+ $(mdandsize flatsource/Sources.gz) Sources.gz
+ $pkgmd Packages
+ $(mdandsize flatsource/Packages.gz) Packages.gz
+EOF
+
+testrun - -b . update 1234 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Release'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Release'
+-v2*=Copy file '$WORKDIR/flatsource/Release' to './lists/flattest_flatsource_flat_Release'...
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Sources.gz'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Sources.gz'
+-v2*=Uncompress '$WORKDIR/flatsource/Sources.gz' into './lists/flattest_flatsource_Sources' using '/bin/gunzip'...
+-v6=aptmethod start 'file:$WORKDIR/./fake.dsc'
+-v1*=aptmethod got 'file:$WORKDIR/./fake.dsc'
+-v2*=Linking file '$WORKDIR/./fake.dsc' to './pool/a/t/test/fake.dsc'...
+stdout
+-v0*=Calculating packages to get...
+-v4*= nothing to do for '1234|bb|source'
+-v4*= nothing to do for '1234|bb|yyyyyyyyyy'
+-v4*= nothing to do for '1234|bb|x'
+-v3*= processing updates for '1234|a|source'
+-v0*= nothing new for '1234|a|yyyyyyyyyy' (use --noskipold to process anyway)
+-v4*= nothing to do for 'u|1234|a|yyyyyyyyyy'
+-v5*= reading './lists/flattest_flatsource_Sources'
+-v4*= nothing to do for 'u|1234|a|x'
+-v3*= nothing new for '1234|a|x' (use --noskipold to process anyway)
+-v0*=Getting packages...
+$(ofa 'pool/a/t/test/fake.dsc')
+-v1*=Shutting down aptmethods...
+-v0*=Installing (and possibly deleting) packages...
+$(opa 'test' unset '1234' 'a' 'source' 'dsc')
+-v0*=Exporting indices...
+-v6*= looking for changes in '1234|a|x'...
+-v6*= looking for changes in 'u|1234|a|x'...
+-v6*= looking for changes in '1234|a|yyyyyyyyyy'...
+-v6*= looking for changes in 'u|1234|a|yyyyyyyyyy'...
+-v6*= looking for changes in '1234|a|source'...
+-v6*= replacing './dists/1234/a/source/Sources' (gzipped)
+-v6*= looking for changes in '1234|bb|x'...
+-v6*= looking for changes in '1234|bb|yyyyyyyyyy'...
+-v6*= looking for changes in '1234|bb|source'...
+EOF
+
+cat > flatsource/Sources <<EOF
+Package: test
+Version: 1
+Files:
+ $EMPTYMD5 ../fake.dsc
+EOF
+srcmd="$(mdandsize flatsource/Sources)"
+gzip -f flatsource/Sources
+cat > flatsource/Release <<EOF
+MD5Sum:
+ $srcmd Sources
+ $(mdandsize flatsource/Sources.gz) Sources.gz
+ $pkgmd Packages
+ $(mdandsize flatsource/Packages.gz) Packages.gz
+EOF
+
+testrun - -b . update 1234 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Release'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Release'
+-v2*=Copy file '$WORKDIR/flatsource/Release' to './lists/flattest_flatsource_flat_Release'...
+-v6=aptmethod start 'file:$WORKDIR/flatsource/Sources.gz'
+-v1*=aptmethod got 'file:$WORKDIR/flatsource/Sources.gz'
+-v2*=Uncompress '$WORKDIR/flatsource/Sources.gz' into './lists/flattest_flatsource_Sources' using '/bin/gunzip'...
+stdout
+-v0*=Calculating packages to get...
+-v4*= nothing to do for '1234|bb|source'
+-v4*= nothing to do for '1234|bb|yyyyyyyyyy'
+-v4*= nothing to do for '1234|bb|x'
+-v3*= processing updates for '1234|a|source'
+-v5*= reading './lists/flattest_flatsource_Sources'
+stderr
+*=Character '/' not allowed within filename '../fake.dsc'!
+*=Forbidden characters in source package 'test'!
+*=Stop reading further chunks from './lists/flattest_flatsource_Sources' due to previous errors.
+stdout
+stderr
+-v0*=There have been errors!
+return 255
+EOF
+
+rm -r -f db conf dists pool lists flatsource fake.dsc
+testsuccess
diff --git a/tests/flood.test b/tests/flood.test
new file mode 100644
index 0000000..1541d23
--- /dev/null
+++ b/tests/flood.test
@@ -0,0 +1,744 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+mkdir test-1
+mkdir test-1/debian
+cat >test-1/debian/control <<END
+Source: test
+Section: interpreters
+Priority: required
+Maintainer: me <guess@who>
+Standards-Version: 0.0
+
+Package: sibling
+Architecture: any
+Description: bla
+ blub
+
+Package: siblingtoo
+Architecture: any
+Description: bla
+ blub
+
+Package: mytest
+Architecture: all
+Description: bla
+ blub
+END
+cat >test-1/debian/changelog <<END
+test (1-1) test; urgency=critical
+
+ * new upstream release (Closes: #allofthem)
+
+ -- me <guess@who> Mon, 01 Jan 1980 01:02:02 +0000
+END
+mkdir -p test-1/debian/tmp/DEBIAN
+touch test-1/debian/tmp/best-file-in-the-root
+cd test-1
+DEB_HOST_ARCH="another" dpkg-gencontrol -psibling -v2
+DEB_HOST_ARCH="another" dpkg --build debian/tmp ..
+DEB_HOST_ARCH="another" dpkg-gencontrol -psiblingtoo -v3
+DEB_HOST_ARCH="another" dpkg --build debian/tmp ..
+DEB_HOST_ARCH="another" dpkg-gencontrol -pmytest -v2
+DEB_HOST_ARCH="another" dpkg --build debian/tmp ..
+DEB_HOST_ARCH="another" dpkg-genchanges -b > ../test-1.changes
+DEB_HOST_ARCH="somemore" dpkg-gencontrol -psiblingtoo -v3
+DEB_HOST_ARCH="somemore" dpkg --build debian/tmp ..
+cd ..
+rm -r test-1
+mkdir test-2
+mkdir test-2/debian
+cat >test-2/debian/control <<END
+Source: test
+Section: interpreters
+Priority: required
+Maintainer: me <guess@who>
+Standards-Version: 0.0
+
+Package: sibling
+Architecture: any
+Description: bla
+ blub
+
+Package: siblingalso
+Architecture: any
+Description: bla
+ blub
+
+Package: mytest
+Architecture: all
+Description: bla
+ blub
+END
+cat >test-2/debian/changelog <<END
+test (2-1) test; urgency=critical
+
+ * bla bla bla (Closes: #allofthem)
+
+ -- me <guess@who> Mon, 01 Jan 1980 01:02:02 +0000
+test (1-1) test; urgency=critical
+
+ * new upstream release (Closes: #allofthem)
+
+ -- me <guess@who> Mon, 01 Jan 1980 01:02:02 +0000
+END
+mkdir -p test-2/debian/tmp/DEBIAN
+touch test-2/debian/tmp/best-file-in-the-root
+cd test-2
+dpkg-gencontrol -psiblingalso -v3.1
+dpkg --build debian/tmp ..
+dpkg-gencontrol -pmytest -v2.4
+dpkg --build debian/tmp ..
+dpkg-gencontrol -psibling -v2.2
+dpkg --build debian/tmp ..
+dpkg-genchanges -b > ../test-2.changes
+rm debian/files
+DEB_HOST_ARCH="another" dpkg-gencontrol -psibling -v2.2
+DEB_HOST_ARCH="another" dpkg --build debian/tmp ..
+dpkg-genchanges -b > ../test-2a.changes
+cd ..
+rm -r test-2
+
+for tracking in false true ; do
+
+mkdir conf
+cat > conf/distributions <<EOF
+Codename: two
+Components: main bad
+Architectures: source abacus another somemore
+EOF
+
+echo "with tracking is $tracking"
+if $tracking ; then
+ echo "Tracking: minimal" >> conf/distributions
+ if test x"${REPREPROOPTIONS#*--verbosedb}" != x"$REPREPROOPTIONS" ; then
+ TRACKINGTESTOPTIONS="-D t=1"
+ else
+ TRACKINGTESTOPTIONS="-D t=0"
+ fi
+else
+ TRACKINGTESTOPTIONS="-D t=0"
+fi
+
+cat >> conf/distributions <<EOF
+
+Codename: test
+Components: main bad
+Architectures: source abacus another somemore
+EOF
+
+testrun - -b . -A another include test test-1.changes 3<<EOF
+stderr
+-v3*=Limiting 'mytest_2_all.deb' to architectures another as requested.
+stdout
+$(odb)
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/t"
+-v2*=Created directory "./pool/main/t/test"
+$(ofa 'pool/main/t/test/mytest_2_all.deb')
+$(ofa 'pool/main/t/test/siblingtoo_3_another.deb')
+$(ofa 'pool/main/t/test/sibling_2_another.deb')
+$(opa 'mytest' 2 'test' 'main' 'another' 'deb')
+$(opa 'siblingtoo' 3 'test' 'main' 'another' 'deb')
+$(opa 'sibling' 2 'test' 'main' 'another' 'deb')
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/test"
+-v2*=Created directory "./dists/test/main"
+-v2*=Created directory "./dists/test/main/binary-abacus"
+-v2*=Created directory "./dists/test/main/binary-another"
+-v2*=Created directory "./dists/test/main/binary-somemore"
+-v2*=Created directory "./dists/test/main/source"
+-v2*=Created directory "./dists/test/bad"
+-v2*=Created directory "./dists/test/bad/binary-abacus"
+-v2*=Created directory "./dists/test/bad/binary-another"
+-v2*=Created directory "./dists/test/bad/binary-somemore"
+-v2*=Created directory "./dists/test/bad/source"
+-v6*= looking for changes in 'test|main|abacus'...
+-v6*= creating './dists/test/main/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'test|main|another'...
+-v6*= creating './dists/test/main/binary-another/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'test|main|somemore'...
+-v6*= creating './dists/test/main/binary-somemore/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'test|main|source'...
+-v6*= creating './dists/test/main/source/Sources' (gzipped)
+-v6*= looking for changes in 'test|bad|abacus'...
+-v6*= creating './dists/test/bad/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'test|bad|another'...
+-v6*= creating './dists/test/bad/binary-another/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'test|bad|somemore'...
+-v6*= creating './dists/test/bad/binary-somemore/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'test|bad|source'...
+-v6*= creating './dists/test/bad/source/Sources' (gzipped)
+EOF
+
+testrun - -b . -A "abacus" include test test-2.changes 3<<EOF
+stderr
+-v3*=Limiting 'mytest_2.4_all.deb' to architectures abacus as requested.
+stdout
+$(ofa 'pool/main/t/test/mytest_2.4_all.deb')
+$(ofa 'pool/main/t/test/siblingalso_3.1_abacus.deb')
+$(ofa 'pool/main/t/test/sibling_2.2_abacus.deb')
+$(opa 'mytest' x 'test' 'main' 'abacus' 'deb')
+$(opa 'siblingalso' x 'test' 'main' 'abacus' 'deb')
+$(opa 'sibling' x 'test' 'main' 'abacus' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test|main|abacus'...
+-v6*= replacing './dists/test/main/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'test|main|another'...
+-v6*= looking for changes in 'test|main|somemore'...
+-v6*= looking for changes in 'test|main|source'...
+-v6*= looking for changes in 'test|bad|abacus'...
+-v6*= looking for changes in 'test|bad|another'...
+-v6*= looking for changes in 'test|bad|somemore'...
+-v6*= looking for changes in 'test|bad|source'...
+EOF
+
+if $tracking ; then
+echo "Tracking: minimal" >> conf/distributions
+testrun - -b . retrack test 3<<EOF
+stdout
+*=Retracking test...
+#2 times:
+$(ota 'test' 'test')
+EOF
+fi
+
+testrun - -b . list test 3<<EOF
+stdout
+*=test|main|abacus: mytest 2.4
+*=test|main|abacus: sibling 2.2
+*=test|main|abacus: siblingalso 3.1
+*=test|main|another: mytest 2
+*=test|main|another: sibling 2
+*=test|main|another: siblingtoo 3
+EOF
+
+testrun - -b . flood test 3<<EOF
+stdout
+$(opa 'mytest' x 'test' 'main' 'somemore' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test|main|abacus'...
+-v6*= looking for changes in 'test|main|another'...
+-v6*= looking for changes in 'test|main|somemore'...
+-v6*= replacing './dists/test/main/binary-somemore/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'test|main|source'...
+-v6*= looking for changes in 'test|bad|abacus'...
+-v6*= looking for changes in 'test|bad|another'...
+-v6*= looking for changes in 'test|bad|somemore'...
+-v6*= looking for changes in 'test|bad|source'...
+EOF
+
+testrun - -b . list test 3<<EOF
+stdout
+*=test|main|abacus: mytest 2.4
+*=test|main|abacus: sibling 2.2
+*=test|main|abacus: siblingalso 3.1
+*=test|main|another: mytest 2
+*=test|main|another: sibling 2
+*=test|main|another: siblingtoo 3
+*=test|main|somemore: mytest 2.4
+EOF
+
+testrun - -b . -C main -A somemore includedeb test siblingtoo_3_somemore.deb 3<<EOF
+stdout
+$(ofa 'pool/main/t/test/siblingtoo_3_somemore.deb')
+$(opa 'siblingtoo' x 'test' 'main' 'somemore' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test|main|abacus'...
+-v6*= looking for changes in 'test|main|another'...
+-v6*= looking for changes in 'test|main|somemore'...
+-v6*= replacing './dists/test/main/binary-somemore/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'test|main|source'...
+-v6*= looking for changes in 'test|bad|abacus'...
+-v6*= looking for changes in 'test|bad|another'...
+-v6*= looking for changes in 'test|bad|somemore'...
+-v6*= looking for changes in 'test|bad|source'...
+EOF
+
+testrun empty -b . flood test
+
+testrun - -b . -A somemore remove test mytest 3<<EOF
+stdout
+$(opd 'mytest' unset test main somemore deb)
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test|main|abacus'...
+-v6*= looking for changes in 'test|main|another'...
+-v6*= looking for changes in 'test|main|somemore'...
+-v6*= replacing './dists/test/main/binary-somemore/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'test|main|source'...
+-v6*= looking for changes in 'test|bad|abacus'...
+-v6*= looking for changes in 'test|bad|another'...
+-v6*= looking for changes in 'test|bad|somemore'...
+-v6*= looking for changes in 'test|bad|source'...
+EOF
+
+testrun - -b . list test 3<<EOF
+stdout
+*=test|main|abacus: mytest 2.4
+*=test|main|abacus: sibling 2.2
+*=test|main|abacus: siblingalso 3.1
+*=test|main|another: mytest 2
+*=test|main|another: sibling 2
+*=test|main|another: siblingtoo 3
+*=test|main|somemore: siblingtoo 3
+EOF
+
+testrun - -b . flood test 3<<EOF
+stdout
+$(opa 'mytest' x 'test' 'main' 'somemore' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test|main|abacus'...
+-v6*= looking for changes in 'test|main|another'...
+-v6*= looking for changes in 'test|main|somemore'...
+-v6*= replacing './dists/test/main/binary-somemore/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'test|main|source'...
+-v6*= looking for changes in 'test|bad|abacus'...
+-v6*= looking for changes in 'test|bad|another'...
+-v6*= looking for changes in 'test|bad|somemore'...
+-v6*= looking for changes in 'test|bad|source'...
+EOF
+
+testrun - -b . list test 3<<EOF
+stdout
+*=test|main|abacus: mytest 2.4
+*=test|main|abacus: sibling 2.2
+*=test|main|abacus: siblingalso 3.1
+*=test|main|another: mytest 2
+*=test|main|another: sibling 2
+*=test|main|another: siblingtoo 3
+*=test|main|somemore: siblingtoo 3
+*=test|main|somemore: mytest 2
+EOF
+
+testrun - -b . -C main includedeb test sibling_2.2_another.deb 3<<EOF
+stdout
+$(ofa 'pool/main/t/test/sibling_2.2_another.deb')
+$(opu 'sibling' x x 'test' 'main' 'another' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test|main|abacus'...
+-v6*= looking for changes in 'test|main|another'...
+-v6*= replacing './dists/test/main/binary-another/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'test|main|somemore'...
+-v6*= looking for changes in 'test|main|source'...
+-v6*= looking for changes in 'test|bad|abacus'...
+-v6*= looking for changes in 'test|bad|another'...
+-v6*= looking for changes in 'test|bad|somemore'...
+-v6*= looking for changes in 'test|bad|source'...
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/main/t/test/sibling_2_another.deb')
+EOF
+
+if $tracking ; then
+testout - -b . dumptracks test 3<<EOF
+EOF
+cat > results.expected <<EOF
+Distribution: test
+Source: test
+Version: 1-1
+Files:
+ pool/main/t/test/mytest_2_all.deb a 2
+ pool/main/t/test/siblingtoo_3_another.deb b 1
+ pool/main/t/test/siblingtoo_3_somemore.deb b 1
+
+Distribution: test
+Source: test
+Version: 2-1
+Files:
+ pool/main/t/test/mytest_2.4_all.deb a 1
+ pool/main/t/test/sibling_2.2_abacus.deb b 1
+ pool/main/t/test/siblingalso_3.1_abacus.deb b 1
+ pool/main/t/test/sibling_2.2_another.deb b 1
+
+EOF
+dodiff results.expected results
+fi
+
+testrun - -b . flood test 3<<EOF
+stdout
+$(opu 'mytest' x x 'test' 'main' 'another' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test|main|abacus'...
+-v6*= looking for changes in 'test|main|another'...
+-v6*= replacing './dists/test/main/binary-another/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'test|main|somemore'...
+-v6*= looking for changes in 'test|main|source'...
+-v6*= looking for changes in 'test|bad|abacus'...
+-v6*= looking for changes in 'test|bad|another'...
+-v6*= looking for changes in 'test|bad|somemore'...
+-v6*= looking for changes in 'test|bad|source'...
+EOF
+
+testrun - -b . list test 3<<EOF
+stdout
+*=test|main|abacus: mytest 2.4
+*=test|main|abacus: sibling 2.2
+*=test|main|abacus: siblingalso 3.1
+*=test|main|another: mytest 2.4
+*=test|main|another: sibling 2.2
+*=test|main|another: siblingtoo 3
+*=test|main|somemore: siblingtoo 3
+*=test|main|somemore: mytest 2
+EOF
+
+if $tracking ; then
+testout - -b . dumptracks test 3<<EOF
+EOF
+cat > results.expected <<EOF
+Distribution: test
+Source: test
+Version: 1-1
+Files:
+ pool/main/t/test/mytest_2_all.deb a 1
+ pool/main/t/test/siblingtoo_3_another.deb b 1
+ pool/main/t/test/siblingtoo_3_somemore.deb b 1
+
+Distribution: test
+Source: test
+Version: 2-1
+Files:
+ pool/main/t/test/mytest_2.4_all.deb a 2
+ pool/main/t/test/sibling_2.2_abacus.deb b 1
+ pool/main/t/test/siblingalso_3.1_abacus.deb b 1
+ pool/main/t/test/sibling_2.2_another.deb b 1
+
+EOF
+dodiff results.expected results
+fi
+
+cat > conf/incoming << EOF
+Name: myrule
+Allow: test>two
+Options: limit_arch_all
+IncomingDir: i
+TempDir: tmp
+EOF
+
+ls *.changes
+mkdir i tmp
+cp test-1.changes sibling_2_another.deb siblingtoo_3_another.deb mytest_2_all.deb i/
+
+testrun - -b . processincoming myrule 3<<EOF
+stdout
+$(ofa 'pool/main/t/test/sibling_2_another.deb')
+$(opa 'mytest' x 'two' 'main' 'another' 'deb')
+$(opa 'siblingtoo' x 'two' 'main' 'another' 'deb')
+$(opa 'sibling' x 'two' 'main' 'another' 'deb')
+$(otta 'two' 'test')
+-v1*=deleting './i/mytest_2_all.deb'...
+-v1*=deleting './i/siblingtoo_3_another.deb'...
+-v1*=deleting './i/test-1.changes'...
+-v1*=deleting './i/sibling_2_another.deb'...
+-v0*=Exporting indices...
+-v2*=Created directory "./dists/two"
+-v2*=Created directory "./dists/two/main"
+-v2*=Created directory "./dists/two/main/binary-abacus"
+-v2*=Created directory "./dists/two/main/binary-another"
+-v2*=Created directory "./dists/two/main/binary-somemore"
+-v2*=Created directory "./dists/two/main/source"
+-v2*=Created directory "./dists/two/bad"
+-v2*=Created directory "./dists/two/bad/binary-abacus"
+-v2*=Created directory "./dists/two/bad/binary-another"
+-v2*=Created directory "./dists/two/bad/binary-somemore"
+-v2*=Created directory "./dists/two/bad/source"
+-v6*= looking for changes in 'two|main|abacus'...
+-v6*= creating './dists/two/main/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'two|main|another'...
+-v6*= creating './dists/two/main/binary-another/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'two|main|somemore'...
+-v6*= creating './dists/two/main/binary-somemore/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'two|main|source'...
+-v6*= creating './dists/two/main/source/Sources' (gzipped)
+-v6*= looking for changes in 'two|bad|abacus'...
+-v6*= creating './dists/two/bad/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'two|bad|another'...
+-v6*= creating './dists/two/bad/binary-another/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'two|bad|somemore'...
+-v6*= creating './dists/two/bad/binary-somemore/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'two|bad|source'...
+-v6*= creating './dists/two/bad/source/Sources' (gzipped)
+EOF
+
+testrun - -b . list two 3<<EOF
+stdout
+*=two|main|another: mytest 2
+*=two|main|another: sibling 2
+*=two|main|another: siblingtoo 3
+EOF
+
+if $tracking ; then
+testrun - -b . dumptracks two 3<<EOF
+stdout
+*=Distribution: two
+*=Source: test
+*=Version: 1-1
+*=Files:
+*= pool/main/t/test/sibling_2_another.deb b 1
+*= pool/main/t/test/siblingtoo_3_another.deb b 1
+*= pool/main/t/test/mytest_2_all.deb a 1
+*=
+EOF
+fi
+
+testrun - -b . flood two 3<<EOF
+stdout
+$(opa 'mytest' x 'two' 'main' 'somemore' 'deb')
+$(opa 'mytest' x 'two' 'main' 'abacus' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'two|main|abacus'...
+-v6*= replacing './dists/two/main/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'two|main|another'...
+-v6*= looking for changes in 'two|main|somemore'...
+-v6*= replacing './dists/two/main/binary-somemore/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'two|main|source'...
+-v6*= looking for changes in 'two|bad|abacus'...
+-v6*= looking for changes in 'two|bad|another'...
+-v6*= looking for changes in 'two|bad|somemore'...
+-v6*= looking for changes in 'two|bad|source'...
+EOF
+
+testrun - -b . list two 3<<EOF
+stdout
+*=two|main|abacus: mytest 2
+*=two|main|another: mytest 2
+*=two|main|another: sibling 2
+*=two|main|another: siblingtoo 3
+*=two|main|somemore: mytest 2
+EOF
+
+if $tracking ; then
+testrun - -b . dumptracks two 3<<EOF
+stdout
+*=Distribution: two
+*=Source: test
+*=Version: 1-1
+*=Files:
+*= pool/main/t/test/sibling_2_another.deb b 1
+*= pool/main/t/test/siblingtoo_3_another.deb b 1
+*= pool/main/t/test/mytest_2_all.deb a 3
+*=
+EOF
+fi
+
+dodo rmdir i
+mkdir i
+
+cp test-2.changes siblingalso_3.1_abacus.deb mytest_2.4_all.deb sibling_2.2_abacus.deb i/
+
+testrun - -b . processincoming myrule 3<<EOF
+stdout
+$(opu 'mytest' x x 'two' 'main' 'abacus' 'deb')
+$(opa 'siblingalso' x 'two' 'main' 'abacus' 'deb')
+$(opa 'sibling' x 'two' 'main' 'abacus' 'deb')
+$(otta 'two' 'test')
+-v1*=deleting './i/mytest_2.4_all.deb'...
+-v1*=deleting './i/siblingalso_3.1_abacus.deb'...
+-v1*=deleting './i/sibling_2.2_abacus.deb'...
+-v1*=deleting './i/test-2.changes'...
+-v0*=Exporting indices...
+-v6*= looking for changes in 'two|main|abacus'...
+-v6*= replacing './dists/two/main/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'two|main|another'...
+-v6*= looking for changes in 'two|main|somemore'...
+-v6*= looking for changes in 'two|main|source'...
+-v6*= looking for changes in 'two|bad|abacus'...
+-v6*= looking for changes in 'two|bad|another'...
+-v6*= looking for changes in 'two|bad|somemore'...
+-v6*= looking for changes in 'two|bad|source'...
+EOF
+
+testrun - -b . list two 3<<EOF
+stdout
+*=two|main|abacus: mytest 2.4
+*=two|main|abacus: sibling 2.2
+*=two|main|abacus: siblingalso 3.1
+*=two|main|another: mytest 2
+*=two|main|another: sibling 2
+*=two|main|another: siblingtoo 3
+*=two|main|somemore: mytest 2
+EOF
+
+if $tracking ; then
+testout "" -b . dumptracks two
+cat > results.expected <<EOF
+Distribution: two
+Source: test
+Version: 1-1
+Files:
+ pool/main/t/test/mytest_2_all.deb a 2
+ pool/main/t/test/sibling_2_another.deb b 1
+ pool/main/t/test/siblingtoo_3_another.deb b 1
+
+Distribution: two
+Source: test
+Version: 2-1
+Files:
+ pool/main/t/test/mytest_2.4_all.deb a 1
+ pool/main/t/test/sibling_2.2_abacus.deb b 1
+ pool/main/t/test/siblingalso_3.1_abacus.deb b 1
+
+EOF
+dodiff results.expected results
+fi
+
+testrun - -b . flood two 3<<EOF
+stdout
+$(opu 'mytest' x x 'two' 'main' 'somemore' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'two|main|abacus'...
+-v6*= looking for changes in 'two|main|another'...
+-v6*= looking for changes in 'two|main|somemore'...
+-v6*= replacing './dists/two/main/binary-somemore/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'two|main|source'...
+-v6*= looking for changes in 'two|bad|abacus'...
+-v6*= looking for changes in 'two|bad|another'...
+-v6*= looking for changes in 'two|bad|somemore'...
+-v6*= looking for changes in 'two|bad|source'...
+EOF
+
+testrun - -b . list two 3<<EOF
+stdout
+*=two|main|abacus: mytest 2.4
+*=two|main|abacus: sibling 2.2
+*=two|main|abacus: siblingalso 3.1
+*=two|main|another: mytest 2
+*=two|main|another: sibling 2
+*=two|main|another: siblingtoo 3
+*=two|main|somemore: mytest 2.4
+EOF
+
+if $tracking ; then
+testout "" -b . dumptracks two
+cat > results.expected <<EOF
+Distribution: two
+Source: test
+Version: 1-1
+Files:
+ pool/main/t/test/mytest_2_all.deb a 1
+ pool/main/t/test/sibling_2_another.deb b 1
+ pool/main/t/test/siblingtoo_3_another.deb b 1
+
+Distribution: two
+Source: test
+Version: 2-1
+Files:
+ pool/main/t/test/mytest_2.4_all.deb a 2
+ pool/main/t/test/sibling_2.2_abacus.deb b 1
+ pool/main/t/test/siblingalso_3.1_abacus.deb b 1
+
+EOF
+dodiff results.expected results
+fi
+
+dodo rmdir i
+mkdir i
+cp test-2a.changes sibling_2.2_another.deb i/
+
+testrun - -b . processincoming myrule 3<<EOF
+stdout
+$(opu 'sibling' x x 'two' 'main' 'another' 'deb')
+-v1*=deleting './i/sibling_2.2_another.deb'...
+-v1*=deleting './i/test-2a.changes'...
+-v0*=Exporting indices...
+-v6*= looking for changes in 'two|main|abacus'...
+-v6*= looking for changes in 'two|main|another'...
+-v6*= replacing './dists/two/main/binary-another/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'two|main|somemore'...
+-v6*= looking for changes in 'two|main|source'...
+-v6*= looking for changes in 'two|bad|abacus'...
+-v6*= looking for changes in 'two|bad|another'...
+-v6*= looking for changes in 'two|bad|somemore'...
+-v6*= looking for changes in 'two|bad|source'...
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/main/t/test/sibling_2_another.deb')
+EOF
+
+testrun - -b . list two 3<<EOF
+stdout
+*=two|main|abacus: mytest 2.4
+*=two|main|abacus: sibling 2.2
+*=two|main|abacus: siblingalso 3.1
+*=two|main|another: mytest 2
+*=two|main|another: sibling 2.2
+*=two|main|another: siblingtoo 3
+*=two|main|somemore: mytest 2.4
+EOF
+
+if $tracking ; then
+testout "" -b . dumptracks two
+cat > results.expected <<EOF
+Distribution: two
+Source: test
+Version: 1-1
+Files:
+ pool/main/t/test/mytest_2_all.deb a 1
+ pool/main/t/test/siblingtoo_3_another.deb b 1
+
+Distribution: two
+Source: test
+Version: 2-1
+Files:
+ pool/main/t/test/mytest_2.4_all.deb a 2
+ pool/main/t/test/sibling_2.2_abacus.deb b 1
+ pool/main/t/test/siblingalso_3.1_abacus.deb b 1
+ pool/main/t/test/sibling_2.2_another.deb b 1
+
+EOF
+dodiff results.expected results
+fi
+
+testrun - -b . flood two 3<<EOF
+stdout
+$(opu 'mytest' x x 'two' 'main' 'another' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'two|main|abacus'...
+-v6*= looking for changes in 'two|main|another'...
+-v6*= replacing './dists/two/main/binary-another/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'two|main|somemore'...
+-v6*= looking for changes in 'two|main|source'...
+-v6*= looking for changes in 'two|bad|abacus'...
+-v6*= looking for changes in 'two|bad|another'...
+-v6*= looking for changes in 'two|bad|somemore'...
+-v6*= looking for changes in 'two|bad|source'...
+EOF
+
+testrun - -b . list two 3<<EOF
+stdout
+*=two|main|abacus: mytest 2.4
+*=two|main|abacus: sibling 2.2
+*=two|main|abacus: siblingalso 3.1
+*=two|main|another: mytest 2.4
+*=two|main|another: sibling 2.2
+*=two|main|another: siblingtoo 3
+*=two|main|somemore: mytest 2.4
+EOF
+
+if $tracking ; then
+testout "" -b . dumptracks two
+cat > results.expected <<EOF
+Distribution: two
+Source: test
+Version: 1-1
+Files:
+ pool/main/t/test/siblingtoo_3_another.deb b 1
+
+Distribution: two
+Source: test
+Version: 2-1
+Files:
+ pool/main/t/test/mytest_2.4_all.deb a 3
+ pool/main/t/test/sibling_2.2_abacus.deb b 1
+ pool/main/t/test/siblingalso_3.1_abacus.deb b 1
+ pool/main/t/test/sibling_2.2_another.deb b 1
+
+EOF
+dodiff results.expected results
+fi
+
+rm -r conf dists pool db
+dodo rmdir i tmp
+done
+
+rm *.deb *.changes results results.expected
+testsuccess
diff --git a/tests/genpackage.sh b/tests/genpackage.sh
new file mode 100755
index 0000000..f228918
--- /dev/null
+++ b/tests/genpackage.sh
@@ -0,0 +1,106 @@
+#!/bin/bash
+set -e
+#PACKAGE=bloat+-0a9z.app
+#EPOCH=99:
+#VERSION=0.9-A:Z+a:z
+#REVISION=-0+aA.9zZ
+if [ "x$OUTPUT" == "x" ] ; then
+ OUTPUT=${PACKAGE}_${VERSION}${REVISION}_${ARCH:-$(dpkg-architecture -qDEB_HOST_ARCH)}.changes
+fi
+
+DIR="$PACKAGE-$VERSION"
+ARCH="${ARCH:-$(dpkg-architecture -qDEB_HOST_ARCH)}"
+rm -rf "$DIR"
+mkdir "$DIR"
+mkdir "$DIR"/debian
+cat >"$DIR"/debian/control <<END
+Source: $PACKAGE
+Section: $SECTION
+Priority: optional
+Maintainer: me <guess@who>
+Standards-Version: 0.0
+
+Package: $PACKAGE
+Architecture: ${ARCH}
+Description: bla
+ blub
+
+Package: ${PACKAGE}-addons
+Architecture: all
+Description: bla
+ blub
+END
+
+if test -n "${DDEB-}" ; then
+cat >>"$DIR"/debian/control <<END
+
+Package: ${PACKAGE}-dbgsym
+Architecture: ${ARCH}
+Description: ${PACKAGE} debug symbols
+Package-Type: ddeb
+END
+fi
+
+if test -z "$DISTRI" ; then
+ DISTRI=test1
+fi
+cat >"$DIR"/debian/changelog <<END
+$PACKAGE ($EPOCH$VERSION$REVISION) $DISTRI; urgency=critical
+
+ * new upstream release (Closes: #allofthem)
+
+ -- me <guess@who> Mon, 01 Jan 1980 01:02:02 +0000
+END
+
+mkdir -p "$DIR/debian/source"
+if test -z "$REVISION"; then
+ echo "3.0 (native)" > "$DIR/debian/source/format"
+else
+ echo "3.0 (quilt)" > "$DIR/debian/source/format"
+ orig_tarball="${PACKAGE}_${VERSION}.orig.tar.gz"
+ if test ! -f "$orig_tarball"; then
+ tar czvf "$orig_tarball" --files-from /dev/null
+ fi
+fi
+
+dpkg-source -b "$DIR" > /dev/null
+mkdir -p "$DIR"/debian/tmp/DEBIAN
+touch "$DIR"/debian/tmp/x
+mkdir "$DIR"/debian/tmp/a
+touch "$DIR"/debian/tmp/a/1
+mkdir "$DIR"/debian/tmp/dir
+touch "$DIR"/debian/tmp/dir/file
+touch "$DIR"/debian/tmp/dir/another
+mkdir "$DIR"/debian/tmp/dir/subdir
+touch "$DIR"/debian/tmp/dir/subdir/file
+cd "$DIR"
+for pkg in `grep '^Package: ' debian/control | sed -e 's/^Package: //'` ; do
+ case "$pkg" in
+ (*-udeb)
+ deb="${pkg}_${VERSION}${REVISION}_${ARCH}.udeb"
+ ;;
+ (*-dbgsym)
+ deb="${pkg}_${VERSION}${REVISION}_${ARCH}.ddeb"
+ ;;
+ (*-addons)
+ deb="${pkg}_${FAKEVER:-${VERSION}${REVISION}}_all.deb"
+ ;;
+ (*)
+ deb="${pkg}_${VERSION}${REVISION}_${ARCH}.deb"
+ ;;
+ esac
+ if [ "x$pkg" != "x${pkg%-addons}" -a -n "$FAKEVER" ] ; then
+ dpkg-gencontrol -p$pkg -v"$FAKEVER"
+ else
+ dpkg-gencontrol -p$pkg
+ fi
+ dpkg --build debian/tmp ../$deb > /dev/null
+done
+dpkg-genchanges -q "$@" > "$OUTPUT".pre
+# simulate dpkg-genchanges behaviour currently in sid so the testsuite runs for backports, too
+awk 'BEGIN{inheader=0} /^Files:/ || (inheader && /^ /) {inheader = 1; next} {inheader = 0 ; print}' "$OUTPUT".pre | sed -e 's/ \+$//' >../"$OUTPUT"
+echo "Files:" >> ../"$OUTPUT"
+awk 'BEGIN{inheader=0} (inheader && /^ .*\.deb$/) {print ; next} /^Files:/ || (inheader && /^ /) {inheader = 1; next} {inheader = 0 ;next}' "$OUTPUT".pre >>../"$OUTPUT"
+awk 'BEGIN{inheader=0} /^Files:/ || (inheader && /^ .*\.deb$/) {inheader = 1 ; next } (inheader && /^ /) {print ; next} {inheader = 0 ;next}' "$OUTPUT".pre >>../"$OUTPUT"
+cd ..
+rm -r "$DIR"
diff --git a/tests/good.key b/tests/good.key
new file mode 100644
index 0000000..eb79388
--- /dev/null
+++ b/tests/good.key
@@ -0,0 +1,18 @@
+-----BEGIN PGP PRIVATE KEY BLOCK-----
+Version: GnuPG v1.4.6 (GNU/Linux)
+
+lQG7BEgsPz8RBADX5e8fzCqw5pxVuzjBbFoK3DqKZ//8wPqoRqu6IvbyqnGI1fCj
+aXgbKPMLBxX4yBSSU47V+o5rQjmAzfQEfDix1NHh1qU3FLqHRLqoop9IQACzgGEp
+qLl4Xyb4SpuMS6zVHiWT5mktlmIByjK3ME2Tog41nT5mvvijHdPOoDZ2PwCg4jSe
+s3vhqQJm1VCFFMOMbnsqkWkEAIMQ/VYH5EawKhCfGDAbPgwbcZ5PAnyi5kF81KcK
+l0T6BxLOZml74Ky7PuKbPgxx0b0MPpBGwjCj2ZiL80phWh/3JWHvCbZ6q9xb6b7Z
+rN5GuX0lwdlkUFFxxq1JIHhAzpTxm/yIfBs4xJtsNqI1fBT6VrfbydUGJRWIVXAG
+0i9xBACORO/dH1eMYxRZTA2029QWwOOkkby1jwVm2AXfw4ZBKtSQKODZWO/OkgC1
++bUn9lsrMvWrcyOqdOBd45iVTezOOlZse4V2VmGbAr2sTSm03f7AMiFvCmsw3uBW
+eH3QC5BkzSkBN4AlixPm6ci/q+2BTcMWW8p8nl2UTuZ6idYQBwAAn3QZLp6CH35G
+9sqCMS5t5Gd0m9QaCbO0S1JlcHJlcHJvIFRlc3RzdWl0ZSBLZXkgMSAoRk9SIFVT
+RSBXSVRISU4gVEVTVFNVSVRFIE9OTFkpIDxnb29kQG5vd2hlcmUudGxkPohgBBMR
+AgAgBQJILD8/AhsDBgsJCAcDAgQVAggDBBYCAwECHgECF4AACgkQgPTEPtw8Kbi7
+GACePQ6nzWAAtx8H8DxbJjijye47SjwAoMDMrZjHw7oXebKyfPolG4YRXy33
+=qUTa
+-----END PGP PRIVATE KEY BLOCK-----
diff --git a/tests/includeasc.test b/tests/includeasc.test
new file mode 100644
index 0000000..ba46079
--- /dev/null
+++ b/tests/includeasc.test
@@ -0,0 +1,221 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+mkdir i j k
+
+# first create some fake package with .asc files:
+mkdir pkg-42
+tar -cvvzf pkg_42.orig.tar.gz pkg-42
+echo "Fake .asc file" > pkg_42.orig.tar.gz.asc
+cd pkg-42
+mkdir debian debian/source
+echo "3.0 (quilt)" > debian/source/format
+cat > debian/rules <<'EOF'
+#!/usr/bin/make
+clean:
+ echo clean
+EOF
+chmod a+x debian/rules
+cat > debian/changelog <<EOF
+pkg (42-42) test; urgency=low
+
+ * now ansers everything
+
+ -- Sky.NET <nowhere@example.com> Sat, 15 Jan 2000 17:12:05 +2700
+EOF
+
+cat > debian/control <<EOF
+Source: pkg
+Section: doc
+Priority: standard
+Maintainer: Sky.NET <nowhere@example.com>
+Standards-Version: Aleph_17
+
+Package: pkg-doc
+Architecture: all
+Description: pkg
+ pkg
+EOF
+
+cd ..
+dpkg-source -Zgzip -b pkg-42
+cd pkg-42
+
+OUTPUT=test.changes
+dpkg-genchanges > ../j/"$OUTPUT"
+cd ..
+cp pkg_* j/
+
+# now with an .asc filename that does not match:
+mv pkg_42.orig.tar.gz.asc pkg_42.tar.gz.asc
+sed -i 's/orig\.tar\.gz\.asc/tar.gz.asc/' pkg_42-42.dsc
+cd pkg-42
+
+dpkg-genchanges > ../k/broken.changes
+cd ..
+mv pkg_* k/
+rm -r pkg-42
+
+ls j
+cp j/* i/
+
+mkdir conf
+# first check files are properly ingored:
+cat > conf/distributions <<EOF
+Codename: test
+Architectures: coal source
+Components: main
+EOF
+
+mkdir -p pool/main/p/pkg
+
+testrun - --export=never include test i/test.changes 3<<EOF
+stderr
+=Warning: database 'test|main|source' was modified but no index file was exported.
+=Changes will only be visible after the next 'export'!
+stdout
+$(odb)
+$(ofa 'pool/main/p/pkg/pkg_42.orig.tar.gz')
+$(ofa 'pool/main/p/pkg/pkg_42.orig.tar.gz.asc')
+$(ofa 'pool/main/p/pkg/pkg_42-42.debian.tar.gz')
+$(ofa 'pool/main/p/pkg/pkg_42-42.dsc')
+$(opa 'pkg' x 'test' 'main' 'source' 'dsc')
+EOF
+rm -r pool db
+
+mkdir -p pool/main/p/pkg
+
+cat > conf/incoming <<EOF
+Name: foo
+IncomingDir: i
+TempDir: tmp
+Default: test
+EOF
+mkdir tmp
+
+testrun - --export=never processincoming foo 3<<EOF
+stderr
+=Warning: database 'test|main|source' was modified but no index file was exported.
+=Changes will only be visible after the next 'export'!
+stdout
+$(odb)
+$(ofa 'pool/main/p/pkg/pkg_42.orig.tar.gz')
+$(ofa 'pool/main/p/pkg/pkg_42.orig.tar.gz.asc')
+$(ofa 'pool/main/p/pkg/pkg_42-42.debian.tar.gz')
+$(ofa 'pool/main/p/pkg/pkg_42-42.dsc')
+$(opa 'pkg' x 'test' 'main' 'source' 'dsc')
+-v3*=deleting './i/test.changes'...
+-v3*=deleting './i/pkg_42.orig.tar.gz.asc'...
+-v3*=deleting './i/pkg_42.orig.tar.gz'...
+-v3*=deleting './i/pkg_42-42.dsc'...
+-v3*=deleting './i/pkg_42-42.debian.tar.gz'...
+EOF
+
+cat >> conf/distributions <<EOF
+Tracking: all
+EOF
+rm -r pool db
+cp j/* i/
+mkdir -p pool/main/p/pkg
+
+testrun - --export=never processincoming foo 3<<EOF
+stderr
+=Warning: database 'test|main|source' was modified but no index file was exported.
+=Changes will only be visible after the next 'export'!
+stdout
+$(odb)
+$(ofa 'pool/main/p/pkg/pkg_42.orig.tar.gz')
+$(ofa 'pool/main/p/pkg/pkg_42.orig.tar.gz.asc')
+$(ofa 'pool/main/p/pkg/pkg_42-42.debian.tar.gz')
+$(ofa 'pool/main/p/pkg/pkg_42-42.dsc')
+$(opa 'pkg' x 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'pkg')
+-v3*=deleting './i/test.changes'...
+-v3*=deleting './i/pkg_42.orig.tar.gz.asc'...
+-v3*=deleting './i/pkg_42.orig.tar.gz'...
+-v3*=deleting './i/pkg_42-42.dsc'...
+-v3*=deleting './i/pkg_42-42.debian.tar.gz'...
+EOF
+
+cat >results.expected <<EOF
+Distribution: test
+Source: pkg
+Version: 42-42
+Files:
+ pool/main/p/pkg/pkg_42-42.dsc s 1
+ pool/main/p/pkg/pkg_42.orig.tar.gz s 1
+ pool/main/p/pkg/pkg_42.orig.tar.gz.asc s 1
+ pool/main/p/pkg/pkg_42-42.debian.tar.gz s 1
+
+EOF
+
+rm -r pool db
+cp j/* i/
+mkdir -p pool/main/p/pkg
+
+testrun - --export=never -C main includedsc test i/pkg_42-42.dsc 3<<EOF
+stderr
+=Warning: database 'test|main|source' was modified but no index file was exported.
+=Changes will only be visible after the next 'export'!
+stdout
+$(odb)
+$(ofa 'pool/main/p/pkg/pkg_42.orig.tar.gz')
+$(ofa 'pool/main/p/pkg/pkg_42.orig.tar.gz.asc')
+$(ofa 'pool/main/p/pkg/pkg_42-42.debian.tar.gz')
+$(ofa 'pool/main/p/pkg/pkg_42-42.dsc')
+$(opa 'pkg' x 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'pkg')
+EOF
+
+testout - dumptracks test 3<<EOF
+EOF
+dodiff results.expected results
+
+rm -r pool db i
+mkdir -p i pool/main/p/pkg
+cp k/* i/
+
+testrun - --export=never include test i/broken.changes 3<<EOF
+returns 255
+stdout
+$(odb)
+stderr
+*=Signature file without file to be signed: 'pkg_42.tar.gz.asc'!
+-v0*=There have been errors!
+EOF
+
+rm -r pool db i
+mkdir -p i pool/main/p/pkg
+cp k/* i/
+
+testrun - --export=never processincoming foo 3<<EOF
+returns 255
+stdout
+$(odb)
+stderr
+*=Signature file without file to be signed: 'pkg_42.tar.gz.asc'!
+-v0*=There have been errors!
+EOF
+
+rm -r pool db i
+mkdir -p i pool/main/p/pkg
+cp k/* i/
+
+# includedsc does not care....
+testrun - --export=never -C main includedsc test i/pkg_42-42.dsc 3<<EOF
+stderr
+=Warning: database 'test|main|source' was modified but no index file was exported.
+=Changes will only be visible after the next 'export'!
+stdout
+$(odb)
+$(ofa 'pool/main/p/pkg/pkg_42.orig.tar.gz')
+$(ofa 'pool/main/p/pkg/pkg_42.tar.gz.asc')
+$(ofa 'pool/main/p/pkg/pkg_42-42.debian.tar.gz')
+$(ofa 'pool/main/p/pkg/pkg_42-42.dsc')
+$(opa 'pkg' x 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'pkg')
+EOF
+
+rm -r db pool
+rm -r i j tmp conf results results.expected
+testsuccess
diff --git a/tests/includeextra.test b/tests/includeextra.test
new file mode 100644
index 0000000..33d9cc1
--- /dev/null
+++ b/tests/includeextra.test
@@ -0,0 +1,857 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+# first create a fake package with logs and byhand files:
+mkdir documentation-9876AD
+cd documentation-9876AD
+mkdir debian
+cat > debian/rules <<'EOF'
+#!/usr/bin/make
+tmp = $(CURDIR)/debian/tmp
+binary-indep:
+ install -m 755 -d $(tmp)/DEBIAN $(tmp)/usr/share/doc/documentation
+ echo "I have told you so" > $(tmp)/usr/share/doc/documentation/NEWS
+ gzip -c9 debian/changelog > $(tmp)/usr/share/doc/documentation/changelog.gz
+ chown -R root.root $(tmp) && chmod -R go=rX $(tmp)
+ dpkg-gencontrol -isp
+ dpkg --build $(tmp) ..
+ echo "I forgot" >> ../manifesto.txt
+ echo "What?" >> ../history.txt
+ dpkg-distaddfile manifesto.txt byhand -
+ dpkg-distaddfile history.txt byhand -
+
+.PHONY: clean binary-arch binary-indep binary build build-indep buil-arch
+EOF
+chmod a+x debian/rules
+cat > debian/changelog <<EOF
+documentation (9876AD) test; urgency=low
+
+ * everything fixed
+
+ -- Sky.NET <nowhere@example.com> Sat, 15 Jan 2011 17:12:05 +2700
+EOF
+
+cat > debian/control <<EOF
+Source: documentation
+Section: doc
+Priority: standard
+Maintainer: Sky.NET <nowhere@example.com>
+Standards-Version: Aleph_17
+
+Package: documentation
+Architecture: all
+Description: documentation
+ documentation
+EOF
+
+cd ..
+dpkg-source -b documentation-9876AD ""
+cd documentation-9876AD
+
+fakeroot make -f debian/rules binary-indep > ../documentation_9876AD_coal+all.log
+OUTPUT=test.changes
+dpkg-genchanges > "$OUTPUT".pre
+# simulate dpkg-genchanges behaviour currently in sid so the testsuite runs for backports, too
+awk 'BEGIN{inheader=0} /^Files:/ || (inheader && /^ /) {inheader = 1; next} {inheader = 0 ; print}' "$OUTPUT".pre | sed -e 's/ \+$//' >../"$OUTPUT"
+echo "Files:" >> ../"$OUTPUT"
+awk 'BEGIN{inheader=0} (inheader && /^ .*\.deb$/) {print ; next} /^Files:/ || (inheader && /^ /) {inheader = 1; next} {inheader = 0 ;next}' "$OUTPUT".pre >>../"$OUTPUT"
+awk 'BEGIN{inheader=0} (inheader && /^ .*\.txt$/) {print ; next} /^Files:/ || (inheader && /^ /) {inheader = 1; next} {inheader = 0 ;next}' "$OUTPUT".pre >>../"$OUTPUT"
+awk 'BEGIN{inheader=0} /^Files:/ || (inheader && /^ .*\.(deb|txt)$/) {inheader = 1 ; next } (inheader && /^ /) {print ; next} {inheader = 0 ;next}' "$OUTPUT".pre >>../"$OUTPUT"
+cd ..
+rm -r documentation-9876AD
+
+ed -s test.changes <<EOF
+/^Files:/a
+ $(mdandsize documentation_9876AD_coal+all.log) - - documentation_9876AD_coal+all.log
+.
+w
+q
+EOF
+
+mkdir conf
+# first check files are properly ingored:
+cat > conf/distributions <<EOF
+Codename: test
+Architectures: coal source
+Components: main
+EOF
+
+testrun - include test test.changes 3<<EOF
+stderr
+*=Ignoring byhand file: 'manifesto.txt'!
+*=Ignoring byhand file: 'history.txt'!
+*=Ignoring log file: 'documentation_9876AD_coal+all.log'!
+stdout
+$(odb)
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/d"
+-v2*=Created directory "./pool/main/d/documentation"
+$(ofa 'pool/main/d/documentation/documentation_9876AD_all.deb')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.tar.gz')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.dsc')
+$(opa 'documentation' x 'test' 'main' 'coal' 'deb')
+$(opa 'documentation' x 'test' 'main' 'source' 'dsc')
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/test"
+-v2*=Created directory "./dists/test/main"
+-v2*=Created directory "./dists/test/main/binary-coal"
+-v6*= looking for changes in 'test|main|coal'...
+-v6*= creating './dists/test/main/binary-coal/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/test/main/source"
+-v6*= looking for changes in 'test|main|source'...
+-v6*= creating './dists/test/main/source/Sources' (gzipped)
+EOF
+rm -r pool dists db
+
+# now include the byhand file:
+cat > conf/distributions <<EOF
+Codename: test
+Architectures: coal source
+Components: main
+Tracking: minimal includebyhand
+EOF
+
+testrun - include test test.changes 3<<EOF
+stderr
+*=Ignoring log file: 'documentation_9876AD_coal+all.log'!
+stdout
+$(odb)
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/d"
+-v2*=Created directory "./pool/main/d/documentation"
+-v2*=Created directory "./pool/main/d/documentation/documentation_9876AD_byhand"
+$(ofa 'pool/main/d/documentation/documentation_9876AD_byhand/history.txt')
+$(ofa 'pool/main/d/documentation/documentation_9876AD_byhand/manifesto.txt')
+$(ofa 'pool/main/d/documentation/documentation_9876AD_all.deb')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.tar.gz')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.dsc')
+$(opa 'documentation' x 'test' 'main' 'coal' 'deb')
+$(opa 'documentation' x 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'documentation')
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/test"
+-v2*=Created directory "./dists/test/main"
+-v2*=Created directory "./dists/test/main/binary-coal"
+-v6*= looking for changes in 'test|main|coal'...
+-v6*= creating './dists/test/main/binary-coal/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/test/main/source"
+-v6*= looking for changes in 'test|main|source'...
+-v6*= creating './dists/test/main/source/Sources' (gzipped)
+EOF
+cat >results.expected <<EOF
+Distribution: test
+Source: documentation
+Version: 9876AD
+Files:
+ pool/main/d/documentation/documentation_9876AD.dsc s 1
+ pool/main/d/documentation/documentation_9876AD.tar.gz s 1
+ pool/main/d/documentation/documentation_9876AD_byhand/manifesto.txt x 0
+ pool/main/d/documentation/documentation_9876AD_byhand/history.txt x 0
+ pool/main/d/documentation/documentation_9876AD_all.deb a 1
+
+EOF
+testout - dumptracks test 3<<EOF
+EOF
+dodiff results.expected results
+testrun - retrack 3<<EOF
+stdout
+-v1*=Retracking test...
+EOF
+testout - dumptracks test 3<<EOF
+EOF
+dodiff results.expected results
+testrun - _listchecksums 3<<EOF
+stdout
+*=pool/main/d/documentation/documentation_9876AD.dsc $(fullchecksum documentation_9876AD.dsc)
+*=pool/main/d/documentation/documentation_9876AD.tar.gz $(fullchecksum documentation_9876AD.tar.gz)
+*=pool/main/d/documentation/documentation_9876AD_all.deb $(fullchecksum documentation_9876AD_all.deb)
+*=pool/main/d/documentation/documentation_9876AD_byhand/history.txt $(fullchecksum history.txt)
+
+*=pool/main/d/documentation/documentation_9876AD_byhand/manifesto.txt $(fullchecksum manifesto.txt)
+EOF
+
+testrun - remove test documentation 3<<EOF
+stdout
+$(opd 'documentation' unset test main coal deb)
+$(opd 'documentation' unset test main source dsc)
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test|main|coal'...
+-v6*= replacing './dists/test/main/binary-coal/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'test|main|source'...
+-v6*= replacing './dists/test/main/source/Sources' (gzipped)
+$(otd 'documentation' '9876AD' 'test')
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/main/d/documentation/documentation_9876AD.dsc')
+$(ofd 'pool/main/d/documentation/documentation_9876AD.tar.gz')
+$(ofd 'pool/main/d/documentation/documentation_9876AD_all.deb')
+$(ofd 'pool/main/d/documentation/documentation_9876AD_byhand/history.txt')
+$(ofd 'pool/main/d/documentation/documentation_9876AD_byhand/manifesto.txt')
+-v2*=removed now empty directory ./pool/main/d/documentation/documentation_9876AD_byhand
+-v2*=removed now empty directory ./pool/main/d/documentation
+-v2*=removed now empty directory ./pool/main/d
+-v2*=removed now empty directory ./pool/main
+-v2*=removed now empty directory ./pool
+EOF
+dodo test ! -e pool
+rm -r dists db
+
+# now include the log file, too:
+cat > conf/distributions <<EOF
+Codename: test
+Architectures: coal source
+Components: main
+Tracking: minimal includebyhand includelogs
+EOF
+
+testrun - include test test.changes 3<<EOF
+stdout
+$(odb)
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/d"
+-v2*=Created directory "./pool/main/d/documentation"
+$(ofa 'pool/main/d/documentation/documentation_9876AD_coal+all.log')
+-v2*=Created directory "./pool/main/d/documentation/documentation_9876AD_byhand"
+$(ofa 'pool/main/d/documentation/documentation_9876AD_byhand/history.txt')
+$(ofa 'pool/main/d/documentation/documentation_9876AD_byhand/manifesto.txt')
+$(ofa 'pool/main/d/documentation/documentation_9876AD_all.deb')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.tar.gz')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.dsc')
+$(opa 'documentation' x 'test' 'main' 'coal' 'deb')
+$(opa 'documentation' x 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'documentation')
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/test"
+-v2*=Created directory "./dists/test/main"
+-v2*=Created directory "./dists/test/main/binary-coal"
+-v6*= looking for changes in 'test|main|coal'...
+-v6*= creating './dists/test/main/binary-coal/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/test/main/source"
+-v6*= looking for changes in 'test|main|source'...
+-v6*= creating './dists/test/main/source/Sources' (gzipped)
+EOF
+cat >results.expected <<EOF
+Distribution: test
+Source: documentation
+Version: 9876AD
+Files:
+ pool/main/d/documentation/documentation_9876AD.dsc s 1
+ pool/main/d/documentation/documentation_9876AD.tar.gz s 1
+ pool/main/d/documentation/documentation_9876AD_byhand/manifesto.txt x 0
+ pool/main/d/documentation/documentation_9876AD_byhand/history.txt x 0
+ pool/main/d/documentation/documentation_9876AD_all.deb a 1
+ pool/main/d/documentation/documentation_9876AD_coal+all.log l 0
+
+EOF
+
+testout - dumptracks test 3<<EOF
+EOF
+dodiff results.expected results
+
+rm -r dists db pool
+
+# and now everything at once, too:
+cat > conf/distributions <<EOF
+Codename: test
+Architectures: coal source
+Components: main
+Tracking: minimal includebyhand includelogs includechanges
+EOF
+
+testrun - include test test.changes 3<<EOF
+stdout
+$(odb)
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/d"
+-v2*=Created directory "./pool/main/d/documentation"
+$(ofa 'pool/main/d/documentation/documentation_9876AD_source+all.changes')
+$(ofa 'pool/main/d/documentation/documentation_9876AD_coal+all.log')
+-v2*=Created directory "./pool/main/d/documentation/documentation_9876AD_byhand"
+$(ofa 'pool/main/d/documentation/documentation_9876AD_byhand/history.txt')
+$(ofa 'pool/main/d/documentation/documentation_9876AD_byhand/manifesto.txt')
+$(ofa 'pool/main/d/documentation/documentation_9876AD_all.deb')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.tar.gz')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.dsc')
+$(opa 'documentation' x 'test' 'main' 'coal' 'deb')
+$(opa 'documentation' x 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'documentation')
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/test"
+-v2*=Created directory "./dists/test/main"
+-v2*=Created directory "./dists/test/main/binary-coal"
+-v6*= looking for changes in 'test|main|coal'...
+-v6*= creating './dists/test/main/binary-coal/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/test/main/source"
+-v6*= looking for changes in 'test|main|source'...
+-v6*= creating './dists/test/main/source/Sources' (gzipped)
+EOF
+cat >results.expected <<EOF
+Distribution: test
+Source: documentation
+Version: 9876AD
+Files:
+ pool/main/d/documentation/documentation_9876AD.dsc s 1
+ pool/main/d/documentation/documentation_9876AD.tar.gz s 1
+ pool/main/d/documentation/documentation_9876AD_byhand/manifesto.txt x 0
+ pool/main/d/documentation/documentation_9876AD_byhand/history.txt x 0
+ pool/main/d/documentation/documentation_9876AD_all.deb a 1
+ pool/main/d/documentation/documentation_9876AD_coal+all.log l 0
+ pool/main/d/documentation/documentation_9876AD_source+all.changes c 0
+
+EOF
+testout - dumptracks test 3<<EOF
+EOF
+dodiff results.expected results
+testrun - _listchecksums 3<<EOF
+stdout
+*=pool/main/d/documentation/documentation_9876AD_coal+all.log $(fullchecksum documentation_9876AD_coal+all.log)
+*=pool/main/d/documentation/documentation_9876AD_source+all.changes $(fullchecksum test.changes)
+*=pool/main/d/documentation/documentation_9876AD.dsc $(fullchecksum documentation_9876AD.dsc)
+*=pool/main/d/documentation/documentation_9876AD.tar.gz $(fullchecksum documentation_9876AD.tar.gz)
+*=pool/main/d/documentation/documentation_9876AD_all.deb $(fullchecksum documentation_9876AD_all.deb)
+*=pool/main/d/documentation/documentation_9876AD_byhand/history.txt $(fullchecksum history.txt)
+
+*=pool/main/d/documentation/documentation_9876AD_byhand/manifesto.txt $(fullchecksum manifesto.txt)
+EOF
+
+testrun - remove test documentation 3<<EOF
+stdout
+$(opd 'documentation' unset test main coal deb)
+$(opd 'documentation' unset test main source dsc)
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test|main|coal'...
+-v6*= replacing './dists/test/main/binary-coal/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'test|main|source'...
+-v6*= replacing './dists/test/main/source/Sources' (gzipped)
+$(otd 'documentation' '9876AD' 'test')
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/main/d/documentation/documentation_9876AD_source+all.changes')
+$(ofd 'pool/main/d/documentation/documentation_9876AD_coal+all.log')
+$(ofd 'pool/main/d/documentation/documentation_9876AD.dsc')
+$(ofd 'pool/main/d/documentation/documentation_9876AD.tar.gz')
+$(ofd 'pool/main/d/documentation/documentation_9876AD_all.deb')
+$(ofd 'pool/main/d/documentation/documentation_9876AD_byhand/history.txt')
+$(ofd 'pool/main/d/documentation/documentation_9876AD_byhand/manifesto.txt')
+-v2*=removed now empty directory ./pool/main/d/documentation/documentation_9876AD_byhand
+-v2*=removed now empty directory ./pool/main/d/documentation
+-v2*=removed now empty directory ./pool/main/d
+-v2*=removed now empty directory ./pool/main
+-v2*=removed now empty directory ./pool
+EOF
+dodo test ! -e pool
+rm -r dists db
+
+mkdir i j tmp
+mv *.txt documentation_9876AD* test.changes j/
+cp j/* i/
+cat > conf/incoming <<EOF
+Name: foo
+IncomingDir: i
+TempDir: tmp
+Default: test
+EOF
+
+testrun - processincoming foo 3<<EOF
+stdout
+$(odb)
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/d"
+-v2*=Created directory "./pool/main/d/documentation"
+$(ofa 'pool/main/d/documentation/documentation_9876AD_source+all.changes')
+$(ofa 'pool/main/d/documentation/documentation_9876AD_coal+all.log')
+-v2*=Created directory "./pool/main/d/documentation/documentation_9876AD_byhand"
+$(ofa 'pool/main/d/documentation/documentation_9876AD_byhand/history.txt')
+$(ofa 'pool/main/d/documentation/documentation_9876AD_byhand/manifesto.txt')
+$(ofa 'pool/main/d/documentation/documentation_9876AD_all.deb')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.tar.gz')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.dsc')
+$(opa 'documentation' x 'test' 'main' 'coal' 'deb')
+$(opa 'documentation' x 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'documentation')
+-v3*=deleting './i/documentation_9876AD_all.deb'...
+-v3*=deleting './i/documentation_9876AD_coal+all.log'...
+-v3*=deleting './i/documentation_9876AD.tar.gz'...
+-v3*=deleting './i/history.txt'...
+-v3*=deleting './i/manifesto.txt'...
+-v3*=deleting './i/documentation_9876AD.dsc'...
+-v3*=deleting './i/test.changes'...
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/test"
+-v2*=Created directory "./dists/test/main"
+-v2*=Created directory "./dists/test/main/binary-coal"
+-v6*= looking for changes in 'test|main|coal'...
+-v6*= creating './dists/test/main/binary-coal/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/test/main/source"
+-v6*= looking for changes in 'test|main|source'...
+-v6*= creating './dists/test/main/source/Sources' (gzipped)
+EOF
+cat >results.expected <<EOF
+Distribution: test
+Source: documentation
+Version: 9876AD
+Files:
+ pool/main/d/documentation/documentation_9876AD_all.deb a 1
+ pool/main/d/documentation/documentation_9876AD.dsc s 1
+ pool/main/d/documentation/documentation_9876AD.tar.gz s 1
+ pool/main/d/documentation/documentation_9876AD_byhand/history.txt x 0
+ pool/main/d/documentation/documentation_9876AD_byhand/manifesto.txt x 0
+ pool/main/d/documentation/documentation_9876AD_coal+all.log l 0
+ pool/main/d/documentation/documentation_9876AD_source+all.changes c 0
+
+EOF
+
+testout - dumptracks test 3<<EOF
+EOF
+dodiff results.expected results
+
+rm -r db pool dists
+
+cp j/* i/
+ed -s conf/distributions <<EOF
+g/^Tracking: /s/include[^ ]*//g
+w
+q
+EOF
+
+testrun - processincoming foo 3<<EOF
+stdout
+$(odb)
+stderr
+*=Error: 'test.changes' contains unused file 'documentation_9876AD_coal+all.log'!
+*=(Do Permit: unused_files to conf/incoming to ignore and
+*= additionally Cleanup: unused_files to delete them)
+*=Alternatively, you can also add a LogDir: for 'foo' into conf/incoming
+*=then files like that will be stored there.
+-v0*=There have been errors!
+returns 255
+EOF
+
+cat >> conf/incoming <<EOF
+Logdir: log
+EOF
+
+testrun - processincoming foo 3<<EOF
+stdout
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/d"
+-v2*=Created directory "./pool/main/d/documentation"
+-v2*=Created directory "./log"
+-v2*=Created directory "./log/documentation_9876AD_source+all.0000000"
+$(ofa 'pool/main/d/documentation/documentation_9876AD_all.deb')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.tar.gz')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.dsc')
+$(opa 'documentation' x 'test' 'main' 'coal' 'deb')
+$(opa 'documentation' x 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'documentation')
+-v3*=deleting './i/documentation_9876AD_all.deb'...
+-v3*=deleting './i/documentation_9876AD_coal+all.log'...
+-v3*=deleting './i/documentation_9876AD.tar.gz'...
+-v3*=deleting './i/history.txt'...
+-v3*=deleting './i/manifesto.txt'...
+-v3*=deleting './i/documentation_9876AD.dsc'...
+-v3*=deleting './i/test.changes'...
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/test"
+-v2*=Created directory "./dists/test/main"
+-v2*=Created directory "./dists/test/main/binary-coal"
+-v6*= looking for changes in 'test|main|coal'...
+-v6*= creating './dists/test/main/binary-coal/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/test/main/source"
+-v6*= looking for changes in 'test|main|source'...
+-v6*= creating './dists/test/main/source/Sources' (gzipped)
+EOF
+
+ls log/documentation_9876AD_source+all.0000000 | sort > results
+cat > results.expected <<EOF
+documentation_9876AD_coal+all.log
+history.txt
+manifesto.txt
+test.changes
+EOF
+dodiff results.expected results
+
+rm -r db pool dists
+
+cp j/* i/
+ed -s conf/distributions <<EOF
+g/^Tracking: /d
+a
+Tracking: all includechanges includelogs includebyhand
+.
+w
+q
+EOF
+
+testrun - processincoming foo 3<<EOF
+stdout
+$(odb)
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/d"
+-v2*=Created directory "./pool/main/d/documentation"
+-v2*=Created directory "./log/documentation_9876AD_source+all.0000001"
+$(ofa 'pool/main/d/documentation/documentation_9876AD_source+all.changes')
+$(ofa 'pool/main/d/documentation/documentation_9876AD_coal+all.log')
+-v2*=Created directory "./pool/main/d/documentation/documentation_9876AD_byhand"
+$(ofa 'pool/main/d/documentation/documentation_9876AD_byhand/history.txt')
+$(ofa 'pool/main/d/documentation/documentation_9876AD_byhand/manifesto.txt')
+$(ofa 'pool/main/d/documentation/documentation_9876AD_all.deb')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.tar.gz')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.dsc')
+$(opa 'documentation' x 'test' 'main' 'coal' 'deb')
+$(opa 'documentation' x 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'documentation')
+-v3*=deleting './i/documentation_9876AD_all.deb'...
+-v3*=deleting './i/documentation_9876AD_coal+all.log'...
+-v3*=deleting './i/documentation_9876AD.tar.gz'...
+-v3*=deleting './i/history.txt'...
+-v3*=deleting './i/manifesto.txt'...
+-v3*=deleting './i/documentation_9876AD.dsc'...
+-v3*=deleting './i/test.changes'...
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/test"
+-v2*=Created directory "./dists/test/main"
+-v2*=Created directory "./dists/test/main/binary-coal"
+-v6*= looking for changes in 'test|main|coal'...
+-v6*= creating './dists/test/main/binary-coal/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/test/main/source"
+-v6*= looking for changes in 'test|main|source'...
+-v6*= creating './dists/test/main/source/Sources' (gzipped)
+EOF
+
+ls log/documentation_9876AD_source+all.0000001 | sort > results
+cat > results.expected <<EOF
+documentation_9876AD_coal+all.log
+test.changes
+EOF
+dodiff results.expected results
+
+# Now add a script to manually handle byhand files:
+
+rm -r db pool dists
+
+cp j/* i/
+
+cat >> conf/distributions <<EOF
+ByhandHooks:
+ byhand * manifesto.txt handle-byhand.sh
+EOF
+
+# first without the script, to check the error:
+
+testrun - processincoming foo 3<<EOF
+stdout
+$(odb)
+-v2*=Created directory "./log/documentation_9876AD_source+all.0000002"
+stderr
+*=Error 2 executing './conf/handle-byhand.sh': No such file or directory
+*=Byhandhook './conf/handle-byhand.sh' 'test' 'byhand' '-' 'manifesto.txt' './tmp/manifesto.txt' failed with exit code 255!
+-v0*=There have been errors!
+return 255
+EOF
+
+# then with the script
+
+cat > conf/handle-byhand.sh <<'EOF'
+#!/bin/sh
+echo "byhand-script called with: " "'$*'" >&2
+EOF
+cat > conf/handle-alternate.sh <<'EOF'
+#!/bin/sh
+echo "alternate-script called with: " "'$*'" >&2
+EOF
+chmod u+x conf/handle-alternate.sh
+chmod u+x conf/handle-byhand.sh
+
+testrun - processincoming foo 3<<EOF
+stdout
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/d"
+-v2*=Created directory "./pool/main/d/documentation"
+-v2*=Created directory "./log/documentation_9876AD_source+all.0000003"
+$(ofa 'pool/main/d/documentation/documentation_9876AD_source+all.changes')
+$(ofa 'pool/main/d/documentation/documentation_9876AD_coal+all.log')
+-v2*=Created directory "./pool/main/d/documentation/documentation_9876AD_byhand"
+$(ofa 'pool/main/d/documentation/documentation_9876AD_byhand/history.txt')
+$(ofa 'pool/main/d/documentation/documentation_9876AD_byhand/manifesto.txt')
+$(ofa 'pool/main/d/documentation/documentation_9876AD_all.deb')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.tar.gz')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.dsc')
+$(opa 'documentation' x 'test' 'main' 'coal' 'deb')
+$(opa 'documentation' x 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'documentation')
+-v3*=deleting './i/documentation_9876AD_all.deb'...
+-v3*=deleting './i/documentation_9876AD_coal+all.log'...
+-v3*=deleting './i/documentation_9876AD.tar.gz'...
+-v3*=deleting './i/history.txt'...
+-v3*=deleting './i/manifesto.txt'...
+-v3*=deleting './i/documentation_9876AD.dsc'...
+-v3*=deleting './i/test.changes'...
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/test"
+-v2*=Created directory "./dists/test/main"
+-v2*=Created directory "./dists/test/main/binary-coal"
+-v6*= looking for changes in 'test|main|coal'...
+-v6*= creating './dists/test/main/binary-coal/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/test/main/source"
+-v6*= looking for changes in 'test|main|source'...
+-v6*= creating './dists/test/main/source/Sources' (gzipped)
+stderr
+*=byhand-script called with: 'test byhand - manifesto.txt ./tmp/manifesto.txt'
+EOF
+
+ls log/documentation_9876AD_source+all.0000003 | sort > results
+cat > results.expected <<EOF
+documentation_9876AD_coal+all.log
+test.changes
+EOF
+dodiff results.expected results
+
+# then don't install byhand, now the unprocessed ones should end up in the log
+
+rm -r db dists pool
+cp j/* i/
+ed -s conf/distributions <<EOF
+g/^Tracking: /d
+i
+Tracking: all
+.
+w
+q
+EOF
+
+testrun - processincoming foo 3<<EOF
+stdout
+$(odb)
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/d"
+-v2*=Created directory "./pool/main/d/documentation"
+-v2*=Created directory "./log/documentation_9876AD_source+all.0000004"
+$(ofa 'pool/main/d/documentation/documentation_9876AD_all.deb')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.tar.gz')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.dsc')
+$(opa 'documentation' x 'test' 'main' 'coal' 'deb')
+$(opa 'documentation' x 'test' 'main' 'source' 'dsc')
+$(ota 'test' 'documentation')
+-v3*=deleting './i/documentation_9876AD_all.deb'...
+-v3*=deleting './i/documentation_9876AD_coal+all.log'...
+-v3*=deleting './i/documentation_9876AD.tar.gz'...
+-v3*=deleting './i/history.txt'...
+-v3*=deleting './i/manifesto.txt'...
+-v3*=deleting './i/documentation_9876AD.dsc'...
+-v3*=deleting './i/test.changes'...
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/test"
+-v2*=Created directory "./dists/test/main"
+-v2*=Created directory "./dists/test/main/binary-coal"
+-v6*= looking for changes in 'test|main|coal'...
+-v6*= creating './dists/test/main/binary-coal/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/test/main/source"
+-v6*= looking for changes in 'test|main|source'...
+-v6*= creating './dists/test/main/source/Sources' (gzipped)
+stderr
+*=byhand-script called with: 'test byhand - manifesto.txt ./tmp/manifesto.txt'
+EOF
+
+ls log/documentation_9876AD_source+all.0000004 | sort > results
+cat > results.expected <<EOF
+documentation_9876AD_coal+all.log
+history.txt
+test.changes
+EOF
+dodiff results.expected results
+
+# then do without tracking at all
+
+rm -r db dists pool
+cp j/* i/
+ed -s conf/distributions <<EOF
+g/^Tracking: /d
+w
+q
+EOF
+
+testrun - processincoming foo 3<<EOF
+stdout
+$(odb)
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/d"
+-v2*=Created directory "./pool/main/d/documentation"
+-v2*=Created directory "./log/documentation_9876AD_source+all.0000005"
+$(ofa 'pool/main/d/documentation/documentation_9876AD_all.deb')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.tar.gz')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.dsc')
+$(opa 'documentation' x 'test' 'main' 'coal' 'deb')
+$(opa 'documentation' x 'test' 'main' 'source' 'dsc')
+-v3*=deleting './i/documentation_9876AD_all.deb'...
+-v3*=deleting './i/documentation_9876AD_coal+all.log'...
+-v3*=deleting './i/documentation_9876AD.tar.gz'...
+-v3*=deleting './i/history.txt'...
+-v3*=deleting './i/manifesto.txt'...
+-v3*=deleting './i/documentation_9876AD.dsc'...
+-v3*=deleting './i/test.changes'...
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/test"
+-v2*=Created directory "./dists/test/main"
+-v2*=Created directory "./dists/test/main/binary-coal"
+-v6*= looking for changes in 'test|main|coal'...
+-v6*= creating './dists/test/main/binary-coal/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/test/main/source"
+-v6*= looking for changes in 'test|main|source'...
+-v6*= creating './dists/test/main/source/Sources' (gzipped)
+stderr
+*=byhand-script called with: 'test byhand - manifesto.txt ./tmp/manifesto.txt'
+EOF
+
+ls log/documentation_9876AD_source+all.0000005 | sort > results
+cat > results.expected <<EOF
+documentation_9876AD_coal+all.log
+history.txt
+test.changes
+EOF
+dodiff results.expected results
+
+# then do without tracking and without log dir
+
+rm -r db dists pool
+cp j/* i/
+ed -s conf/incoming <<EOF
+g/^Logdir: /d
+w
+q
+EOF
+ed -s i/test.changes <<'EOF'
+g/^ .*\.log$/d
+w
+q
+EOF
+
+testrun - processincoming foo 3<<EOF
+stdout
+$(odb)
+stderr
+*=Error: 'test.changes' contains unused file 'history.txt'!
+*=(Do Permit: unused_files to conf/incoming to ignore and
+*= additionally Cleanup: unused_files to delete them)
+*=Alternatively, you can also add a LogDir: for 'foo' into conf/incoming
+*=then files like that will be stored there.
+-v0*=There have been errors!
+returns 255
+EOF
+
+# add more hooks:
+
+cat >> conf/distributions <<EOF
+ * * * handle-alternate.sh
+EOF
+
+testrun - processincoming foo 3<<EOF
+stdout
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/d"
+-v2*=Created directory "./pool/main/d/documentation"
+$(ofa 'pool/main/d/documentation/documentation_9876AD_all.deb')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.tar.gz')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.dsc')
+$(opa 'documentation' x 'test' 'main' 'coal' 'deb')
+$(opa 'documentation' x 'test' 'main' 'source' 'dsc')
+-v3*=deleting './i/documentation_9876AD_all.deb'...
+-v3*=deleting './i/documentation_9876AD.tar.gz'...
+-v3*=deleting './i/history.txt'...
+-v3*=deleting './i/manifesto.txt'...
+-v3*=deleting './i/documentation_9876AD.dsc'...
+-v3*=deleting './i/test.changes'...
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/test"
+-v2*=Created directory "./dists/test/main"
+-v2*=Created directory "./dists/test/main/binary-coal"
+-v6*= looking for changes in 'test|main|coal'...
+-v6*= creating './dists/test/main/binary-coal/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/test/main/source"
+-v6*= looking for changes in 'test|main|source'...
+-v6*= creating './dists/test/main/source/Sources' (gzipped)
+stderr
+*=byhand-script called with: 'test byhand - manifesto.txt ./tmp/manifesto.txt'
+*=alternate-script called with: 'test byhand - history.txt ./tmp/history.txt'
+EOF
+
+# try a more real-worl example.
+
+rm -r db dists pool
+cp j/* i/
+ed -s i/test.changes <<'EOF'
+g/^ .*\.log$/d
+w
+q
+EOF
+ed -s conf/distributions <<EOF
+g/handle-/d
+a
+ byhand - * $SRCDIR/docs/copybyhand.example
+.
+w
+q
+EOF
+
+testrun - processincoming foo 3<<EOF
+stdout
+$(odb)
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/d"
+-v2*=Created directory "./pool/main/d/documentation"
+$(ofa 'pool/main/d/documentation/documentation_9876AD_all.deb')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.tar.gz')
+$(ofa 'pool/main/d/documentation/documentation_9876AD.dsc')
+$(opa 'documentation' x 'test' 'main' 'coal' 'deb')
+$(opa 'documentation' x 'test' 'main' 'source' 'dsc')
+-v3*=deleting './i/documentation_9876AD_all.deb'...
+-v3*=deleting './i/documentation_9876AD.tar.gz'...
+-v3*=deleting './i/history.txt'...
+-v3*=deleting './i/manifesto.txt'...
+-v3*=deleting './i/documentation_9876AD.dsc'...
+-v3*=deleting './i/test.changes'...
+-v0*=Exporting indices...
+-v2*=Created directory "./dists/test/main"
+-v2*=Created directory "./dists/test/main/binary-coal"
+-v6*= looking for changes in 'test|main|coal'...
+-v6*= creating './dists/test/main/binary-coal/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/test/main/source"
+-v6*= looking for changes in 'test|main|source'...
+-v6*= creating './dists/test/main/source/Sources' (gzipped)
+stderr
+EOF
+
+ls dists/test/extra/ | sort > results
+cat > results.expected <<EOF
+history.txt
+manifesto.txt
+EOF
+dodiff results.expected results
+
+# TODO: check for multiple distributions
+# some storing some not, and when the handling script is implemented
+
+rm -r db pool dists
+rm -r i j tmp conf results results.expected log
+testsuccess
diff --git a/tests/layeredupdate.test b/tests/layeredupdate.test
new file mode 100644
index 0000000..6bdc381
--- /dev/null
+++ b/tests/layeredupdate.test
@@ -0,0 +1,684 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+dodo test ! -d db
+mkdir -p conf dists
+echo "export never" > conf/options
+cat > conf/distributions <<EOF
+Codename: codename1
+Update: notexisting
+Components: component
+Architectures: architecture
+EOF
+cat > conf/updates <<EOF
+Name: chainb5
+From: chainb4
+
+Name: chainb4
+From: chainb3
+
+Name: chainb3
+From: chainb2
+
+Name: chainb2
+From: chainb1
+
+Name: chainb1
+From: circular2
+
+Name: circular1
+From: circular2
+
+Name: circular2
+From: circular1
+
+Name: chaina1
+From: circular1
+
+Name: chaina2
+From: chaina1
+
+Name: chaina3
+From: chaina2
+
+Name: chaina4
+From: chaina3
+
+Name: chaina5
+From: chaina4
+
+Name: chaina6
+From: chaina5
+EOF
+
+mkdir lists db
+
+testrun - -b . update 3<<EOF
+returns 255
+stderr
+*=Error: Update rule 'circular1' part of circular From-referencing.
+-v0*=There have been errors!
+stdout
+EOF
+
+cat > conf/updates <<EOF
+Name: name
+From: broken
+EOF
+
+testrun - -b . update 3<<EOF
+returns 255
+stderr
+*=./conf/updates: Update pattern 'name' references unknown pattern 'broken' via From!
+-v0*=There have been errors!
+stdout
+EOF
+
+cat > conf/updates <<EOF
+EOF
+
+testrun - -b . update 3<<EOF
+returns 255
+stderr
+*=Cannot find definition of upgrade-rule 'notexisting' for distribution 'codename1'!
+-v0*=There have been errors!
+stdout
+EOF
+
+cat > conf/distributions <<EOF
+Codename: codename1
+Update: test
+Components: component
+Architectures: architecture
+EOF
+cat > conf/updates <<EOF
+Name: test
+Components: comonent
+Architectures: achitecture
+VerifyRelease: blindtrust
+Method: file:///notexistant
+EOF
+
+testrun - -b . update 3<<EOF
+returns 255
+stderr
+*=Warning parsing ./conf/updates, line 2: unknown component 'comonent' will be ignored!
+*=Warning parsing ./conf/updates, line 3: unknown architecture 'achitecture' will be ignored!
+-v6=aptmethod start 'file:///notexistant/dists/codename1/InRelease'
+*=aptmethod error receiving 'file:///notexistant/dists/codename1/InRelease':
+-v6=aptmethod start 'file:///notexistant/dists/codename1/Release'
+*=aptmethod error receiving 'file:///notexistant/dists/codename1/Release':
+='File not found'
+='File not found - /notexistant/dists/codename1/Release (2: No such file or directory)'
+='File not found - /notexistant/dists/codename1/InRelease (2: No such file or directory)'
+-v0*=There have been errors!
+stdout
+EOF
+
+cat > conf/updates <<EOF
+Name: test
+Components: comonent
+EOF
+
+rm -r db
+mkdir db
+
+cat > conf/distributions <<EOF
+Codename: codename1
+Components: a bb
+UDebComponents: a
+Architectures: x yyyyyyyyyy source
+Update: a b - b c
+
+Codename: codename2
+Components: a bb
+Architectures: x yyyyyyyyyy
+Update: c - a
+EOF
+cat > conf/updates <<EOF
+Name: base
+VerifyRelease: blindtrust
+Method: file:$WORKDIR/testsource
+Components: error1
+
+Name: a
+Components: a
+From: base
+
+Name: b
+Components: a
+From: base
+
+Name: c
+From: base
+EOF
+
+#testrun - -b . update 3<<EOF
+#returns 255
+#stderr
+#-v0*=There have been errors!
+#stdout
+#EOF
+
+cat > conf/updates <<EOF
+Name: base
+VerifyRelease: blindtrust
+Method: file:$WORKDIR/testsource
+Suite: test
+
+Name: a
+Suite: codename1
+From: base
+
+Name: b
+Suite: codename2
+DownloadListsAs: .gz .lzma
+From: base
+
+Name: c
+Suite: *
+From: base
+EOF
+
+testrun - -b . update codename2 3<<EOF
+returns 255
+stderr
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename1/InRelease'
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename1/Release'
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename2/InRelease'
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename2/Release'
+*=aptmethod error receiving 'file:$WORKDIR/testsource/dists/codename1/InRelease':
+*=aptmethod error receiving 'file:$WORKDIR/testsource/dists/codename1/Release':
+*=aptmethod error receiving 'file:$WORKDIR/testsource/dists/codename2/InRelease':
+*=aptmethod error receiving 'file:$WORKDIR/testsource/dists/codename2/Release':
+='File not found'
+='File not found - $WORKDIR/testsource/dists/codename1/InRelease (2: No such file or directory)'
+='File not found - $WORKDIR/testsource/dists/codename2/InRelease (2: No such file or directory)'
+='File not found - $WORKDIR/testsource/dists/codename1/Release (2: No such file or directory)'
+='File not found - $WORKDIR/testsource/dists/codename2/Release (2: No such file or directory)'
+-v0*=There have been errors!
+stdout
+EOF
+
+mkdir testsource testsource/dists testsource/dists/codename1 testsource/dists/codename2
+touch testsource/dists/codename1/InRelease testsource/dists/codename2/InRelease
+
+testrun - -b . update codename2 3<<EOF
+returns 255
+stderr
+-v6*=aptmethod start 'file:$WORKDIR/testsource/dists/codename1/InRelease'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename1/InRelease'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename2/InRelease' to './lists/base_codename2_InRelease'...
+-v6*=aptmethod start 'file:$WORKDIR/testsource/dists/codename2/InRelease'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename2/InRelease'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename1/InRelease' to './lists/base_codename1_InRelease'...
+*=WARNING: No signature found in ./lists/base_codename2_InRelease, assuming it is unsigned!
+*=Missing checksums in Release file './lists/base_codename2_InRelease'!
+-v0*=There have been errors!
+stdout
+EOF
+
+cat > testsource/dists/codename1/InRelease <<EOF
+Codename: codename1
+Architectures: x yyyyyyyyyy
+Components: a bb
+MD5Sum:
+EOF
+cat > testsource/dists/codename2/InRelease <<EOF
+Codename: codename2
+Architectures: x yyyyyyyyyy
+Components: a bb
+MD5Sum:
+EOF
+
+testrun - -b . update codename2 3<<EOF
+returns 254
+stderr
+-v6*=aptmethod start 'file:$WORKDIR/testsource/dists/codename1/InRelease'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename1/InRelease'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename2/InRelease' to './lists/base_codename2_InRelease'...
+-v6*=aptmethod start 'file:$WORKDIR/testsource/dists/codename2/InRelease'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename2/InRelease'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename1/InRelease' to './lists/base_codename1_InRelease'...
+*=WARNING: No signature found in ./lists/base_codename2_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/base_codename1_InRelease, assuming it is unsigned!
+*=Could not find 'a/binary-x/Packages' within './lists/base_codename2_InRelease'
+-v0*=There have been errors!
+stdout
+EOF
+
+mkdir -p testsource/dists/codename1/a/debian-installer/binary-x
+touch testsource/dists/codename1/a/debian-installer/binary-x/Packages
+mkdir -p testsource/dists/codename1/a/debian-installer/binary-yyyyyyyyyy
+touch testsource/dists/codename1/a/debian-installer/binary-yyyyyyyyyy/Packages
+mkdir -p testsource/dists/codename1/a/binary-x
+touch testsource/dists/codename1/a/binary-x/Packages
+mkdir -p testsource/dists/codename1/a/binary-yyyyyyyyyy
+touch testsource/dists/codename1/a/binary-yyyyyyyyyy/Packages
+mkdir -p testsource/dists/codename1/a/source
+touch testsource/dists/codename1/a/source/Sources
+mkdir -p testsource/dists/codename1/bb/binary-x
+touch testsource/dists/codename1/bb/binary-x/Packages
+mkdir -p testsource/dists/codename1/bb/binary-yyyyyyyyyy
+touch testsource/dists/codename1/bb/binary-yyyyyyyyyy/Packages
+mkdir -p testsource/dists/codename1/bb/source
+touch testsource/dists/codename1/bb/source/Sources
+
+cat > testsource/dists/codename1/InRelease <<EOF
+Codename: codename1
+Architectures: x yyyyyyyyyy
+Components: a bb
+MD5Sum:
+ 11111111111111111111111111111111 17 bb/source/Sources.lzma
+ $(cd testsource ; md5releaseline codename1 a/debian-installer/binary-x/Packages)
+ $(cd testsource ; md5releaseline codename1 a/debian-installer/binary-yyyyyyyyyy/Packages)
+ $(cd testsource ; md5releaseline codename1 a/binary-x/Packages)
+ $(cd testsource ; md5releaseline codename1 a/binary-yyyyyyyyyy/Packages)
+ $(cd testsource ; md5releaseline codename1 a/source/Sources)
+ $(cd testsource ; md5releaseline codename1 bb/binary-x/Packages)
+ $(cd testsource ; md5releaseline codename1 bb/binary-yyyyyyyyyy/Packages)
+ $(cd testsource ; md5releaseline codename1 bb/source/Sources)
+EOF
+
+mkdir -p testsource/dists/codename2/a/binary-x
+touch testsource/dists/codename2/a/binary-x/Packages
+mkdir -p testsource/dists/codename2/a/binary-yyyyyyyyyy
+touch testsource/dists/codename2/a/binary-yyyyyyyyyy/Packages
+mkdir -p testsource/dists/codename2/bb/binary-x
+touch testsource/dists/codename2/bb/binary-x/Packages
+mkdir -p testsource/dists/codename2/bb/binary-yyyyyyyyyy
+touch testsource/dists/codename2/bb/binary-yyyyyyyyyy/Packages
+mkdir -p testsource/dists/codename2/a/debian-installer/binary-x
+touch testsource/dists/codename2/a/debian-installer/binary-x/Packages
+mkdir -p testsource/dists/codename2/a/debian-installer/binary-yyyyyyyyyy
+touch testsource/dists/codename2/a/debian-installer/binary-yyyyyyyyyy/Packages
+mkdir -p testsource/dists/codename2/a/source
+touch testsource/dists/codename2/a/source/Sources
+mkdir -p testsource/dists/codename2/bb/source
+touch testsource/dists/codename2/bb/source/Sources
+
+cat > testsource/dists/codename2/InRelease <<EOF
+Codename: codename2
+Architectures: x yyyyyyyyyy
+Components: a bb
+MD5Sum:
+ $(cd testsource ; md5releaseline codename2 a/debian-installer/binary-x/Packages)
+ $(cd testsource ; md5releaseline codename2 a/debian-installer/binary-yyyyyyyyyy/Packages)
+ $(cd testsource ; md5releaseline codename2 a/binary-x/Packages)
+ $(cd testsource ; md5releaseline codename2 a/binary-yyyyyyyyyy/Packages)
+ $(cd testsource ; md5releaseline codename2 a/source/Sources)
+ $(cd testsource ; md5releaseline codename2 bb/binary-x/Packages)
+ $(cd testsource ; md5releaseline codename2 bb/binary-yyyyyyyyyy/Packages)
+ $(cd testsource ; md5releaseline codename2 bb/source/Sources)
+EOF
+
+lzma testsource/dists/codename2/a/binary-x/Packages
+lzma testsource/dists/codename2/a/source/Sources
+lzma testsource/dists/codename2/bb/source/Sources
+lzma testsource/dists/codename2/a/debian-installer/binary-yyyyyyyyyy/Packages
+lzma testsource/dists/codename2/bb/binary-yyyyyyyyyy/Packages
+lzma testsource/dists/codename2/bb/binary-x/Packages
+lzma testsource/dists/codename2/a/binary-yyyyyyyyyy/Packages
+lzma testsource/dists/codename2/a/debian-installer/binary-x/Packages
+
+cat >> testsource/dists/codename2/InRelease <<EOF
+ $(cd testsource ; md5releaseline codename2 a/debian-installer/binary-x/Packages.lzma)
+ $(cd testsource ; md5releaseline codename2 a/debian-installer/binary-yyyyyyyyyy/Packages.lzma)
+ $(cd testsource ; md5releaseline codename2 a/binary-x/Packages.lzma)
+ $(cd testsource ; md5releaseline codename2 a/binary-yyyyyyyyyy/Packages.lzma)
+ $(cd testsource ; md5releaseline codename2 a/source/Sources.lzma)
+ $(cd testsource ; md5releaseline codename2 bb/binary-x/Packages.lzma)
+ $(cd testsource ; md5releaseline codename2 bb/binary-yyyyyyyyyy/Packages.lzma)
+ $(cd testsource ; md5releaseline codename2 bb/source/Sources.lzma)
+EOF
+
+
+testout - -b . update codename2 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename1/InRelease'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename1/InRelease'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename2/InRelease' to './lists/base_codename2_InRelease'...
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename2/InRelease'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename2/InRelease'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename1/InRelease' to './lists/base_codename1_InRelease'...
+*=WARNING: No signature found in ./lists/base_codename1_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/base_codename2_InRelease, assuming it is unsigned!
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename1/a/binary-x/Packages'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename1/a/binary-x/Packages'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename1/a/binary-x/Packages' to './lists/base_codename1_a_x_Packages'...
+-v1=aptmethod start 'file:$WORKDIR/testsource/dists/codename1/bb/binary-x/Packages'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename1/bb/binary-x/Packages'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename1/bb/binary-x/Packages' to './lists/base_codename1_bb_x_Packages'...
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename1/a/binary-yyyyyyyyyy/Packages'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename1/a/binary-yyyyyyyyyy/Packages'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename1/a/binary-yyyyyyyyyy/Packages' to './lists/base_codename1_a_yyyyyyyyyy_Packages'...
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename1/bb/binary-yyyyyyyyyy/Packages'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename1/bb/binary-yyyyyyyyyy/Packages'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename1/bb/binary-yyyyyyyyyy/Packages' to './lists/base_codename1_bb_yyyyyyyyyy_Packages'...
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename2/a/binary-x/Packages.lzma'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename2/a/binary-x/Packages.lzma'
+-v2*=Uncompress '$WORKDIR/testsource/dists/codename2/a/binary-x/Packages.lzma' into './lists/base_codename2_a_x_Packages' using '/usr/bin/unlzma'...
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename2/bb/binary-x/Packages.lzma'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename2/bb/binary-x/Packages.lzma'
+-v2*=Uncompress '$WORKDIR/testsource/dists/codename2/bb/binary-x/Packages.lzma' into './lists/base_codename2_bb_x_Packages' using '/usr/bin/unlzma'...
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename2/a/binary-yyyyyyyyyy/Packages.lzma'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename2/a/binary-yyyyyyyyyy/Packages.lzma'
+-v2*=Uncompress '$WORKDIR/testsource/dists/codename2/a/binary-yyyyyyyyyy/Packages.lzma' into './lists/base_codename2_a_yyyyyyyyyy_Packages' using '/usr/bin/unlzma'...
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename2/bb/binary-yyyyyyyyyy/Packages.lzma'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename2/bb/binary-yyyyyyyyyy/Packages.lzma'
+-v2*=Uncompress '$WORKDIR/testsource/dists/codename2/bb/binary-yyyyyyyyyy/Packages.lzma' into './lists/base_codename2_bb_yyyyyyyyyy_Packages' using '/usr/bin/unlzma'...
+EOF
+
+true > results.expected
+if [ $verbosity -ge 0 ] ; then
+echo "Calculating packages to get..." > results.expected ; fi
+if [ $verbosity -ge 3 ] ; then
+echo " processing updates for 'codename2|bb|yyyyyyyyyy'" >>results.expected ; fi
+if [ $verbosity -ge 5 ] ; then
+echo " reading './lists/base_codename2_bb_yyyyyyyyyy_Packages'" >>results.expected
+echo " marking everything to be deleted" >>results.expected
+echo " reading './lists/base_codename1_bb_yyyyyyyyyy_Packages'" >>results.expected ; fi
+if [ $verbosity -ge 3 ] ; then
+echo " processing updates for 'codename2|bb|x'" >>results.expected ; fi
+if [ $verbosity -ge 5 ] ; then
+echo " reading './lists/base_codename2_bb_x_Packages'" >>results.expected
+echo " marking everything to be deleted" >>results.expected
+echo " reading './lists/base_codename1_bb_x_Packages'" >>results.expected ; fi
+if [ $verbosity -ge 3 ] ; then
+echo " processing updates for 'codename2|a|yyyyyyyyyy'" >>results.expected ; fi
+if [ $verbosity -ge 5 ] ; then
+echo " reading './lists/base_codename2_a_yyyyyyyyyy_Packages'" >>results.expected
+echo " marking everything to be deleted" >>results.expected
+echo " reading './lists/base_codename1_a_yyyyyyyyyy_Packages'" >>results.expected ; fi
+if [ $verbosity -ge 3 ] ; then
+echo " processing updates for 'codename2|a|x'" >>results.expected ; fi
+if [ $verbosity -ge 5 ] ; then
+echo " reading './lists/base_codename2_a_x_Packages'" >>results.expected
+echo " marking everything to be deleted" >>results.expected
+echo " reading './lists/base_codename1_a_x_Packages'" >>results.expected ; fi
+dodiff results.expected results
+mv results.expected results2.expected
+
+testout - -b . update codename1 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename1/InRelease'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename1/InRelease'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename2/InRelease' to './lists/base_codename2_InRelease'...
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename2/InRelease'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename2/InRelease'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename1/InRelease' to './lists/base_codename1_InRelease'...
+*=WARNING: No signature found in ./lists/base_codename1_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/base_codename2_InRelease, assuming it is unsigned!
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename1/a/debian-installer/binary-x/Packages'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename1/a/debian-installer/binary-x/Packages'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename1/a/debian-installer/binary-x/Packages' to './lists/base_codename1_a_x_uPackages'...
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename1/a/debian-installer/binary-yyyyyyyyyy/Packages'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename1/a/debian-installer/binary-yyyyyyyyyy/Packages'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename1/a/debian-installer/binary-yyyyyyyyyy/Packages' to './lists/base_codename1_a_yyyyyyyyyy_uPackages'...
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename2/a/debian-installer/binary-x/Packages.lzma'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename2/a/debian-installer/binary-x/Packages.lzma'
+-v2*=Uncompress '$WORKDIR/testsource/dists/codename2/a/debian-installer/binary-x/Packages.lzma' into './lists/base_codename2_a_x_uPackages' using '/usr/bin/unlzma'...
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename2/a/debian-installer/binary-yyyyyyyyyy/Packages.lzma'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename2/a/debian-installer/binary-yyyyyyyyyy/Packages.lzma'
+-v2*=Uncompress '$WORKDIR/testsource/dists/codename2/a/debian-installer/binary-yyyyyyyyyy/Packages.lzma' into './lists/base_codename2_a_yyyyyyyyyy_uPackages' using '/usr/bin/unlzma'...
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename1/a/source/Sources'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename1/a/source/Sources'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename1/a/source/Sources' to './lists/base_codename1_a_Sources'...
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename1/bb/source/Sources.lzma'
+-v1*=aptmethod error receiving 'file:$WORKDIR/testsource/dists/codename1/bb/source/Sources.lzma':
+-v1='File not found'
+-v1='File not found - $WORKDIR/testsource/dists/codename1/bb/source/Sources.lzma (2: No such file or directory)'
+-v1='<File not there, apt-method suggests '$WORKDIR/testsource/dists/codename1/bb/source/Sources' instead>'
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename1/bb/source/Sources'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename1/bb/source/Sources'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename1/bb/source/Sources' to './lists/base_codename1_bb_Sources'...
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename2/a/source/Sources.lzma'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename2/a/source/Sources.lzma'
+-v2*=Uncompress '$WORKDIR/testsource/dists/codename2/a/source/Sources.lzma' into './lists/base_codename2_a_Sources' using '/usr/bin/unlzma'...
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename2/bb/source/Sources.lzma'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename2/bb/source/Sources.lzma'
+-v2*=Uncompress '$WORKDIR/testsource/dists/codename2/bb/source/Sources.lzma' into './lists/base_codename2_bb_Sources' using '/usr/bin/unlzma'...
+EOF
+
+ed -s testsource/dists/codename1/InRelease <<EOF
+g/^ 11111111111111111/d
+w
+q
+EOF
+
+true > results.expected
+if [ $verbosity -ge 0 ] ; then
+echo "Calculating packages to get..." > results.expected ; fi
+if [ $verbosity -ge 3 ] ; then
+echo " processing updates for 'codename1|bb|source'" >>results.expected ; fi
+if [ $verbosity -ge 5 ] ; then
+echo " reading './lists/base_codename1_bb_Sources'" >>results.expected
+echo " reading './lists/base_codename2_bb_Sources'" >>results.expected
+echo " marking everything to be deleted" >>results.expected
+echo " reading './lists/base_codename2_bb_Sources'" >>results.expected
+echo " reading './lists/base_codename1_bb_Sources'" >>results.expected
+fi
+if [ $verbosity -ge 3 ] ; then
+echo " processing updates for 'codename1|bb|yyyyyyyyyy'" >>results.expected ; fi
+if [ $verbosity -ge 5 ] ; then
+echo " reading './lists/base_codename1_bb_yyyyyyyyyy_Packages'" >>results.expected
+echo " reading './lists/base_codename2_bb_yyyyyyyyyy_Packages'" >>results.expected
+echo " marking everything to be deleted" >>results.expected
+echo " reading './lists/base_codename2_bb_yyyyyyyyyy_Packages'" >>results.expected
+echo " reading './lists/base_codename1_bb_yyyyyyyyyy_Packages'" >>results.expected
+fi
+if [ $verbosity -ge 3 ] ; then
+echo " processing updates for 'codename1|bb|x'" >>results.expected ; fi
+if [ $verbosity -ge 5 ] ; then
+echo " reading './lists/base_codename1_bb_x_Packages'" >>results.expected
+echo " reading './lists/base_codename2_bb_x_Packages'" >>results.expected
+echo " marking everything to be deleted" >>results.expected
+echo " reading './lists/base_codename2_bb_x_Packages'" >>results.expected
+echo " reading './lists/base_codename1_bb_x_Packages'" >>results.expected
+fi
+if [ $verbosity -ge 3 ] ; then
+echo " processing updates for 'codename1|a|source'" >>results.expected ; fi
+if [ $verbosity -ge 5 ] ; then
+echo " reading './lists/base_codename1_a_Sources'" >>results.expected
+echo " reading './lists/base_codename2_a_Sources'" >>results.expected
+echo " marking everything to be deleted" >>results.expected
+echo " reading './lists/base_codename2_a_Sources'" >>results.expected
+echo " reading './lists/base_codename1_a_Sources'" >>results.expected
+fi
+if [ $verbosity -ge 3 ] ; then
+echo " processing updates for 'u|codename1|a|yyyyyyyyyy'" >>results.expected ; fi
+if [ $verbosity -ge 5 ] ; then
+echo " reading './lists/base_codename1_a_yyyyyyyyyy_uPackages'" >>results.expected
+echo " reading './lists/base_codename2_a_yyyyyyyyyy_uPackages'" >>results.expected
+echo " marking everything to be deleted" >>results.expected
+echo " reading './lists/base_codename2_a_yyyyyyyyyy_uPackages'" >>results.expected
+echo " reading './lists/base_codename1_a_yyyyyyyyyy_uPackages'" >>results.expected
+fi
+if [ $verbosity -ge 3 ] ; then
+echo " processing updates for 'codename1|a|yyyyyyyyyy'" >>results.expected ; fi
+if [ $verbosity -ge 5 ] ; then
+echo " reading './lists/base_codename1_a_yyyyyyyyyy_Packages'" >>results.expected
+echo " reading './lists/base_codename2_a_yyyyyyyyyy_Packages'" >>results.expected
+echo " marking everything to be deleted" >>results.expected
+echo " reading './lists/base_codename2_a_yyyyyyyyyy_Packages'" >>results.expected
+echo " reading './lists/base_codename1_a_yyyyyyyyyy_Packages'" >>results.expected
+fi
+if [ $verbosity -ge 3 ] ; then
+echo " processing updates for 'u|codename1|a|x'" >>results.expected ; fi
+if [ $verbosity -ge 5 ] ; then
+echo " reading './lists/base_codename1_a_x_uPackages'" >>results.expected
+echo " reading './lists/base_codename2_a_x_uPackages'" >>results.expected
+echo " marking everything to be deleted" >>results.expected
+echo " reading './lists/base_codename2_a_x_uPackages'" >>results.expected
+echo " reading './lists/base_codename1_a_x_uPackages'" >>results.expected
+fi
+if [ $verbosity -ge 3 ] ; then
+echo " processing updates for 'codename1|a|x'" >>results.expected ; fi
+if [ $verbosity -ge 5 ] ; then
+echo " reading './lists/base_codename1_a_x_Packages'" >>results.expected
+echo " reading './lists/base_codename2_a_x_Packages'" >>results.expected
+echo " marking everything to be deleted" >>results.expected
+echo " reading './lists/base_codename2_a_x_Packages'" >>results.expected
+echo " reading './lists/base_codename1_a_x_Packages'" >>results.expected
+fi
+dodiff results.expected results
+
+testrun - -b . update codename2 codename1 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename1/InRelease'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename1/InRelease'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename2/InRelease' to './lists/base_codename2_InRelease'...
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename2/InRelease'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename2/InRelease'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename1/InRelease' to './lists/base_codename1_InRelease'...
+*=WARNING: No signature found in ./lists/base_codename1_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/base_codename2_InRelease, assuming it is unsigned!
+stdout
+-v0*=Nothing to do found. (Use --noskipold to force processing)
+EOF
+dodo rm lists/_codename*
+testout - -b . update codename2 codename1 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename1/InRelease'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename1/InRelease'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename2/InRelease' to './lists/base_codename2_InRelease'...
+-v6=aptmethod start 'file:$WORKDIR/testsource/dists/codename2/InRelease'
+-v1*=aptmethod got 'file:$WORKDIR/testsource/dists/codename2/InRelease'
+-v2*=Copy file '$WORKDIR/testsource/dists/codename1/InRelease' to './lists/base_codename1_InRelease'...
+*=WARNING: No signature found in ./lists/base_codename1_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/base_codename2_InRelease, assuming it is unsigned!
+EOF
+grep '^C' results.expected > resultsboth.expected || true
+grep '^ ' results2.expected >> resultsboth.expected || true
+grep '^ ' results.expected >> resultsboth.expected || true
+grep '^[^ C]' results.expected >> resultsboth.expected || true
+dodiff resultsboth.expected results
+
+sed -i -e "s/Method: file:/Method: copy:/" conf/updates
+
+dodo rm lists/_codename*
+testout - -b . update codename1 3<<EOF
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename1/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename1/InRelease'
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename2/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename2/InRelease'
+*=WARNING: No signature found in ./lists/base_codename1_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/base_codename2_InRelease, assuming it is unsigned!
+EOF
+dodiff results.expected results
+
+rm -r lists ; mkdir lists
+
+testout - -b . update codename2 3<<EOF
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename1/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename1/InRelease'
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename2/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename2/InRelease'
+*=WARNING: No signature found in ./lists/base_codename1_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/base_codename2_InRelease, assuming it is unsigned!
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename1/a/binary-x/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename1/a/binary-x/Packages'
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename1/bb/binary-x/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename1/bb/binary-x/Packages'
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename1/a/binary-yyyyyyyyyy/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename1/a/binary-yyyyyyyyyy/Packages'
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename1/bb/binary-yyyyyyyyyy/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename1/bb/binary-yyyyyyyyyy/Packages'
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename2/a/binary-x/Packages.lzma'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename2/a/binary-x/Packages.lzma'
+-v2*=Uncompress './lists/base_codename2_a_x_Packages.lzma' into './lists/base_codename2_a_x_Packages' using '/usr/bin/unlzma'...
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename2/bb/binary-x/Packages.lzma'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename2/bb/binary-x/Packages.lzma'
+-v2*=Uncompress './lists/base_codename2_bb_x_Packages.lzma' into './lists/base_codename2_bb_x_Packages' using '/usr/bin/unlzma'...
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename2/a/binary-yyyyyyyyyy/Packages.lzma'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename2/a/binary-yyyyyyyyyy/Packages.lzma'
+-v2*=Uncompress './lists/base_codename2_a_yyyyyyyyyy_Packages.lzma' into './lists/base_codename2_a_yyyyyyyyyy_Packages' using '/usr/bin/unlzma'...
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename2/bb/binary-yyyyyyyyyy/Packages.lzma'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename2/bb/binary-yyyyyyyyyy/Packages.lzma'
+-v2*=Uncompress './lists/base_codename2_bb_yyyyyyyyyy_Packages.lzma' into './lists/base_codename2_bb_yyyyyyyyyy_Packages' using '/usr/bin/unlzma'...
+EOF
+dodiff results2.expected results
+
+testout - -b . update codename1 3<<EOF
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename1/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename1/InRelease'
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename2/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename2/InRelease'
+*=WARNING: No signature found in ./lists/base_codename1_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/base_codename2_InRelease, assuming it is unsigned!
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename1/a/debian-installer/binary-x/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename1/a/debian-installer/binary-x/Packages'
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename1/a/debian-installer/binary-yyyyyyyyyy/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename1/a/debian-installer/binary-yyyyyyyyyy/Packages'
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename2/a/debian-installer/binary-x/Packages.lzma'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename2/a/debian-installer/binary-x/Packages.lzma'
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename2/a/debian-installer/binary-yyyyyyyyyy/Packages.lzma'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename2/a/debian-installer/binary-yyyyyyyyyy/Packages.lzma'
+-v2*=Uncompress './lists/base_codename2_a_x_uPackages.lzma' into './lists/base_codename2_a_x_uPackages' using '/usr/bin/unlzma'...
+-v2*=Uncompress './lists/base_codename2_a_yyyyyyyyyy_uPackages.lzma' into './lists/base_codename2_a_yyyyyyyyyy_uPackages' using '/usr/bin/unlzma'...
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename1/a/source/Sources'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename1/a/source/Sources'
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename1/bb/source/Sources'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename1/bb/source/Sources'
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename2/a/source/Sources.lzma'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename2/a/source/Sources.lzma'
+-v2*=Uncompress './lists/base_codename2_a_Sources.lzma' into './lists/base_codename2_a_Sources' using '/usr/bin/unlzma'...
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename2/bb/source/Sources.lzma'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename2/bb/source/Sources.lzma'
+-v2*=Uncompress './lists/base_codename2_bb_Sources.lzma' into './lists/base_codename2_bb_Sources' using '/usr/bin/unlzma'...
+EOF
+dodiff results.expected results
+
+# Test repositories without uncompressed files listed:
+printf '%%g/^ .*[^a]$/d\nw\nq\n' | ed -s testsource/dists/codename2/InRelease
+# lists/_codename* no longer has to be deleted, as without the uncompressed checksums
+# reprepro does not know it already processed those (it only saves the uncompressed
+# checksums of the already processed files)
+
+# As the checksums for the uncompressed files are not know, and the .lzma files
+# not saved, the lzma files have to be downloaded again:
+testout - -b . update codename2 3<<EOF
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename1/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename1/InRelease'
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename2/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename2/InRelease'
+*=WARNING: No signature found in ./lists/base_codename1_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/base_codename2_InRelease, assuming it is unsigned!
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename2/a/binary-x/Packages.lzma'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename2/a/binary-x/Packages.lzma'
+-v2*=Uncompress './lists/base_codename2_a_x_Packages.lzma' into './lists/base_codename2_a_x_Packages' using '/usr/bin/unlzma'...
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename2/bb/binary-x/Packages.lzma'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename2/bb/binary-x/Packages.lzma'
+-v2*=Uncompress './lists/base_codename2_bb_x_Packages.lzma' into './lists/base_codename2_bb_x_Packages' using '/usr/bin/unlzma'...
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename2/a/binary-yyyyyyyyyy/Packages.lzma'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename2/a/binary-yyyyyyyyyy/Packages.lzma'
+-v2*=Uncompress './lists/base_codename2_a_yyyyyyyyyy_Packages.lzma' into './lists/base_codename2_a_yyyyyyyyyy_Packages' using '/usr/bin/unlzma'...
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename2/bb/binary-yyyyyyyyyy/Packages.lzma'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename2/bb/binary-yyyyyyyyyy/Packages.lzma'
+-v2*=Uncompress './lists/base_codename2_bb_yyyyyyyyyy_Packages.lzma' into './lists/base_codename2_bb_yyyyyyyyyy_Packages' using '/usr/bin/unlzma'...
+EOF
+dodiff results2.expected results
+
+# last time the .lzma files should have not been deleted, so no download
+# but uncompress has still to be done...
+testout - -b . update codename2 3<<EOF
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename1/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename1/InRelease'
+-v6*=aptmethod start 'copy:$WORKDIR/testsource/dists/codename2/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/testsource/dists/codename2/InRelease'
+*=WARNING: No signature found in ./lists/base_codename1_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/base_codename2_InRelease, assuming it is unsigned!
+-v2*=Uncompress './lists/base_codename2_a_x_Packages.lzma' into './lists/base_codename2_a_x_Packages'...
+-v2*=Uncompress './lists/base_codename2_bb_x_Packages.lzma' into './lists/base_codename2_bb_x_Packages'...
+-v2*=Uncompress './lists/base_codename2_a_yyyyyyyyyy_Packages.lzma' into './lists/base_codename2_a_yyyyyyyyyy_Packages'...
+-v2*=Uncompress './lists/base_codename2_bb_yyyyyyyyyy_Packages.lzma' into './lists/base_codename2_bb_yyyyyyyyyy_Packages'...
+EOF
+dodiff results2.expected results
+
+rm -r -f db conf dists pool lists testsource
+testsuccess
diff --git a/tests/layeredupdate2.test b/tests/layeredupdate2.test
new file mode 100644
index 0000000..ce6166d
--- /dev/null
+++ b/tests/layeredupdate2.test
@@ -0,0 +1,683 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+dodo test ! -d db
+mkdir -p conf dists
+echo "export silent-never" > conf/options
+cat > conf/updatelog.sh <<EOF
+#!/bin/sh
+echo "\$@" >> '$WORKDIR/updatelog'
+exit 0
+EOF
+cat > conf/shouldnothappen.sh <<EOF
+#!/bin/sh
+echo "\$@" >> '$WORKDIR/shouldnothappen'
+exit 0
+EOF
+chmod a+x conf/updatelog.sh conf/shouldnothappen.sh
+cat > conf/distributions <<EOF
+Codename: boring
+Suite: unstable
+Components: main firmware
+Architectures: abacus coal source
+Log:
+ --via update updatelog.sh
+ --via include shouldnothappen.sh
+Update: - 1 2 3 4
+
+Codename: interesting
+Suite: experimental
+Components: main firmware
+Architectures: abacus coal source
+Update: 5 6 - 7 8
+
+Codename: dummy
+Components: dummycomponent
+Architectures: dummyarchitecture
+EOF
+mkdir source1 source2
+cat > conf/updates <<EOF
+Name: a
+VerifyRelease: blindtrust
+Method: copy:$WORKDIR/source1
+Architectures: dummyarchitecture
+DownloadListsAs: .lzma .lzma .lzma .lzma .lzma .lzma .lzma .lzma .lzma .lzma .lzma .lzma .lzma .lzma .lzma .lzma .lzma .lzma .lzma
+Components: dummycomponent
+
+Name: b
+VerifyRelease: blindtrust
+Method: copy:$WORKDIR/source2
+Architectures: dummyarchitecture
+DownloadListsAs: .lzma .bz2 .gz .
+Flat: dummycomponent
+
+Name: ca
+From: a
+Architectures: dummyarchitecture
+Components: dummycomponent
+
+Name: ma
+From: ca
+Architectures: dummyarchitecture
+Components: main
+
+Name: wa
+From: ma
+Suite: suitename
+Architectures: source
+
+Name: 3
+From: wa
+
+Name: 4
+Suite: suitename
+From: a
+Architectures: abacus coal
+#without this I do not get a warning, why?
+Components: main firmware
+
+Name: pre1
+Flat: firmware
+From: b
+#without this I do not get a warning, why?
+Architectures: abacus coal
+FilterFormula: section (>=firmware/), section(<< firmware0)
+
+Name: 1
+From: pre1
+Suite: x
+
+Name: 2
+Flat: main
+From: b
+#without this I do not get a warning, why?
+Architectures: abacus coal source
+FilterFormula: section (<<firmware/) | section(>= firmware0) | !section
+Suite: x
+
+Name: 5
+From: b
+
+Name: 6
+From: b
+
+Name: 7
+From: b
+
+Name: 8
+From: b
+EOF
+
+DISTRI=dummy PACKAGE=aa EPOCH="" VERSION=1 REVISION=-1000 SECTION="base" genpackage.sh -sa
+DISTRI=dummy PACKAGE=bb EPOCH="" VERSION=2 REVISION=-0 SECTION="firmware/base" genpackage.sh -sa
+DISTRI=dummy PACKAGE=cc EPOCH="" VERSION=1 REVISION=-1000 SECTION="base" genpackage.sh -sa
+DISTRI=dummy PACKAGE=dd EPOCH="" VERSION=2 REVISION=-0 SECTION="firmware/base" genpackage.sh -sa
+
+mkdir source1/pool source1/pool/main source1/pool/firmware
+mv aa* source1/pool/main
+mv bb* source1/pool/firmware
+mv cc* source2
+mv dd* source2
+
+mkdir source2/x
+cd source2
+echo 'dpkg-scanpackages . /dev/null > x/Packages'
+dpkg-scanpackages . /dev/null > x/Packages
+cd ..
+cat > sourcesections <<EOF
+cc standard base
+dd standard firmware/base
+EOF
+cd source2
+echo 'dpkg-scansources . sourcesections > x/Sources'
+dpkg-scansources . ../sourcesections > x/Sources
+cd ..
+rm sourcesections
+
+cat > source2/x/InRelease <<EOF
+Codename: x
+Suite: toostupidfornonflat
+Architectures: coal abacus
+MD5Sum:
+ $(mdandsize source2/x/Sources) Sources
+ $(mdandsize source2/x/Packages) Packages
+EOF
+
+mkdir -p source1/dists/suitename/main/binary-abacus
+mkdir source1/dists/suitename/main/binary-coal
+mkdir source1/dists/suitename/main/source
+mkdir -p source1/dists/suitename/firmware/binary-abacus
+mkdir source1/dists/suitename/firmware/binary-coal
+mkdir source1/dists/suitename/firmware/source
+
+cd source1
+dpkg-scansources pool/main /dev/null > dists/suitename/main/source/Sources
+dpkg-scanpackages pool/main /dev/null > dists/suitename/main/binary-abacus/Packages
+dpkg-scanpackages -a coal pool/main /dev/null > dists/suitename/main/binary-coal/Packages
+dpkg-scansources pool/firmware /dev/null > dists/suitename/firmware/source/Sources
+dpkg-scanpackages pool/firmware /dev/null > dists/suitename/firmware/binary-abacus/Packages
+dpkg-scanpackages -a coal pool/firmware /dev/null > dists/suitename/firmware/binary-coal/Packages
+cd ..
+
+cat > source1/dists/suitename/InRelease <<EOF
+Codename: hohoho
+Suite: suitename
+Architectures: coal abacus
+MD5Sum:
+ 00000000000000000000000000000000 0 main/binary-abacus/Packages.lz
+ 00000000000000000000000000000000 0 main/binary-abacus/Packages.gz
+ 00000000000000000000000000000000 0 main/binary-coal/Packages.lz
+ 00000000000000000000000000000000 0 main/source/Sources.lz
+ 00000000000000000000000000000000 0 firmware/binary-abacus/Packages.lz
+ 00000000000000000000000000000000 0 firmware/binary-coal/Packages.lz
+ 00000000000000000000000000000000 0 firmware/source/Sources.lz
+ 00000000000000000000000000000000 0 main/binary-coal/Packages.gz
+ 00000000000000000000000000000000 0 main/source/Sources.gz
+ 00000000000000000000000000000000 0 firmware/binary-abacus/Packages.gz
+ 00000000000000000000000000000000 0 firmware/binary-coal/Packages.gz
+ 00000000000000000000000000000000 0 firmware/source/Sources.gz
+EOF
+
+sed -e 's/\.lzma/.lz/' -i conf/updates
+
+testrun - --lunzip=NONE update boring 3<<EOF
+stdout
+$(odb)
+-v2*=Created directory "./lists"
+stderr
+*=./conf/updates:5:124: Ignoring all but first 18 entries...
+-v6*=aptmethod start 'copy:$WORKDIR/source2/x/InRelease'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/dists/suitename/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/x/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/dists/suitename/InRelease'
+*=WARNING: No signature found in ./lists/a_suitename_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/b_x_flat_InRelease, assuming it is unsigned!
+*=Error: './lists/a_suitename_InRelease' only lists unusable or unrequested compressions of 'main/binary-abacus/Packages'.
+*=Try e.g the '--lunzip' option (or check what it is set to) to make more useable.
+*=Or change your DownloadListsAs to request e.g. '.gz'.
+-v0*=There have been errors!
+returns 255
+EOF
+
+cat > source1/dists/suitename/InRelease <<EOF
+Codename: hohoho
+Suite: suitename
+Architectures: coal abacus
+MD5Sum:
+ 00000000000000000000000000000000 0 main/binary-abacus/Packages.lz
+ 00000000000000000000000000000000 0 main/binary-coal/Packages.lz
+ 00000000000000000000000000000000 0 main/source/Sources.lz
+ 00000000000000000000000000000000 0 firmware/binary-abacus/Packages.lz
+ 00000000000000000000000000000000 0 firmware/binary-coal/Packages.lz
+ 00000000000000000000000000000000 0 firmware/source/Sources.lz
+EOF
+
+testrun - --lunzip=NONE update boring 3<<EOF
+stderr
+*=./conf/updates:5:124: Ignoring all but first 18 entries...
+-v6*=aptmethod start 'copy:$WORKDIR/source2/x/InRelease'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/dists/suitename/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/x/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/dists/suitename/InRelease'
+*=WARNING: No signature found in ./lists/a_suitename_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/b_x_flat_InRelease, assuming it is unsigned!
+*=Error: './lists/a_suitename_InRelease' only lists unusable compressions of 'main/binary-abacus/Packages'.
+*=Try e.g the '--lunzip' option (or check what it is set to) to make more useable.
+-v0*=There have been errors!
+returns 255
+EOF
+
+sed -e 's/\.lz\>/.lzma/' -i conf/updates
+
+cat > source1/dists/suitename/InRelease <<EOF
+Codename: hohoho
+Suite: suitename
+Architectures: coal abacus
+MD5Sum:
+ $(cd source1 ; md5releaseline suitename main/binary-abacus/Packages)
+ $(cd source1 ; md5releaseline suitename main/binary-coal/Packages)
+ $(cd source1 ; md5releaseline suitename main/source/Sources)
+ $(cd source1 ; md5releaseline suitename firmware/binary-abacus/Packages)
+ $(cd source1 ; md5releaseline suitename firmware/binary-coal/Packages)
+ $(cd source1 ; md5releaseline suitename firmware/source/Sources)
+EOF
+
+testrun - update boring 3<<EOF
+stderr
+*=./conf/updates:5:126: Ignoring all but first 18 entries...
+-v6*=aptmethod start 'copy:$WORKDIR/source2/x/InRelease'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/dists/suitename/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/x/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/dists/suitename/InRelease'
+*=WARNING: No signature found in ./lists/a_suitename_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/b_x_flat_InRelease, assuming it is unsigned!
+*=Error: './lists/a_suitename_InRelease' only lists unrequested compressions of 'main/binary-abacus/Packages'.
+*=Try changing your DownloadListsAs to request e.g. '.'.
+-v0*=There have been errors!
+returns 255
+EOF
+
+ed -s conf/updates <<EOF
+g/.lzma .lzma .lzma .lzma/d
+w
+q
+EOF
+
+testrun - update boring 3<<EOF
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/source2/x/InRelease'
+-v6*=aptmethod start 'copy:$WORKDIR/source2/x/Sources'
+-v6*=aptmethod start 'copy:$WORKDIR/source2/x/Packages'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/dists/suitename/InRelease'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/dists/suitename/main/source/Sources'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/dists/suitename/main/binary-abacus/Packages'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/dists/suitename/main/binary-coal/Packages'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/dists/suitename/firmware/binary-abacus/Packages'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/dists/suitename/firmware/binary-coal/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/x/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/x/Sources'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/x/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/dists/suitename/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/dists/suitename/main/source/Sources'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/dists/suitename/main/binary-abacus/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/dists/suitename/main/binary-coal/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/dists/suitename/firmware/binary-abacus/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/dists/suitename/firmware/binary-coal/Packages'
+*=WARNING: No signature found in ./lists/a_suitename_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/b_x_flat_InRelease, assuming it is unsigned!
+stdout
+-v0*=Calculating packages to get...
+-v3*= processing updates for 'boring|firmware|source'
+# 6 times:
+-v5*= marking everything to be deleted
+-v3*= processing updates for 'boring|firmware|coal'
+-v5*= reading './lists/a_suitename_firmware_coal_Packages'
+-v3*= processing updates for 'boring|firmware|abacus'
+-v5*= reading './lists/a_suitename_firmware_abacus_Packages'
+-v3*= processing updates for 'boring|main|source'
+-v5*= reading './lists/b_x_Sources'
+-v5*= reading './lists/a_suitename_main_Sources'
+-v3*= processing updates for 'boring|main|coal'
+-v5*= reading './lists/b_x_Packages'
+-v5*= reading './lists/a_suitename_main_coal_Packages'
+-v3*= processing updates for 'boring|main|abacus'
+#-v5*= reading './lists/b_x_Packages'
+-v5*= reading './lists/a_suitename_main_abacus_Packages'
+-v0*=Getting packages...
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/source2/./cc-addons_1-1000_all.deb'
+-v6*=aptmethod start 'copy:$WORKDIR/source2/./dd-addons_2-0_all.deb'
+-v6*=aptmethod start 'copy:$WORKDIR/source2/./cc_1-1000_abacus.deb'
+-v6*=aptmethod start 'copy:$WORKDIR/source2/./dd_2-0_abacus.deb'
+-v6*=aptmethod start 'copy:$WORKDIR/source2/./cc_1-1000.tar.gz'
+-v6*=aptmethod start 'copy:$WORKDIR/source2/./cc_1-1000.dsc'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/./cc-addons_1-1000_all.deb'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/./dd-addons_2-0_all.deb'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/./cc_1-1000_abacus.deb'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/./dd_2-0_abacus.deb'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/./cc_1-1000.tar.gz'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/./cc_1-1000.dsc'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/pool/main/aa-addons_1-1000_all.deb'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/pool/firmware/bb-addons_2-0_all.deb'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/pool/main/aa_1-1000_abacus.deb'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/pool/firmware/bb_2-0_abacus.deb'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/pool/main/aa_1-1000.tar.gz'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/pool/main/aa_1-1000.dsc'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/pool/main/aa-addons_1-1000_all.deb'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/pool/firmware/bb-addons_2-0_all.deb'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/pool/main/aa_1-1000_abacus.deb'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/pool/firmware/bb_2-0_abacus.deb'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/pool/main/aa_1-1000.tar.gz'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/pool/main/aa_1-1000.dsc'
+stdout
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/firmware"
+-v2*=Created directory "./pool/firmware/b"
+-v2*=Created directory "./pool/firmware/b/bb"
+-v2*=Created directory "./pool/firmware/d"
+-v2*=Created directory "./pool/firmware/d/dd"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/c"
+-v2*=Created directory "./pool/main/c/cc"
+-v2*=Created directory "./pool/main/a"
+-v2*=Created directory "./pool/main/a/aa"
+$(ofa 'pool/firmware/d/dd/dd-addons_2-0_all.deb')
+$(ofa 'pool/firmware/d/dd/dd_2-0_abacus.deb')
+$(ofa 'pool/main/c/cc/cc-addons_1-1000_all.deb')
+$(ofa 'pool/main/c/cc/cc_1-1000_abacus.deb')
+$(ofa 'pool/main/c/cc/cc_1-1000.dsc')
+$(ofa 'pool/main/c/cc/cc_1-1000.tar.gz')
+$(ofa 'pool/firmware/b/bb/bb-addons_2-0_all.deb')
+$(ofa 'pool/firmware/b/bb/bb_2-0_abacus.deb')
+$(ofa 'pool/main/a/aa/aa-addons_1-1000_all.deb')
+$(ofa 'pool/main/a/aa/aa_1-1000_abacus.deb')
+$(ofa 'pool/main/a/aa/aa_1-1000.dsc')
+$(ofa 'pool/main/a/aa/aa_1-1000.tar.gz')
+-v1*=Shutting down aptmethods...
+-v0*=Installing (and possibly deleting) packages...
+$(opa 'dd-addons' x 'boring' 'firmware' 'coal' 'deb')
+$(opa 'dd' x 'boring' 'firmware' 'abacus' 'deb')
+$(opa 'dd-addons' x 'boring' 'firmware' 'abacus' 'deb')
+$(opa 'cc-addons' x 'boring' 'main' 'coal' 'deb')
+$(opa 'cc' x 'boring' 'main' 'source' 'dsc')
+$(opa 'cc' x 'boring' 'main' 'abacus' 'deb')
+$(opa 'cc-addons' x 'boring' 'main' 'abacus' 'deb')
+$(opa 'bb-addons' x 'boring' 'firmware' 'coal' 'deb')
+$(opa 'bb' x 'boring' 'firmware' 'abacus' 'deb')
+$(opa 'bb-addons' x 'boring' 'firmware' 'abacus' 'deb')
+$(opa 'aa-addons' x 'boring' 'main' 'coal' 'deb')
+$(opa 'aa' x 'boring' 'main' 'source' 'dsc')
+$(opa 'aa' x 'boring' 'main' 'abacus' 'deb')
+$(opa 'aa-addons' x 'boring' 'main' 'abacus' 'deb')
+EOF
+
+DISTRI=dummy PACKAGE=aa EPOCH="" VERSION=2 REVISION=-1 SECTION="base" genpackage.sh -sa
+DISTRI=dummy PACKAGE=bb EPOCH="" VERSION=1 REVISION=-1 SECTION="firmware/base" genpackage.sh -sa
+DISTRI=dummy PACKAGE=ee EPOCH="" VERSION=2 REVISION=-1 SECTION="firmware/base" genpackage.sh -sa
+
+rm source1/pool/firmware/bb*
+mv aa* source1/pool/main
+mv ee* bb* source1/pool/firmware
+
+cd source1
+dpkg-scansources pool/main /dev/null > dists/suitename/main/source/Sources
+dpkg-scanpackages pool/main /dev/null > dists/suitename/main/binary-abacus/Packages
+dpkg-scanpackages -a coal pool/main /dev/null > dists/suitename/main/binary-coal/Packages
+dpkg-scansources pool/firmware /dev/null > dists/suitename/firmware/source/Sources
+dpkg-scanpackages pool/firmware /dev/null > dists/suitename/firmware/binary-abacus/Packages
+dpkg-scanpackages -a coal pool/firmware /dev/null > dists/suitename/firmware/binary-coal/Packages
+cd ..
+
+cat > source1/dists/suitename/InRelease <<EOF
+Codename: hohoho
+Suite: suitename
+Architectures: coal abacus
+MD5Sum:
+ $(cd source1 ; md5releaseline suitename main/binary-abacus/Packages)
+ $(cd source1 ; md5releaseline suitename main/binary-coal/Packages)
+ $(cd source1 ; md5releaseline suitename main/source/Sources)
+ $(cd source1 ; md5releaseline suitename firmware/binary-abacus/Packages)
+ $(cd source1 ; md5releaseline suitename firmware/binary-coal/Packages)
+ $(cd source1 ; md5releaseline suitename firmware/source/Sources)
+EOF
+
+sed -e 's/Update: - 1/Update: 1/' -i conf/distributions
+ed -s conf/updates <<EOF
+1a
+FilterList: upgradeonly
+.
+w
+q
+EOF
+
+testrun - --keepunreferenced update boring 3<<EOF
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/source2/x/InRelease'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/dists/suitename/InRelease'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/dists/suitename/main/source/Sources'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/dists/suitename/main/binary-abacus/Packages'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/dists/suitename/main/binary-coal/Packages'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/dists/suitename/firmware/binary-abacus/Packages'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/dists/suitename/firmware/binary-coal/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/x/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/dists/suitename/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/dists/suitename/main/source/Sources'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/dists/suitename/main/binary-abacus/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/dists/suitename/main/binary-coal/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/dists/suitename/firmware/binary-abacus/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/dists/suitename/firmware/binary-coal/Packages'
+*=WARNING: No signature found in ./lists/a_suitename_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/b_x_flat_InRelease, assuming it is unsigned!
+stdout
+-v0*=Calculating packages to get...
+-v4*= nothing to do for 'boring|firmware|source'
+-v3*= processing updates for 'boring|firmware|coal'
+-v5*= reading './lists/a_suitename_firmware_coal_Packages'
+-v3*= processing updates for 'boring|firmware|abacus'
+-v5*= reading './lists/a_suitename_firmware_abacus_Packages'
+-v3*= processing updates for 'boring|main|source'
+-v5*= reading './lists/b_x_Sources'
+-v5*= reading './lists/a_suitename_main_Sources'
+-v3*= processing updates for 'boring|main|coal'
+-v5*= reading './lists/b_x_Packages'
+-v5*= reading './lists/a_suitename_main_coal_Packages'
+-v3*= processing updates for 'boring|main|abacus'
+#-v5*= reading './lists/b_x_Packages'
+-v5*= reading './lists/a_suitename_main_abacus_Packages'
+-v0*=Getting packages...
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/source1/pool/main/aa-addons_2-1_all.deb'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/pool/main/aa_2-1_abacus.deb'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/pool/main/aa_2-1.tar.gz'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/pool/main/aa_2-1.dsc'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/pool/main/aa-addons_2-1_all.deb'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/pool/main/aa_2-1_abacus.deb'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/pool/main/aa_2-1.tar.gz'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/pool/main/aa_2-1.dsc'
+stdout
+$(ofa 'pool/main/a/aa/aa-addons_2-1_all.deb')
+$(ofa 'pool/main/a/aa/aa_2-1_abacus.deb')
+$(ofa 'pool/main/a/aa/aa_2-1.dsc')
+$(ofa 'pool/main/a/aa/aa_2-1.tar.gz')
+-v1*=Shutting down aptmethods...
+-v0*=Installing (and possibly deleting) packages...
+$(opu 'aa-addons' x x 'boring' 'main' 'coal' 'deb')
+$(opu 'aa' x x 'boring' 'main' 'source' 'dsc')
+$(opu 'aa' x x 'boring' 'main' 'abacus' 'deb')
+$(opu 'aa-addons' x x 'boring' 'main' 'abacus' 'deb')
+-v1*=4 files lost their last reference.
+-v1*=(dumpunreferenced lists such files, use deleteunreferenced to delete them.)
+EOF
+
+#remove upgradeonly again, letting ee in
+ed -s conf/updates <<EOF
+%g/FilterList: upgradeonly/d
+w
+q
+EOF
+
+testrun - --keepunreferenced update boring 3<<EOF
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/source2/x/InRelease'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/dists/suitename/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/x/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/dists/suitename/InRelease'
+*=WARNING: No signature found in ./lists/a_suitename_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/b_x_flat_InRelease, assuming it is unsigned!
+stdout
+-v0*=Nothing to do found. (Use --noskipold to force processing)
+EOF
+
+testrun - --nolistsdownload --keepunreferenced update boring 3<<EOF
+stderr
+*=WARNING: No signature found in ./lists/a_suitename_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/b_x_flat_InRelease, assuming it is unsigned!
+stdout
+-v0*=Nothing to do found. (Use --noskipold to force processing)
+EOF
+
+testrun - --nolistsdownload --noskipold --keepunreferenced update boring 3<<EOF
+stderr
+*=WARNING: No signature found in ./lists/a_suitename_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/b_x_flat_InRelease, assuming it is unsigned!
+stdout
+-v0*=Calculating packages to get...
+-v4*= nothing to do for 'boring|firmware|source'
+-v3*= processing updates for 'boring|firmware|coal'
+-v5*= reading './lists/a_suitename_firmware_coal_Packages'
+-v3*= processing updates for 'boring|firmware|abacus'
+-v5*= reading './lists/a_suitename_firmware_abacus_Packages'
+-v3*= processing updates for 'boring|main|source'
+-v5*= reading './lists/b_x_Sources'
+-v5*= reading './lists/a_suitename_main_Sources'
+-v3*= processing updates for 'boring|main|coal'
+-v5*= reading './lists/b_x_Packages'
+-v5*= reading './lists/a_suitename_main_coal_Packages'
+-v3*= processing updates for 'boring|main|abacus'
+#-v5*= reading './lists/b_x_Packages'
+-v5*= reading './lists/a_suitename_main_abacus_Packages'
+-v0*=Getting packages...
+-v2*=Created directory "./pool/firmware/e"
+-v2*=Created directory "./pool/firmware/e/ee"
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/source1/pool/firmware/ee-addons_2-1_all.deb'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/pool/firmware/ee_2-1_abacus.deb'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/pool/firmware/ee-addons_2-1_all.deb'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/pool/firmware/ee_2-1_abacus.deb'
+stdout
+$(ofa 'pool/firmware/e/ee/ee-addons_2-1_all.deb')
+$(ofa 'pool/firmware/e/ee/ee_2-1_abacus.deb')
+-v1*=Shutting down aptmethods...
+-v0*=Installing (and possibly deleting) packages...
+$(opa 'ee-addons' x 'boring' 'firmware' 'coal' 'deb')
+$(opa 'ee' x 'boring' 'firmware' 'abacus' 'deb')
+$(opa 'ee-addons' x 'boring' 'firmware' 'abacus' 'deb')
+EOF
+
+# reinsert delete rule, this should cause a downgrade of bb
+sed -e 's/Update: 1/Update: - 1/' -i conf/distributions
+
+# changes to the clean rules causes automatic reprocessing, so new noskipold needed here
+
+testrun - --keepunreferenced update boring 3<<EOF
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/source2/x/InRelease'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/dists/suitename/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/x/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/dists/suitename/InRelease'
+*=WARNING: No signature found in ./lists/a_suitename_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/b_x_flat_InRelease, assuming it is unsigned!
+stdout
+-v0*=Calculating packages to get...
+-v3*= processing updates for 'boring|firmware|source'
+# 6 times:
+-v5*= marking everything to be deleted
+-v3*= processing updates for 'boring|firmware|coal'
+-v5*= reading './lists/a_suitename_firmware_coal_Packages'
+-v3*= processing updates for 'boring|firmware|abacus'
+-v5*= reading './lists/a_suitename_firmware_abacus_Packages'
+-v3*= processing updates for 'boring|main|source'
+-v5*= reading './lists/b_x_Sources'
+-v5*= reading './lists/a_suitename_main_Sources'
+-v3*= processing updates for 'boring|main|coal'
+-v5*= reading './lists/b_x_Packages'
+-v5*= reading './lists/a_suitename_main_coal_Packages'
+-v3*= processing updates for 'boring|main|abacus'
+#-v5*= reading './lists/b_x_Packages'
+-v5*= reading './lists/a_suitename_main_abacus_Packages'
+-v0*=Getting packages...
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/source1/pool/firmware/bb-addons_1-1_all.deb'
+-v6*=aptmethod start 'copy:$WORKDIR/source1/pool/firmware/bb_1-1_abacus.deb'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/pool/firmware/bb-addons_1-1_all.deb'
+-v1*=aptmethod got 'copy:$WORKDIR/source1/pool/firmware/bb_1-1_abacus.deb'
+*=Warning: downgrading 'bb-addons' from '2-0' to '1-1' in 'boring|firmware|coal'!
+*=Warning: downgrading 'bb' from '2-0' to '1-1' in 'boring|firmware|abacus'!
+*=Warning: downgrading 'bb-addons' from '2-0' to '1-1' in 'boring|firmware|abacus'!
+stdout
+$(ofa 'pool/firmware/b/bb/bb-addons_1-1_all.deb')
+$(ofa 'pool/firmware/b/bb/bb_1-1_abacus.deb')
+-v1*=Shutting down aptmethods...
+-v0*=Installing (and possibly deleting) packages...
+$(opu 'bb-addons' x x 'boring' 'firmware' 'coal' 'deb')
+$(opu 'bb' x x 'boring' 'firmware' 'abacus' 'deb')
+$(opu 'bb-addons' x x 'boring' 'firmware' 'abacus' 'deb')
+stdout
+-v1*=2 files lost their last reference.
+-v1*=(dumpunreferenced lists such files, use deleteunreferenced to delete them.)
+EOF
+
+#Now it gets evil! Name flat and non-flat the same
+dodo sed -i -e 's/suitename/x/' source1/dists/suitename/InRelease
+mv source1/dists/suitename source1/dists/x
+mv source1/dists source2/dists
+dodo sed -i -e 's/suitename/x/' -e 's/^From: a$/From: b/' -e 's/Flat: dummycomponent/#&/' conf/updates
+
+testrun - update boring 3<<EOF
+stderr
+-v0*=Warning: From the same remote repository 'copy:${WORKDIR}/source2', distribution 'x'
+-v0*=is requested both flat and non-flat. While this is possible
+-v0*=(having copy:${WORKDIR}/source2/dists/x and copy:${WORKDIR}/source2/x), it is unlikely.
+-v0*=To no longer see this message, use --ignore=flatandnonflat.
+-v6*=aptmethod start 'copy:$WORKDIR/source2/x/InRelease'
+-v6*=aptmethod start 'copy:$WORKDIR/source2/dists/x/InRelease'
+-v6*=aptmethod start 'copy:$WORKDIR/source2/dists/x/main/source/Sources'
+-v6*=aptmethod start 'copy:$WORKDIR/source2/dists/x/main/binary-abacus/Packages'
+-v6*=aptmethod start 'copy:$WORKDIR/source2/dists/x/main/binary-coal/Packages'
+-v6*=aptmethod start 'copy:$WORKDIR/source2/dists/x/firmware/binary-abacus/Packages'
+-v6*=aptmethod start 'copy:$WORKDIR/source2/dists/x/firmware/binary-coal/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/x/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/dists/x/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/dists/x/main/source/Sources'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/dists/x/main/binary-abacus/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/dists/x/main/binary-coal/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/dists/x/firmware/binary-abacus/Packages'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/dists/x/firmware/binary-coal/Packages'
+*=WARNING: No signature found in ./lists/b_x_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/b_x_flat_InRelease, assuming it is unsigned!
+stdout
+-v0*=Calculating packages to get...
+-v0*= nothing new for 'boring|firmware|source' (use --noskipold to process anyway)
+-v3*= processing updates for 'boring|firmware|coal'
+# 5 times:
+-v5*= marking everything to be deleted
+-v5*= reading './lists/b_x_firmware_coal_Packages'
+-v3*= processing updates for 'boring|firmware|abacus'
+-v5*= reading './lists/b_x_firmware_abacus_Packages'
+-v3*= processing updates for 'boring|main|source'
+-v5*= reading './lists/b_x_Sources'
+-v5*= reading './lists/b_x_main_Sources'
+-v3*= processing updates for 'boring|main|coal'
+-v5*= reading './lists/b_x_Packages'
+-v5*= reading './lists/b_x_main_coal_Packages'
+-v3*= processing updates for 'boring|main|abacus'
+#-v5*= reading './lists/b_x_Packages'
+-v5*= reading './lists/b_x_main_abacus_Packages'
+stderr
+EOF
+
+testrun - --ignore=flatandnonflat update boring 3<<EOF
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/source2/x/InRelease'
+-v6*=aptmethod start 'copy:$WORKDIR/source2/dists/x/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/x/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/source2/dists/x/InRelease'
+*=WARNING: No signature found in ./lists/b_x_InRelease, assuming it is unsigned!
+*=WARNING: No signature found in ./lists/b_x_flat_InRelease, assuming it is unsigned!
+stdout
+-v0*=Nothing to do found. (Use --noskipold to force processing)
+stderr
+EOF
+
+cat > results.expected <<EOF
+add boring deb firmware coal bb-addons 2-0 -- pool/firmware/b/bb/bb-addons_2-0_all.deb
+add boring deb firmware coal dd-addons 2-0 -- pool/firmware/d/dd/dd-addons_2-0_all.deb
+add boring deb firmware abacus bb 2-0 -- pool/firmware/b/bb/bb_2-0_abacus.deb
+add boring deb firmware abacus bb-addons 2-0 -- pool/firmware/b/bb/bb-addons_2-0_all.deb
+add boring deb firmware abacus dd 2-0 -- pool/firmware/d/dd/dd_2-0_abacus.deb
+add boring deb firmware abacus dd-addons 2-0 -- pool/firmware/d/dd/dd-addons_2-0_all.deb
+add boring dsc main source aa 1-1000 -- pool/main/a/aa/aa_1-1000.dsc pool/main/a/aa/aa_1-1000.tar.gz
+add boring dsc main source cc 1-1000 -- pool/main/c/cc/cc_1-1000.dsc pool/main/c/cc/cc_1-1000.tar.gz
+add boring deb main coal aa-addons 1-1000 -- pool/main/a/aa/aa-addons_1-1000_all.deb
+add boring deb main coal cc-addons 1-1000 -- pool/main/c/cc/cc-addons_1-1000_all.deb
+add boring deb main abacus aa 1-1000 -- pool/main/a/aa/aa_1-1000_abacus.deb
+add boring deb main abacus aa-addons 1-1000 -- pool/main/a/aa/aa-addons_1-1000_all.deb
+add boring deb main abacus cc 1-1000 -- pool/main/c/cc/cc_1-1000_abacus.deb
+add boring deb main abacus cc-addons 1-1000 -- pool/main/c/cc/cc-addons_1-1000_all.deb
+replace boring dsc main source aa 2-1 1-1000 -- pool/main/a/aa/aa_2-1.dsc pool/main/a/aa/aa_2-1.tar.gz -- pool/main/a/aa/aa_1-1000.dsc pool/main/a/aa/aa_1-1000.tar.gz
+replace boring deb main coal aa-addons 2-1 1-1000 -- pool/main/a/aa/aa-addons_2-1_all.deb -- pool/main/a/aa/aa-addons_1-1000_all.deb
+replace boring deb main abacus aa 2-1 1-1000 -- pool/main/a/aa/aa_2-1_abacus.deb -- pool/main/a/aa/aa_1-1000_abacus.deb
+replace boring deb main abacus aa-addons 2-1 1-1000 -- pool/main/a/aa/aa-addons_2-1_all.deb -- pool/main/a/aa/aa-addons_1-1000_all.deb
+add boring deb firmware coal ee-addons 2-1 -- pool/firmware/e/ee/ee-addons_2-1_all.deb
+add boring deb firmware abacus ee 2-1 -- pool/firmware/e/ee/ee_2-1_abacus.deb
+add boring deb firmware abacus ee-addons 2-1 -- pool/firmware/e/ee/ee-addons_2-1_all.deb
+replace boring deb firmware coal bb-addons 1-1 2-0 -- pool/firmware/b/bb/bb-addons_1-1_all.deb -- pool/firmware/b/bb/bb-addons_2-0_all.deb
+replace boring deb firmware abacus bb 1-1 2-0 -- pool/firmware/b/bb/bb_1-1_abacus.deb -- pool/firmware/b/bb/bb_2-0_abacus.deb
+replace boring deb firmware abacus bb-addons 1-1 2-0 -- pool/firmware/b/bb/bb-addons_1-1_all.deb -- pool/firmware/b/bb/bb-addons_2-0_all.deb
+EOF
+
+dodo test ! -f shouldnothappen
+dodiff results.expected updatelog
+rm updatelog results.expected
+rm -r -f db conf dists pool lists source1 source2 test.changes
+testsuccess
diff --git a/tests/listcodenames.test b/tests/listcodenames.test
new file mode 100644
index 0000000..90b08a2
--- /dev/null
+++ b/tests/listcodenames.test
@@ -0,0 +1,41 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+testrun - -b . _listcodenames 3<<EOF
+return 254
+stderr
+*=Error opening config file './conf/distributions': No such file or directory(2)
+-v0*=There have been errors!
+stdout
+EOF
+mkdir -p conf
+touch conf/distributions
+testrun - -b . _listcodenames 3<<EOF
+return 249
+stderr
+*=No distribution definitions found in ./conf/distributions!
+-v0*=There have been errors!
+stdout
+EOF
+cat > conf/distributions <<EOF
+Codename: foo/updates
+Suite: suitename
+Components: a bb ccc dddd
+UDebComponents: a dddd
+Architectures: x source
+EOF
+testrun - -b . _listcodenames 3<<EOF
+stderr
+stdout
+*=foo/updates
+EOF
+testrun - -b . --nothingiserror _listcodenames 3<<EOF
+stderr
+stdout
+*=foo/updates
+EOF
+dodo test ! -d db
+dodo test ! -d pool
+dodo test ! -d dists
+rm -r -f conf
+testsuccess
diff --git a/tests/morgue.test b/tests/morgue.test
new file mode 100644
index 0000000..a302ec2
--- /dev/null
+++ b/tests/morgue.test
@@ -0,0 +1,276 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+mkdir conf
+cat > conf/options <<EOF
+morguedir ./morgue
+export silent-never
+EOF
+cat > conf/distributions <<EOF
+Codename: test
+Architectures: source
+Components: main
+EOF
+cat > fake.dsc <<EOF
+Format: 1.0
+Source: bla
+Binary: bla
+Architecture: all
+Section: whatever
+Priority: important
+Version: 1.7
+Maintainer: nobody <nobody@localhost>
+Files:
+EOF
+
+
+testrun - -C main includedsc test fake.dsc 3<<EOF
+stdout
+$(odb)
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/b"
+-v2*=Created directory "./pool/main/b/bla"
+$(ofa 'pool/main/b/bla/bla_1.7.dsc')
+$(opa 'bla' unset 'test' 'main' 'source' 'dsc')
+EOF
+
+testrun - remove test bla 3<<EOF
+stdout
+$(opd 'bla' unset test main source dsc)
+-v0*=Deleting files no longer referenced...
+-v2*=Created directory "./morgue"
+-v2*=removed now empty directory ./pool/main/b/bla
+-v2*=removed now empty directory ./pool/main/b
+-v2*=removed now empty directory ./pool/main
+-v2*=removed now empty directory ./pool
+$(ofd 'pool/main/b/bla/bla_1.7.dsc')
+EOF
+
+ls -la morgue
+dodo test -f morgue/bla_1.7.dsc
+dodo test ! -e pool
+
+rm -r morgue
+# test what happens if one cannot write there:
+mkdir morgue
+chmod a-w morgue
+
+testrun - -C main includedsc test fake.dsc 3<<EOF
+stdout
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/b"
+-v2*=Created directory "./pool/main/b/bla"
+$(ofa 'pool/main/b/bla/bla_1.7.dsc')
+$(opa 'bla' unset 'test' 'main' 'source' 'dsc')
+EOF
+
+testrun - remove test bla 3<<EOF
+stdout
+$(opd 'bla' unset test main source dsc)
+-v0*=Deleting files no longer referenced...
+-v1*=deleting and forgetting pool/main/b/bla/bla_1.7.dsc
+stderr
+*=error 13 creating morgue-file ./morgue/bla_1.7.dsc: Permission denied
+-v0*=There have been errors!
+returns 243
+EOF
+
+find morgue -mindepth 1 | sort > results
+cat > results.expected <<EOF
+EOF
+dodiff results.expected results
+
+# if it could not be moved to the morgue, it should stay in the pool:
+testrun - dumpunreferenced 3<<EOF
+stdout
+*=pool/main/b/bla/bla_1.7.dsc
+EOF
+
+# and deleting it there of course fails again:
+testrun - deleteunreferenced 3<<EOF
+stdout
+-v1*=deleting and forgetting pool/main/b/bla/bla_1.7.dsc
+stderr
+*=error 13 creating morgue-file ./morgue/bla_1.7.dsc: Permission denied
+-v0*=There have been errors!
+returns 243
+EOF
+
+# if it could not be moved to the morgue, it should stay in the pool:
+testrun - dumpunreferenced 3<<EOF
+stdout
+*=pool/main/b/bla/bla_1.7.dsc
+EOF
+
+chmod u+w morgue
+
+# now it should work:
+testrun - deleteunreferenced 3<<EOF
+stdout
+-v2*=removed now empty directory ./pool/main/b/bla
+-v2*=removed now empty directory ./pool/main/b
+-v2*=removed now empty directory ./pool/main
+-v2*=removed now empty directory ./pool
+$(ofd 'pool/main/b/bla/bla_1.7.dsc')
+EOF
+find morgue -mindepth 1 | sort > results
+cat > results.expected <<EOF
+morgue/bla_1.7.dsc
+EOF
+dodiff results.expected results
+# and be gone:
+testrun empty dumpunreferenced
+
+
+
+ls -la morgue
+dodo test -f morgue/bla_1.7.dsc
+dodo test ! -e pool
+
+# Next test: what if the file is missing?
+
+testrun - -C main includedsc test fake.dsc 3<<EOF
+stdout
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/b"
+-v2*=Created directory "./pool/main/b/bla"
+$(ofa 'pool/main/b/bla/bla_1.7.dsc')
+$(opa 'bla' unset 'test' 'main' 'source' 'dsc')
+EOF
+
+dodo rm pool/main/b/bla/bla_1.7.dsc
+
+testrun - remove test bla 3<<EOF
+stdout
+$(opd 'bla' unset test main source dsc)
+-v0*=Deleting files no longer referenced...
+stderr
+*=./pool/main/b/bla/bla_1.7.dsc not found, forgetting anyway
+stdout
+$(ofd 'pool/main/b/bla/bla_1.7.dsc')
+EOF
+
+find morgue -mindepth 1 | sort > results
+cat > results.expected <<EOF
+morgue/bla_1.7.dsc
+EOF
+dodiff results.expected results
+
+# Next test: file cannot be moved
+
+testrun - -C main includedsc test fake.dsc 3<<EOF
+stdout
+$(ofa 'pool/main/b/bla/bla_1.7.dsc')
+$(opa 'bla' unset 'test' 'main' 'source' 'dsc')
+EOF
+
+dodo chmod a-w pool/main/b/bla
+
+testrun - remove test bla 3<<EOF
+stdout
+$(opd 'bla' unset test main source dsc)
+-v0*=Deleting files no longer referenced...
+-v1*=deleting and forgetting pool/main/b/bla/bla_1.7.dsc
+stderr
+*=error 13 while unlinking ./pool/main/b/bla/bla_1.7.dsc: Permission denied
+-v0*=There have been errors!
+returns 243
+EOF
+
+dodo chmod u+w pool/main/b/bla
+
+find morgue -mindepth 1 | sort > results
+cat > results.expected <<EOF
+morgue/bla_1.7.dsc
+EOF
+dodiff results.expected results
+testrun - dumpunreferenced 3<<EOF
+stdout
+*=pool/main/b/bla/bla_1.7.dsc
+EOF
+
+# now it should work:
+testrun - deleteunreferenced 3<<EOF
+stdout
+-v2*=removed now empty directory ./pool/main/b/bla
+-v2*=removed now empty directory ./pool/main/b
+-v2*=removed now empty directory ./pool/main
+-v2*=removed now empty directory ./pool
+$(ofd 'pool/main/b/bla/bla_1.7.dsc')
+EOF
+find morgue -mindepth 1 | sort > results
+cat > results.expected <<EOF
+morgue/bla_1.7.dsc
+morgue/bla_1.7.dsc-1
+EOF
+dodiff results.expected results
+# and be gone:
+testrun empty dumpunreferenced
+
+# Test symbolic link:
+testrun - -C main includedsc test fake.dsc 3<<EOF
+stdout
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/main"
+-v2*=Created directory "./pool/main/b"
+-v2*=Created directory "./pool/main/b/bla"
+$(ofa 'pool/main/b/bla/bla_1.7.dsc')
+$(opa 'bla' unset 'test' 'main' 'source' 'dsc')
+EOF
+
+dodo mv pool/main/b/bla/bla_1.7.dsc pool/main/b/bla/bla_1.7.dscc
+dodo ln -s bla_1.7.dscc pool/main/b/bla/bla_1.7.dsc
+
+testrun - remove test bla 3<<EOF
+stdout
+$(opd 'bla' unset test main source dsc)
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/main/b/bla/bla_1.7.dsc')
+EOF
+
+ls -l morgue
+find morgue -mindepth 1 | sort > results
+cat > results.expected <<EOF
+morgue/bla_1.7.dsc
+morgue/bla_1.7.dsc-1
+EOF
+dodiff results.expected results
+
+dodo mv pool/main/b/bla/bla_1.7.dscc pool/main/b/bla/bla_1.7.dsc
+testrun - _detect pool/main/b/bla/bla_1.7.dsc 3<<EOF
+stdout
+$(ofa 'pool/main/b/bla/bla_1.7.dsc')
+-v0*=1 files were added but not used.
+-v0*=The next deleteunreferenced call will delete them.
+EOF
+
+dodo chmod a-r pool/main/b/bla/bla_1.7.dsc
+testrun - deleteunreferenced 3<<EOF
+stdout
+$(ofd 'pool/main/b/bla/bla_1.7.dsc')
+-v2*=removed now empty directory ./pool/main/b/bla
+-v2*=removed now empty directory ./pool/main/b
+-v2*=removed now empty directory ./pool/main
+-v2*=removed now empty directory ./pool
+EOF
+ls -l morgue
+find morgue -mindepth 1 | sort > results
+cat > results.expected <<EOF
+morgue/bla_1.7.dsc
+morgue/bla_1.7.dsc-1
+morgue/bla_1.7.dsc-2
+EOF
+dodiff results.expected results
+
+# TODO: is there a way to check if failing copying is handled correctly?
+# that needs a file not readable, not renameable to morgue, but can be unlinked...
+
+# TODO: check if things like a failed include work correctly
+# (they should only copy things to the morgue that were in the pool previously)
+
+dodo test ! -e pool
+rm -r db morgue fake.dsc conf results results.expected
+testsuccess
diff --git a/tests/multiversion.sh b/tests/multiversion.sh
new file mode 100755
index 0000000..a7b83ee
--- /dev/null
+++ b/tests/multiversion.sh
@@ -0,0 +1,353 @@
+#!/bin/sh
+set -u
+
+# Copyright (C) 2017, Benjamin Drung <benjamin.drung@profitbricks.com>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+. "${0%/*}/shunit2-helper-functions.sh"
+
+oneTimeSetUp() {
+ for revision in 1 2 2+deb8u1 10; do
+ mkdir -p "$PKGS"
+ (cd $PKGS && PACKAGE=hello SECTION=main DISTRI=buster EPOCH="" VERSION=2.9 REVISION=-$revision ../genpackage.sh)
+ done
+}
+
+setUp() {
+ create_repo
+ echo "Limit: -1" >> $REPO/conf/distributions
+}
+
+tearDown() {
+ check_db
+}
+
+four_hellos() {
+ for revision in 1 2 2+deb8u1 10; do
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-${revision}_${ARCH}.deb
+ done
+}
+
+test_ls() {
+ (cd $PKGS && PACKAGE=kvm SECTION=main DISTRI=buster VERSION=1.2.1 REVISION=-8 ../genpackage.sh)
+ (cd $PKGS && PACKAGE=kvm SECTION=main DISTRI=buster VERSION=1.2.1 REVISION=-9 ../genpackage.sh)
+ (cd $PKGS && PACKAGE=appdirs SECTION=main DISTRI=buster VERSION=1.3.0 REVISION=-1 ../genpackage.sh)
+ for package in hello_2.9-1 kvm_1.2.1-8 kvm_1.2.1-9 appdirs_1.3.0-1; do
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/${package}_${ARCH}.deb
+ done
+ assertEquals "\
+kvm | 1.2.1-9 | buster | $ARCH
+kvm | 1.2.1-8 | buster | $ARCH" "$($REPREPRO -b $REPO ls kvm)"
+ assertEquals "\
+buster|main|$ARCH: kvm 1.2.1-9
+buster|main|$ARCH: kvm 1.2.1-8" "$($REPREPRO -b $REPO list buster kvm)"
+}
+
+test_sorting() {
+ four_hellos
+ assertEquals "\
+buster|main|$ARCH: hello 2.9-10
+buster|main|$ARCH: hello 2.9-2+deb8u1
+buster|main|$ARCH: hello 2.9-2
+buster|main|$ARCH: hello 2.9-1" "$($REPREPRO -b $REPO list buster)"
+ assertEquals "\
+hello | 2.9-10 | buster | $ARCH
+hello | 2.9-2+deb8u1 | buster | $ARCH
+hello | 2.9-2 | buster | $ARCH
+hello | 2.9-1 | buster | $ARCH" "$($REPREPRO -b $REPO ls hello)"
+}
+
+test_include_twice() {
+ for revision in 1 2; do
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-${revision}_${ARCH}.deb
+ done
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-1_${ARCH}.deb
+ assertEquals "\
+hello | 2.9-2 | buster | $ARCH
+hello | 2.9-1 | buster | $ARCH" "$($REPREPRO -b $REPO ls hello)"
+}
+
+test_copy_latest() {
+ four_hellos
+ add_distro bullseye "Limit: -1"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO copy bullseye buster hello hello
+ assertEquals "bullseye|main|$ARCH: hello 2.9-10" "$($REPREPRO -b $REPO list bullseye)"
+}
+
+test_copy_specific() {
+ four_hellos
+ add_distro bullseye "Limit: -1"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO copy bullseye buster hello=2.9-10 hello=2.9-1 hello=2.9-10
+ assertEquals "\
+bullseye|main|$ARCH: hello 2.9-10
+bullseye|main|$ARCH: hello 2.9-1" "$($REPREPRO -b $REPO list bullseye)"
+}
+
+test_remove_latest() {
+ four_hellos
+ add_distro bullseye "Limit: -1"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO copy bullseye buster hello=2.9-10 hello=2.9-1 hello=2.9-10
+ call $REPREPRO $VERBOSE_ARGS -b $REPO remove bullseye hello
+ assertEquals "\
+hello | 2.9-10 | buster | $ARCH
+hello | 2.9-2+deb8u1 | buster | $ARCH
+hello | 2.9-2 | buster | $ARCH
+hello | 2.9-1 | buster | $ARCH
+hello | 2.9-1 | bullseye | $ARCH" "$($REPREPRO -b $REPO ls hello)"
+}
+
+test_remove_specific() {
+ four_hellos
+ call $REPREPRO $VERBOSE_ARGS -b $REPO remove buster hello=2.9-2+deb8u1 hellox hello=2.9-2+deb8u1
+ assertEquals "\
+buster|main|$ARCH: hello 2.9-10
+buster|main|$ARCH: hello 2.9-2
+buster|main|$ARCH: hello 2.9-1" "$($REPREPRO -b $REPO list buster)"
+}
+
+test_removefilter() {
+ (cd $PKGS && PACKAGE=kvm SECTION=main DISTRI=buster VERSION=1.2.1 REVISION=-8 ../genpackage.sh)
+ (cd $PKGS && PACKAGE=kvm SECTION=main DISTRI=buster VERSION=1.2.1 REVISION=-9 ../genpackage.sh)
+ for package in hello_2.9-1 kvm_1.2.1-8 kvm_1.2.1-9; do
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/${package}_${ARCH}.deb
+ done
+ assertEquals "\
+buster|main|$ARCH: hello 2.9-1
+buster|main|$ARCH: kvm 1.2.1-9
+buster|main|$ARCH: kvm 1.2.1-8" "$($REPREPRO -b $REPO list buster)"
+
+ add_distro bullseye "Limit: -1"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO copy bullseye buster kvm
+ assertEquals "bullseye|main|$ARCH: kvm 1.2.1-9" "$($REPREPRO -b $REPO list bullseye)"
+
+ call $REPREPRO $VERBOSE_ARGS -b $REPO removefilter buster "Package (= kvm)"
+ assertEquals "buster|main|$ARCH: hello 2.9-1" "$($REPREPRO -b $REPO list buster)"
+ assertTrue "kvm_1.2.1-8_$ARCH.deb is still in the pool!" "test ! -e $REPO/pool/main/k/kvm/kvm_1.2.1-8_$ARCH.deb"
+ assertTrue "kvm_1.2.1-9_$ARCH.deb is missing from the pool!" "test -e $REPO/pool/main/k/kvm/kvm_1.2.1-9_$ARCH.deb"
+
+ call $REPREPRO $VERBOSE_ARGS -b $REPO removefilter bullseye "Package (= kvm)"
+ assertEquals "buster|main|$ARCH: hello 2.9-1" "$($REPREPRO -b $REPO list buster)"
+ assertTrue "kvm_1.2.1-9_$ARCH.deb is still in the pool!" "test ! -e $REPO/pool/main/k/kvm/kvm_1.2.1-9_$ARCH.deb"
+}
+
+test_readd_distribution() {
+ # Test case for https://github.com/profitbricks/reprepro/issues/1
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-1_${ARCH}.deb
+
+ # Add distribution
+ cp $REPO/conf/distributions $REPO/conf/distributions.backup
+ add_distro bullseye "Limit: -1"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb bullseye $PKGS/hello_2.9-2_${ARCH}.deb
+
+ # Remove distribution
+ mv $REPO/conf/distributions.backup $REPO/conf/distributions
+ call $REPREPRO $VERBOSE_ARGS -b $REPO --delete clearvanished
+
+ # Re-add distribution again
+ echo "I: Re-adding bullseye..."
+ add_distro bullseye "Limit: -1"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb bullseye $PKGS/hello_2.9-10_${ARCH}.deb
+ assertEquals "bullseye|main|$ARCH: hello 2.9-10" "$($REPREPRO -b $REPO list bullseye)"
+}
+
+test_limit3() {
+ sed -i 's/^Limit: .*$/Limit: 3/' $REPO/conf/distributions
+ for revision in 1 2 2+deb8u1; do
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-${revision}_${ARCH}.deb
+ done
+ assertEquals "\
+buster|main|${ARCH}: hello 2.9-2+deb8u1
+buster|main|${ARCH}: hello 2.9-2
+buster|main|${ARCH}: hello 2.9-1" "$($REPREPRO -b $REPO list buster)"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-10_${ARCH}.deb
+ assertEquals "\
+buster|main|${ARCH}: hello 2.9-10
+buster|main|${ARCH}: hello 2.9-2+deb8u1
+buster|main|${ARCH}: hello 2.9-2" "$($REPREPRO -b $REPO list buster)"
+}
+
+test_reduce_limit() {
+ for revision in 1 2 2+deb8u1; do
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-${revision}_${ARCH}.deb
+ done
+ assertEquals "\
+buster|main|${ARCH}: hello 2.9-2+deb8u1
+buster|main|${ARCH}: hello 2.9-2
+buster|main|${ARCH}: hello 2.9-1" "$($REPREPRO -b $REPO list buster)"
+ sed -i 's/^Limit: .*$/Limit: 1/' $REPO/conf/distributions
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-10_${ARCH}.deb
+ assertEquals "buster|main|${ARCH}: hello 2.9-10" "$($REPREPRO -b $REPO list buster)"
+ assertEquals "\
+Distribution: buster
+Source: hello
+Version: 2.9-10
+Files:
+ pool/main/h/hello/hello_2.9-10_$ARCH.deb b 1" "$($REPREPRO -b $REPO dumptracks)"
+}
+
+test_reduce_limit_archive() {
+ clear_distro
+ add_distro buster-archive "Limit: 7"
+ add_distro buster "Limit: -1\nArchive: buster-archive"
+ for revision in 1 2; do
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-${revision}_${ARCH}.deb
+ done
+ assertEquals "\
+buster|main|${ARCH}: hello 2.9-2
+buster|main|${ARCH}: hello 2.9-1" "$($REPREPRO -b $REPO list buster)"
+ sed -i 's/^Limit: -1$/Limit: 1/' $REPO/conf/distributions
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-10_${ARCH}.deb
+ assertEquals "\
+hello | 2.9-2 | buster-archive | $ARCH
+hello | 2.9-1 | buster-archive | $ARCH
+hello | 2.9-10 | buster | $ARCH" "$($REPREPRO -b $REPO ls hello)"
+ assertEquals "\
+Distribution: buster-archive
+Source: hello
+Version: 2.9-1
+Files:
+ pool/main/h/hello/hello_2.9-1_$ARCH.deb b 1
+
+Distribution: buster-archive
+Source: hello
+Version: 2.9-2
+Files:
+ pool/main/h/hello/hello_2.9-2_$ARCH.deb b 1
+
+Distribution: buster
+Source: hello
+Version: 2.9-10
+Files:
+ pool/main/h/hello/hello_2.9-10_$ARCH.deb b 1" "$($REPREPRO -b $REPO dumptracks)"
+}
+
+test_limit_old() {
+ for revision in 1 2 10; do
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-${revision}_${ARCH}.deb
+ done
+ assertEquals "\
+buster|main|${ARCH}: hello 2.9-10
+buster|main|${ARCH}: hello 2.9-2
+buster|main|${ARCH}: hello 2.9-1" "$($REPREPRO -b $REPO list buster)"
+ sed -i 's/^Limit: .*$/Limit: 2/' $REPO/conf/distributions
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb buster $PKGS/hello_2.9-2+deb8u1_${ARCH}.deb
+ assertEquals "\
+buster|main|${ARCH}: hello 2.9-10
+buster|main|${ARCH}: hello 2.9-2+deb8u1" "$($REPREPRO -b $REPO list buster)"
+}
+
+test_update_packages() {
+ # Test case for https://github.com/profitbricks/reprepro/issues/6
+ local upstream_repo
+ upstream_repo="${0%/*}/upstreamrepo"
+
+ four_hellos
+ rm -rf "$upstream_repo"
+ mv "$REPO" "$upstream_repo"
+
+ mkdir -p "$REPO/conf"
+ cat > "$REPO/conf/distributions" <<EOF
+Origin: Icinga2
+Label: Icinga2
+Suite: icinga-stretch
+Codename: icinga-stretch
+Description: Icinga2 packages for Debian Stretch
+Architectures: $ARCH
+Components: main
+Update: icinga-stretch
+Log: icinga2.log
+Limit: -1
+EOF
+ cat > "$REPO/conf/updates" <<EOF
+Name: icinga-stretch
+Method: file://$(readlink -f $upstream_repo)
+Suite: buster
+Components: main
+Architectures: $ARCH
+VerifyRelease: blindtrust
+GetInRelease: no
+EOF
+ call $REPREPRO $VERBOSE_ARGS -b $REPO --noskipold update
+ assertEquals "icinga-stretch|main|$ARCH: hello 2.9-10" "$($REPREPRO -b $REPO list icinga-stretch)"
+
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedeb icinga-stretch $PKGS/hello_2.9-2_${ARCH}.deb
+ call $REPREPRO $VERBOSE_ARGS -b $REPO --noskipold update
+ assertEquals "\
+icinga-stretch|main|$ARCH: hello 2.9-10
+icinga-stretch|main|$ARCH: hello 2.9-2" "$($REPREPRO -b $REPO list icinga-stretch)"
+}
+
+test_includedsc_sources() {
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedsc buster $PKGS/hello_2.9-1.dsc
+ call $REPREPRO $VERBOSE_ARGS -b $REPO -C main includedsc buster $PKGS/hello_2.9-2.dsc
+ assertEquals "\
+buster|main|source: hello 2.9-2
+buster|main|source: hello 2.9-1" "$($REPREPRO -b $REPO list buster)"
+
+ call $REPREPRO $VERBOSE_ARGS -b $REPO removesrc buster hello 2.9-1
+ assertEquals "buster|main|source: hello 2.9-2" "$($REPREPRO -b $REPO list buster)"
+}
+
+test_database_upgrade() {
+ # Test case for https://github.com/profitbricks/reprepro/issues/8
+ rm -rf "$REPO"
+ cp -r "${0%/*}/old-database" "$REPO"
+ call $REPREPRO $VERBOSE_ARGS -b $REPO export
+ assertEquals "\
+bullseye|main|amd64
+bullseye|main|i386
+bullseye|main|source
+bullseye|non-free|amd64
+bullseye|non-free|i386
+bullseye|non-free|source" "$(db_dump "$REPO/db/packages.db" | sed -n 's/^database=//p')"
+}
+
+test_move_specific() {
+ four_hellos
+ add_distro bullseye
+ $REPREPRO -b $REPO export bullseye
+ call $REPREPRO $VERBOSE_ARGS -b $REPO move bullseye buster hello=2.9-2
+ assertEquals "\
+buster|main|$ARCH: hello 2.9-10
+buster|main|$ARCH: hello 2.9-2+deb8u1
+buster|main|$ARCH: hello 2.9-1" "$($REPREPRO -b $REPO list buster)"
+ assertEquals "bullseye|main|$ARCH: hello 2.9-2" "$($REPREPRO -b $REPO list bullseye)"
+}
+
+test_movesrc_specific() {
+ four_hellos
+ add_distro bullseye
+ $REPREPRO -b $REPO export bullseye
+ call $REPREPRO $VERBOSE_ARGS -b $REPO movesrc bullseye buster hello 2.9-2
+ assertEquals "\
+buster|main|$ARCH: hello 2.9-10
+buster|main|$ARCH: hello 2.9-2+deb8u1
+buster|main|$ARCH: hello 2.9-1" "$($REPREPRO -b $REPO list buster)"
+ assertEquals "bullseye|main|$ARCH: hello 2.9-2" "$($REPREPRO -b $REPO list bullseye)"
+}
+
+test_movefilter_specific() {
+ four_hellos
+ add_distro bullseye "Limit: -1"
+ $REPREPRO -b $REPO export bullseye
+ call $REPREPRO $VERBOSE_ARGS -b $REPO movefilter bullseye buster 'Package (= hello), $Version (>> 2.9-2)'
+ assertEquals "\
+buster|main|$ARCH: hello 2.9-2
+buster|main|$ARCH: hello 2.9-1" "$($REPREPRO -b $REPO list buster)"
+ assertEquals "\
+bullseye|main|$ARCH: hello 2.9-10
+bullseye|main|$ARCH: hello 2.9-2+deb8u1" "$($REPREPRO -b $REPO list bullseye)"
+}
+
+. shunit2
diff --git a/tests/old-database/conf/distributions b/tests/old-database/conf/distributions
new file mode 100644
index 0000000..80ba858
--- /dev/null
+++ b/tests/old-database/conf/distributions
@@ -0,0 +1,5 @@
+Codename: bullseye
+Architectures: amd64 i386 source
+Components: main non-free
+Log: testrepo.log
+Tracking: all
diff --git a/tests/old-database/db/checksums.db b/tests/old-database/db/checksums.db
new file mode 100644
index 0000000..842fdd1
--- /dev/null
+++ b/tests/old-database/db/checksums.db
Binary files differ
diff --git a/tests/old-database/db/contents.cache.db b/tests/old-database/db/contents.cache.db
new file mode 100644
index 0000000..646a2fd
--- /dev/null
+++ b/tests/old-database/db/contents.cache.db
Binary files differ
diff --git a/tests/old-database/db/packages.db b/tests/old-database/db/packages.db
new file mode 100644
index 0000000..6a7d498
--- /dev/null
+++ b/tests/old-database/db/packages.db
Binary files differ
diff --git a/tests/old-database/db/references.db b/tests/old-database/db/references.db
new file mode 100644
index 0000000..7b8e4f8
--- /dev/null
+++ b/tests/old-database/db/references.db
Binary files differ
diff --git a/tests/old-database/db/release.caches.db b/tests/old-database/db/release.caches.db
new file mode 100644
index 0000000..7958f47
--- /dev/null
+++ b/tests/old-database/db/release.caches.db
Binary files differ
diff --git a/tests/old-database/db/version b/tests/old-database/db/version
new file mode 100644
index 0000000..50d2a22
--- /dev/null
+++ b/tests/old-database/db/version
@@ -0,0 +1,4 @@
+5.2.0
+3.3.0
+bdb5.3.28
+bdb5.3.0
diff --git a/tests/onlysmalldeletes.test b/tests/onlysmalldeletes.test
new file mode 100644
index 0000000..6042eeb
--- /dev/null
+++ b/tests/onlysmalldeletes.test
@@ -0,0 +1,142 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+mkdir conf
+cat >conf/distributions <<EOF
+Codename: test
+Architectures: abacus source
+Components: all
+
+Codename: copy
+Architectures: abacus source
+Components: all
+Pull: rule
+EOF
+touch conf/updates
+cat >conf/pulls <<EOF
+Name: rule
+From: test
+EOF
+cat >conf/incoming <<EOF
+Name: i
+Tempdir: tmp
+Incomingdir: i
+Default: test
+EOF
+cat >conf/options <<EOF
+onlysmalldeletes
+EOF
+
+mkdir i
+cd i
+for i in $(seq 1 40) ; do
+PACKAGE=a$i EPOCH="" VERSION=$i REVISION="" SECTION="many" genpackage.sh
+mv test.changes a$i.changes
+done
+cd ..
+
+cat > pi.rules <<EOF
+stdout
+$(odb)
+-v2*=Created directory "./tmp"
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/all"
+-v2*=Created directory "./pool/all/a"
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/test"
+-v2*=Created directory "./dists/test/all"
+-v2*=Created directory "./dists/test/all/binary-abacus"
+-v6*= looking for changes in 'test|all|abacus'...
+-v6*= creating './dists/test/all/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/test/all/source"
+-v6*= looking for changes in 'test|all|source'...
+-v6*= creating './dists/test/all/source/Sources' (gzipped)
+EOF
+
+for i in $(seq 1 40) ; do
+cat >>pi.rules <<EOF
+-v2*=Created directory "./pool/all/a/a$i"
+$(ofa "pool/all/a/a${i}/a${i}_${i}.dsc")
+$(ofa "pool/all/a/a${i}/a${i}_${i}.tar.gz")
+$(ofa "pool/all/a/a${i}/a${i}_${i}_abacus.deb")
+$(ofa "pool/all/a/a${i}/a${i}-addons_${i}_all.deb")
+$(opa "a${i}" unset 'test' 'all' 'source' 'dsc')
+$(opa "a${i}" x 'test' 'all' 'abacus' 'deb')
+$(opa "a${i}-addons" x 'test' 'all' 'abacus' 'deb')
+-v1*=deleting './i/a${i}.changes'...
+-v1*=deleting './i/a${i}_${i}.dsc'...
+-v1*=deleting './i/a${i}_${i}.tar.gz'...
+-v1*=deleting './i/a${i}_${i}_abacus.deb'...
+-v1*=deleting './i/a${i}-addons_${i}_all.deb'...
+EOF
+done
+
+testrun pi -b . processincoming i
+dodo rmdir i
+rm pi.rules
+
+cat >pull.rules <<EOF
+stdout
+-v0*=Calculating packages to pull...
+-v3*= pulling into 'copy|all|source'
+-v5*= looking what to get from 'test|all|source'
+-v3*= pulling into 'copy|all|abacus'
+-v5*= looking what to get from 'test|all|abacus'
+-v0*=Installing (and possibly deleting) packages...
+-v0*=Exporting indices...
+-v2*=Created directory "./dists/copy"
+-v2*=Created directory "./dists/copy/all"
+-v2*=Created directory "./dists/copy/all/binary-abacus"
+-v6*= looking for changes in 'copy|all|abacus'...
+-v6*= creating './dists/copy/all/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/copy/all/source"
+-v6*= looking for changes in 'copy|all|source'...
+-v6*= creating './dists/copy/all/source/Sources' (gzipped)
+EOF
+
+for i in $(seq 1 40) ; do
+cat >>pull.rules <<EOF
+$(opa "a${i}" unset 'copy' 'all' 'source' 'dsc')
+$(opa "a${i}" x 'copy' 'all' 'abacus' 'deb')
+$(opa "a${i}-addons" x 'copy' 'all' 'abacus' 'deb')
+EOF
+done
+
+testrun pull -b . pull
+rm pull.rules
+
+sed -e 's/Pull: rule/Pull: -/' -i conf/distributions
+
+testrun - -b . pull 3<<EOF
+stdout
+-v0*=Calculating packages to pull...
+-v3*= pulling into 'copy|all|source'
+-v5*= marking everything to be deleted
+-v3*= pulling into 'copy|all|abacus'
+#-v5*= marking everything to be deleted
+-v0*=Installing (and possibly deleting) packages...
+stderr
+*=Not processing 'copy' because of --onlysmalldeletes
+EOF
+
+sed -e 's/Pull: -/Update: -/' -i conf/distributions
+testrun - -b . --noskipold update 3<<EOF
+stdout
+-v2*=Created directory "./lists"
+-v0*=Calculating packages to get...
+-v3*= processing updates for 'copy|all|source'
+-v5*= marking everything to be deleted
+-v3*= processing updates for 'copy|all|abacus'
+#-v5*= marking everything to be deleted
+stderr
+*=Not processing updates for 'copy' because of --onlysmalldeletes!
+EOF
+
+rm -r conf
+rm -r db
+rm -r pool
+rm -r dists
+rmdir tmp
+rmdir lists
+testsuccess
diff --git a/tests/override.test b/tests/override.test
new file mode 100644
index 0000000..84e8634
--- /dev/null
+++ b/tests/override.test
@@ -0,0 +1,172 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+mkdir -p conf dists/c/main/source
+mkdir -p conf dists/d/main/source
+mkdir -p conf dists/c/main/binary-abacus
+mkdir -p conf dists/d/main/binary-abacus
+mkdir -p conf dists/c/component/source
+mkdir -p conf dists/d/component/source
+mkdir -p conf dists/c/component/binary-abacus
+mkdir -p conf dists/d/component/binary-abacus
+mkdir -p dists/c/main/source
+mkdir -p dists/d/main/source
+mkdir -p dists/c/main/binary-abacus
+mkdir -p dists/d/main/binary-abacus
+mkdir -p pool/main/a/aa pool/component/b/bb
+mkdir -p pool/component/a/aa pool/main/b/bb
+cat > conf/distributions <<EOF
+Codename: c
+Components: main component
+Architectures: abacus source
+# Don't do that at home, kids....
+DebIndices: Index .
+DscIndices: Index .
+DebOverride: override-c-deb
+DscOverride: override-c-dsc
+
+Codename: d
+Components: main component
+Architectures: abacus source
+# Don't do that at home, kids....
+DebIndices: Index .
+DscIndices: Index .
+DebOverride: override-d-deb
+DscOverride: override-d-dsc
+EOF
+cat > conf/override-c-deb <<EOF
+EOF
+cat > conf/override-c-dsc <<EOF
+EOF
+cat > conf/override-d-deb <<EOF
+aa Section component/section
+aa Somefield value
+aa-addons Section component/addons
+a* ShouldNot ShowUp
+bb Section base
+bb-addons Section addons
+b* Section blub
+EOF
+cat > conf/override-d-dsc <<EOF
+a* Section component/section
+b? Section base
+b? SomeOtherfield somevalue
+b* ShouldNot ShowUp
+EOF
+
+DISTRI=c PACKAGE=aa EPOCH="" VERSION=1 REVISION="-1" SECTION="section" genpackage.sh
+mv test.changes aa.changes
+DISTRI=c PACKAGE=bb EPOCH="" VERSION=1 REVISION="-1" SECTION="component/base" genpackage.sh
+mv test.changes bb.changes
+
+testrun - --nodelete include c aa.changes 3<<EOF
+stdout
+$(odb)
+$(ofa 'pool/main/a/aa/aa-addons_1-1_all.deb')
+$(ofa 'pool/main/a/aa/aa_1-1_abacus.deb')
+$(ofa 'pool/main/a/aa/aa_1-1.tar.gz')
+$(ofa 'pool/main/a/aa/aa_1-1.dsc')
+$(opa 'aa-addons' x 'c' 'main' 'abacus' 'deb')
+$(opa 'aa' x 'c' 'main' 'abacus' 'deb')
+$(opa 'aa' unset 'c' 'main' 'source' 'dsc')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'c|main|abacus'...
+-v6*= creating './dists/c/main/binary-abacus/Index' (uncompressed)
+-v6*= looking for changes in 'c|component|abacus'...
+-v6*= creating './dists/c/component/binary-abacus/Index' (uncompressed)
+-v6*= looking for changes in 'c|main|source'...
+-v6*= creating './dists/c/main/source/Index' (uncompressed)
+-v6*= looking for changes in 'c|component|source'...
+-v6*= creating './dists/c/component/source/Index' (uncompressed)
+EOF
+testrun - --nodelete include c bb.changes 3<<EOF
+stdout
+$(ofa 'pool/component/b/bb/bb-addons_1-1_all.deb')
+$(ofa 'pool/component/b/bb/bb_1-1_abacus.deb')
+$(ofa 'pool/component/b/bb/bb_1-1.tar.gz')
+$(ofa 'pool/component/b/bb/bb_1-1.dsc')
+$(opa 'bb-addons' x 'c' 'component' 'abacus' 'deb')
+$(opa 'bb' x 'c' 'component' 'abacus' 'deb')
+$(opa 'bb' unset 'c' 'component' 'source' 'dsc')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'c|main|abacus'...
+-v6*= looking for changes in 'c|component|abacus'...
+-v6*= replacing './dists/c/component/binary-abacus/Index' (uncompressed)
+-v6*= looking for changes in 'c|main|source'...
+-v6*= looking for changes in 'c|component|source'...
+-v6*= replacing './dists/c/component/source/Index' (uncompressed)
+EOF
+ed -s aa.changes <<EOF
+g/^Distribution/s/ c/ d/
+w
+q
+EOF
+ed -s bb.changes <<EOF
+g/^Distribution/s/ c/ d/
+w
+q
+EOF
+testrun - --nodelete include d aa.changes 3<<EOF
+stdout
+$(ofa 'pool/component/a/aa/aa-addons_1-1_all.deb')
+$(ofa 'pool/component/a/aa/aa_1-1_abacus.deb')
+$(ofa 'pool/component/a/aa/aa_1-1.tar.gz')
+$(ofa 'pool/component/a/aa/aa_1-1.dsc')
+$(opa 'aa-addons' x 'd' 'component' 'abacus' 'deb')
+$(opa 'aa' x 'd' 'component' 'abacus' 'deb')
+$(opa 'aa' unset 'd' 'component' 'source' 'dsc')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'd|component|abacus'...
+-v6*= creating './dists/d/component/binary-abacus/Index' (uncompressed)
+-v6*= looking for changes in 'd|main|abacus'...
+-v6*= creating './dists/d/main/binary-abacus/Index' (uncompressed)
+-v6*= looking for changes in 'd|component|source'...
+-v6*= creating './dists/d/component/source/Index' (uncompressed)
+-v6*= looking for changes in 'd|main|source'...
+-v6*= creating './dists/d/main/source/Index' (uncompressed)
+EOF
+testrun - --nodelete include d bb.changes 3<<EOF
+stdout
+$(ofa 'pool/main/b/bb/bb-addons_1-1_all.deb')
+$(ofa 'pool/main/b/bb/bb_1-1_abacus.deb')
+$(ofa 'pool/main/b/bb/bb_1-1.tar.gz')
+$(ofa 'pool/main/b/bb/bb_1-1.dsc')
+$(opa 'bb-addons' x 'd' 'main' 'abacus' 'deb')
+$(opa 'bb' x 'd' 'main' 'abacus' 'deb')
+$(opa 'bb' unset 'd' 'main' 'source' 'dsc')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'd|component|abacus'...
+-v6*= looking for changes in 'd|main|abacus'...
+-v6*= replacing './dists/d/main/binary-abacus/Index' (uncompressed)
+-v6*= looking for changes in 'd|component|source'...
+-v6*= looking for changes in 'd|main|source'...
+-v6*= replacing './dists/d/main/source/Index' (uncompressed)
+EOF
+
+cp dists/c/main/binary-abacus/Index Index.expected
+ed -s Index.expected <<EOF
+/^Priority:/i
+Somefield: value
+.
+g/Section/s#section#component/addons#
+/Section/s#addons#section#
+%s/main/component/
+w
+EOF
+dodiff Index.expected dists/d/component/binary-abacus/Index
+
+cp dists/c/component/source/Index Index.expected
+ed -s Index.expected <<EOF
+/^Priority:/i
+SomeOtherfield: somevalue
+.
+g/Section/s#component/base#base#
+g/Directory/s/component/main/
+w
+EOF
+dodiff Index.expected dists/d/main/source/Index
+
+
+dodo rm -r aa* bb* pool dists db conf
+
+testsuccess
diff --git a/tests/packagediff.test b/tests/packagediff.test
new file mode 100644
index 0000000..c726bea
--- /dev/null
+++ b/tests/packagediff.test
@@ -0,0 +1,287 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+mkdir conf db pool fakes old
+mkdir -p dists/sourcedistribution/main/binary-coal
+
+cp "$SRCDIR/docs/pdiff.example" conf/pdiff.py
+cat > conf/distributions <<EOF
+Codename: sourcedistribution
+Architectures: coal
+Components: main
+DebIndices: Packages Release . pdiff.py
+
+Codename: test
+Architectures: coal
+Components: main
+Update: fromsource
+EOF
+
+testrun - -b . export sourcedistribution 3<<EOF
+stdout
+-v1*=Exporting sourcedistribution...
+-v6*= exporting 'sourcedistribution|main|coal'...
+-v6*= creating './dists/sourcedistribution/main/binary-coal/Packages' (uncompressed,script: pdiff.py)
+EOF
+
+dodo test -f dists/sourcedistribution/main/binary-coal/Packages
+dodo test -f dists/sourcedistribution/main/binary-coal/Release
+dodo test \! -e dists/sourcedistribution/main/binary-coal/Packages.diff
+
+testrun - -b . _addpackage sourcedistribution fakes/1 a 3<<EOF
+stderr
+*=_addpackage needs -C and -A and -T set!
+-v0*=There have been errors!
+returns 255
+EOF
+
+testrun - -b . -C main -A coal -T deb _addpackage sourcedistribution fakes/1 a 3<<EOF
+stderr
+*=Error 2 opening 'fakes/1': No such file or directory!
+-v0*=There have been errors!
+return 254
+EOF
+
+touch fakes/1
+
+# TODO: getting a warning here would be nice...
+testrun - -b . -C main -A coal -T deb _addpackage sourcedistribution fakes/1 a 3<<EOF
+EOF
+testrun - --nothingiserror -b . -C main -A coal -T deb _addpackage sourcedistribution fakes/1 a 3<<EOF
+returns 1
+EOF
+
+cat > fakes/1 <<EOF
+Package: 5dchess
+Priority: extra
+Section: games
+Installed-Size: 400000
+Maintainer: test <nobody@nowhere>
+Architecture: coal
+Version: 0.0-1
+Filename: pool/main/5/5dchess/5dchess_0.0-1_coal.deb
+MD5sum: $EMPTYMD5ONLY
+Size: 0
+Description: the lazy fox
+ jumps over the quick brown dog.
+
+Package: a
+Priority: critical
+Section: required
+Installed-Size: 1
+Maintainer: test <nobody@nowhere>
+Architecture: all
+Version: 1
+Filename: pool/main/a/a/a_1_all.deb
+MD5sum: $EMPTYMD5ONLY
+Size: 0
+Description: the lazy fox
+ jumps over the quick brown dog.
+
+Package: b
+Source: baa
+Priority: critical
+Section: required
+Installed-Size: 1
+Maintainer: test <nobody@nowhere>
+Architecture: coal
+Version: 2
+Filename: pool/main/b/baa/b_2_coal.deb
+MD5sum: $EMPTYMD5ONLY
+Size: 0
+Description: the lazy fox
+ jumps over the quick brown dog.
+EOF
+
+cat > fakes/2 <<EOF
+Package: a
+Priority: critical
+Section: required
+Installed-Size: 2
+Maintainer: test <nobody@nowhere>
+Architecture: all
+Version: 2
+Filename: pool/main/a/a/a_2_all.deb
+MD5sum: $EMPTYMD5ONLY
+Size: 0
+Description: the lazy fox
+ jumps over the quick brown dog.
+EOF
+
+testrun - -b . -C main -A coal -T deb _addpackage sourcedistribution fakes/1 a 3<<EOF
+*=Error: package a version 1 lists file pool/main/a/a/a_1_all.deb not yet in the pool!
+-v0*=There have been errors!
+returns 249
+EOF
+
+cat > addchecksums.rules <<EOF
+stdout
+$(ofa 'pool/main/a/a/a_1_all.deb')
+$(ofa 'pool/main/a/a/a_2_all.deb')
+$(ofa 'pool/main/b/baa/b_2_coal.deb')
+$(ofa 'pool/main/5/5dchess/5dchess_0.0-1_coal.deb')
+-v0*=4 files were added but not used.
+-v0*=The next deleteunreferenced call will delete them.
+EOF
+
+testrun addchecksums -b . _addchecksums <<EOF
+pool/main/b/baa/b_2_coal.deb $EMPTYMD5
+pool/main/a/a/a_1_all.deb $EMPTYMD5
+pool/main/a/a/a_2_all.deb $EMPTYMD5
+pool/main/5/5dchess/5dchess_0.0-1_coal.deb $EMPTYMD5
+EOF
+
+testrun - -b . -C main -A coal -T deb _addpackage sourcedistribution fakes/1 a 3<<EOF
+stdout
+-v1*=Adding 'a' '1' to 'sourcedistribution|main|coal'.
+$(opa 'a' x 'sourcedistribution' 'main' 'coal' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'sourcedistribution|main|coal'...
+-v6*= replacing './dists/sourcedistribution/main/binary-coal/Packages' (uncompressed,script: pdiff.py)
+=making diffs between ./dists/sourcedistribution/main/binary-coal/Packages and ./dists/sourcedistribution/main/binary-coal/Packages.new:
+=generating diff
+EOF
+sleep 1
+testrun - -b . -C main -A coal -T deb _addpackage sourcedistribution fakes/1 5dchess 3<<EOF
+stdout
+-v1*=Adding '5dchess' '0.0-1' to 'sourcedistribution|main|coal'.
+$(opa '5dchess' x 'sourcedistribution' 'main' 'coal' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'sourcedistribution|main|coal'...
+-v6*= replacing './dists/sourcedistribution/main/binary-coal/Packages' (uncompressed,script: pdiff.py)
+=making diffs between ./dists/sourcedistribution/main/binary-coal/Packages and ./dists/sourcedistribution/main/binary-coal/Packages.new:
+=generating diff
+=This was too fast, diffile already there, waiting a bit...
+EOF
+sleep 1
+cp dists/sourcedistribution/main/binary-coal/Packages old/1
+testrun - -b . -C main -A coal -T deb _addpackage sourcedistribution fakes/2 a 3<<EOF
+stderr
+*=./pool/main/a/a/a_1_all.deb not found, forgetting anyway
+stdout
+-v1*=Adding 'a' '2' to 'sourcedistribution|main|coal'.
+$(opu 'a' x x 'sourcedistribution' 'main' 'coal' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'sourcedistribution|main|coal'...
+-v6*= replacing './dists/sourcedistribution/main/binary-coal/Packages' (uncompressed,script: pdiff.py)
+=making diffs between ./dists/sourcedistribution/main/binary-coal/Packages and ./dists/sourcedistribution/main/binary-coal/Packages.new:
+=generating diff
+=This was too fast, diffile already there, waiting a bit...
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/main/a/a/a_1_all.deb')
+EOF
+cp dists/sourcedistribution/main/binary-coal/Packages old/2
+sleep 1
+testrun - -b . -C main -A coal -T deb _addpackage sourcedistribution fakes/1 b 3<<EOF
+stdout
+-v1*=Adding 'b' '2' to 'sourcedistribution|main|coal'.
+$(opa 'b' x 'sourcedistribution' 'main' 'coal' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'sourcedistribution|main|coal'...
+-v6*= replacing './dists/sourcedistribution/main/binary-coal/Packages' (uncompressed,script: pdiff.py)
+=making diffs between ./dists/sourcedistribution/main/binary-coal/Packages and ./dists/sourcedistribution/main/binary-coal/Packages.new:
+=generating diff
+=This was too fast, diffile already there, waiting a bit...
+EOF
+
+dodo test -f dists/sourcedistribution/main/binary-coal/Packages
+dodo test -f dists/sourcedistribution/main/binary-coal/Release
+dodo test -d dists/sourcedistribution/main/binary-coal/Packages.diff
+dodo test -f dists/sourcedistribution/main/binary-coal/Packages.diff/Index
+testrun empty -b . dumpunreferenced
+
+# now update from that one....
+cat > conf/updates <<EOF
+Name: fromsource
+Suite: sourcedistribution
+VerifyRelease: blindtrust
+GetInRelease: no
+DownloadListsAs: .diff
+Method: file:$WORKDIR
+EOF
+mkdir lists
+mkdir -p dists/test/main/binary-coal
+
+cp old/2 lists/fromsource_sourcedistribution_main_coal_Packages
+
+diffname="$(grep "^ $(sha1 old/2)" dists/sourcedistribution/main/binary-coal/Packages.diff/Index | sed -e 's/.* //')"
+
+testrun - -b . update test 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/Release'
+-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/Release'
+-v2*=Copy file '$WORKDIR/dists/sourcedistribution/Release' to './lists/fromsource_sourcedistribution_Release'...
+-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/Index'
+-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/Index'
+-v2*=Copy file '$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/Index' to './lists/fromsource_sourcedistribution_main_coal_Packages.diffindex'...
+-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname}.gz'
+-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname}.gz'
+-v2*=Uncompress '$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname}.gz' into './lists/fromsource_sourcedistribution_main_coal_Packages.diff-${diffname}' using '/bin/gunzip'...
+stdout
+-v0*=Calculating packages to get...
+-v3*= processing updates for 'test|main|coal'
+-v5*= reading './lists/fromsource_sourcedistribution_main_coal_Packages'
+-v0*=Getting packages...
+-v1*=Shutting down aptmethods...
+-v0*=Installing (and possibly deleting) packages...
+$(opa '5dchess' x 'test' 'main' 'coal' 'deb')
+$(opa 'a' x 'test' 'main' 'coal' 'deb')
+$(opa 'b' x 'test' 'main' 'coal' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test|main|coal'...
+-v6*= creating './dists/test/main/binary-coal/Packages' (uncompressed,gzipped)
+EOF
+
+dodiff dists/sourcedistribution/main/binary-coal/Packages lists/fromsource_sourcedistribution_main_coal_Packages
+
+cp old/1 lists/fromsource_sourcedistribution_main_coal_Packages
+
+diffname2="$(grep "^ $(sha1 old/1)" dists/sourcedistribution/main/binary-coal/Packages.diff/Index | sed -e 's/.* //')"
+testrun - --noskipold -b . update test 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/Release'
+-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/Release'
+-v2*=Copy file '$WORKDIR/dists/sourcedistribution/Release' to './lists/fromsource_sourcedistribution_Release'...
+-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/Index'
+-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/Index'
+-v2*=Copy file '$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/Index' to './lists/fromsource_sourcedistribution_main_coal_Packages.diffindex'...
+-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname2}.gz'
+-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname2}.gz'
+-v2*=Uncompress '$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname2}.gz' into './lists/fromsource_sourcedistribution_main_coal_Packages.diff-${diffname2}' using '/bin/gunzip'...
+-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname}.gz'
+-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname}.gz'
+-v2*=Uncompress '$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages.diff/${diffname}.gz' into './lists/fromsource_sourcedistribution_main_coal_Packages.diff-${diffname}' using '/bin/gunzip'...
+stdout
+-v0*=Calculating packages to get...
+-v3*= processing updates for 'test|main|coal'
+-v5*= reading './lists/fromsource_sourcedistribution_main_coal_Packages'
+EOF
+
+dodiff dists/sourcedistribution/main/binary-coal/Packages lists/fromsource_sourcedistribution_main_coal_Packages
+
+# Check without DownLoadListsAs and not index file
+cat > conf/updates <<EOF
+Name: fromsource
+Suite: sourcedistribution
+GetInRelease: no
+VerifyRelease: blindtrust
+Method: file:$WORKDIR
+EOF
+rm -r lists
+mkdir lists
+testrun - --noskipold -b . update test 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/Release'
+-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/Release'
+-v2*=Copy file '$WORKDIR/dists/sourcedistribution/Release' to './lists/fromsource_sourcedistribution_Release'...
+-v6=aptmethod start 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages'
+-v1*=aptmethod got 'file:$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages'
+-v2*=Copy file '$WORKDIR/dists/sourcedistribution/main/binary-coal/Packages' to './lists/fromsource_sourcedistribution_main_coal_Packages'...
+stdout
+-v0*=Calculating packages to get...
+-v3*= processing updates for 'test|main|coal'
+-v5*= reading './lists/fromsource_sourcedistribution_main_coal_Packages'
+EOF
+
+rm -r conf dists pool db fakes addchecksums.rules old lists
+testsuccess
diff --git a/tests/revoked.key b/tests/revoked.key
new file mode 100644
index 0000000..841536b
--- /dev/null
+++ b/tests/revoked.key
Binary files differ
diff --git a/tests/revoked.pkey b/tests/revoked.pkey
new file mode 100644
index 0000000..2941473
--- /dev/null
+++ b/tests/revoked.pkey
Binary files differ
diff --git a/tests/shunit2-helper-functions.sh b/tests/shunit2-helper-functions.sh
new file mode 100644
index 0000000..8f664b8
--- /dev/null
+++ b/tests/shunit2-helper-functions.sh
@@ -0,0 +1,68 @@
+# Copyright (C) 2017, Benjamin Drung <benjamin.drung@profitbricks.com>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+REPO="${0%/*}/testrepo"
+PKGS="${0%/*}/testpkgs"
+ARCH=${ARCH:-$(dpkg-architecture -qDEB_HOST_ARCH)}
+REPREPRO=$(realpath -m "${0%/*}/.." --relative-base=.)/reprepro
+VERBOSE_ARGS="${VERBOSE_ARGS-}"
+
+call() {
+ command="$@"
+ echo "I: Calling $@"
+ "$@" || fail "Command '$command' failed with exit code $?."
+}
+
+check_db() {
+ db_verify $REPO/db/packages.db || fail "BerkeleyDB 'packages.db' is broken."
+ db_verify -o $REPO/db/packagenames.db || fail "BerkeleyDB 'packagenames.db' is broken."
+}
+
+add_distro() {
+ local name="$1"
+ if test -e $REPO/conf/distributions; then
+ echo >> $REPO/conf/distributions
+ fi
+ cat >> $REPO/conf/distributions <<EOF
+Codename: $name
+Architectures: $ARCH source
+Components: main non-free
+Log: testrepo.log
+Tracking: all
+EOF
+ if test -n "${2-}"; then
+ echo "$2" >> $REPO/conf/distributions
+ fi
+}
+
+clear_distro() {
+ rm -f $REPO/conf/distributions
+}
+
+create_repo() {
+ rm -rf $REPO
+ mkdir -p $REPO/conf
+ add_distro buster
+ mkdir -p $PKGS
+ $REPREPRO -b $REPO export
+}
+
+# See https://github.com/wting/shunit2/issues/23
+if test -n "${TEST_CASES-}"; then
+ suite() {
+ for testcase in "${TEST_CASES}" ; do
+ suite_addTest $testcase
+ done
+ }
+fi
diff --git a/tests/signatures.test b/tests/signatures.test
new file mode 100644
index 0000000..bca35ff
--- /dev/null
+++ b/tests/signatures.test
@@ -0,0 +1,286 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+if ! which gpg 2>/dev/null ; then
+ echo "SKIPPED: gpg not found!"
+ exit 0
+fi
+
+rm -rf db dists pool lists conf gpgtestdir
+
+mkdir -p gpgtestdir
+export GNUPGHOME="`pwd`/gpgtestdir"
+gpg --import $TESTSDIR/good.key $TESTSDIR/evil.key $TESTSDIR/expired.key $TESTSDIR/revoked.key
+
+mkdir -p conf
+cat > conf/options <<CONFEND
+export changed
+CONFEND
+cat > conf/distributions <<CONFEND
+Codename: ATest
+Uploaders: auploaders
+Architectures: abacus source
+Components: everything
+
+Codename: BTest
+Uploaders: buploaders
+Architectures: abacus source
+Components: everything
+
+Codename: CTest
+Uploaders: cuploaders
+Architectures: abacus source
+Components: everything
+CONFEND
+
+gpg --list-keys
+
+cat > conf/auploaders <<CONFEND
+# Nothing is allowed in here
+CONFEND
+cat > conf/buploaders <<CONFEND
+allow * by key FFFFFFFF
+allow * by key DC3C29B8
+allow * by key 685AF714
+allow * by key 00000000
+CONFEND
+cat > conf/cuploaders <<CONFEND
+allow * by key FFFFFFFF
+allow * by any key
+allow * by unsigned
+allow * by key 00000000
+allow * by anybody
+CONFEND
+cat > conf/incoming <<CONFEND
+Name: abc
+Incomingdir: i
+TempDir: tmp
+Allow: ATest BTest CTest
+
+Name: ab
+Incomingdir: i
+TempDir: tmp
+Allow: ATest BTest
+CONFEND
+mkdir i tmp
+
+DISTRI="ATest BTest CTest" PACKAGE=package EPOCH="" VERSION=9 REVISION="-2" SECTION="otherofs" genpackage.sh
+echo generating signature with evil key:
+gpg --default-key evil@nowhere.tld --sign -a test.changes
+mv test.changes.asc testbadsigned.changes
+echo generating signature with good key:
+gpg --default-key good@nowhere.tld --sign -a test.changes
+mv test.changes.asc testsigned.changes
+echo generating signature with revoked key:
+gpg --expert --default-key revoked@nowhere.tld --sign -a test.changes
+mv test.changes.asc testrevsigned.changes
+gpg --import $TESTSDIR/revoked.pkey
+
+
+testrun - -b . include ATest test.changes 3<<EOF
+return 255
+stderr
+*=No rule allowing this package in found in auploaders!
+*=To ignore use --ignore=uploaders.
+-v0*=There have been errors!
+stdout
+$(odb)
+EOF
+
+testrun - -b . include BTest test.changes 3<<EOF
+return 255
+stderr
+*=No rule allowing this package in found in buploaders!
+*=To ignore use --ignore=uploaders.
+-v0*=There have been errors!
+stdout
+EOF
+
+testrun - -b . include CTest test.changes 3<<EOF
+stdout
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/everything"
+-v2*=Created directory "./pool/everything/p"
+-v2*=Created directory "./pool/everything/p/package"
+$(ofa 'pool/everything/p/package/package-addons_9-2_all.deb')
+$(ofa 'pool/everything/p/package/package_9-2_abacus.deb')
+$(ofa 'pool/everything/p/package/package_9-2.tar.gz')
+$(ofa 'pool/everything/p/package/package_9-2.dsc')
+$(opa 'package-addons' x 'CTest' 'everything' 'abacus' 'deb')
+$(opa 'package' x 'CTest' 'everything' 'abacus' 'deb')
+$(opa 'package' unset 'CTest' 'everything' 'source' 'dsc')
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/CTest"
+-v2*=Created directory "./dists/CTest/everything"
+-v2*=Created directory "./dists/CTest/everything/binary-abacus"
+-v6*= looking for changes in 'CTest|everything|abacus'...
+-v6*= creating './dists/CTest/everything/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/CTest/everything/source"
+-v6*= looking for changes in 'CTest|everything|source'...
+-v6*= creating './dists/CTest/everything/source/Sources' (gzipped)
+EOF
+
+testrun - -b . include ATest testbadsigned.changes 3<<EOF
+return 255
+stderr
+*=No rule allowing this package in found in auploaders!
+*=To ignore use --ignore=uploaders.
+-v0*=There have been errors!
+stdout
+EOF
+
+testrun - -b . include BTest testbadsigned.changes 3<<EOF
+return 255
+stderr
+*=No rule allowing this package in found in buploaders!
+*=To ignore use --ignore=uploaders.
+-v0*=There have been errors!
+stdout
+EOF
+
+testrun - -b . include CTest testbadsigned.changes 3<<EOF
+stderr
+*=Skipping inclusion of 'package-addons' '9-2' in 'CTest|everything|abacus', as it has already '9-2'.
+*=Skipping inclusion of 'package' '9-2' in 'CTest|everything|abacus', as it has already '9-2'.
+*=Skipping inclusion of 'package' '9-2' in 'CTest|everything|source', as it has already '9-2'.
+stdout
+EOF
+
+testrun - -b . include ATest testrevsigned.changes 3<<EOF
+return 255
+stderr
+-v1*=Ignoring signature with '12D6C95C8C737389EAAF535972F1D61F685AF714' on 'testrevsigned.changes', as the key is revoked.
+*=No rule allowing this package in found in auploaders!
+*=To ignore use --ignore=uploaders.
+-v0*=There have been errors!
+stdout
+EOF
+
+testrun - -b . include BTest testrevsigned.changes 3<<EOF
+return 255
+stderr
+-v1*=Ignoring signature with '12D6C95C8C737389EAAF535972F1D61F685AF714' on 'testrevsigned.changes', as the key is revoked.
+*=No rule allowing this package in found in buploaders!
+*=To ignore use --ignore=uploaders.
+-v0*=There have been errors!
+stdout
+EOF
+
+testrun - -b . include CTest testrevsigned.changes 3<<EOF
+stderr
+-v1*=Ignoring signature with '12D6C95C8C737389EAAF535972F1D61F685AF714' on 'testrevsigned.changes', as the key is revoked.
+*=Skipping inclusion of 'package-addons' '9-2' in 'CTest|everything|abacus', as it has already '9-2'.
+*=Skipping inclusion of 'package' '9-2' in 'CTest|everything|abacus', as it has already '9-2'.
+*=Skipping inclusion of 'package' '9-2' in 'CTest|everything|source', as it has already '9-2'.
+stdout
+EOF
+
+testrun - -b . include ATest testsigned.changes 3<<EOF
+return 255
+stderr
+*=No rule allowing this package in found in auploaders!
+*=To ignore use --ignore=uploaders.
+-v0*=There have been errors!
+stdout
+EOF
+
+testrun - -b . include BTest testsigned.changes 3<<EOF
+stdout
+$(opa 'package-addons' x 'BTest' 'everything' 'abacus' 'deb')
+$(opa 'package' x 'BTest' 'everything' 'abacus' 'deb')
+$(opa 'package' unset 'BTest' 'everything' 'source' 'dsc')
+-v0*=Exporting indices...
+-v2*=Created directory "./dists/BTest"
+-v2*=Created directory "./dists/BTest/everything"
+-v2*=Created directory "./dists/BTest/everything/binary-abacus"
+-v6*= looking for changes in 'BTest|everything|abacus'...
+-v6*= creating './dists/BTest/everything/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/BTest/everything/source"
+-v6*= looking for changes in 'BTest|everything|source'...
+-v6*= creating './dists/BTest/everything/source/Sources' (gzipped)
+EOF
+
+testrun - -b . include CTest testsigned.changes 3<<EOF
+stderr
+*=Skipping inclusion of 'package-addons' '9-2' in 'CTest|everything|abacus', as it has already '9-2'.
+*=Skipping inclusion of 'package' '9-2' in 'CTest|everything|abacus', as it has already '9-2'.
+*=Skipping inclusion of 'package' '9-2' in 'CTest|everything|source', as it has already '9-2'.
+stdout
+EOF
+
+cp package* i/
+cp test.changes i/
+testrun - -b . processincoming ab 3<<EOF
+return 243
+stderr
+*=No distribution accepting 'test.changes' (i.e. none of the candidate distributions allowed inclusion)!
+-v0*=There have been errors!
+stdout
+EOF
+testrun - -b . processincoming abc 3<<EOF
+stdout
+-v3*=Will not put 'package' in 'CTest|everything|source', as already there with same version '9-2'.
+-v3*=Will not put 'package' in 'CTest|everything|abacus', as already there with same version '9-2'.
+-v3*=Will not put 'package-addons' in 'CTest|everything|abacus', as already there with same version '9-2'.
+-v0*=Skipping test.changes because all packages are skipped!
+-v3*=deleting './i/package_9-2.dsc'...
+-v3*=deleting './i/package-addons_9-2_all.deb'...
+-v3*=deleting './i/package_9-2.tar.gz'...
+-v3*=deleting './i/package_9-2_abacus.deb'...
+-v3*=deleting './i/test.changes'...
+EOF
+
+cp -i package* i/
+cp testrevsigned.changes i/
+testrun - -b . processincoming ab 3<<EOF
+return 243
+stderr
+*=No distribution accepting 'testrevsigned.changes' (i.e. none of the candidate distributions allowed inclusion)!
+-v0*=There have been errors!
+-v1*=Ignoring signature with '12D6C95C8C737389EAAF535972F1D61F685AF714' on 'testrevsigned.changes', as the key is revoked.
+#-v0*='testrevsigned.changes' would have been accepted into 'BTest' if signature with '12D6C95C8C737389EAAF535972F1D61F685AF714' was checkable and valid.
+stdout
+EOF
+testrun - -b . processincoming abc 3<<EOF
+stderr
+-v1*=Ignoring signature with '12D6C95C8C737389EAAF535972F1D61F685AF714' on 'testrevsigned.changes', as the key is revoked.
+#-v0*='testrevsigned.changes' would have been accepted into 'BTest' if signature with '12D6C95C8C737389EAAF535972F1D61F685AF714' was checkable and valid.
+stdout
+-v3*=Will not put 'package' in 'CTest|everything|source', as already there with same version '9-2'.
+-v3*=Will not put 'package' in 'CTest|everything|abacus', as already there with same version '9-2'.
+-v3*=Will not put 'package-addons' in 'CTest|everything|abacus', as already there with same version '9-2'.
+-v0*=Skipping testrevsigned.changes because all packages are skipped!
+-v3*=deleting './i/package_9-2.dsc'...
+-v3*=deleting './i/package-addons_9-2_all.deb'...
+-v3*=deleting './i/package_9-2.tar.gz'...
+-v3*=deleting './i/package_9-2_abacus.deb'...
+-v3*=deleting './i/testrevsigned.changes'...
+EOF
+
+cp -i package* i/
+cp testbadsigned.changes i/
+testrun - -b . processincoming ab 3<<EOF
+return 243
+stderr
+*=No distribution accepting 'testbadsigned.changes' (i.e. some distribution found but the package is not allowed there)!
+-v0*=There have been errors!
+stdout
+EOF
+testrun - -b . processincoming abc 3<<EOF
+stdout
+-v3*=Will not put 'package' in 'CTest|everything|source', as already there with same version '9-2'.
+-v3*=Will not put 'package' in 'CTest|everything|abacus', as already there with same version '9-2'.
+-v3*=Will not put 'package-addons' in 'CTest|everything|abacus', as already there with same version '9-2'.
+-v0*=Skipping testbadsigned.changes because all packages are skipped!
+-v3*=deleting './i/package_9-2.dsc'...
+-v3*=deleting './i/package-addons_9-2_all.deb'...
+-v3*=deleting './i/package_9-2.tar.gz'...
+-v3*=deleting './i/package_9-2_abacus.deb'...
+-v3*=deleting './i/testbadsigned.changes'...
+EOF
+
+rm -rf db conf dists pool gpgtestdir i tmp
+rm package-addons* package_* *.changes
+
+testsuccess
diff --git a/tests/signed.test b/tests/signed.test
new file mode 100644
index 0000000..8e7dba8
--- /dev/null
+++ b/tests/signed.test
@@ -0,0 +1,68 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+mkdir -p gpgtestdir
+export GNUPGHOME="`pwd`/gpgtestdir"
+gpg --import $TESTSDIR/good.key
+
+mkdir -p conf
+cat > conf/distributions <<CONFEND
+Codename: ATest
+Architectures: abacus source
+Components: everything
+SignWith: good@nowhere.tld
+CONFEND
+
+gpg --list-keys
+
+testrun - -b . export 3<<EOF
+stdout
+$(odb)
+-v1*=Exporting ATest...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/ATest"
+-v2*=Created directory "./dists/ATest/everything"
+-v2*=Created directory "./dists/ATest/everything/binary-abacus"
+-v6*= exporting 'ATest|everything|abacus'...
+-v6*= creating './dists/ATest/everything/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/ATest/everything/source"
+-v6*= exporting 'ATest|everything|source'...
+-v6*= creating './dists/ATest/everything/source/Sources' (gzipped)
+-v2*=Successfully created './dists/ATest/Release.gpg.new'
+-v2*=Successfully created './dists/ATest/InRelease.new'
+EOF
+
+find dists/ATest | sort > results
+cat > results.expected <<EOF
+dists/ATest
+dists/ATest/InRelease
+dists/ATest/Release
+dists/ATest/Release.gpg
+dists/ATest/everything
+dists/ATest/everything/binary-abacus
+dists/ATest/everything/binary-abacus/Packages
+dists/ATest/everything/binary-abacus/Packages.gz
+dists/ATest/everything/binary-abacus/Release
+dists/ATest/everything/source
+dists/ATest/everything/source/Release
+dists/ATest/everything/source/Sources.gz
+EOF
+
+dodiff results.expected results
+
+dodo gpg --verify dists/ATest/Release.gpg dists/ATest/Release
+dodo gpg --verify dists/ATest/InRelease
+
+cp dists/ATest/InRelease InRelease
+ed -s InRelease <<'EOF'
+H
+/^-----BEGIN PGP SIGNED MESSAGE-----$/,/^$/d
+/^-----BEGIN PGP SIGNATURE-----$/,$d
+w
+q
+EOF
+dodiff dists/ATest/Release InRelease
+
+rm -r conf db dists gpgtestdir InRelease results results.expected
+
+testsuccess
diff --git a/tests/snapshotcopyrestore.test b/tests/snapshotcopyrestore.test
new file mode 100644
index 0000000..fdb4155
--- /dev/null
+++ b/tests/snapshotcopyrestore.test
@@ -0,0 +1,597 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+mkdir -p conf
+cat > conf/options <<CONFEND
+outhook $SRCDIR/docs/outstore.py
+CONFEND
+export REPREPRO_OUT_DB=db.out
+cat > conf/distributions <<CONFEND
+Codename: A
+Architectures: abacus calculator
+Components: dog cat
+Log: logfile
+ -A=nonexistant -C=nocomponent --type=none --withcontrol noscript.sh
+
+Codename: B
+Architectures: abacus source
+Components: dog cat
+Contents:
+Log: logfile
+CONFEND
+mkdir logs
+
+testrun - -b . export 3<<EOF
+stderr
+*=Warning: unknown architecture 'nonexistant', ignoring notificator line at line 5 in ./conf/distributions
+stdout
+$(odb)
+-v1*=Exporting B...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/B"
+-v2*=Created directory "./dists/B/dog"
+-v2*=Created directory "./dists/B/dog/binary-abacus"
+-v6*= exporting 'B|dog|abacus'...
+-v6*= creating './dists/B/dog/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/B/dog/source"
+-v6*= exporting 'B|dog|source'...
+-v6*= creating './dists/B/dog/source/Sources' (gzipped)
+-v2*=Created directory "./dists/B/cat"
+-v2*=Created directory "./dists/B/cat/binary-abacus"
+-v6*= exporting 'B|cat|abacus'...
+-v2*=Created directory "./dists/B/cat/source"
+-v6*= creating './dists/B/cat/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= exporting 'B|cat|source'...
+-v6*= creating './dists/B/cat/source/Sources' (gzipped)
+-v1*= generating dog/Contents-abacus...
+-v1*= generating cat/Contents-abacus...
+-v1*=Exporting A...
+-v2*=Created directory "./dists/A"
+-v2*=Created directory "./dists/A/dog"
+-v2*=Created directory "./dists/A/dog/binary-abacus"
+-v6*= exporting 'A|dog|abacus'...
+-v6*= creating './dists/A/dog/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/A/dog/binary-calculator"
+-v6*= exporting 'A|dog|calculator'...
+-v6*= creating './dists/A/dog/binary-calculator/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/A/cat"
+-v2*=Created directory "./dists/A/cat/binary-abacus"
+-v6*= exporting 'A|cat|abacus'...
+-v6*= creating './dists/A/cat/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/A/cat/binary-calculator"
+-v6*= exporting 'A|cat|calculator'...
+-v6*= creating './dists/A/cat/binary-calculator/Packages' (uncompressed,gzipped)
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+dodo test -f db/checksums.db
+
+ed -s conf/distributions <<EOF
+g/^ -A=nonexistant/s/nonexistant/calculator/
+w
+q
+EOF
+
+touch importindex
+
+testrun - -b . _addpackage B importindex bar foo 3<<EOF
+returns 255
+stderr
+*=Warning: unknown component 'nocomponent', ignoring notificator line at line 5 in ./conf/distributions
+*=_addpackage needs -C and -A and -T set!
+-v0*=There have been errors!
+EOF
+
+ed -s conf/distributions <<EOF
+g/^ -A/s/nocomponent/cat/
+w
+q
+EOF
+
+testrun - -b . -A source -T dsc _addpackage B importindex bar foo 3<<EOF
+returns 255
+stderr
+*=Warning: unknown packagetype 'none', ignoring notificator line at line 5 in ./conf/distributions
+*=_addpackage needs -C and -A and -T set!
+-v0*=There have been errors!
+EOF
+
+# -A=calculator -C=cat --type=dsc --via=include --withcontrol noscript.sh
+ed -s conf/distributions <<EOF
+g/^ -A=/s/=none/=dsc --via=include/
+w
+q
+EOF
+
+
+testrun - -b . -A abacus -C dog _addpackage B importindex bar foo 3<<EOF
+returns 255
+stderr
+*=_addpackage needs -C and -A and -T set!
+-v0*=There have been errors!
+EOF
+
+testrun - -b . -T deb -C dog _addpackage B importindex bar foo 3<<EOF
+returns 255
+stderr
+*=_addpackage needs -C and -A and -T set!
+-v0*=There have been errors!
+EOF
+
+testrun - -b . -T deb -A abacus -C dog _addpackage B importindex bar foo 3<<EOF
+stderr
+stdout
+EOF
+
+cat > importindex <<EOF
+Test:
+EOF
+
+testrun - -b . -T deb -A abacus -C dog _addpackage B importindex bar foo 3<<EOF
+returns 249
+stderr
+*=Error parsing importindex line 1 to 1: Chunk without 'Package:' field!
+-v0*=There have been errors!
+stdout
+EOF
+
+cat > importindex <<EOF
+Package: another
+Version: 0
+Architecture: abacus
+MD5Sum: 0
+Size: 0
+Filename: none
+EOF
+
+testrun - -b . -T deb -A abacus -C dog _addpackage B importindex bar foo 3<<EOF
+stderr
+stdout
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+
+cat > importindex <<EOF
+Package: foo
+Version: 0
+Architecture: abacus
+EOF
+
+testrun - -b . -T deb -A abacus -C dog _addpackage B importindex bar foo 3<<EOF
+returns 255
+stderr
+*=Data does not look like binary control: 'Package: foo
+*=Version: 0
+*=Architecture: abacus'
+-v0*=There have been errors!
+stdout
+EOF
+
+cat > importindex <<EOF
+Package: foo
+Version: 0
+Architecture: abacus
+MD5sum: 0
+Size: 0
+Filename: none
+EOF
+
+testrun - -b . -T deb -A abacus -C dog _addpackage B importindex bar foo 3<<EOF
+returns 249
+stderr
+*=Error: cannot yet deal with files changing their position
+*=(pool/dog/f/foo/foo_0_abacus.deb vs none in foo version 0)
+-v0*=There have been errors!
+stdout
+EOF
+
+mkdir -p pool/dog/f/foo
+echo "some data" > foo_0_abacus.deb
+
+cat > importindex <<EOF
+Package: foo
+Version: 0
+Architecture: abacus
+MD5sum: $(md5 foo_0_abacus.deb)
+Size: $(stat -c "%s" foo_0_abacus.deb)
+Filename: pool/dog/f/foo/foo_0_abacus.deb
+EOF
+
+testrun - -b . -T deb -A abacus -C dog _addpackage B importindex bar foo 3<<EOF
+returns 249
+stderr
+*=Error: package foo version 0 lists file pool/dog/f/foo/foo_0_abacus.deb not yet in the pool!
+-v0*=There have been errors!
+stdout
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+
+testrun empty -b . dumpunreferenced
+
+mv foo_0_abacus.deb pool/dog/f/foo/foo_0_abacus.deb
+testrun - -b . _detect pool/dog/f/foo/foo_0_abacus.deb 3<<EOF
+stderr
+stdout
+$(ofa 'pool/dog/f/foo/foo_0_abacus.deb')
+-v0*=1 files were added but not used.
+-v0*=The next deleteunreferenced call will delete them.
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+
+testrun - -b . dumpunreferenced 3<<EOF
+stderr
+stdout
+*=pool/dog/f/foo/foo_0_abacus.deb
+EOF
+
+# TODO: why is there no error for faulty .deb here?
+
+testrun - -b . -T deb -A abacus -C dog _addpackage B importindex bar foo 3<<EOF
+stderr
+*=Strange control data for 'foo': no Description at all
+stdout
+-v1*=Adding 'foo' '0' to 'B|dog|abacus'.
+$(opa 'foo' x 'B' 'dog' 'abacus' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'B|dog|abacus'...
+-v6*= replacing './dists/B/dog/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'B|dog|source'...
+-v6*= looking for changes in 'B|cat|abacus'...
+-v6*= looking for changes in 'B|cat|source'...
+-v1*= generating dog/Contents-abacus...
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+
+testrun empty -b . dumpunreferenced
+
+echo "dsc-content" > pool/dog/f/foo/foo_1.dsc
+echo "tar-content" > pool/dog/f/foo/foo_1.tar.gz
+
+cat > importindex <<EOF
+Package: foo
+Version: 1
+Directory: pool/dog/f/foo
+Files:
+ $(mdandsize pool/dog/f/foo/foo_1.dsc) foo_1.dsc
+ $(mdandsize pool/dog/f/foo/foo_1.tar.gz) foo_1.tar.gz
+EOF
+
+testrun - -b . -T dsc -C dog _addpackage B importindex bar foo 3<<EOF
+returns 249
+stderr
+*=Error: package foo version 1 lists file pool/dog/f/foo/foo_1.dsc not yet in the pool!
+-v0*=There have been errors!
+stdout
+EOF
+
+testrun empty -b . dumpunreferenced
+
+testrun - -b . _detect pool/dog/f/foo/foo_1.dsc 3<<EOF
+stderr
+stdout
+$(ofa 'pool/dog/f/foo/foo_1.dsc')
+-v0*=1 files were added but not used.
+-v0*=The next deleteunreferenced call will delete them.
+EOF
+
+mv pool/dog/f/foo/foo_1.tar.gz foo_1.tar.gz
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+mv foo_1.tar.gz pool/dog/f/foo/foo_1.tar.gz
+
+testrun - -b . -T dsc -C dog _addpackage B importindex bar foo 3<<EOF
+returns 249
+stderr
+*=Error: package foo version 1 lists file pool/dog/f/foo/foo_1.tar.gz not yet in the pool!
+-v0*=There have been errors!
+stdout
+EOF
+
+testrun - -b . _detect pool/dog/f/foo/foo_1.tar.gz 3<<EOF
+stderr
+stdout
+$(ofa 'pool/dog/f/foo/foo_1.tar.gz')
+-v0*=1 files were added but not used.
+-v0*=The next deleteunreferenced call will delete them.
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+
+testrun - -b . dumpunreferenced 3<<EOF
+stderr
+stdout
+*=pool/dog/f/foo/foo_1.dsc
+*=pool/dog/f/foo/foo_1.tar.gz
+EOF
+
+testrun - -b . -T dsc -C dog _addpackage B importindex bar foo 3<<EOF
+stderr
+stdout
+-v1*=Adding 'foo' '1' to 'B|dog|source'.
+$(opa 'foo' x 'B' 'dog' 'source' 'dsc')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'B|dog|abacus'...
+-v6*= looking for changes in 'B|dog|source'...
+-v6*= replacing './dists/B/dog/source/Sources' (gzipped)
+-v6*= looking for changes in 'B|cat|abacus'...
+-v6*= looking for changes in 'B|cat|source'...
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+
+testrun empty -b . dumpunreferenced
+
+testrun - -b . gensnapshot B now 3<<EOF
+stdout
+-v2*=Created directory "./dists/B/snapshots"
+-v2*=Created directory "./dists/B/snapshots/now"
+-v2*=Created directory "./dists/B/snapshots/now/dog"
+-v2*=Created directory "./dists/B/snapshots/now/dog/binary-abacus"
+-v6*= exporting 'B|dog|abacus'...
+-v6*= creating './dists/B/snapshots/now/dog/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/B/snapshots/now/dog/source"
+-v6*= exporting 'B|dog|source'...
+-v6*= creating './dists/B/snapshots/now/dog/source/Sources' (gzipped)
+-v2*=Created directory "./dists/B/snapshots/now/cat"
+-v2*=Created directory "./dists/B/snapshots/now/cat/binary-abacus"
+-v6*= exporting 'B|cat|abacus'...
+-v6*= creating './dists/B/snapshots/now/cat/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/B/snapshots/now/cat/source"
+-v6*= exporting 'B|cat|source'...
+-v6*= creating './dists/B/snapshots/now/cat/source/Sources' (gzipped)
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+
+testrun - -b . dumpreferences 3<<EOF
+stdout
+*=B|dog|abacus pool/dog/f/foo/foo_0_abacus.deb
+*=s=B=now pool/dog/f/foo/foo_0_abacus.deb
+*=B|dog|source pool/dog/f/foo/foo_1.dsc
+*=s=B=now pool/dog/f/foo/foo_1.dsc
+*=B|dog|source pool/dog/f/foo/foo_1.tar.gz
+*=s=B=now pool/dog/f/foo/foo_1.tar.gz
+EOF
+
+testrun - -b . gensnapshot A now 3<<EOF
+stdout
+-v2*=Created directory "./dists/A/snapshots"
+-v2*=Created directory "./dists/A/snapshots/now"
+-v2*=Created directory "./dists/A/snapshots/now/dog"
+-v2*=Created directory "./dists/A/snapshots/now/dog/binary-abacus"
+-v6*= exporting 'A|dog|abacus'...
+-v6*= creating './dists/A/snapshots/now/dog/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/A/snapshots/now/dog/binary-calculator"
+-v6*= exporting 'A|dog|calculator'...
+-v6*= creating './dists/A/snapshots/now/dog/binary-calculator/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/A/snapshots/now/cat"
+-v2*=Created directory "./dists/A/snapshots/now/cat/binary-abacus"
+-v6*= exporting 'A|cat|abacus'...
+-v6*= creating './dists/A/snapshots/now/cat/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/A/snapshots/now/cat/binary-calculator"
+-v6*= exporting 'A|cat|calculator'...
+-v6*= creating './dists/A/snapshots/now/cat/binary-calculator/Packages' (uncompressed,gzipped)
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+
+testout "" -b . dumpreferences
+grep '^.|' results | sed -e 's/|[^ ]* / contains /' | sort | uniq > references.normal
+grep '^s=' results | sed -e 's/^s=\(.\)=[^ ]* /\1 contains /' | sort > references.snapshot
+dodiff -u references.normal references.snapshot
+rm references.normal references.snapshot
+# Remove contents from original, to make them more look alike:
+for n in dists/B/Release dists/B/snapshots/now/Release dists/A/Release dists/A/snapshots/now/Release ; do
+ ed -s $n <<EOF
+g/^Date: /s/ .*/ unified/
+g,^Suite: ./snapshots/now$,d
+w
+q
+EOF
+done
+mkdir tmp
+mv dists/B/Contents-abacus.gz tmp/
+mv dists/B/dog/Contents-abacus.gz tmp/dog
+mv dists/B/cat/Contents-abacus.gz tmp/cat
+mv dists/B/snapshots/now dists/B.snapshot
+mv dists/A/snapshots/now dists/A.snapshot
+printf 'g/Contents-/d\nw\nq\n' | ed -s dists/B/Release
+rmdir dists/B/snapshots
+rmdir dists/A/snapshots
+dodiff -r -u dists/B.snapshot dists/B
+dodiff -r -u dists/A.snapshot dists/A
+mkdir dists/B/snapshots
+mkdir dists/A/snapshots
+mv dists/B.snapshot dists/B/snapshots/now
+mv dists/A.snapshot dists/A/snapshots/now
+mv tmp/dog dists/B/dog/Contents-abacus.gz
+mv tmp/cat dists/B/cat/Contents-abacus.gz
+mv tmp/Contents-abacus.gz dists/B/
+
+testrun empty -b . dumpunreferenced
+
+testrun - -b . restore B before foo 3<<EOF
+stderr
+*=Could not find './dists/B/snapshots/before/dog/binary-abacus/Packages' nor './dists/B/snapshots/before/dog/binary-abacus/Packages.gz',
+*=ignoring that part of the snapshot.
+*=Could not find './dists/B/snapshots/before/dog/source/Sources' nor './dists/B/snapshots/before/dog/source/Sources.gz',
+*=Could not find './dists/B/snapshots/before/cat/binary-abacus/Packages' nor './dists/B/snapshots/before/cat/binary-abacus/Packages.gz',
+*=Could not find './dists/B/snapshots/before/cat/source/Sources' nor './dists/B/snapshots/before/cat/source/Sources.gz',
+stdout
+EOF
+
+testrun - -b . dumpreferences 3<<EOF
+stdout
+*=B|dog|abacus pool/dog/f/foo/foo_0_abacus.deb
+*=s=B=now pool/dog/f/foo/foo_0_abacus.deb
+*=B|dog|source pool/dog/f/foo/foo_1.dsc
+*=s=B=now pool/dog/f/foo/foo_1.dsc
+*=B|dog|source pool/dog/f/foo/foo_1.tar.gz
+*=s=B=now pool/dog/f/foo/foo_1.tar.gz
+EOF
+
+testrun - -b . restore B now foo 3<<EOF
+stderr
+*=Strange control data for 'foo': no Description at all
+*=Warning: replacing 'foo' version '0' with equal version '0' in 'B|dog|abacus'!
+*=Warning: replacing 'foo' version '1' with equal version '1' in 'B|dog|source'!
+stdout
+-v1*=Adding 'foo' '0' to 'B|dog|abacus'.
+$(opu 'foo' x x 'B' 'dog' 'abacus' 'deb')
+-v1*=Adding 'foo' '1' to 'B|dog|source'.
+$(opu 'foo' x x 'B' 'dog' 'source' 'dsc')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'B|dog|abacus'...
+-v6*= replacing './dists/B/dog/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'B|dog|source'...
+-v6*= replacing './dists/B/dog/source/Sources' (gzipped)
+-v6*= looking for changes in 'B|cat|abacus'...
+-v6*= looking for changes in 'B|cat|source'...
+-v1*= generating dog/Contents-abacus...
+EOF
+
+testrun empty -b . dumpunreferenced
+testrun - -b . dumpreferences 3<<EOF
+stdout
+*=B|dog|abacus pool/dog/f/foo/foo_0_abacus.deb
+*=s=B=now pool/dog/f/foo/foo_0_abacus.deb
+*=B|dog|source pool/dog/f/foo/foo_1.dsc
+*=s=B=now pool/dog/f/foo/foo_1.dsc
+*=B|dog|source pool/dog/f/foo/foo_1.tar.gz
+*=s=B=now pool/dog/f/foo/foo_1.tar.gz
+EOF
+
+testrun - -b . restoresrc B now foo 0 1 3<<EOF
+stderr
+*=Strange control data for 'foo': no Description at all
+*=Warning: replacing 'foo' version '0' with equal version '0' in 'B|dog|abacus'!
+*=Warning: replacing 'foo' version '1' with equal version '1' in 'B|dog|source'!
+stdout
+-v1*=Adding 'foo' '0' to 'B|dog|abacus'.
+$(opu 'foo' x x 'B' 'dog' 'abacus' 'deb')
+-v1*=Adding 'foo' '1' to 'B|dog|source'.
+$(opu 'foo' x x 'B' 'dog' 'source' 'dsc')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'B|dog|abacus'...
+-v6*= replacing './dists/B/dog/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'B|dog|source'...
+-v6*= replacing './dists/B/dog/source/Sources' (gzipped)
+-v6*= looking for changes in 'B|cat|abacus'...
+-v6*= looking for changes in 'B|cat|source'...
+-v1*= generating dog/Contents-abacus...
+EOF
+
+testrun - -b . restoresrc B now foo 0 3<<EOF
+stderr
+*=Strange control data for 'foo': no Description at all
+*=Warning: replacing 'foo' version '0' with equal version '0' in 'B|dog|abacus'!
+stdout
+-v1*=Adding 'foo' '0' to 'B|dog|abacus'.
+$(opu 'foo' x x 'B' 'dog' 'abacus' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'B|dog|abacus'...
+-v6*= replacing './dists/B/dog/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'B|dog|source'...
+-v6*= looking for changes in 'B|cat|abacus'...
+-v6*= looking for changes in 'B|cat|source'...
+-v1*= generating dog/Contents-abacus...
+EOF
+
+testrun - -b . restoresrc B now foo 1 3<<EOF
+stderr
+*=Warning: replacing 'foo' version '1' with equal version '1' in 'B|dog|source'!
+stdout
+-v1*=Adding 'foo' '1' to 'B|dog|source'.
+$(opu 'foo' x x 'B' 'dog' 'source' 'dsc')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'B|dog|abacus'...
+-v6*= looking for changes in 'B|dog|source'...
+-v6*= replacing './dists/B/dog/source/Sources' (gzipped)
+-v6*= looking for changes in 'B|cat|abacus'...
+-v6*= looking for changes in 'B|cat|source'...
+EOF
+testrun - -b . restorefilter B now 'Directory' 3<<EOF
+stderr
+*=Warning: replacing 'foo' version '1' with equal version '1' in 'B|dog|source'!
+stdout
+-v1*=Adding 'foo' '1' to 'B|dog|source'.
+$(opu 'foo' x x 'B' 'dog' 'source' 'dsc')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'B|dog|abacus'...
+-v6*= looking for changes in 'B|dog|source'...
+-v6*= replacing './dists/B/dog/source/Sources' (gzipped)
+-v6*= looking for changes in 'B|cat|abacus'...
+-v6*= looking for changes in 'B|cat|source'...
+EOF
+
+testrun - -b . remove B bar foo 3<<EOF
+stderr
+-v0*=Not removed as not found: bar
+stdout
+$(opd 'foo' unset B dog abacus deb)
+$(opd 'foo' unset B dog source dsc)
+-v0*=Exporting indices...
+-v6*= looking for changes in 'B|dog|abacus'...
+-v6*= replacing './dists/B/dog/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'B|dog|source'...
+-v6*= replacing './dists/B/dog/source/Sources' (gzipped)
+-v6*= looking for changes in 'B|cat|abacus'...
+-v6*= looking for changes in 'B|cat|source'...
+-v1*= generating dog/Contents-abacus...
+EOF
+
+testrun - -b . dumpreferences 3<<EOF
+stdout
+*=s=B=now pool/dog/f/foo/foo_0_abacus.deb
+*=s=B=now pool/dog/f/foo/foo_1.dsc
+*=s=B=now pool/dog/f/foo/foo_1.tar.gz
+EOF
+
+testrun empty -b . dumpunreferenced
+
+dodo test -f pool/dog/f/foo/foo_1.dsc
+
+testrun - -b . restore B now bar foo 3<<EOF
+stderr
+*=Strange control data for 'foo': no Description at all
+stdout
+-v1*=Adding 'foo' '0' to 'B|dog|abacus'.
+$(opa 'foo' x 'B' 'dog' 'abacus' 'deb')
+-v1*=Adding 'foo' '1' to 'B|dog|source'.
+$(opa 'foo' x 'B' 'dog' 'source' 'dsc')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'B|dog|abacus'...
+-v6*= replacing './dists/B/dog/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'B|dog|source'...
+-v6*= replacing './dists/B/dog/source/Sources' (gzipped)
+-v6*= looking for changes in 'B|cat|abacus'...
+-v6*= looking for changes in 'B|cat|source'...
+-v1*= generating dog/Contents-abacus...
+EOF
+
+testrun empty -b . unreferencesnapshot B now
+
+testrun empty -b . dumpunreferenced
+
+testrun - -b . remove B bar foo 3<<EOF
+stderr
+-v0*=Not removed as not found: bar
+stdout
+$(opd 'foo' unset B dog abacus deb)
+$(opd 'foo' unset B dog source dsc)
+-v0*=Exporting indices...
+-v6*= looking for changes in 'B|dog|abacus'...
+-v6*= replacing './dists/B/dog/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'B|dog|source'...
+-v6*= replacing './dists/B/dog/source/Sources' (gzipped)
+-v6*= looking for changes in 'B|cat|abacus'...
+-v6*= looking for changes in 'B|cat|source'...
+-v1*= generating dog/Contents-abacus...
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/dog/f/foo/foo_0_abacus.deb')
+$(ofd 'pool/dog/f/foo/foo_1.dsc')
+$(ofd 'pool/dog/f/foo/foo_1.tar.gz')
+-v2*=removed now empty directory ./pool/dog/f/foo
+-v2*=removed now empty directory ./pool/dog/f
+-v2*=removed now empty directory ./pool/dog
+-v2*=removed now empty directory ./pool
+EOF
+
+testrun empty -b . dumpunreferenced
+testrun empty -b . dumpreferences
+
+rm -r conf db dists importindex logs tmp db.out*
+testsuccess
diff --git a/tests/srcfilterlist.test b/tests/srcfilterlist.test
new file mode 100644
index 0000000..0808dfd
--- /dev/null
+++ b/tests/srcfilterlist.test
@@ -0,0 +1,221 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+mkdir conf
+cat > conf/options <<EOF
+export silent-never
+EOF
+
+cat > conf/distributions <<EOF
+Codename: test
+Architectures: abacus source
+Components: main
+
+Codename: a
+Architectures: abacus source
+Components: main
+Pull: a
+
+Codename: b
+Architectures: abacus source
+Components: main
+Pull: b
+
+Codename: c
+Architectures: abacus source
+Components: main
+Pull: c
+
+Codename: d
+Architectures: abacus source
+Components: main
+Pull: d
+
+Codename: e
+Architectures: abacus source
+Components: main
+Pull: e
+
+Codename: f
+Architectures: abacus source
+Components: main
+Pull: f
+EOF
+
+DISTRI=test PACKAGE=a VERSION=1 REVISION=-1 FAKEVER=7-1 SECTION=base genpackage.sh
+mkdir -p pool/main/a/a
+testrun - --delete include test test.changes 3<<EOF
+stdout
+$(odb)
+$(ofa pool/main/a/a/a_1-1.tar.gz)
+$(ofa pool/main/a/a/a_1-1.dsc)
+$(ofa pool/main/a/a/a_1-1_abacus.deb)
+$(ofa pool/main/a/a/a-addons_7-1_all.deb)
+$(opa a 1-1 test main source dsc)
+$(opa a 1-1 test main abacus deb)
+$(opa a-addons 7-1 test main abacus deb)
+EOF
+DISTRI=test PACKAGE=b VERSION=1 REVISION=-1 FAKEVER=7-1 SECTION=base genpackage.sh
+mkdir -p pool/main/b/b
+testrun - --delete include test test.changes 3<<EOF
+stdout
+$(ofa pool/main/b/b/b_1-1.tar.gz)
+$(ofa pool/main/b/b/b_1-1.dsc)
+$(ofa pool/main/b/b/b_1-1_abacus.deb)
+$(ofa pool/main/b/b/b-addons_7-1_all.deb)
+$(opa b 1-1 test main source dsc)
+$(opa b 1-1 test main abacus deb)
+$(opa b-addons 7-1 test main abacus deb)
+EOF
+
+dodo test ! -d dists
+
+cat > conf/pulls <<EOF
+Name: a
+From: test
+FilterList: deinstall bin
+
+Name: b
+From: test
+FilterSrcList: deinstall src
+
+Name: c
+From: test
+FilterList: deinstall bin
+FilterSrcList: deinstall src
+
+Name: d
+From: test
+
+Name: e
+From: test
+FilterList: hold
+
+Name: f
+From: test
+FilterList: deinstall
+EOF
+cat > conf/bin <<EOF
+a = 1-1
+a-addons = 7-1
+b-addons = 1-1
+b = 7-1
+EOF
+cat > conf/src <<EOF
+b = 1-1
+a = 7-1
+a-addons = 7-1
+EOF
+
+testout - --restrict-bin a=1-1 dumppull 3</dev/null
+cat > results.expected <<EOF
+Updates needed for 'a|main|source':
+Updates needed for 'a|main|abacus':
+add 'a' - '1-1' 'a'
+Updates needed for 'b|main|source':
+Updates needed for 'b|main|abacus':
+Updates needed for 'c|main|source':
+Updates needed for 'c|main|abacus':
+add 'a' - '1-1' 'c'
+Updates needed for 'd|main|source':
+Updates needed for 'd|main|abacus':
+add 'a' - '1-1' 'd'
+Updates needed for 'e|main|source':
+Updates needed for 'e|main|abacus':
+add 'a' - '1-1' 'e'
+Updates needed for 'f|main|source':
+Updates needed for 'f|main|abacus':
+EOF
+dodiff results.expected results
+
+testout - --restrict-file-bin /dev/stdin dumppull 3</dev/null <<EOF
+a = 1-1
+EOF
+cat > results.expected <<EOF
+Updates needed for 'a|main|source':
+Updates needed for 'a|main|abacus':
+add 'a' - '1-1' 'a'
+Updates needed for 'b|main|source':
+Updates needed for 'b|main|abacus':
+Updates needed for 'c|main|source':
+Updates needed for 'c|main|abacus':
+add 'a' - '1-1' 'c'
+Updates needed for 'd|main|source':
+Updates needed for 'd|main|abacus':
+add 'a' - '1-1' 'd'
+Updates needed for 'e|main|source':
+Updates needed for 'e|main|abacus':
+add 'a' - '1-1' 'e'
+Updates needed for 'f|main|source':
+Updates needed for 'f|main|abacus':
+EOF
+dodiff results.expected results
+
+testout - --restrict a=1-1 --restrict-bin b=1-1 dumppull 3</dev/null
+cat > results.expected <<EOF
+Updates needed for 'a|main|source':
+add 'a' - '1-1' 'a'
+Updates needed for 'a|main|abacus':
+add 'a' - '1-1' 'a'
+add 'a-addons' - '7-1' 'a'
+Updates needed for 'b|main|source':
+Updates needed for 'b|main|abacus':
+add 'b' - '1-1' 'b'
+Updates needed for 'c|main|source':
+Updates needed for 'c|main|abacus':
+add 'a' - '1-1' 'c'
+add 'a-addons' - '7-1' 'c'
+Updates needed for 'd|main|source':
+add 'a' - '1-1' 'd'
+Updates needed for 'd|main|abacus':
+add 'a' - '1-1' 'd'
+add 'a-addons' - '7-1' 'd'
+add 'b' - '1-1' 'd'
+Updates needed for 'e|main|source':
+add 'a' - '1-1' 'e'
+Updates needed for 'e|main|abacus':
+add 'a' - '1-1' 'e'
+add 'a-addons' - '7-1' 'e'
+add 'b' - '1-1' 'e'
+Updates needed for 'f|main|source':
+Updates needed for 'f|main|abacus':
+EOF
+dodiff results.expected results
+
+testrun - pull 3<<EOF
+stdout
+-v0*=Calculating packages to pull...
+-v3*= pulling into 'a|main|source'
+-v5*= looking what to get from 'test|main|source'
+-v3*= pulling into 'a|main|abacus'
+-v5*= looking what to get from 'test|main|abacus'
+-v3*= pulling into 'b|main|source'
+-v3*= pulling into 'b|main|abacus'
+-v3*= pulling into 'c|main|source'
+-v3*= pulling into 'c|main|abacus'
+-v3*= pulling into 'd|main|source'
+-v3*= pulling into 'd|main|abacus'
+-v3*= pulling into 'e|main|source'
+-v3*= pulling into 'e|main|abacus'
+-v3*= pulling into 'f|main|source'
+-v3*= pulling into 'f|main|abacus'
+-v0*=Installing (and possibly deleting) packages...
+$(opa a 1-1 d main source dsc)
+$(opa a 1-1 d main abacus deb)
+$(opa a-addons 7-1 d main abacus deb)
+$(opa b 1-1 d main source dsc)
+$(opa b 1-1 d main abacus deb)
+$(opa b-addons 7-1 d main abacus deb)
+$(opa a 1-1 a main source dsc)
+$(opa a 1-1 a main abacus deb)
+$(opa a-addons 7-1 a main abacus deb)
+$(opa b 1-1 b main source dsc)
+$(opa b 1-1 b main abacus deb)
+$(opa b-addons 7-1 b main abacus deb)
+$(opa a 1-1 c main abacus deb)
+$(opa a-addons 7-1 c main abacus deb)
+$(opa b 1-1 c main source dsc)
+EOF
+
+rm -r db pool
+testsuccess
diff --git a/tests/subcomponents.test b/tests/subcomponents.test
new file mode 100644
index 0000000..016bd7a
--- /dev/null
+++ b/tests/subcomponents.test
@@ -0,0 +1,502 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+dodo test ! -d db
+testrun - -b . _versioncompare 0 1 3<<EOF
+stdout
+*='0' is smaller than '1'.
+EOF
+dodo test ! -d db
+mkdir -p conf
+cat > conf/distributions <<EOF
+Codename: foo/updates
+Components: a bb ccc dddd
+UDebComponents: a dddd
+Architectures: x source
+EOF
+testrun - -b . export foo/updates 3<<EOF
+stderr
+stdout
+$(odb)
+-v1*=Exporting foo/updates...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/foo"
+-v2*=Created directory "./dists/foo/updates"
+-v2*=Created directory "./dists/foo/updates/a"
+-v2*=Created directory "./dists/foo/updates/a/binary-x"
+-v6*= exporting 'foo/updates|a|x'...
+-v6*= creating './dists/foo/updates/a/binary-x/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/foo/updates/a/debian-installer"
+-v2*=Created directory "./dists/foo/updates/a/debian-installer/binary-x"
+-v6*= exporting 'u|foo/updates|a|x'...
+-v6*= creating './dists/foo/updates/a/debian-installer/binary-x/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/foo/updates/a/source"
+-v6*= exporting 'foo/updates|a|source'...
+-v6*= creating './dists/foo/updates/a/source/Sources' (gzipped)
+-v2*=Created directory "./dists/foo/updates/bb"
+-v2*=Created directory "./dists/foo/updates/bb/binary-x"
+-v6*= exporting 'foo/updates|bb|x'...
+-v6*= creating './dists/foo/updates/bb/binary-x/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/foo/updates/bb/source"
+-v6*= exporting 'foo/updates|bb|source'...
+-v6*= creating './dists/foo/updates/bb/source/Sources' (gzipped)
+-v2*=Created directory "./dists/foo/updates/ccc"
+-v2*=Created directory "./dists/foo/updates/ccc/binary-x"
+-v6*= exporting 'foo/updates|ccc|x'...
+-v6*= creating './dists/foo/updates/ccc/binary-x/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/foo/updates/ccc/source"
+-v6*= exporting 'foo/updates|ccc|source'...
+-v6*= creating './dists/foo/updates/ccc/source/Sources' (gzipped)
+-v2*=Created directory "./dists/foo/updates/dddd"
+-v2*=Created directory "./dists/foo/updates/dddd/binary-x"
+-v6*= exporting 'foo/updates|dddd|x'...
+-v6*= creating './dists/foo/updates/dddd/binary-x/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/foo/updates/dddd/debian-installer"
+-v2*=Created directory "./dists/foo/updates/dddd/debian-installer/binary-x"
+-v6*= exporting 'u|foo/updates|dddd|x'...
+-v6*= creating './dists/foo/updates/dddd/debian-installer/binary-x/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/foo/updates/dddd/source"
+-v6*= exporting 'foo/updates|dddd|source'...
+-v6*= creating './dists/foo/updates/dddd/source/Sources' (gzipped)
+EOF
+cat > results.expected <<EOF
+Codename: foo/updates
+Date: normalized
+Architectures: x
+Components: a bb ccc dddd
+MD5Sum:
+ $EMPTYMD5 a/binary-x/Packages
+ $EMPTYGZMD5 a/binary-x/Packages.gz
+ 62d4df25a6de22ca443076ace929ec5b 29 a/binary-x/Release
+ $EMPTYMD5 a/debian-installer/binary-x/Packages
+ $EMPTYGZMD5 a/debian-installer/binary-x/Packages.gz
+ $EMPTYMD5 a/source/Sources
+ $EMPTYGZMD5 a/source/Sources.gz
+ bc76dd633c41acb37f24e22bf755dc84 34 a/source/Release
+ $EMPTYMD5 bb/binary-x/Packages
+ $EMPTYGZMD5 bb/binary-x/Packages.gz
+ 6b882eefa465a6e3c43d512f7e8da6e4 30 bb/binary-x/Release
+ $EMPTYMD5 bb/source/Sources
+ $EMPTYGZMD5 bb/source/Sources.gz
+ 808be3988e695c1ef966f19641383275 35 bb/source/Release
+ $EMPTYMD5 ccc/binary-x/Packages
+ $EMPTYGZMD5 ccc/binary-x/Packages.gz
+ dec38be5c92799814c9113335317a319 31 ccc/binary-x/Release
+ $EMPTYMD5 ccc/source/Sources
+ $EMPTYGZMD5 ccc/source/Sources.gz
+ 650f349d34e8e929dfc732abbf90c74e 36 ccc/source/Release
+ $EMPTYMD5 dddd/binary-x/Packages
+ $EMPTYGZMD5 dddd/binary-x/Packages.gz
+ 3e4c48246400818d451e65fb03e48f01 32 dddd/binary-x/Release
+ $EMPTYMD5 dddd/debian-installer/binary-x/Packages
+ $EMPTYGZMD5 dddd/debian-installer/binary-x/Packages.gz
+ $EMPTYMD5 dddd/source/Sources
+ $EMPTYGZMD5 dddd/source/Sources.gz
+ bb7b15c091463b7ea884ccca385f1f0a 37 dddd/source/Release
+SHA1:
+ $EMPTYSHA1 a/binary-x/Packages
+ $EMPTYGZSHA1 a/binary-x/Packages.gz
+ f312c487ee55fc60c23e9117c6a664cbbd862ae6 29 a/binary-x/Release
+ $EMPTYSHA1 a/debian-installer/binary-x/Packages
+ $EMPTYGZSHA1 a/debian-installer/binary-x/Packages.gz
+ $EMPTYSHA1 a/source/Sources
+ $EMPTYGZSHA1 a/source/Sources.gz
+ 186977630f5f42744cd6ea6fcf8ea54960992a2f 34 a/source/Release
+ $EMPTYSHA1 bb/binary-x/Packages
+ $EMPTYGZSHA1 bb/binary-x/Packages.gz
+ c4c6cb0f765a9f71682f3d1bfd02279e58609e6b 30 bb/binary-x/Release
+ $EMPTYSHA1 bb/source/Sources
+ $EMPTYGZSHA1 bb/source/Sources.gz
+ 59260e2f6e121943909241c125c57aed6fca09ad 35 bb/source/Release
+ $EMPTYSHA1 ccc/binary-x/Packages
+ $EMPTYGZSHA1 ccc/binary-x/Packages.gz
+ 7d1913a67637add61ce5ef1ba82eeeb8bc5fe8c6 31 ccc/binary-x/Release
+ $EMPTYSHA1 ccc/source/Sources
+ $EMPTYGZSHA1 ccc/source/Sources.gz
+ a7df74b575289d0697214261e393bc390f428af9 36 ccc/source/Release
+ $EMPTYSHA1 dddd/binary-x/Packages
+ $EMPTYGZSHA1 dddd/binary-x/Packages.gz
+ fc2ab0a76469f8fc81632aa904ceb9c1125ac2c5 32 dddd/binary-x/Release
+ $EMPTYSHA1 dddd/debian-installer/binary-x/Packages
+ $EMPTYGZSHA1 dddd/debian-installer/binary-x/Packages.gz
+ $EMPTYSHA1 dddd/source/Sources
+ $EMPTYGZSHA1 dddd/source/Sources.gz
+ 1d44f88f82a325658ee96dd7e7cee975ffa50e4d 37 dddd/source/Release
+SHA256:
+ $EMPTYSHA2 a/binary-x/Packages
+ $EMPTYGZSHA2 a/binary-x/Packages.gz
+ d5e5ba98f784efc26ac8f5ff1f293fab43f37878c92b3da0a7fce39c1da0b463 29 a/binary-x/Release
+ $EMPTYSHA2 a/debian-installer/binary-x/Packages
+ $EMPTYGZSHA2 a/debian-installer/binary-x/Packages.gz
+ $EMPTYSHA2 a/source/Sources
+ $EMPTYGZSHA2 a/source/Sources.gz
+ edd9dad3b1239657da74dfbf45af401ab810b54236b12386189accc0fbc4befa 34 a/source/Release
+ $EMPTYSHA2 bb/binary-x/Packages
+ $EMPTYGZSHA2 bb/binary-x/Packages.gz
+ 2d578ea088ccb77f24a437c4657663e9f5a76939c8a23745f8df9f425cc4c137 30 bb/binary-x/Release
+ $EMPTYSHA2 bb/source/Sources
+ $EMPTYGZSHA2 bb/source/Sources.gz
+ 4653987e3d0be59da18afcc446e59a0118dd995a13e976162749017e95e6709a 35 bb/source/Release
+ $EMPTYSHA2 ccc/binary-x/Packages
+ $EMPTYGZSHA2 ccc/binary-x/Packages.gz
+ e46b90afc77272a351bdde96253f57cba5852317546467fc61ae47d7696500a6 31 ccc/binary-x/Release
+ $EMPTYSHA2 ccc/source/Sources
+ $EMPTYGZSHA2 ccc/source/Sources.gz
+ a6ef831ba0cc6044019e4d598c5f2483872cf047cb65949bb68c73c028864d76 36 ccc/source/Release
+ $EMPTYSHA2 dddd/binary-x/Packages
+ $EMPTYGZSHA2 dddd/binary-x/Packages.gz
+ 70a6c3a457abe60f107f63f0cdb29ab040a4494fefc55922fff0164c97c7a124 32 dddd/binary-x/Release
+ $EMPTYSHA2 dddd/debian-installer/binary-x/Packages
+ $EMPTYGZSHA2 dddd/debian-installer/binary-x/Packages.gz
+ $EMPTYSHA2 dddd/source/Sources
+ $EMPTYGZSHA2 dddd/source/Sources.gz
+ 504549b725951e79fb2e43149bb0cf42619286284890666b8e9fe5fb0787f306 37 dddd/source/Release
+EOF
+normalizerelease dists/foo/updates/Release > results
+dodiff results.expected results
+cat > conf/distributions <<EOF
+Codename: foo/updates
+Components: a bb ccc dddd
+UDebComponents: a dddd
+Architectures: x source
+FakeComponentPrefix: updates
+EOF
+testrun - -b . export foo/updates 3<<EOF
+stderr
+stdout
+-v1*=Exporting foo/updates...
+-v6*= exporting 'foo/updates|a|x'...
+-v6*= replacing './dists/foo/updates/a/binary-x/Packages' (uncompressed,gzipped)
+-v6*= exporting 'u|foo/updates|a|x'...
+-v6*= replacing './dists/foo/updates/a/debian-installer/binary-x/Packages' (uncompressed,gzipped)
+-v6*= exporting 'foo/updates|a|source'...
+-v6*= replacing './dists/foo/updates/a/source/Sources' (gzipped)
+-v6*= exporting 'foo/updates|bb|x'...
+-v6*= replacing './dists/foo/updates/bb/binary-x/Packages' (uncompressed,gzipped)
+-v6*= exporting 'foo/updates|bb|source'...
+-v6*= replacing './dists/foo/updates/bb/source/Sources' (gzipped)
+-v6*= exporting 'foo/updates|ccc|x'...
+-v6*= replacing './dists/foo/updates/ccc/binary-x/Packages' (uncompressed,gzipped)
+-v6*= exporting 'foo/updates|ccc|source'...
+-v6*= replacing './dists/foo/updates/ccc/source/Sources' (gzipped)
+-v6*= exporting 'foo/updates|dddd|x'...
+-v6*= replacing './dists/foo/updates/dddd/binary-x/Packages' (uncompressed,gzipped)
+-v6*= exporting 'u|foo/updates|dddd|x'...
+-v6*= replacing './dists/foo/updates/dddd/debian-installer/binary-x/Packages' (uncompressed,gzipped)
+-v6*= exporting 'foo/updates|dddd|source'...
+-v6*= replacing './dists/foo/updates/dddd/source/Sources' (gzipped)
+EOF
+cat > results.expected <<EOF
+Codename: foo
+Date: normalized
+Architectures: x
+Components: updates/a updates/bb updates/ccc updates/dddd
+MD5Sum:
+ $EMPTYMD5 a/binary-x/Packages
+ $EMPTYGZMD5 a/binary-x/Packages.gz
+ 62d4df25a6de22ca443076ace929ec5b 29 a/binary-x/Release
+ $EMPTYMD5 a/debian-installer/binary-x/Packages
+ $EMPTYGZMD5 a/debian-installer/binary-x/Packages.gz
+ $EMPTYMD5 a/source/Sources
+ $EMPTYGZMD5 a/source/Sources.gz
+ bc76dd633c41acb37f24e22bf755dc84 34 a/source/Release
+ $EMPTYMD5 bb/binary-x/Packages
+ $EMPTYGZMD5 bb/binary-x/Packages.gz
+ 6b882eefa465a6e3c43d512f7e8da6e4 30 bb/binary-x/Release
+ $EMPTYMD5 bb/source/Sources
+ $EMPTYGZMD5 bb/source/Sources.gz
+ 808be3988e695c1ef966f19641383275 35 bb/source/Release
+ $EMPTYMD5 ccc/binary-x/Packages
+ $EMPTYGZMD5 ccc/binary-x/Packages.gz
+ dec38be5c92799814c9113335317a319 31 ccc/binary-x/Release
+ $EMPTYMD5 ccc/source/Sources
+ $EMPTYGZMD5 ccc/source/Sources.gz
+ 650f349d34e8e929dfc732abbf90c74e 36 ccc/source/Release
+ $EMPTYMD5 dddd/binary-x/Packages
+ $EMPTYGZMD5 dddd/binary-x/Packages.gz
+ 3e4c48246400818d451e65fb03e48f01 32 dddd/binary-x/Release
+ $EMPTYMD5 dddd/debian-installer/binary-x/Packages
+ $EMPTYGZMD5 dddd/debian-installer/binary-x/Packages.gz
+ $EMPTYMD5 dddd/source/Sources
+ $EMPTYGZMD5 dddd/source/Sources.gz
+ bb7b15c091463b7ea884ccca385f1f0a 37 dddd/source/Release
+SHA1:
+ $EMPTYSHA1 a/binary-x/Packages
+ $EMPTYGZSHA1 a/binary-x/Packages.gz
+ f312c487ee55fc60c23e9117c6a664cbbd862ae6 29 a/binary-x/Release
+ $EMPTYSHA1 a/debian-installer/binary-x/Packages
+ $EMPTYGZSHA1 a/debian-installer/binary-x/Packages.gz
+ $EMPTYSHA1 a/source/Sources
+ $EMPTYGZSHA1 a/source/Sources.gz
+ 186977630f5f42744cd6ea6fcf8ea54960992a2f 34 a/source/Release
+ $EMPTYSHA1 bb/binary-x/Packages
+ $EMPTYGZSHA1 bb/binary-x/Packages.gz
+ c4c6cb0f765a9f71682f3d1bfd02279e58609e6b 30 bb/binary-x/Release
+ $EMPTYSHA1 bb/source/Sources
+ $EMPTYGZSHA1 bb/source/Sources.gz
+ 59260e2f6e121943909241c125c57aed6fca09ad 35 bb/source/Release
+ $EMPTYSHA1 ccc/binary-x/Packages
+ $EMPTYGZSHA1 ccc/binary-x/Packages.gz
+ 7d1913a67637add61ce5ef1ba82eeeb8bc5fe8c6 31 ccc/binary-x/Release
+ $EMPTYSHA1 ccc/source/Sources
+ $EMPTYGZSHA1 ccc/source/Sources.gz
+ a7df74b575289d0697214261e393bc390f428af9 36 ccc/source/Release
+ $EMPTYSHA1 dddd/binary-x/Packages
+ $EMPTYGZSHA1 dddd/binary-x/Packages.gz
+ fc2ab0a76469f8fc81632aa904ceb9c1125ac2c5 32 dddd/binary-x/Release
+ $EMPTYSHA1 dddd/debian-installer/binary-x/Packages
+ $EMPTYGZSHA1 dddd/debian-installer/binary-x/Packages.gz
+ $EMPTYSHA1 dddd/source/Sources
+ $EMPTYGZSHA1 dddd/source/Sources.gz
+ 1d44f88f82a325658ee96dd7e7cee975ffa50e4d 37 dddd/source/Release
+SHA256:
+ $EMPTYSHA2 a/binary-x/Packages
+ $EMPTYGZSHA2 a/binary-x/Packages.gz
+ d5e5ba98f784efc26ac8f5ff1f293fab43f37878c92b3da0a7fce39c1da0b463 29 a/binary-x/Release
+ $EMPTYSHA2 a/debian-installer/binary-x/Packages
+ $EMPTYGZSHA2 a/debian-installer/binary-x/Packages.gz
+ $EMPTYSHA2 a/source/Sources
+ $EMPTYGZSHA2 a/source/Sources.gz
+ edd9dad3b1239657da74dfbf45af401ab810b54236b12386189accc0fbc4befa 34 a/source/Release
+ $EMPTYSHA2 bb/binary-x/Packages
+ $EMPTYGZSHA2 bb/binary-x/Packages.gz
+ 2d578ea088ccb77f24a437c4657663e9f5a76939c8a23745f8df9f425cc4c137 30 bb/binary-x/Release
+ $EMPTYSHA2 bb/source/Sources
+ $EMPTYGZSHA2 bb/source/Sources.gz
+ 4653987e3d0be59da18afcc446e59a0118dd995a13e976162749017e95e6709a 35 bb/source/Release
+ $EMPTYSHA2 ccc/binary-x/Packages
+ $EMPTYGZSHA2 ccc/binary-x/Packages.gz
+ e46b90afc77272a351bdde96253f57cba5852317546467fc61ae47d7696500a6 31 ccc/binary-x/Release
+ $EMPTYSHA2 ccc/source/Sources
+ $EMPTYGZSHA2 ccc/source/Sources.gz
+ a6ef831ba0cc6044019e4d598c5f2483872cf047cb65949bb68c73c028864d76 36 ccc/source/Release
+ $EMPTYSHA2 dddd/binary-x/Packages
+ $EMPTYGZSHA2 dddd/binary-x/Packages.gz
+ 70a6c3a457abe60f107f63f0cdb29ab040a4494fefc55922fff0164c97c7a124 32 dddd/binary-x/Release
+ $EMPTYSHA2 dddd/debian-installer/binary-x/Packages
+ $EMPTYGZSHA2 dddd/debian-installer/binary-x/Packages.gz
+ $EMPTYSHA2 dddd/source/Sources
+ $EMPTYGZSHA2 dddd/source/Sources.gz
+ 504549b725951e79fb2e43149bb0cf42619286284890666b8e9fe5fb0787f306 37 dddd/source/Release
+EOF
+normalizerelease dists/foo/updates/Release > results
+dodiff results.expected results
+# Now try with suite
+cat > conf/distributions <<EOF
+Codename: foo/updates
+Suite: bla/updates
+Components: a bb ccc dddd
+UDebComponents: a dddd
+Architectures: x source
+FakeComponentPrefix: updates
+EOF
+testrun - -b . export foo/updates 3<<EOF
+stderr
+stdout
+-v1*=Exporting foo/updates...
+-v6*= exporting 'foo/updates|a|x'...
+-v6*= replacing './dists/foo/updates/a/binary-x/Packages' (uncompressed,gzipped)
+-v6*= exporting 'u|foo/updates|a|x'...
+-v6*= replacing './dists/foo/updates/a/debian-installer/binary-x/Packages' (uncompressed,gzipped)
+-v6*= exporting 'foo/updates|a|source'...
+-v6*= replacing './dists/foo/updates/a/source/Sources' (gzipped)
+-v6*= exporting 'foo/updates|bb|x'...
+-v6*= replacing './dists/foo/updates/bb/binary-x/Packages' (uncompressed,gzipped)
+-v6*= exporting 'foo/updates|bb|source'...
+-v6*= replacing './dists/foo/updates/bb/source/Sources' (gzipped)
+-v6*= exporting 'foo/updates|ccc|x'...
+-v6*= replacing './dists/foo/updates/ccc/binary-x/Packages' (uncompressed,gzipped)
+-v6*= exporting 'foo/updates|ccc|source'...
+-v6*= replacing './dists/foo/updates/ccc/source/Sources' (gzipped)
+-v6*= exporting 'foo/updates|dddd|x'...
+-v6*= replacing './dists/foo/updates/dddd/binary-x/Packages' (uncompressed,gzipped)
+-v6*= exporting 'u|foo/updates|dddd|x'...
+-v6*= replacing './dists/foo/updates/dddd/debian-installer/binary-x/Packages' (uncompressed,gzipped)
+-v6*= exporting 'foo/updates|dddd|source'...
+-v6*= replacing './dists/foo/updates/dddd/source/Sources' (gzipped)
+EOF
+cat > results.expected <<EOF
+Suite: bla
+Codename: foo
+Date: normalized
+Architectures: x
+Components: updates/a updates/bb updates/ccc updates/dddd
+MD5Sum:
+ $EMPTYMD5 a/binary-x/Packages
+ $EMPTYGZMD5 a/binary-x/Packages.gz
+ $(md5releaseline foo/updates a/binary-x/Release)
+ $EMPTYMD5 a/debian-installer/binary-x/Packages
+ $EMPTYGZMD5 a/debian-installer/binary-x/Packages.gz
+ $EMPTYMD5 a/source/Sources
+ $EMPTYGZMD5 a/source/Sources.gz
+ $(md5releaseline foo/updates a/source/Release)
+ $EMPTYMD5 bb/binary-x/Packages
+ $EMPTYGZMD5 bb/binary-x/Packages.gz
+ $(md5releaseline foo/updates bb/binary-x/Release)
+ $EMPTYMD5 bb/source/Sources
+ $EMPTYGZMD5 bb/source/Sources.gz
+ $(md5releaseline foo/updates bb/source/Release)
+ $EMPTYMD5 ccc/binary-x/Packages
+ $EMPTYGZMD5 ccc/binary-x/Packages.gz
+ $(md5releaseline foo/updates ccc/binary-x/Release)
+ $EMPTYMD5 ccc/source/Sources
+ $EMPTYGZMD5 ccc/source/Sources.gz
+ $(md5releaseline foo/updates ccc/source/Release)
+ $EMPTYMD5 dddd/binary-x/Packages
+ $EMPTYGZMD5 dddd/binary-x/Packages.gz
+ $(md5releaseline foo/updates dddd/binary-x/Release)
+ $EMPTYMD5 dddd/debian-installer/binary-x/Packages
+ $EMPTYGZMD5 dddd/debian-installer/binary-x/Packages.gz
+ $EMPTYMD5 dddd/source/Sources
+ $EMPTYGZMD5 dddd/source/Sources.gz
+ $(md5releaseline foo/updates dddd/source/Release)
+SHA1:
+ $EMPTYSHA1 a/binary-x/Packages
+ $EMPTYGZSHA1 a/binary-x/Packages.gz
+ $(sha1releaseline foo/updates a/binary-x/Release)
+ $EMPTYSHA1 a/debian-installer/binary-x/Packages
+ $EMPTYGZSHA1 a/debian-installer/binary-x/Packages.gz
+ $EMPTYSHA1 a/source/Sources
+ $EMPTYGZSHA1 a/source/Sources.gz
+ $(sha1releaseline foo/updates a/source/Release)
+ $EMPTYSHA1 bb/binary-x/Packages
+ $EMPTYGZSHA1 bb/binary-x/Packages.gz
+ $(sha1releaseline foo/updates bb/binary-x/Release)
+ $EMPTYSHA1 bb/source/Sources
+ $EMPTYGZSHA1 bb/source/Sources.gz
+ $(sha1releaseline foo/updates bb/source/Release)
+ $EMPTYSHA1 ccc/binary-x/Packages
+ $EMPTYGZSHA1 ccc/binary-x/Packages.gz
+ $(sha1releaseline foo/updates ccc/binary-x/Release)
+ $EMPTYSHA1 ccc/source/Sources
+ $EMPTYGZSHA1 ccc/source/Sources.gz
+ $(sha1releaseline foo/updates ccc/source/Release)
+ $EMPTYSHA1 dddd/binary-x/Packages
+ $EMPTYGZSHA1 dddd/binary-x/Packages.gz
+ $(sha1releaseline foo/updates dddd/binary-x/Release)
+ $EMPTYSHA1 dddd/debian-installer/binary-x/Packages
+ $EMPTYGZSHA1 dddd/debian-installer/binary-x/Packages.gz
+ $EMPTYSHA1 dddd/source/Sources
+ $EMPTYGZSHA1 dddd/source/Sources.gz
+ $(sha1releaseline foo/updates dddd/source/Release)
+SHA256:
+ $EMPTYSHA2 a/binary-x/Packages
+ $EMPTYGZSHA2 a/binary-x/Packages.gz
+ $(sha2releaseline foo/updates a/binary-x/Release)
+ $EMPTYSHA2 a/debian-installer/binary-x/Packages
+ $EMPTYGZSHA2 a/debian-installer/binary-x/Packages.gz
+ $EMPTYSHA2 a/source/Sources
+ $EMPTYGZSHA2 a/source/Sources.gz
+ $(sha2releaseline foo/updates a/source/Release)
+ $EMPTYSHA2 bb/binary-x/Packages
+ $EMPTYGZSHA2 bb/binary-x/Packages.gz
+ $(sha2releaseline foo/updates bb/binary-x/Release)
+ $EMPTYSHA2 bb/source/Sources
+ $EMPTYGZSHA2 bb/source/Sources.gz
+ $(sha2releaseline foo/updates bb/source/Release)
+ $EMPTYSHA2 ccc/binary-x/Packages
+ $EMPTYGZSHA2 ccc/binary-x/Packages.gz
+ $(sha2releaseline foo/updates ccc/binary-x/Release)
+ $EMPTYSHA2 ccc/source/Sources
+ $EMPTYGZSHA2 ccc/source/Sources.gz
+ $(sha2releaseline foo/updates ccc/source/Release)
+ $EMPTYSHA2 dddd/binary-x/Packages
+ $EMPTYGZSHA2 dddd/binary-x/Packages.gz
+ $(sha2releaseline foo/updates dddd/binary-x/Release)
+ $EMPTYSHA2 dddd/debian-installer/binary-x/Packages
+ $EMPTYGZSHA2 dddd/debian-installer/binary-x/Packages.gz
+ $EMPTYSHA2 dddd/source/Sources
+ $EMPTYGZSHA2 dddd/source/Sources.gz
+ $(sha2releaseline foo/updates dddd/source/Release)
+EOF
+normalizerelease dists/foo/updates/Release > results
+dodiff results.expected results
+testrun - -b . createsymlinks 3<<EOF
+stderr
+-v0*=Creating symlinks with '/' in them is not yet supported:
+-v0*=Not creating 'bla/updates' -> 'foo/updates' because of '/'.
+stdout
+EOF
+cat >> conf/distributions <<EOF
+
+Codename: foo
+Suite: bla
+Architectures: ooooooooooooooooooooooooooooooooooooooooo source
+Components:
+ x a
+EOF
+testrun - -b . createsymlinks 3<<EOF
+stderr
+-v2*=Not creating 'bla/updates' -> 'foo/updates' because of the '/' in it.
+-v2*=Hopefully something else will link 'bla' -> 'foo' then this is not needed.
+stdout
+-v1*=Created ./dists/bla->foo
+EOF
+# check a .dsc with nothing in it:
+cat > test.dsc <<EOF
+
+EOF
+testrun - -b . includedsc foo test.dsc 3<<EOF
+return 255
+stderr
+*=Could only find spaces within 'test.dsc'!
+-v0*=There have been errors!
+stdout
+EOF
+cat > test.dsc <<EOF
+Format: 0.0
+Source: test
+Version: 0
+Maintainer: me <guess@who>
+Section: section
+Priority: priority
+Files:
+EOF
+testrun - -C a -b . includedsc foo test.dsc 3<<EOF
+stdout
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/a"
+-v2*=Created directory "./pool/a/t"
+-v2*=Created directory "./pool/a/t/test"
+$(ofa 'pool/a/t/test/test_0.dsc')
+$(opa 'test' unset 'foo' 'a' 'source' 'dsc')
+-v0*=Exporting indices...
+-v2*=Created directory "./dists/foo/x"
+-v2*=Created directory "./dists/foo/x/binary-ooooooooooooooooooooooooooooooooooooooooo"
+-v6*= looking for changes in 'foo|x|ooooooooooooooooooooooooooooooooooooooooo'...
+-v6*= creating './dists/foo/x/binary-ooooooooooooooooooooooooooooooooooooooooo/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/foo/x/source"
+-v6*= looking for changes in 'foo|x|source'...
+-v6*= creating './dists/foo/x/source/Sources' (gzipped)
+-v2*=Created directory "./dists/foo/a"
+-v2*=Created directory "./dists/foo/a/binary-ooooooooooooooooooooooooooooooooooooooooo"
+-v6*= looking for changes in 'foo|a|ooooooooooooooooooooooooooooooooooooooooo'...
+-v6*= creating './dists/foo/a/binary-ooooooooooooooooooooooooooooooooooooooooo/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/foo/a/source"
+-v6*= looking for changes in 'foo|a|source'...
+-v6*= creating './dists/foo/a/source/Sources' (gzipped)
+EOF
+testrun - -b . copy foo/updates foo test test test test 3<<EOF
+stderr
+-v0*=Hint: 'test' was listed multiple times, ignoring all but first!
+stdout
+-v3*=Not looking into 'foo|x|ooooooooooooooooooooooooooooooooooooooooo' as no matching target in 'foo/updates'!
+-v3*=Not looking into 'foo|x|source' as no matching target in 'foo/updates'!
+-v3*=Not looking into 'foo|a|ooooooooooooooooooooooooooooooooooooooooo' as no matching target in 'foo/updates'!
+-v1*=Adding 'test' '0' to 'foo/updates|a|source'.
+$(opa 'test' unset 'foo/updates' 'a' 'source' 'dsc')
+-v*=Exporting indices...
+-v6*= looking for changes in 'foo/updates|a|x'...
+-v6*= looking for changes in 'u|foo/updates|a|x'...
+-v6*= looking for changes in 'foo/updates|a|source'...
+-v6*= replacing './dists/foo/updates/a/source/Sources' (gzipped)
+-v6*= looking for changes in 'foo/updates|bb|x'...
+-v6*= looking for changes in 'foo/updates|bb|source'...
+-v6*= looking for changes in 'foo/updates|ccc|x'...
+-v6*= looking for changes in 'foo/updates|ccc|source'...
+-v6*= looking for changes in 'foo/updates|dddd|x'...
+-v6*= looking for changes in 'u|foo/updates|dddd|x'...
+-v6*= looking for changes in 'foo/updates|dddd|source'...
+EOF
+rm -r -f db conf dists pool
+testsuccess
diff --git a/tests/template.test b/tests/template.test
new file mode 100644
index 0000000..e2de105
--- /dev/null
+++ b/tests/template.test
@@ -0,0 +1,4 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+testsuccess
diff --git a/tests/test.inc b/tests/test.inc
new file mode 100644
index 0000000..42d51b5
--- /dev/null
+++ b/tests/test.inc
@@ -0,0 +1,237 @@
+# Shell script snippets used in the test scripts...
+
+set -e -u
+
+export LC_ALL=C
+
+testrun() {
+rules=$1
+shift
+if test "x$rules" = "x" ; then
+ "$TESTTOOL" -C $TRACKINGTESTOPTIONS $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@"
+elif test "x$rules" = "x-" ; then
+ "$TESTTOOL" -r -C $TRACKINGTESTOPTIONS $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@"
+else
+ "$TESTTOOL" -r -C $TRACKINGTESTOPTIONS $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@" 3<"$rules".rules
+fi
+}
+testout() {
+rules=$1
+shift
+if test "x$rules" = "x" ; then
+ "$TESTTOOL" -o results $TRACKINGTESTOPTIONS $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@"
+elif test "x$rules" = "x-" ; then
+ "$TESTTOOL" -o results -r $TRACKINGTESTOPTIONS $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@"
+else
+ "$TESTTOOL" -o results -r $TRACKINGTESTOPTIONS $TESTOPTIONS "$REPREPRO" $REPREPROOPTIONS "$@" 3<"$rules".rules
+fi
+}
+dogrep() {
+echo grep -q "$@"
+grep -q "$@"
+}
+dongrep() {
+echo "!grep" -q "$@"
+! grep -q "$@"
+}
+dodiff() {
+echo diff -u "$@"
+diff -u "$@"
+}
+dodo() {
+echo "$@"
+"$@"
+}
+
+if test -z "$SRCDIR" || ! test -d "$SRCDIR" ; then
+ echo "SRCDIR='$SRCDIR' not a valid directory!" >&2
+ exit 1
+fi
+if test -z "$TESTSDIR" || ! test -d "$TESTSDIR" ; then
+ echo "TESTSDIR='$TESTSDIR' not a valid directory!" >&2
+ exit 1
+fi
+if test -z "$WORKDIR" || ! test -d "$WORKDIR" ; then
+ echo "WORKDIR='$WORKDIR' not a valid directory!" >&2
+ exit 1
+fi
+
+# avoid architecture dependency of the test-suite:
+export DEB_HOST_ARCH="abacus"
+
+export PATH="$TESTSDIR:$PATH"
+if ! [ -x "$REPREPRO" ] ; then
+ echo "Could not find $REPREPRO!" >&2
+ exit 1
+fi
+
+checknolog() {
+ dodo test ! -f logs/"$1"
+}
+checklog() {
+ sort > results.log.expected
+ LOGDATE="$(date +'%Y-%m-%d %H:')"
+ echo normalizing "$1": DATESTR is "$LOGDATE??:??"
+ sed -e 's/^'"$LOGDATE"'[0-9][0-9]:[0-9][0-9] /DATESTR /g' logs/"$1" | sort > results.log
+ dodiff results.log.expected results.log
+ rm logs/"$1" results.log
+}
+md5() {
+md5sum "$1" | cut -d' ' -f1
+}
+sha1() {
+sha1sum "$1" | cut -d' ' -f1
+}
+sha256() {
+sha256sum "$1" | cut -d' ' -f1
+}
+printindexpart() {
+ FILENAME="$1"
+ dpkg-deb -I "$FILENAME" control >"$FILENAME".control
+ ed -s "$FILENAME".control << EOF
+H
+/^Description:/ kd
+/^Priority/ m 'd-1
+/^Section/ m 'd-1
+'d i
+Filename: $FILENAME
+Size: $(stat -c "%s" "$FILENAME")
+SHA256: $(sha256 "$FILENAME")
+SHA1: $(sha1 "$FILENAME")
+MD5sum: $(md5 "$FILENAME")
+.
+$ a
+
+.
+w
+q
+EOF
+cat "$FILENAME".control
+rm "$FILENAME".control
+}
+withoutchecksums() {
+awk 'BEGIN{inheader=0} /^Checksums-.*:/ || (inheader && /^ /) {inheader = 1; next} {inheader = 0 ; print}' "$@"
+}
+mdandsize() {
+cat <<EOF
+$(md5sum "$1" | cut -d' ' -f1) $(stat -c "%s" "$1")
+EOF
+}
+sha() {
+echo -n ":1:"
+sha1sum "$1" | cut -d' ' -f1
+}
+sha1andsize() {
+cat <<EOF
+$(sha1sum "$1" | cut -d' ' -f1) $(stat -c "%s" "$1")
+EOF
+}
+sha1and7size() {
+cat <<EOF
+$(sha1sum "$1" | cut -d' ' -f1) $(stat -c "%7s" "$1")
+EOF
+}
+sha2() {
+echo -n ":2:"
+sha256sum "$1" | cut -d' ' -f1
+}
+sha2andsize() {
+cat <<EOF
+$(sha256sum "$1" | cut -d' ' -f1) $(stat -c "%s" "$1")
+EOF
+}
+sizeonly() {
+stat -c "%s" "$1"
+}
+sha2only() {
+sha256sum "$1" | cut -d' ' -f1
+}
+fullchecksum() {
+cat <<EOF
+$(sha "$1") $(sha2 "$1") $(md5sum "$1" | cut -d' ' -f1) $(stat -c "%s" "$1")
+EOF
+}
+md5releaseline() {
+ echo "$(mdandsize dists/"$1"/"$2") $2"
+}
+sha1releaseline() {
+ echo "$(sha1andsize dists/"$1"/"$2") $2"
+}
+sha2releaseline() {
+ echo "$(sha2andsize dists/"$1"/"$2") $2"
+}
+normalizerelease() {
+ sed -e 's/^Date: .*/Date: normalized/' "$1"
+}
+
+EMPTYMD5ONLY="d41d8cd98f00b204e9800998ecf8427e"
+EMPTYMD5="d41d8cd98f00b204e9800998ecf8427e 0"
+EMPTYGZMD5="7029066c27ac6f5ef18d660d5741979a 20"
+EMPTYBZ2MD5="4059d198768f9f8dc9372dc1c54bc3c3 14"
+EMPTYSHA1="da39a3ee5e6b4b0d3255bfef95601890afd80709 0"
+EMPTYGZSHA1="46c6643f07aa7f6bfe7118de926b86defc5087c4 20"
+EMPTYBZ2SHA1="64a543afbb5f4bf728636bdcbbe7a2ed0804adc2 14"
+EMPTYSHA2="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0"
+EMPTYGZSHA2="59869db34853933b239f1e2219cf7d431da006aa919635478511fabbfc8849d2 20"
+EMPTYBZ2SHA2="d3dda84eb03b9738d118eb2be78e246106900493c0ae07819ad60815134a8058 14"
+
+testsuccess() {
+ echo "Test$TESTNAME completed successfully"
+}
+
+odb() {
+ printf -- '-v2*=Created directory "./db"'
+}
+
+otd() {
+ local name="$1" version="$2" codename="$3"
+ printf -- "-d1*=db: '%s' '%s' removed from tracking.db(%s)." "$name" "$version" "$codename"
+}
+ottd() {
+ local name="$1" version="$2" codename="$3"
+ printf -- "-t1*=db: '%s' '%s' removed from tracking.db(%s)." "$name" "$version" "$codename"
+}
+ota() {
+ printf -- "-d1*=db: '%s' added to tracking.db(%s)." "$2" "$1"
+}
+otta() {
+ printf -- "-t1*=db: '%s' added to tracking.db(%s)." "$2" "$1"
+}
+ofa() {
+ printf -- "-d1*=db: '%s' added to checksums.db(pool)." "$1"
+}
+ofd() {
+ if ${2:-true} ; then
+ printf -- "-v1${3-*}"'=deleting and forgetting %s\n' "$1"
+ fi
+ printf -- "-d1${3-*}=db: '%s' removed from checksums.db(pool)." "$1"
+}
+opa() {
+ local name="$1" version="$2" codename="$3" component="$4" arch="$5" type="$6" u=""
+ if test "$type" = "udeb" ; then u='u|' ; fi
+ printf -- "-d1*=db: '%s' added to packages.db(%s%s|%s|%s)." \
+ "$name" "$u" "$codename" "$component" "$arch"
+}
+opu() {
+ local name="$1" oldversion="$2" version="$3" codename="$4" component="$5" arch="$6" type="$7" u=""
+ if test "$type" = "udeb" ; then u='u|' ; fi
+ printf -- "-d1*=db: '%s' removed from packages.db(%s%s|%s|%s).\n" \
+ "$name" "$u" "$codename" "$component" "$arch"
+ printf -- "-d1*=db: '%s' added to packages.db(%s%s|%s|%s)." \
+ "$name" "$u" "$codename" "$component" "$arch"
+}
+opd() {
+ local name="$1" version="$2" codename="$3" component="$4" arch="$5" type="$6" u=""
+ if test "$type" = "udeb" ; then u='u|' ; fi
+ printf -- "-v1*=removing '%s' from '%s%s|%s|%s'...\n" \
+ "$name" "$u" "$codename" "$component" "$arch"
+ printf -- "-d1*=db: '%s' removed from packages.db(%s%s|%s|%s)." \
+ "$name" "$u" "$codename" "$component" "$arch"
+}
+
+cat > empty.rules <<EOF
+stdout
+stderr
+returns 0
+EOF
+
diff --git a/tests/test.sh b/tests/test.sh
new file mode 100755
index 0000000..64851f6
--- /dev/null
+++ b/tests/test.sh
@@ -0,0 +1,271 @@
+#!/bin/dash
+
+# This needs installed:
+# apt, dpkg-dev, ed, python3-apt, xz, lzma, python3, dbX.Y-util
+# it will fail if run over a changing hour
+
+set -e -u
+
+export LC_ALL=C
+
+SRCDIR="$(readlink -e "$(dirname $0)/..")"
+WORKDIR="`pwd`/testdir"
+USE_VALGRIND=""
+VALGRIND_LEAK=summary
+VALGRIND_EXTRA_OPTIONS=""
+VALGRIND_SUP=""
+TESTOPTIONS=""
+VERBOSEDB="1"
+TESTSHELLOPTS=
+testtorun="all"
+verbosity=6
+deleteifmarked=true
+
+while [ $# -gt 0 ] ; do
+ case "$1" in
+ --srcdir)
+ shift
+ SRCDIR="$(readlink -e "$1")"
+ shift
+ ;;
+ --neverdelete)
+ deleteifmarked=false
+ shift
+ ;;
+ --test)
+ shift
+ testtorun="$1"
+ shift
+ ;;
+ --trace)
+ shift
+ TESTSHELLOPTS=-x
+ ;;
+ --delete)
+ if ! $deleteifmarked ; then
+ rm -r "$WORKDIR" || true
+ fi
+ shift
+ ;;
+ --valgrind)
+ USE_VALGRIND=1
+ shift
+ ;;
+ --valgrind)
+ USE_VALGRIND=1
+ VALGRIND_LEAK=full
+ shift
+ ;;
+ --valgrind-supp)
+ USE_VALGRIND=1
+ shift
+ VALGRIND_SUP="$1"
+ shift
+ ;;
+ --valgrind-opts)
+ shift
+ VALGRIND_EXTRA_OPTIONS="${VALGRIND_EXTRA_OPTIONS} $1"
+ shift
+ ;;
+ --verbosity)
+ shift
+ verbosity="$1"
+ shift
+ ;;
+ --noverbosedb)
+ VERBOSEDB=""
+ shift
+ ;;
+ --*)
+ echo "Unsupported option $1" >&2
+ exit 1
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
+if [ "2" -lt "$#" ] ; then
+ echo "Syntax: test.sh [<testtool-binary>] [<reprepro-binary>]" >&2
+ exit 1
+fi
+echo "SRCDIR is '$SRCDIR'"
+if [ ! -d "$SRCDIR" ] || [ ! -d "$SRCDIR/tests" ] ; then
+ echo "Error: Could not find source directory (tried: '$SRCDIR')!" >&2
+ exit 1
+fi
+TESTSDIR="$SRCDIR/tests"
+if [ "1" -le "$#" ] ; then
+ TESTTOOL="$(readlink -e "$1")"
+else
+ TESTTOOL=testtool
+fi
+if [ "2" -le "$#" ] ; then
+ REPREPRO="$(readlink -e "$2")"
+else
+ REPREPRO="$SRCDIR/reprepro"
+fi
+RREDTOOL="$(dirname "$REPREPRO")/rredtool"
+
+if [ -z "$TESTOPTIONS" ] ; then
+ if [ -z "$USE_VALGRIND" ] ; then
+ TESTOPTIONS="-e -a"
+ elif [ -z "$VALGRIND_SUP" ] ; then
+ # leak-check=full is better than leak-check=summary,
+ # sadly squeeze's valgrind counts them into the error number
+ # with full, and we want to ignore them for childs....
+ TESTOPTIONS="-e -a --debug ${VALGRIND_EXTRA_OPTIONS} --leak-check=${VALGRIND_LEAK} --suppressions=$TESTSDIR/valgrind.supp"
+ else
+ TESTOPTIONS="-e -a --debug ${VALGRIND_EXTRA_OPTIONS} --leak-check=${VALGRIND_LEAK} --suppressions=$VALGRIND_SUP"
+ fi
+fi
+case "$verbosity" in
+ -1) VERBOSITY="-s" ;;
+ 0) VERBOSITY="" ;;
+ 1) VERBOSITY="-v" ;;
+ 2) VERBOSITY="-vv" ;;
+ 3) VERBOSITY="-vvv" ;;
+ 4) VERBOSITY="-vvvv" ;;
+ 5) VERBOSITY="-vvvvv" ;;
+ 6) VERBOSITY="-vvvvvv" ;;
+ *) echo "Unsupported verbosity $verbosity" >&2
+ exit 1
+ ;;
+esac
+TESTOPTIONS="-D v=$verbosity $TESTOPTIONS"
+REPREPROOPTIONS="$VERBOSITY"
+if test -n "$VERBOSEDB" ; then
+ TESTOPTIONS="-D x=0 -D d=1 $TESTOPTIONS"
+ REPREPROOPTIONS="--verbosedb $REPREPROOPTIONS"
+else
+ TESTOPTIONS="-D x=0 -D d=0 $TESTOPTIONS"
+fi
+TRACKINGTESTOPTIONS="-D t=0"
+
+if ! [ -x "$REPREPRO" ] ; then
+ echo "Could not find $REPREPRO!" >&2
+ exit 1
+fi
+TESTTOOLVERSION="`$TESTTOOL --version`"
+case $TESTTOOLVERSION in
+ "testtool version "*) ;;
+ *) echo "Failed to get version of testtool($TESTTOOL)"
+ exit 1
+ ;;
+esac
+
+if test -d "$WORKDIR" && test -f "$WORKDIR/ThisDirectoryWillBeDeleted" && $deleteifmarked ; then
+ rm -r "$WORKDIR" || exit 3
+fi
+
+if ! which fakeroot >/dev/null 2>&1 ; then
+ echo "WARNING: fakeroot not installed, some tests might fail!"
+fi
+if ! which python3 >/dev/null 2>&1 ; then
+ echo "WARNING: python3 not installed, some tests might fail!"
+fi
+if ! which lzma >/dev/null 2>&1 ; then
+ echo "WARNING: lzma not installed, some tests might fail!"
+fi
+if ! which ed >/dev/null 2>&1 ; then
+ echo "WARNING: ed not installed, some tests might fail!"
+fi
+if ! which lunzip >/dev/null 2>&1 ; then
+ echo "WARNING: lunzip not installed, some tests might be incomplete!"
+else
+if ! which lzip >/dev/null 2>&1 ; then
+ echo "WARNING: lunzip installed but lunzip not, some tests might fail!"
+fi
+fi
+if ! dpkg -s python3-apt | grep -q -s "Status: .* ok installed" ; then
+ echo "WARNING: python3-apt not installed, some tests might fail!"
+fi
+if ! dpkg -s dpkg-dev | grep -q -s "Status: .* ok installed" ; then
+ echo "WARNING: dpkg-dev not installed, most tests might fail!"
+fi
+
+mkdir "$WORKDIR" || exit 1
+echo "Remove this file to avoid silent removal" > "$WORKDIR"/ThisDirectoryWillBeDeleted
+cd "$WORKDIR"
+
+# dpkg-deb doesn't like too restrictive directories
+umask 022
+
+number_tests=0
+number_missing=0
+number_success=0
+number_skipped=0
+number_failed=0
+
+runtest() {
+ if ! test -f "$SRCDIR/tests/$1.test" ; then
+ echo "Cannot find $SRCDIR/tests/$1.test!" >&2
+ number_missing="$(( $number_missing + 1 ))"
+ return
+ fi
+ number_tests="$(( $number_tests + 1 ))"
+ echo "Running test '$1'.."
+ TESTNAME=" $1"
+ mkdir "dir_$1"
+ rc=0
+ ( cd "dir_$1" || exit 1
+ export TESTNAME
+ export SRCDIR TESTSDIR
+ export TESTTOOL RREDTOOL REPREPRO
+ export TRACKINGTESTOPTIONS TESTOPTIONS REPREPROOPTIONS verbosity
+ WORKDIR="$WORKDIR/dir_$1" CALLEDFROMTESTSUITE=true dash $TESTSHELLOPTS "$SRCDIR/tests/$1.test"
+ ) > "log_$1" 2>&1 || rc=$?
+ if test "$rc" -ne 0 ; then
+ number_failed="$(( $number_failed + 1 ))"
+ echo "test '$1' failed (see $WORKDIR/log_$1 for details)!" >&2
+ elif grep -q -s '^SKIPPED: ' "log_$1" ; then
+ number_skipped="$(( $number_skipped + 1 ))"
+ echo "test '$1' skipped:"
+ sed -n -e 's/^SKIPPED://p' "log_$1"
+ rm -r "dir_$1" "log_$1"
+ else
+ number_success="$(( $number_success + 1 ))"
+ rm -r "dir_$1" "log_$1"
+ fi
+}
+
+if test x"$testtorun" != x"all" ; then
+ runtest "$testtorun"
+else
+ runtest export
+ runtest buildinfo
+ runtest updatepullreject
+ runtest descriptions
+ runtest easyupdate
+ runtest srcfilterlist
+ runtest uploaders
+ runtest wrongarch
+ runtest flood
+ runtest exporthooks
+ runtest updatecorners
+ runtest packagediff
+ runtest includeextra
+ runtest atoms
+ runtest trackingcorruption
+ runtest layeredupdate
+ runtest layeredupdate2
+ runtest uncompress
+ runtest check
+ runtest flat
+ runtest subcomponents
+ runtest snapshotcopyrestore
+ runtest various1
+ runtest various2
+ runtest various3
+ runtest copy
+ runtest buildneeding
+ runtest morgue
+ runtest diffgeneration
+ runtest onlysmalldeletes
+ runtest override
+ runtest includeasc
+ runtest listcodenames
+fi
+echo "$number_tests tests, $number_success succeded, $number_failed failed, $number_skipped skipped, $number_missing missing"
+exit 0
diff --git a/tests/trackingcorruption.test b/tests/trackingcorruption.test
new file mode 100644
index 0000000..6110e26
--- /dev/null
+++ b/tests/trackingcorruption.test
@@ -0,0 +1,79 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+dodo test ! -d db
+mkdir -p conf
+echo "export silent-never" > conf/options
+cat > conf/distributions <<EOF
+Codename: breakme
+Components: something
+Architectures: abacus coal source
+Tracking: all
+EOF
+
+DISTRI=breakme PACKAGE=aa EPOCH="" VERSION=1 REVISION=-1 SECTION="base" genpackage.sh -sa
+
+testrun - include breakme test.changes 3<<EOF
+stdout
+$(odb)
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/something"
+-v2*=Created directory "./pool/something/a"
+-v2*=Created directory "./pool/something/a/aa"
+$(ofa 'pool/something/a/aa/aa-addons_1-1_all.deb')
+$(ofa 'pool/something/a/aa/aa_1-1_abacus.deb')
+$(ofa 'pool/something/a/aa/aa_1-1.tar.gz')
+$(ofa 'pool/something/a/aa/aa_1-1.dsc')
+$(opa 'aa-addons' x 'breakme' 'something' 'abacus' 'deb')
+$(opa 'aa-addons' x 'breakme' 'something' 'coal' 'deb')
+$(opa 'aa' x 'breakme' 'something' 'abacus' 'deb')
+$(opa 'aa' x 'breakme' 'something' 'source' 'dsc')
+$(ota 'breakme' 'aa')
+EOF
+rm aa_* aa-addons* test.changes
+
+dodo mv db/tracking.db .
+
+testrun - removesrc breakme aa 3<<EOF
+stderr
+*=Nothing about source package 'aa' found in the tracking data of 'breakme'!
+*=This either means nothing from this source in this version is there,
+*=or the tracking information might be out of date.
+EOF
+
+testrun - --keepunreferenced remove breakme aa aa-addons 3<<EOF
+stderr
+*=Could not find tracking data for aa_1-1 in breakme to remove old files from it.
+stdout
+$(opd 'aa' unset breakme something abacus deb)
+$(opd 'aa-addons' unset breakme something abacus deb)
+$(opd 'aa-addons' unset breakme something coal deb)
+$(opd 'aa' unset breakme something source dsc)
+EOF
+
+dodo mv tracking.db db/
+
+testrun - --keepunreferenced removesrc breakme aa 3<<EOF
+stderr
+*=Warning: tracking data might be inconsistent:
+*=cannot find 'aa' in 'breakme|something|abacus', but 'pool/something/a/aa/aa_1-1_abacus.deb' should be there.
+*=cannot find 'aa' in 'breakme|something|source', but 'pool/something/a/aa/aa_1-1.dsc' should be there.
+*=There was an inconsistency in the tracking data of 'breakme':
+*='pool/something/a/aa/aa-addons_1-1_all.deb' has refcount > 0, but was nowhere found.
+*='pool/something/a/aa/aa_1-1_abacus.deb' has refcount > 0, but was nowhere found.
+*='pool/something/a/aa/aa_1-1.dsc' has refcount > 0, but was nowhere found.
+*='pool/something/a/aa/aa_1-1.tar.gz' has refcount > 0, but was nowhere found.
+stdout
+$(otd 'aa' '1-1' 'breakme')
+-v1*=4 files lost their last reference.
+-v1*=(dumpunreferenced lists such files, use deleteunreferenced to delete them.)
+EOF
+
+testrun - retrack breakme 3<<EOF
+stderr
+stdout
+-v1*=Retracking breakme...
+EOF
+
+rm -r db conf pool
+testsuccess
diff --git a/tests/uncompress.test b/tests/uncompress.test
new file mode 100644
index 0000000..57ffabb
--- /dev/null
+++ b/tests/uncompress.test
@@ -0,0 +1,514 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+# First test if finding the binaries works properly...
+
+testrun - --lunzip=NONE --unxz=NONE __dumpuncompressors 3<<EOF
+stdout
+*=.gz: built-in + '/bin/gunzip'
+*=.bz2: built-in + '/bin/bunzip2'
+*=.lzma: built-in + '/usr/bin/unlzma'
+*=.xz: built-in
+*=.lz: not supported (install lzip or use --lunzip to tell where lunzip is).
+EOF
+
+testrun - --lunzip=NONE --gunzip=NONE --bunzip2=NONE --unlzma=NONE --unxz=NONE __dumpuncompressors 3<<EOF
+stdout
+*=.gz: built-in
+*=.bz2: built-in
+*=.lzma: built-in
+*=.xz: built-in
+*=.lz: not supported (install lzip or use --lunzip to tell where lunzip is).
+EOF
+
+testrun - --lunzip=NONE --gunzip=false --bunzip2=false --unlzma=false --unxz=NONE __dumpuncompressors 3<<EOF
+stdout
+*=.gz: built-in + '/bin/false'
+*=.bz2: built-in + '/bin/false'
+*=.lzma: built-in + '/bin/false'
+*=.xz: built-in
+*=.lz: not supported (install lzip or use --lunzip to tell where lunzip is).
+EOF
+
+touch fakeg fakeb fakel fakexz fakelz
+
+testrun - --lunzip=./fakelz --gunzip=./fakeg --bunzip2=./fakeb --unlzma=./fakel --unxz=./fakexz __dumpuncompressors 3<<EOF
+stdout
+*=.gz: built-in
+*=.bz2: built-in
+*=.lzma: built-in
+*=.xz: built-in
+*=.lz: not supported (install lzip or use --lunzip to tell where lunzip is).
+EOF
+
+chmod u+x fakeg fakeb fakel fakexz fakelz
+
+testrun - --lunzip=./fakelz --gunzip=./fakeg --bunzip2=./fakeb --unlzma=./fakel --unxz=./fakexz __dumpuncompressors 3<<EOF
+stdout
+*=.gz: built-in + './fakeg'
+*=.bz2: built-in + './fakeb'
+*=.lzma: built-in + './fakel'
+*=.xz: built-in + './fakexz'
+*=.lz: './fakelz'
+EOF
+
+rm fakeg fakeb fakel fakexz fakelz
+
+# Then test the builtin formats and the external one...
+
+echo "start" > testfile
+dd if=/dev/zero bs=1024 count=1024 >> testfile
+echo "" >> testfile
+echo "middle" >> testfile
+dd if=/dev/zero bs=1024 count=1024 >> testfile
+echo "" >> testfile
+echo "end" >> testfile
+
+echo "Ohm" > smallfile
+
+echo gzip -c testfile \> testfile.gz
+gzip -c testfile > testfile.gz
+echo bzip2 -c testfile \> testfile.bz2
+bzip2 -c testfile > testfile.bz2
+echo lzma -c testfile \> testfile.lzma
+lzma -c testfile > testfile.lzma
+echo xz -c testfile \> testfile.xz
+xz -c testfile > testfile.xz
+
+echo gzip -c smallfile \> smallfile.gz
+gzip -c smallfile > smallfile.gz
+echo bzip2 -c smallfile \> smallfile.bz2
+bzip2 -c smallfile > smallfile.bz2
+echo lzma -c smallfile \> smallfile.lzma
+lzma -c smallfile > smallfile.lzma
+echo xz -c smallfile \> smallfile.xz
+xz -c smallfile > smallfile.xz
+
+echo gzip -c \< /dev/null \> emptyfile.gz
+gzip -c < /dev/null > emptyfile.gz
+echo bzip2 -c \< /dev/null \> emptyfile.bz2
+bzip2 -c < /dev/null > emptyfile.bz2
+echo lzma -c \< /dev/null \> emptyfile.lzma
+lzma -c < /dev/null > emptyfile.lzma
+echo xz -c \< /dev/null \> emptyfile.xz
+xz -c < /dev/null > emptyfile.xz
+
+testrun - --lunzip /bin/cat __uncompress .lz notexists.lz notexists.lz.uncompressed 3<<EOF
+-v2*=Uncompress 'notexists.lz' into 'notexists.lz.uncompressed' using '/bin/cat'...
+*=Error 2 opening notexists.lz: No such file or directory
+-v0*=There have been errors!
+returns 254
+EOF
+
+if test -x /usr/bin/lzip ; then
+# uncompression message is different as this is no builtin.
+echo lzip -c testfile \> testfile.lz
+lzip -c testfile > testfile.lz
+echo lzip -c smallfile \> smallfile.lz
+lzip -c smallfile > smallfile.lz
+testrun - __uncompress .lz testfile.lz testfile.lz.uncompressed 3<<EOF
+-v2*=Uncompress 'testfile.lz' into 'testfile.lz.uncompressed' using '/usr/bin/lunzip'...
+EOF
+dodiff testfile testfile.lz.uncompressed
+rm *.uncompressed
+testrun - __uncompress .lz smallfile.lz smallfile.lz.uncompressed 3<<EOF
+-v2*=Uncompress 'smallfile.lz' into 'smallfile.lz.uncompressed' using '/usr/bin/lunzip'...
+EOF
+dodiff smallfile smallfile.lz.uncompressed
+rm *.uncompressed
+fi
+
+for ext in gz bz2 lzma xz ; do
+ testrun - __uncompress .${ext} testfile.${ext} testfile.${ext}.uncompressed 3<<EOF
+-v2*=Uncompress 'testfile.${ext}' into 'testfile.${ext}.uncompressed'...
+EOF
+ dodiff testfile testfile.${ext}.uncompressed
+ rm *.uncompressed
+
+ testrun - __uncompress .${ext} smallfile.${ext} smallfile.${ext}.uncompressed 3<<EOF
+-v2*=Uncompress 'smallfile.${ext}' into 'smallfile.${ext}.uncompressed'...
+EOF
+ dodiff smallfile smallfile.${ext}.uncompressed
+ rm *.uncompressed
+done
+
+# unlzma does not support concatenated files, so we do neither.
+for ext in gz bz2 xz ; do
+ cat testfile.${ext} emptyfile.${ext} > concatenatedtestfile.${ext}
+ testrun - __uncompress .${ext} concatenatedtestfile.${ext} concatenatedtestfile.${ext}.uncompressed 3<<EOF
+-v2*=Uncompress 'concatenatedtestfile.${ext}' into 'concatenatedtestfile.${ext}.uncompressed'...
+EOF
+ dodiff testfile concatenatedtestfile.${ext}.uncompressed
+ rm concatenated*
+
+ cat testfile testfile > concatenatedtestfile
+ cat testfile.${ext} testfile.${ext} > concatenatedtestfile.${ext}
+ testrun - __uncompress .${ext} concatenatedtestfile.${ext} concatenatedtestfile.${ext}.uncompressed 3<<EOF
+-v2*=Uncompress 'concatenatedtestfile.${ext}' into 'concatenatedtestfile.${ext}.uncompressed'...
+EOF
+ dodiff concatenatedtestfile concatenatedtestfile.${ext}.uncompressed
+ rm concatenated*
+done
+
+# Test for trailing garbage detection
+for ext in gz bz2 lzma ; do
+ cat testfile.${ext} smallfile > invalidtestfile.${ext}
+ testrun - __uncompress .${ext} invalidtestfile.${ext} invalidtestfile.${ext}.uncompressed 3<<EOF
+stderr
+-v2*=Uncompress 'invalidtestfile.${ext}' into 'invalidtestfile.${ext}.uncompressed'...
+*=Error reading from invalidtestfile.${ext}: Trailing garbage after compressed data!
+-v0*=There have been errors!
+returns 255
+EOF
+ dodo test ! -e invalidtestfile.${ext}.uncompressed
+ rm invalid*
+done
+
+# .xz does not see the trailing stuff, but an end of file while reading the header:
+cat testfile.xz smallfile > invalidtestfile.xz
+testrun - __uncompress .xz invalidtestfile.xz invalidtestfile.xz.uncompressed 3<<EOF
+stderr
+-v2*=Uncompress 'invalidtestfile.xz' into 'invalidtestfile.xz.uncompressed'...
+*=Error 10 decompressing lzma data
+*=Error reading from invalidtestfile.xz: Uncompression error!
+-v0*=There have been errors!
+returns 255
+EOF
+dodo test ! -e invalidtestfile.xz.uncompressed
+rm invalid*
+
+touch fake.lz
+testrun - --lunzip=false __uncompress .lz fake.lz fake.lz.uncompressed 3<<EOF
+-v2*=Uncompress 'fake.lz' into 'fake.lz.uncompressed' using '/bin/false'...
+*='/bin/false' < fake.lz > fake.lz.uncompressed exited with errorcode 1!
+-v0*=There have been errors!
+returns 255
+EOF
+dodo test ! -e fake.lz.uncompressed
+
+
+# Now check for compressed parts of an .a file:
+
+cat > control <<EOF
+Package: fake
+Version: fake
+Architecture: all
+EOF
+
+# looks like control.tar.lzma is not possible because the name is too
+# long for the old ar format dpkg-deb needs...
+echo tar -cf - ./control \| bzip2 \> control.tar.bz2
+tar -cf - ./control | bzip2 > control.tar.bz2
+echo tar -cf - testfile\* \| lzma \> data.tar.lzma
+tar -cf - testfile* | lzma > data.tar.lzma
+echo tar -cf - testfile\* \| bzip2 \> data.tar.bz2
+tar -cf - testfile* | bzip2 > data.tar.bz2
+echo tar -cf - testfile\* \| gzip \> data.tar.gz
+tar -cf - testfile* | gzip > data.tar.gz
+echo tar -cf - testfile\* \| xz \> data.tar.xz
+tar -cf - testfile* | xz > data.tar.xz
+echo 2.0 > debian-binary
+datatestlist="gz bz2 lzma xz"
+for ext in $datatestlist ; do
+ dodo ar qcfS fake_${ext}.deb debian-binary control.tar.bz2 data.tar.${ext}
+ # one .deb with trailing garbage at the end of the data tar:
+ echo "trailing garbage" >> data.tar.${ext}
+ dodo ar qcfS fake_${ext}_t.deb debian-binary control.tar.bz2 data.tar.${ext}
+ # and one .deb where the the length is correct but the .ar header differs
+ cp fake_${ext}_t.deb fake_${ext}_w.deb
+ origlength=$(stat -c '%s' fake_${ext}.deb)
+ newlength=$(stat -c '%s' fake_${ext}_w.deb)
+ if test $((origlength + 18)) -eq $((newlength)) ; then
+ # new length is 17 + one padding, so original did not have padding:
+ truncate -s "$origlength" fake_${ext}_w.deb
+ else
+ # also remove the padding byte:
+ truncate -s "$((origlength - 1))" fake_${ext}_w.deb
+ fi
+done
+rm debian-binary control *.tar.*
+
+# TODO: there could be a problem here with .deb files that have data after the
+# ./control file in data.tar and using an external uncompressor.
+# But how to test this when there is no way to trigger it in the default built?
+
+testrun - __extractcontrol fake_gz.deb 3<<EOF
+stdout
+*=Package: fake
+*=Version: fake
+*=Architecture: all
+*=
+EOF
+for ext in $datatestlist ; do
+testrun - __extractfilelist fake_${ext}.deb 3<<EOF
+stdout
+*=/testfile
+*=/testfile.bz2
+*=/testfile.gz
+*=/testfile.lzma
+=/testfile.xz
+=/testfile.lz
+EOF
+ if test $ext = xz ; then
+testrun - __extractfilelist fake_${ext}_t.deb 3<<EOF
+stderr
+*=Error 9 decompressing lzma data
+*=Error reading data.tar from fake_xz_t.deb: Uncompression error
+-v0*=There have been errors!
+return 255
+EOF
+ else
+testrun - __extractfilelist fake_${ext}_t.deb 3<<EOF
+stderr
+*=Error reading data.tar from fake_${ext}_t.deb: Trailing garbage after compressed data
+-v0*=There have been errors!
+return 255
+EOF
+ fi
+ if test $ext = xz ; then
+ : # xz has too large blocks to trigger this (tar is done before this is read)
+ else
+testrun - __extractfilelist fake_${ext}_w.deb 3<<EOF
+*=Error reading data.tar from fake_${ext}_w.deb: Compressed data of unexpected length
+-v0*=There have been errors!
+return 255
+EOF
+ fi
+done
+
+rm fake_*.deb
+
+for compressor in lz lzma ; do
+case $compressor in
+ lz)
+ compressor_program=lzip
+ uncompressor=lunzip
+ ;;
+ lzma)
+ compressor_program=lzma
+ uncompressor=""
+ ;;
+esac
+export uncompressor
+if ! test -x /usr/bin/$compressor_program ; then
+ echo "SKIPPING $compressor because /usr/bin/$compressor_program is missing!"
+ continue
+fi
+
+# Now check extracting Section/Priority from an .dsc
+mkdir debian
+cat > debian/control <<EOF
+Package: fake
+Maintainer: Me
+Section: admin
+Priority: extra
+
+Package: abinary
+Architecture: all
+EOF
+echo generating fake dirs
+for n in $(seq 100000) ; do echo "/$n" ; done > debian/dirs
+dd if=/dev/zero of=debian/zzz bs=1024 count=4096
+tar -cf - debian | $compressor_program > fake_1-1.debian.tar.$compressor
+mkdir fake-1
+mkdir fake-1.orig
+cp -al debian fake-1/debian
+cp -al debian fake-1.orig/debian
+sed -e 's/1/2/' fake-1/debian/dirs > fake-1/debian.dirs.new
+mv fake-1/debian.dirs.new fake-1/debian/dirs
+diff -ruN fake-1.orig fake-1 | $compressor_program > fake_1-1.diff.$compressor
+rm -r debian
+
+# .debian.tar and .diff usually do not happen at the same time, but easier testing...
+cat > fake_1-1.dsc << EOF
+Format: 3.0
+Source: fake
+Binary: abinary
+Architecture: all
+Version: 17
+Maintainer: Me
+Files:
+ $(mdandsize fake_1-1.diff.${compressor}) fake_1-1.diff.${compressor}
+ $(mdandsize fake_1-1.debian.tar.${compressor}) fake_1-1.debian.tar.${compressor}
+ 00000000000000000000000000000000 0 fake_1.orig.tar.${compressor}
+EOF
+
+testrun - __extractsourcesection fake_1-1.dsc 3<<EOF
+stdout
+*=Section: admin
+*=Priority: extra
+EOF
+
+# It would be nice to damage the .lzma file here, but that has a problem:
+# A random damage to the file will usually lead to some garbage output
+# before lzma realizes the error.
+# Once reprepro sees the garbage (which will usually not be a valid diff)
+# it will decide it is a format it does not understand and abort further
+# reading giving up.
+# This is a race condition with one of the following results:
+# reprepro is much faster: no error output (as unknown format is no error,
+# but only no success)
+# reprepro a bit faster: unlzma can still output an error, but not
+# is terminated by reprepro before issuing an error code.
+# unlzma is faster: reprepro will see an child returning with error...
+#
+# Thus we can only fake a damaged file by replacing the uncompressor:
+
+if test -n "${uncompressor}" ; then
+testrun - --${uncompressor}=brokenuncompressor.sh __extractsourcesection fake_1-1.dsc 3<<EOF
+returns 255
+*=brokenuncompressor.sh: claiming broken archive
+*=Error reading from ./fake_1-1.diff.${compressor}: $TESTSDIR/brokenuncompressor.sh exited with code 1!
+-v0*=There have been errors!
+stdout
+EOF
+fi
+
+mv fake_1-1.debian.tar.${compressor} save.tar.${compressor}
+
+# a missing file is no error, but no success either...
+testrun - __extractsourcesection fake_1-1.dsc 3<<EOF
+stdout
+EOF
+
+cp save.tar.${compressor} fake_1.orig.tar.${compressor}
+# a missing file is no error, but no success either (and not reading further files)
+testrun - __extractsourcesection fake_1-1.dsc 3<<EOF
+stdout
+EOF
+
+dodo mkdir debian
+dodo touch debian/test
+echo tar -cf - debian \| ${compressor_program} \> fake_1-1.debian.tar.${compressor}
+tar -cf - debian | ${compressor_program} > fake_1-1.debian.tar.${compressor}
+rm -r debian
+
+testrun - __extractsourcesection fake_1-1.dsc 3<<EOF
+stdout
+*=Section: admin
+*=Priority: extra
+EOF
+
+if test -n "${uncompressor}" ; then
+touch breakon2nd
+testrun - --${uncompressor}=brokenuncompressor.sh __extractsourcesection fake_1-1.dsc 3<<EOF
+returns 255
+*=brokenuncompressor.sh: claiming broken archive
+*=Error reading from ./fake_1-1.debian.tar.${compressor}: $TESTSDIR/brokenuncompressor.sh exited with code 1!
+-v0*=There have been errors!
+stdout
+EOF
+
+testrun - --${uncompressor}=brokenuncompressor.sh __extractsourcesection fake_1-1.dsc 3<<EOF
+returns 255
+*=brokenuncompressor.sh: claiming broken archive
+*=Error reading from ./fake_1-1.diff.${compressor}: $TESTSDIR/brokenuncompressor.sh exited with code 1!
+-v0*=There have been errors!
+stdout
+EOF
+fi
+
+
+# sadly different output depending on libarchive version....
+# dd if=/dev/zero of=fake_1-1.debian.tar.lzma bs=5 count=1
+#
+# testrun - __extractsourcesection fake_1-1.dsc 3<<EOF
+# returns 255
+# *=/usr/bin/unlzma: Read error
+# *=Error 84 trying to extract control information from ./fake_1-1.debian.tar.${compressor}:
+# *=Empty input file: Invalid or incomplete multibyte or wide character
+# -v0*=There have been errors!
+# stdout
+# EOF
+
+mv save.tar.${compressor} fake_1-1.debian.tar.${compressor}
+rm fake_1.orig.tar.${compressor}
+
+# now check only partial reading of the .diff
+# (i.e. diff containing a control):
+rm fake-1/debian/control
+cat > fake-1/debian/control <<EOF
+Package: fake
+Maintainer: MeToo
+Section: base
+Priority: required
+
+Package: abinary
+Architecture: all
+EOF
+cat > fake-1/debian/aaaaa <<EOF
+also test debian/control not being the first file...
+EOF
+diff -ruN fake-1.orig fake-1 | ${compressor_program} > fake_1-1.diff.${compressor}
+rm -r fake-1 fake-1.orig
+
+
+cat > fake_1-1.dsc << EOF
+Format: 3.0
+Source: fake
+Binary: abinary
+Architecture: all
+Version: 17
+Maintainer: Me
+Files:
+ $(mdandsize fake_1-1.diff.${compressor}) fake_1-1.diff.${compressor}
+ $(mdandsize fake_1-1.debian.tar.${compressor}) fake_1-1.debian.tar.${compressor}
+ 00000000000000000000000000000000 0 fake_1.orig.tar.${compressor}
+EOF
+
+testrun - __extractsourcesection fake_1-1.dsc 3<<EOF
+stdout
+*=Section: base
+*=Priority: required
+EOF
+
+if test -n "$uncompressor" ; then
+testrun - --${uncompressor}=false __extractsourcesection fake_1-1.dsc 3<<EOF
+returns 255
+*=Error reading from ./fake_1-1.diff.${compressor}: /bin/false exited with code 1!
+-v0*=There have been errors!
+stdout
+EOF
+fi
+
+done
+
+rm testfile* smallfile* emptyfile*
+
+cat > fake_1-2.diff <<EOF
+--- bla/Makefile
++++ bla/Makefile
+@@ -1000,1 +1000,1 @@
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+--- bla/debian/control
++++ bla/debian/control
+@@ -0,0 +1,10 @@
++Source: fake
++Section: sssss
++# new-fangled comment
++Priority: ppp
++Homepage: gopher://never-never-land/
++
+EOF
+dodo gzip fake_1-2.diff
+
+cat > fake_1-2.dsc << EOF
+Format: 3.0
+Source: fake
+Binary: abinary
+Architecture: all
+Version: 17
+Maintainer: Me
+Files:
+ $(mdandsize fake_1-2.diff.gz) fake_1-2.diff.gz
+ 00000000000000000000000000000000 0 fake_1.orig.tar.gz
+EOF
+
+testrun - __extractsourcesection fake_1-2.dsc 3<<EOF
+stdout
+*=Section: sssss
+*=Priority: ppp
+EOF
+
+rm fake*
+testsuccess
diff --git a/tests/updatecorners.test b/tests/updatecorners.test
new file mode 100644
index 0000000..ee6f905
--- /dev/null
+++ b/tests/updatecorners.test
@@ -0,0 +1,176 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+# test some corner cases in updating:
+# IgnoreInRelease, force, errors, resuming...
+
+mkdir -p conf test/dists/a/c/source test/test lists
+
+echo "test" > test/test/test.dsc
+echo "fake-gz-file" > test/test/test.tar.gz
+
+cat >test/dists/a/c/source/Sources <<EOF
+Package: test
+Version: 7777
+Priority: extra
+Section: somewhere
+Maintainer: noone
+Directory: test
+Files:
+ $(mdandsize test/test/test.dsc) test.dsc
+ $(mdandsize test/test/test.tar.gz) test.tar.gz
+EOF
+
+sourcesmd=$(md5 test/dists/a/c/source/Sources)
+sourcessize=$(stat -c "%s" test/dists/a/c/source/Sources)
+cat > test/dists/a/InRelease <<EOF
+Codename: a
+MD5Sum:
+ $sourcesmd $sourcessize c/source/Sources
+EOF
+lzma test/dists/a/c/source/Sources
+
+cat >conf/distributions <<EOF
+Codename: t
+Architectures: source
+Components: c
+Update: u
+EOF
+
+cat >conf/updates <<EOF
+Name: u
+Method: copy:$WORKDIR/test
+VerifyRelease: blindtrust
+Suite: a
+EOF
+
+testrun - -b . update 3<<EOF
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/test/dists/a/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/test/dists/a/InRelease'
+*=WARNING: No signature found in ./lists/u_a_InRelease, assuming it is unsigned!
+*=aptmethod error receiving 'copy:$WORKDIR/test/dists/a/c/source/Sources':
+='Failed to stat - stat (2 No such file or directory)'
+='Failed to stat - stat (2: No such file or directory)'
+-v0*=There have been errors!
+stdout
+$(odb)
+returns 255
+EOF
+
+cat >>conf/updates <<EOF
+DownloadListsAs: .lzma
+EOF
+
+testrun - -b . update 3<<EOF
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/test/dists/a/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/test/dists/a/InRelease'
+*=WARNING: No signature found in ./lists/u_a_InRelease, assuming it is unsigned!
+*=Error: './lists/u_a_InRelease' only lists unrequested compressions of 'c/source/Sources'.
+*=Try changing your DownloadListsAs to request e.g. '.'.
+-v0*=There have been errors!
+returns 255
+EOF
+ed -s conf/updates <<EOF
+g/^DownloadListsAs:/s/.lzma/force.gz force.lzma/
+w
+q
+EOF
+
+testrun - -b . update 3<<EOF
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/test/dists/a/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/test/dists/a/InRelease'
+*=WARNING: No signature found in ./lists/u_a_InRelease, assuming it is unsigned!
+*=aptmethod error receiving 'copy:$WORKDIR/test/dists/a/c/source/Sources.gz':
+='Failed to stat - stat (2 No such file or directory)'
+='Failed to stat - stat (2: No such file or directory)'
+-v6*=aptmethod start 'copy:${WORKDIR}/test/dists/a/c/source/Sources.lzma'
+-v1*=aptmethod got 'copy:${WORKDIR}/test/dists/a/c/source/Sources.lzma'
+-v2*=Uncompress './lists/u_a_c_Sources.lzma' into './lists/u_a_c_Sources' using '/usr/bin/unlzma'...
+stdout
+-v0*=Calculating packages to get...
+-v3*= processing updates for 't|c|source'
+-v5*= reading './lists/u_a_c_Sources'
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/c"
+-v2*=Created directory "./pool/c/t"
+-v2*=Created directory "./pool/c/t/test"
+stderr
+-v6*=aptmethod start 'copy:${WORKDIR}/test/test/test.dsc'
+-v1*=aptmethod got 'copy:${WORKDIR}/test/test/test.dsc'
+-v6*=aptmethod start 'copy:${WORKDIR}/test/test/test.tar.gz'
+-v1*=aptmethod got 'copy:${WORKDIR}/test/test/test.tar.gz'
+stdout
+-v0*=Getting packages...
+$(ofa 'pool/c/t/test/test.dsc')
+$(ofa 'pool/c/t/test/test.tar.gz')
+-v1*=Shutting down aptmethods...
+-v0*=Installing (and possibly deleting) packages...
+$(opa 'test' x 't' 'c' 'source' 'dsc')
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/t"
+-v2*=Created directory "./dists/t/c"
+-v2*=Created directory "./dists/t/c/source"
+-v6*= looking for changes in 't|c|source'...
+-v6*= creating './dists/t/c/source/Sources' (gzipped)
+EOF
+
+# test what happens if some compression is forces (i.e. not listed
+# in the InRelease file), but the downloaded file is not correct:
+
+ed -s test/dists/a/InRelease <<EOF
+,s/^ [^ ]*/ 00000000000000000000000000000000/
+w
+q
+EOF
+
+testrun - -b . update 3<<EOF
+stderr
+-v6*=aptmethod start 'copy:$WORKDIR/test/dists/a/InRelease'
+-v1*=aptmethod got 'copy:$WORKDIR/test/dists/a/InRelease'
+*=WARNING: No signature found in ./lists/u_a_InRelease, assuming it is unsigned!
+*=aptmethod error receiving 'copy:$WORKDIR/test/dists/a/c/source/Sources.gz':
+='Failed to stat - stat (2 No such file or directory)'
+='Failed to stat - stat (2: No such file or directory)'
+-v6*=aptmethod start 'copy:${WORKDIR}/test/dists/a/c/source/Sources.lzma'
+-v1*=aptmethod got 'copy:${WORKDIR}/test/dists/a/c/source/Sources.lzma'
+-v2*=Uncompress './lists/u_a_c_Sources.lzma' into './lists/u_a_c_Sources' using '/usr/bin/unlzma'...
+*=Wrong checksum of uncompressed content of './lists/u_a_c_Sources.lzma':
+*=md5 expected: 00000000000000000000000000000000, got: $sourcesmd
+-v0*=There have been errors!
+returns 254
+EOF
+
+rm test/dists/a/InRelease
+
+testrun - -b . update 3<<EOF
+stderr
+*=aptmethod error receiving 'copy:$WORKDIR/test/dists/a/InRelease':
+*=aptmethod error receiving 'copy:$WORKDIR/test/dists/a/Release':
+='Failed to stat - stat (2 No such file or directory)'
+='Failed to stat - stat (2: No such file or directory)'
+-v0*=There have been errors!
+returns 255
+EOF
+
+echo "IgnoreRelease: Yes" >> conf/updates
+
+testrun - -b . update 3<<EOF
+stderr
+*=aptmethod error receiving 'copy:$WORKDIR/test/dists/a/c/source/Sources.gz':
+='Failed to stat - stat (2 No such file or directory)'
+='Failed to stat - stat (2: No such file or directory)'
+-v6*=aptmethod start 'copy:${WORKDIR}/test/dists/a/c/source/Sources.lzma'
+-v1*=aptmethod got 'copy:${WORKDIR}/test/dists/a/c/source/Sources.lzma'
+-v2*=Uncompress './lists/u_a_c_Sources.lzma' into './lists/u_a_c_Sources' using '/usr/bin/unlzma'...
+stdout
+-v0*=Calculating packages to get...
+-v3*= processing updates for 't|c|source'
+-v5*= reading './lists/u_a_c_Sources'
+EOF
+
+rm -r conf db test lists pool dists
+testsuccess
diff --git a/tests/updatepullreject.test b/tests/updatepullreject.test
new file mode 100644
index 0000000..a2b4bbd
--- /dev/null
+++ b/tests/updatepullreject.test
@@ -0,0 +1,555 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+dodo test ! -d db
+mkdir -p conf
+cat > conf/distributions <<EOF
+Codename: 1234
+Components: component
+Architectures: something source
+DebIndices: Packages .xz
+DscIndices: Sources .xz
+Update: test
+EOF
+cat > conf/updates <<EOF
+Name: test
+GetInRelease: no
+VerifyRelease: blindtrust
+Method: file:$WORKDIR/in
+FilterList: error filterlist
+FilterSrcList: error filtersrclist
+Suite: 4321
+EOF
+echo > conf/filterlist
+echo > conf/filtersrclist
+
+testrun - -b . export 1234 3<<EOF
+stderr
+stdout
+$(odb)
+-v1*=Exporting 1234...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/1234"
+-v2*=Created directory "./dists/1234/component"
+-v2*=Created directory "./dists/1234/component/binary-something"
+-v6*= exporting '1234|component|something'...
+-v6*= creating './dists/1234/component/binary-something/Packages' (xzed)
+-v2*=Created directory "./dists/1234/component/source"
+-v6*= exporting '1234|component|source'...
+-v6*= creating './dists/1234/component/source/Sources' (xzed)
+EOF
+
+mkdir lists
+mkdir -p in/dists/4321
+touch in/dists/4321/Release
+
+testrun - -b . update 1234 3<<EOF
+returns 255
+stderr
+-v6=aptmethod start 'file:$WORKDIR/in/dists/4321/Release'
+-v1*=aptmethod got 'file:$WORKDIR/in/dists/4321/Release'
+-v2*=Copy file '$WORKDIR/in/dists/4321/Release' to './lists/test_4321_Release'...
+*=Missing checksums in Release file './lists/test_4321_Release'!
+-v0*=There have been errors!
+stdout
+EOF
+
+echo "SHA256:" > in/dists/4321/Release
+
+testrun - -b . update 1234 3<<EOF
+returns 254
+stderr
+-v6=aptmethod start 'file:$WORKDIR/in/dists/4321/Release'
+-v1*=aptmethod got 'file:$WORKDIR/in/dists/4321/Release'
+-v2*=Copy file '$WORKDIR/in/dists/4321/Release' to './lists/test_4321_Release'...
+*=Could not find 'component/binary-something/Packages' within './lists/test_4321_Release'
+-v0*=There have been errors!
+stdout
+EOF
+
+mkdir -p in/dists/4321/component/source in/dists/4321/component/binary-something
+xz -c < /dev/null > in/dists/4321/component/source/Sources.xz
+xz -c < /dev/null > in/dists/4321/component/binary-something/Packages.xz
+cat > in/dists/4321/Release <<EOF
+SHA256:
+ $EMPTYSHA2 component/source/Sources
+ $(sha2andsize in/dists/4321/component/source/Sources.xz) component/source/Sources.xz
+ $(sha2andsize in/dists/4321/component/binary-something/Packages.xz) component/binary-something/Packages.xz
+EOF
+
+testrun - -b . update 1234 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/in/dists/4321/Release'
+-v1*=aptmethod got 'file:$WORKDIR/in/dists/4321/Release'
+-v2*=Copy file '$WORKDIR/in/dists/4321/Release' to './lists/test_4321_Release'...
+-v6=aptmethod start 'file:$WORKDIR/in/dists/4321/component/source/Sources.xz'
+-v1*=aptmethod got 'file:$WORKDIR/in/dists/4321/component/source/Sources.xz'
+-v2*=Uncompress '$WORKDIR/in/dists/4321/component/source/Sources.xz' into './lists/test_4321_component_Sources' using '/usr/bin/unxz'...
+-v6=aptmethod start 'file:$WORKDIR/in/dists/4321/component/binary-something/Packages.xz'
+-v1*=aptmethod got 'file:$WORKDIR/in/dists/4321/component/binary-something/Packages.xz'
+-v2*=Uncompress '$WORKDIR/in/dists/4321/component/binary-something/Packages.xz' into './lists/test_4321_component_something_Packages' using '/usr/bin/unxz'...
+stdout
+-v0*=Calculating packages to get...
+-v3*= processing updates for '1234|component|source'
+-v5*= reading './lists/test_4321_component_Sources'
+-v3*= processing updates for '1234|component|something'
+-v5*= reading './lists/test_4321_component_something_Packages'
+EOF
+
+# an extremely manually built package to ensure only some things are there:
+mkdir -p build/test-1/src
+echo a > build/test-1/src/sourcefile
+srcorigname=test_1.orig.tar.xz
+tar -cJf build/${srcorigname} -C build test-1
+srcorigsha=$(sha2andsize build/${srcorigname})
+mkdir -p build/test-1/debian
+cat > build/test-1/debian/control <<EOF
+Source: test
+Maintainer: <me@me>
+
+Package: name
+Architecture: all
+EOF
+touch build/test-1/debian/changelog
+srcdebname=test_1-1.debian.tar.xz
+tar -cJf build/${srcdebname} -C build/test-1 debian
+srcdebsha=$(sha2andsize build/${srcdebname})
+srcdscname=test_1-1.dsc
+cat > build/${srcdscname} <<EOF
+Source: test
+EOF
+srcdscsha=$(sha2andsize build/${srcdscname})
+mkdir -p build/name/opt/
+echo trash > build/name/opt/trash
+mkdir -p build/name/DEBIAN
+cat > build/name/DEBIAN/control <<EOF
+Package: name
+Architecture: all
+Version: 17-2
+Source: test (1-1)
+Maintainer: <me@me>
+Description: some
+ description
+EOF
+bindebname=name_17-2_all.deb
+dpkg-deb -Z xz -b build/name build/${bindebname}
+bindebsha=$(sha2only build/${bindebname})
+bindebsize=$(sizeonly build/${bindebname})
+
+rm in/dists/4321/component/binary-something/Packages.xz
+cat > in/dists/4321/component/binary-something/Packages <<EOF
+Package: name
+Version: 17-2
+Source: test (1-1)
+Maintainer: <me@me>
+Architecture: all
+Size: ${bindebsize}
+SHA256: ${bindebsha}
+Filename: ../build/${bindebname}
+Description: some
+ description
+EOF
+packagessha=$(sha2andsize in/dists/4321/component/binary-something/Packages)
+xz in/dists/4321/component/binary-something/Packages
+packagesxzsha=$(sha2andsize in/dists/4321/component/binary-something/Packages.xz)
+
+rm in/dists/4321/component/source/Sources.xz
+cat > in/dists/4321/component/source/Sources <<EOF
+Package: test
+Version: 1-1
+Maintainer: <me@me>
+Directory: ../build
+Checksums-Sha256:
+ ${srcdscsha} ${srcdscname}
+ ${srcdebsha} ${srcdebname}
+ ${srcorigsha} ${srcorigname}
+EOF
+sourcessha=$(sha2andsize in/dists/4321/component/source/Sources)
+xz in/dists/4321/component/source/Sources
+sourcesxzsha=$(sha2andsize in/dists/4321/component/source/Sources.xz)
+
+cat > in/dists/4321/Release <<EOF
+SHA256:
+ $sourcessha component/source/Sources
+ $sourcesxzsha component/source/Sources.xz
+ $packagessha component/binary-something/Packages
+ $packagesxzsha component/binary-something/Packages.xz
+EOF
+
+mkdir -p pool/component/t/test
+
+testrun - -b . update 1234 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/in/dists/4321/Release'
+-v1*=aptmethod got 'file:$WORKDIR/in/dists/4321/Release'
+-v2*=Copy file '$WORKDIR/in/dists/4321/Release' to './lists/test_4321_Release'...
+-v6=aptmethod start 'file:$WORKDIR/in/dists/4321/component/source/Sources.xz'
+-v1*=aptmethod got 'file:$WORKDIR/in/dists/4321/component/source/Sources.xz'
+-v2*=Uncompress '$WORKDIR/in/dists/4321/component/source/Sources.xz' into './lists/test_4321_component_Sources' using '/usr/bin/unxz'...
+-v6=aptmethod start 'file:$WORKDIR/in/dists/4321/component/binary-something/Packages.xz'
+-v1*=aptmethod got 'file:$WORKDIR/in/dists/4321/component/binary-something/Packages.xz'
+-v2*=Uncompress '$WORKDIR/in/dists/4321/component/binary-something/Packages.xz' into './lists/test_4321_component_something_Packages' using '/usr/bin/unxz'...
+*=Package name marked to be unexpected('error'): 'test'!
+*=Stop reading further chunks from './lists/test_4321_component_Sources' due to previous errors.
+*=There have been errors!
+returns 255
+stdout
+-v0*=Calculating packages to get...
+-v3*= processing updates for '1234|component|source'
+-v5*= reading './lists/test_4321_component_Sources'
+EOF
+
+echo "test =1-1" > conf/filtersrclist
+
+testrun - -b . update 1234 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/in/dists/4321/Release'
+-v1*=aptmethod got 'file:$WORKDIR/in/dists/4321/Release'
+-v2*=Copy file '$WORKDIR/in/dists/4321/Release' to './lists/test_4321_Release'...
+*=Package name marked to be unexpected('error'): 'name'!
+*=Stop reading further chunks from './lists/test_4321_component_something_Packages' due to previous errors.
+*=There have been errors!
+returns 255
+stdout
+-v0*=Calculating packages to get...
+-v3*= processing updates for '1234|component|source'
+-v5*= reading './lists/test_4321_component_Sources'
+-v3*= processing updates for '1234|component|something'
+-v5*= reading './lists/test_4321_component_something_Packages'
+EOF
+
+echo "name =17-2" > conf/filterlist
+
+testrun - -b . update 1234 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/in/dists/4321/Release'
+-v1*=aptmethod got 'file:$WORKDIR/in/dists/4321/Release'
+-v2*=Copy file '$WORKDIR/in/dists/4321/Release' to './lists/test_4321_Release'...
+-v6=aptmethod start 'file:$WORKDIR/in/../build/${srcdscname}'
+-v1*=aptmethod got 'file:$WORKDIR/in/../build/${srcdscname}'
+-v2*=Linking file '$WORKDIR/in/../build/${srcdscname}' to './pool/component/t/test/${srcdscname}'...
+-v6=aptmethod start 'file:$WORKDIR/in/../build/${srcdebname}'
+-v1*=aptmethod got 'file:$WORKDIR/in/../build/${srcdebname}'
+-v2*=Linking file '$WORKDIR/in/../build/${srcdebname}' to './pool/component/t/test/${srcdebname}'...
+-v6=aptmethod start 'file:$WORKDIR/in/../build/${srcorigname}'
+-v1*=aptmethod got 'file:$WORKDIR/in/../build/${srcorigname}'
+-v2*=Linking file '$WORKDIR/in/../build/${srcorigname}' to './pool/component/t/test/${srcorigname}'...
+-v6=aptmethod start 'file:$WORKDIR/in/../build/${bindebname}'
+-v1*=aptmethod got 'file:$WORKDIR/in/../build/${bindebname}'
+-v2*=Linking file '$WORKDIR/in/../build/${bindebname}' to './pool/component/t/test/${bindebname}'...
+stdout
+$(ofa pool/component/t/test/${srcdscname})
+$(ofa pool/component/t/test/${srcdebname})
+$(ofa pool/component/t/test/${srcorigname})
+$(ofa pool/component/t/test/${bindebname})
+-v0*=Calculating packages to get...
+-v3*= processing updates for '1234|component|source'
+-v5*= reading './lists/test_4321_component_Sources'
+-v3*= processing updates for '1234|component|something'
+-v5*= reading './lists/test_4321_component_something_Packages'
+-v0*=Getting packages...
+-v1*=Shutting down aptmethods...
+-v0*=Installing (and possibly deleting) packages...
+$(opa 'test' unset '1234' 'component' 'source' 'dsc')
+$(opa 'name' x '1234' 'component' 'something' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in '1234|component|something'...
+-v6*= replacing './dists/1234/component/binary-something/Packages' (xzed)
+-v6*= looking for changes in '1234|component|source'...
+-v6*= replacing './dists/1234/component/source/Sources' (xzed)
+EOF
+
+rm -r build in lists
+echo "update-rules done, now pull-rules"
+
+cat >> conf/distributions <<EOF
+
+Codename: dest
+Components: component
+Architectures: something source
+DebIndices: Packages .xz
+DscIndices: Sources .xz
+Pull: test
+EOF
+cat > conf/pulls <<EOF
+Name: test
+From: 1234
+FilterList: error filterlist
+FilterSrcList: error filtersrclist
+EOF
+echo > conf/filterlist
+echo > conf/filtersrclist
+
+testrun - -b . export dest 3<<EOF
+stderr
+stdout
+-v1*=Exporting dest...
+-v2*=Created directory "./dists/dest"
+-v2*=Created directory "./dists/dest/component"
+-v2*=Created directory "./dists/dest/component/binary-something"
+-v6*= exporting 'dest|component|something'...
+-v6*= creating './dists/dest/component/binary-something/Packages' (xzed)
+-v2*=Created directory "./dists/dest/component/source"
+-v6*= exporting 'dest|component|source'...
+-v6*= creating './dists/dest/component/source/Sources' (xzed)
+EOF
+
+testrun - -b . pull dest 3<<EOF
+stderr
+*=Package name marked to be unexpected('error'): 'test'!
+*=There have been errors!
+returns 255
+stdout
+-v0*=Calculating packages to pull...
+-v3*= pulling into 'dest|component|source'
+-v5*= looking what to get from '1234|component|source'
+EOF
+
+echo "test =1-1" > conf/filtersrclist
+
+testrun - -b . pull dest 3<<EOF
+stderr
+*=Package name marked to be unexpected('error'): 'name'!
+*=There have been errors!
+returns 255
+stdout
+-v0*=Calculating packages to pull...
+-v3*= pulling into 'dest|component|source'
+-v5*= looking what to get from '1234|component|source'
+-v3*= pulling into 'dest|component|something'
+-v5*= looking what to get from '1234|component|something'
+EOF
+
+echo "name =17-2" > conf/filterlist
+
+testrun - -b . pull dest 3<<EOF
+stdout
+-v0*=Calculating packages to pull...
+-v3*= pulling into 'dest|component|source'
+-v5*= looking what to get from '1234|component|source'
+-v3*= pulling into 'dest|component|something'
+-v5*= looking what to get from '1234|component|something'
+-v0*=Installing (and possibly deleting) packages...
+$(opa 'test' unset 'dest' 'component' 'source' 'dsc')
+$(opa 'name' x 'dest' 'component' 'something' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'dest|component|something'...
+-v6*= replacing './dists/dest/component/binary-something/Packages' (xzed)
+-v6*= looking for changes in 'dest|component|source'...
+-v6*= replacing './dists/dest/component/source/Sources' (xzed)
+EOF
+
+echo "and now the same again with a new version"
+
+mkdir -p build/test-1/debian
+cat > build/test-1/debian/control <<EOF
+Source: test
+Maintainer: <me@me>
+
+Package: name
+Architecture: all
+EOF
+echo "2" > build/test-1/debian/changelog
+src2debname=test_1-2.debian.tar.xz
+tar -cJf build/${src2debname} -C build/test-1 debian
+src2debsha=$(sha2andsize build/${src2debname})
+src2dscname=test_1-2.dsc
+cat > build/${src2dscname} <<EOF
+Source: test
+Maintainer: <me@me>
+EOF
+src2dscsha=$(sha2andsize build/${src2dscname})
+mkdir -p build/name/opt/
+echo trash > build/name/opt/trash
+mkdir -p build/name/DEBIAN
+cat > build/name/DEBIAN/control <<EOF
+Package: name
+Architecture: all
+Version: 17-3
+Source: test (1-2)
+Maintainer: <me@me>
+Description: some
+ description
+EOF
+bin2debname=name_17-3_all.deb
+dpkg-deb -Z xz -b build/name build/${bin2debname}
+bin2debsha=$(sha2only build/${bin2debname})
+bin2debsize=$(sizeonly build/${bin2debname})
+
+mkdir -p in/dists/4321/component/binary-something in/dists/4321/component/source
+cat > in/dists/4321/component/binary-something/Packages <<EOF
+Package: name
+Version: 17-3
+Source: test (1-2)
+Maintainer: <me@me>
+Architecture: all
+Size: ${bin2debsize}
+SHA256: ${bin2debsha}
+Filename: ../build/${bin2debname}
+Description: some
+ description
+EOF
+packagessha=$(sha2andsize in/dists/4321/component/binary-something/Packages)
+xz in/dists/4321/component/binary-something/Packages
+packagesxzsha=$(sha2andsize in/dists/4321/component/binary-something/Packages.xz)
+
+cat > in/dists/4321/component/source/Sources <<EOF
+Package: test
+Version: 1-2
+Maintainer: <me@me>
+Directory: ../build
+Checksums-Sha256:
+ ${src2dscsha} ${src2dscname}
+ ${src2debsha} ${src2debname}
+ ${srcorigsha} ${srcorigname}
+EOF
+sourcessha=$(sha2andsize in/dists/4321/component/source/Sources)
+xz in/dists/4321/component/source/Sources
+sourcesxzsha=$(sha2andsize in/dists/4321/component/source/Sources.xz)
+
+cat > in/dists/4321/Release <<EOF
+SHA256:
+ $sourcessha component/source/Sources
+ $sourcesxzsha component/source/Sources.xz
+ $packagessha component/binary-something/Packages
+ $packagesxzsha component/binary-something/Packages.xz
+EOF
+
+echo "test warning" > conf/filtersrclist
+echo "name warning" > conf/filterlist
+dodo mkdir lists
+
+testrun - -b . update 1234 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/in/dists/4321/Release'
+-v1*=aptmethod got 'file:$WORKDIR/in/dists/4321/Release'
+-v2*=Copy file '$WORKDIR/in/dists/4321/Release' to './lists/test_4321_Release'...
+-v6=aptmethod start 'file:$WORKDIR/in/dists/4321/component/source/Sources.xz'
+-v1*=aptmethod got 'file:$WORKDIR/in/dists/4321/component/source/Sources.xz'
+-v2*=Uncompress '$WORKDIR/in/dists/4321/component/source/Sources.xz' into './lists/test_4321_component_Sources' using '/usr/bin/unxz'...
+-v6=aptmethod start 'file:$WORKDIR/in/dists/4321/component/binary-something/Packages.xz'
+-v1*=aptmethod got 'file:$WORKDIR/in/dists/4321/component/binary-something/Packages.xz'
+-v2*=Uncompress '$WORKDIR/in/dists/4321/component/binary-something/Packages.xz' into './lists/test_4321_component_something_Packages' using '/usr/bin/unxz'...
+*=Loudly rejecting 'name' '17-3' to enter '1234|component|something'!
+*=Loudly rejecting 'test' '1-2' to enter '1234|component|source'!
+stdout
+-v0*=Calculating packages to get...
+-v3*= processing updates for '1234|component|source'
+-v5*= reading './lists/test_4321_component_Sources'
+-v3*= processing updates for '1234|component|something'
+-v5*= reading './lists/test_4321_component_something_Packages'
+EOF
+
+dodo echo check if the fallback to filtersrclist works:
+sed -e 's/^FilterList/#&/' -i conf/updates
+rm conf/filterlist
+
+testrun - -b . --noskipold update 1234 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/in/dists/4321/Release'
+-v1*=aptmethod got 'file:$WORKDIR/in/dists/4321/Release'
+-v2*=Copy file '$WORKDIR/in/dists/4321/Release' to './lists/test_4321_Release'...
+*=Loudly rejecting 'name' '17-3' to enter '1234|component|something'!
+*=Loudly rejecting 'test' '1-2' to enter '1234|component|source'!
+stdout
+-v0*=Calculating packages to get...
+-v3*= processing updates for '1234|component|source'
+-v5*= reading './lists/test_4321_component_Sources'
+-v3*= processing updates for '1234|component|something'
+-v5*= reading './lists/test_4321_component_something_Packages'
+EOF
+
+echo "test =1-2" > conf/filtersrclist
+
+testrun - -b . --noskipold update 1234 3<<EOF
+stderr
+-v6=aptmethod start 'file:$WORKDIR/in/dists/4321/Release'
+-v1*=aptmethod got 'file:$WORKDIR/in/dists/4321/Release'
+-v2*=Copy file '$WORKDIR/in/dists/4321/Release' to './lists/test_4321_Release'...
+-v6=aptmethod start 'file:$WORKDIR/in/../build/${src2dscname}'
+-v1*=aptmethod got 'file:$WORKDIR/in/../build/${src2dscname}'
+-v2*=Linking file '$WORKDIR/in/../build/${src2dscname}' to './pool/component/t/test/${src2dscname}'...
+-v6=aptmethod start 'file:$WORKDIR/in/../build/${src2debname}'
+-v1*=aptmethod got 'file:$WORKDIR/in/../build/${src2debname}'
+-v2*=Linking file '$WORKDIR/in/../build/${src2debname}' to './pool/component/t/test/${src2debname}'...
+-v6=aptmethod start 'file:$WORKDIR/in/../build/${bin2debname}'
+-v1*=aptmethod got 'file:$WORKDIR/in/../build/${bin2debname}'
+-v2*=Linking file '$WORKDIR/in/../build/${bin2debname}' to './pool/component/t/test/${bin2debname}'...
+stdout
+$(ofa pool/component/t/test/${src2dscname})
+$(ofa pool/component/t/test/${src2debname})
+$(ofa pool/component/t/test/${bin2debname})
+-v0*=Calculating packages to get...
+-v3*= processing updates for '1234|component|source'
+-v5*= reading './lists/test_4321_component_Sources'
+-v3*= processing updates for '1234|component|something'
+-v5*= reading './lists/test_4321_component_something_Packages'
+-v0*=Getting packages...
+-v1*=Shutting down aptmethods...
+-v0*=Installing (and possibly deleting) packages...
+$(opu 'test' x x '1234' 'component' 'source' 'dsc')
+$(opu 'name' x x '1234' 'component' 'something' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in '1234|component|something'...
+-v6*= replacing './dists/1234/component/binary-something/Packages' (xzed)
+-v6*= looking for changes in '1234|component|source'...
+-v6*= replacing './dists/1234/component/source/Sources' (xzed)
+EOF
+
+rm -r lists build in
+
+echo "test warning" > conf/filtersrclist
+echo "name warning" > conf/filterlist
+
+testrun - -b . pull dest 3<<EOF
+*=Loudly rejecting 'name' '17-3' to enter 'dest|component|something'!
+*=Loudly rejecting 'test' '1-2' to enter 'dest|component|source'!
+stdout
+-v0*=Calculating packages to pull...
+-v3*= pulling into 'dest|component|source'
+-v5*= looking what to get from '1234|component|source'
+-v3*= pulling into 'dest|component|something'
+-v5*= looking what to get from '1234|component|something'
+-v0*=Installing (and possibly deleting) packages...
+EOF
+
+sed -e 's/^FilterList/#&/' -i conf/pulls
+rm conf/filterlist
+
+testrun - -b . pull dest 3<<EOF
+*=Loudly rejecting 'name' '17-3' to enter 'dest|component|something'!
+*=Loudly rejecting 'test' '1-2' to enter 'dest|component|source'!
+stdout
+-v0*=Calculating packages to pull...
+-v3*= pulling into 'dest|component|source'
+-v5*= looking what to get from '1234|component|source'
+-v3*= pulling into 'dest|component|something'
+-v5*= looking what to get from '1234|component|something'
+-v0*=Installing (and possibly deleting) packages...
+EOF
+
+echo "test =1-2" > conf/filtersrclist
+
+testrun - -b . pull dest 3<<EOF
+stdout
+-v0*=Calculating packages to pull...
+-v3*= pulling into 'dest|component|source'
+-v5*= looking what to get from '1234|component|source'
+-v3*= pulling into 'dest|component|something'
+-v5*= looking what to get from '1234|component|something'
+-v0*=Installing (and possibly deleting) packages...
+$(opu 'test' x x 'dest' 'component' 'source' 'dsc')
+$(opu 'name' x x 'dest' 'component' 'something' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'dest|component|something'...
+-v6*= replacing './dists/dest/component/binary-something/Packages' (xzed)
+-v6*= looking for changes in 'dest|component|source'...
+-v6*= replacing './dists/dest/component/source/Sources' (xzed)
+-v0*=Deleting files no longer referenced...
+$(ofd pool/component/t/test/${srcdscname})
+$(ofd pool/component/t/test/${srcdebname})
+$(ofd pool/component/t/test/${bindebname})
+EOF
+
+rm -r -f db conf dists pool
+testsuccess
diff --git a/tests/uploaders.test b/tests/uploaders.test
new file mode 100644
index 0000000..6260996
--- /dev/null
+++ b/tests/uploaders.test
@@ -0,0 +1,253 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+mkdir -p conf
+cat > conf/distributions <<EOF
+Codename: test1
+Components: main
+Architectures: source coal
+Uploaders: uploaders1
+
+Codename: test2
+Components: main
+Architectures: source coal
+Uploaders: uploaders2
+EOF
+
+checknonetakes() {
+testrun - -b . __checkuploaders test1 test2 < "$1" 3<<EOF
+stdout
+*='testpackage' would NOT have been accepted by any of the distributions selected.
+EOF
+}
+
+check1takes() {
+testrun - -b . __checkuploaders test1 test2 < "$1" 3<<EOF
+stdout
+*='testpackage' would have been accepted by 'test1'
+EOF
+}
+check2takes() {
+testrun - -b . __checkuploaders test1 test2 < "$1" 3<<EOF
+stdout
+*='testpackage' would have been accepted by 'test2'
+EOF
+}
+
+cat > descr1 <<EOF
+source testpackage
+architecture source
+EOF
+
+testrun - -b . __checkuploaders test1 test2 < descr1 3<<EOF
+*=Error opening './conf/uploaders1': No such file or directory
+-v0*=There have been errors!
+returns 254
+EOF
+
+cat > conf/uploaders1 <<EOF
+EOF
+
+testrun - -b . __checkuploaders test1 test2 < descr1 3<<EOF
+*=Error opening './conf/uploaders2': No such file or directory
+-v0*=There have been errors!
+returns 254
+EOF
+
+cat > conf/uploaders2 <<EOF
+include uploaders2
+EOF
+
+testrun - -b . __checkuploaders test1 test2 < descr1 3<<EOF
+*=./conf/uploaders2:1:0: Too deeply nested include directives (> 100). Built some recursion?
+*=included from './conf/uploaders2' line 1
+-v0*=There have been errors!
+returns 255
+EOF
+
+cat > conf/uploaders2 <<EOF
+allow source 'testpackage' by unsigned
+EOF
+
+check2takes descr1
+
+cat > descrbad <<EOF
+unknowncommand
+EOF
+
+testrun - -b . __checkuploaders test1 test2 < descrbad 3<<EOF
+*=Unparseable line 'unknowncommand'
+-v0*=There have been errors!
+returns 255
+EOF
+
+cat > descrbad <<EOF
+architecture source
+EOF
+
+testrun - -b . __checkuploaders test1 test2 < descrbad 3<<EOF
+*=No source name specified!
+-v0*=There have been errors!
+returns 255
+EOF
+
+cat > descres <<EOF
+source testpackage
+architecture source
+signature e0000000000000000
+EOF
+cat > descrs <<EOF
+source testpackage
+architecture source
+signature 0000000000000000
+EOF
+
+checknonetakes descres
+checknonetakes descrs
+
+echo "now test2 accepts all valid signatures for testpackage"
+cat >> conf/uploaders2 <<EOF
+allow source 'testpackage' by any key
+EOF
+
+check2takes descrs
+checknonetakes descres
+
+cat >>conf/uploaders1 <<EOF
+group test
+EOF
+testrun - -b . __checkuploaders test1 test2 < descrbad 3<<EOF
+*=./conf/uploaders1:1:11: missing 'add', 'contains', 'unused' or 'empty' keyword.
+-v0*=There have been errors!
+returns 255
+EOF
+
+cat >conf/uploaders1 <<EOF
+group test add
+EOF
+
+testrun - -b . __checkuploaders test1 test2 < descrbad 3<<EOF
+*=./conf/uploaders1:1:15: key id or fingerprint expected!
+-v0*=There have been errors!
+returns 255
+EOF
+
+cat >conf/uploaders1 <<EOF
+group test add 00000000
+EOF
+
+testrun - -b . __checkuploaders test1 test2 < descres 3<<EOF
+-v0*=./conf/uploaders1:1: Warning: group 'test' gets members but is not used in any rule
+stdout
+*='testpackage' would NOT have been accepted by any of the distributions selected.
+EOF
+
+cat >>conf/uploaders1 <<EOF
+group test unused
+EOF
+
+checknonetakes descres
+
+cat >>conf/uploaders1 <<EOF
+allow * by group test
+EOF
+
+testrun - -b . __checkuploaders test1 test2 < descrbad 3<<EOF
+*=./conf/uploaders1:3: cannot use group 'test' marked as unused!
+*=./conf/uploaders1:2: here it was marked as unused.
+-v0*=There have been errors!
+returns 255
+EOF
+
+cat >conf/uploaders1 <<EOF
+group test add 00000000
+group test unused
+allow * by group tset
+EOF
+
+testrun - -b . __checkuploaders test1 test2 < descres 3<<EOF
+-v0*=./conf/uploaders1:3: Warning: group 'tset' gets used but never gets any members
+stdout
+*='testpackage' would NOT have been accepted by any of the distributions selected.
+EOF
+
+cat >>conf/uploaders1 <<EOF
+group tset contains test
+EOF
+
+testrun - -b . __checkuploaders test1 test2 < descres 3<<EOF
+*=./conf/uploaders1:4: cannot use group 'test' marked as unused!
+*=./conf/uploaders1:2: here it got marked as unused.
+-v0*=There have been errors!
+returns 255
+EOF
+
+sed -e '/unused/d' -i conf/uploaders1
+
+check1takes descrs
+checknonetakes descres
+
+cat >>conf/uploaders1 <<EOF
+group test contains indirection
+group indirection contains test
+EOF
+
+testrun - -b . __checkuploaders test1 test2 < descres 3<<EOF
+*=./conf/uploaders1:5: cannot add group 'test' to group 'indirection' as the later is already member of the former!
+-v0*=There have been errors!
+returns 255
+EOF
+
+cat >conf/uploaders1 <<EOF
+group group add 76543210
+group foo add 00000000
+group bla contains group
+group blub contains foo
+group g5 contains foo
+group g5 unused
+group g6 contains foo
+group g6 unused
+group g7 contains foo
+group g7 unused
+group g8 contains foo
+group g8 unused
+group g9 contains foo
+group g9 unused
+group g10 contains foo
+group g10 unused
+group g11 contains foo
+group g11 unused
+group g12 contains foo
+group g12 unused
+group g13 contains foo
+group g13 unused
+group g14 contains foo
+group g14 unused
+group g15 contains foo
+group g15 unused
+group g16 contains foo
+group g16 unused
+group g17 contains foo
+group g17 unused
+group g18 contains foo
+group g18 unused
+group g19 contains foo
+group g19 unused
+group g20 contains foo
+group g20 unused
+group g21 contains foo
+group g21 unused
+allow * by group bla
+allow architectures contain 'coal' by group blub
+EOF
+
+check2takes descrs
+sed -e 's/0000000000000000/fedcba9876543210/g' descrs >> descr2
+sed -e 's/0000000000000000/fedcba9876542210/g' descrs >> descr3
+echo "architecture coal" >> descrs
+check1takes descrs
+check1takes descr2
+check2takes descr3
+
+rm -r conf descr*
+testsuccess
diff --git a/tests/valgrind.supp b/tests/valgrind.supp
new file mode 100644
index 0000000..d6659b1
--- /dev/null
+++ b/tests/valgrind.supp
@@ -0,0 +1,128 @@
+{
+ libz-not-initializing-buffer
+ Memcheck:Cond
+ fun:inflateReset2
+ fun:inflateInit2_
+ obj:/usr/lib*/libz.so.*
+}
+{
+ still-careless-libdb
+ Memcheck:Param
+ pwrite64(buf)
+ fun:pwrite
+ fun:__os_io
+ obj:/usr/lib/x86_64-linux-gnu/libdb-*.so
+ fun:__memp_bhwrite
+ fun:__memp_sync_int
+}
+
+{
+ careless-libdb
+ Memcheck:Param
+ pwrite64(buf)
+ fun:__pwrite*_nocancel
+ fun:__os_io
+ obj:/usr/lib*/libdb-*.so
+ fun:__memp_bhwrite
+ fun:__memp_sync_int
+}
+{
+ more-careless-libdb6
+ Memcheck:Cond
+ fun:__bam_stkrel
+ obj:/usr/lib*/libdb-6*.so
+ fun:__dbc_iput
+ fun:__db_put
+}
+{
+ more-careless-libdb5
+ Memcheck:Cond
+ fun:__bam_stkrel
+ obj:/usr/lib*/libdb-5*.so
+ fun:__dbc_iput
+ fun:__db_put
+}
+{
+ stupid-db4.6
+ Memcheck:Param
+ pwrite64(buf)
+ obj:/lib/ld-2.7.so
+ fun:__os_io
+ obj:/usr/lib/libdb-4.6.so
+ fun:__memp_bhwrite
+ fun:__memp_sync_int
+ fun:__memp_fsync
+ fun:__db_sync
+}
+{
+ stupid-db4.6-withlibc-dbg
+ Memcheck:Param
+ pwrite64(buf)
+ fun:pwrite64
+ fun:__os_io
+ obj:/usr/lib/libdb-4.6.so
+ fun:__memp_bhwrite
+ fun:__memp_sync_int
+ fun:__memp_fsync
+ fun:__db_sync
+}
+{
+ stupid-db3
+ Memcheck:Param
+ pwrite64(buf)
+ fun:pwrite64
+ fun:__os_io
+ obj:/usr/lib/libdb-4.3.so
+ fun:__memp_bhwrite
+ fun:__memp_sync_int
+ fun:__memp_fsync
+ fun:__db_sync
+}
+{
+ stupid-db3-withlibc-dbg
+ Memcheck:Param
+ pwrite64(buf)
+ fun:do_pwrite64
+ fun:__os_io
+ obj:/usr/lib/libdb-4.3.so
+ fun:__memp_bhwrite
+ fun:__memp_sync_int
+ fun:__memp_fsync
+ fun:__db_sync
+}
+{
+ libz-looking-far
+ Memcheck:Cond
+ obj:/usr/lib/libz.so.*
+ obj:/usr/lib/libz.so.*
+ fun:deflate
+}
+{
+ gpgme11-gpgme_data_release_and_get_mem_leak
+ Memcheck:Leak
+ fun:calloc
+ obj:*/libgpgme.so.*
+ fun:gpgme_data_new
+ fun:gpgme_data_new_from_filepart
+ fun:gpgme_data_new_from_file
+ fun:signature_readsignedchunk
+}
+{
+ gpgme11-gpgme_data_release_and_get_mem_leak2
+ Memcheck:Leak
+ fun:calloc
+ obj:*/libgpgme.so.*
+ fun:gpgme_data_new
+ fun:signature_readsignedchunk
+}
+{
+ liblzma-thinks-random-jumps-are-fun
+ Memcheck:Cond
+ obj:/lib/x86_64-linux-gnu/liblzma.so.5*
+ obj:/lib/x86_64-linux-gnu/liblzma.so.5*
+ obj:/lib/x86_64-linux-gnu/liblzma.so.5*
+ obj:/lib/x86_64-linux-gnu/liblzma.so.5*
+ obj:/lib/x86_64-linux-gnu/liblzma.so.5*
+ fun:lzma_stream_encoder
+ fun:lzma_easy_encoder
+}
diff --git a/tests/various1.test b/tests/various1.test
new file mode 100644
index 0000000..96623d2
--- /dev/null
+++ b/tests/various1.test
@@ -0,0 +1,1430 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+mkdir -p conf
+cat > conf/distributions <<EOF
+
+#
+
+Codename: test
+Architectures:
+# This is an comment
+ a
+Components:
+ c
+
+#
+#
+
+EOF
+touch conf/updates
+dodo test ! -d db
+mkdir logs
+testrun - -b . checkupdate test 3<<EOF
+stderr
+*=Nothing to do, because none of the selected distributions has an Update: field.
+stdout
+$(odb)
+-v2=Created directory "./lists"
+EOF
+rm -r -f lists
+rm -r -f db conf
+dodo test ! -d d/ab
+mkdir -p conf
+cat > conf/options <<CONFEND
+outhook $SRCDIR/docs/outstore.py
+export changed
+CONFEND
+export REPREPRO_OUT_DB=db/out
+cat > conf/distributions <<CONFEND
+Codename: A
+Architectures: abacus calculator
+Components: dog cat
+Log: logfile
+ --bla
+CONFEND
+testrun - -b . export 3<<EOF
+return 255
+stdout
+stderr
+*=Unknown Log notifier option in ./conf/distributions, line 5, column 2: '--bla'
+-v0*=There have been errors!
+EOF
+cat > conf/distributions <<CONFEND
+Codename: A
+Architectures: abacus calculator
+Components: dog cat
+Log: logfile
+ -A
+CONFEND
+testrun - -b . export 3<<EOF
+return 255
+*=Log notifier option -A misses an argument in ./conf/distributions, line 5, column 4
+-v0*=There have been errors!
+EOF
+cat > conf/distributions <<CONFEND
+Codename: A
+Architectures: abacus calculator
+Components: dog cat
+Log: logfile
+ -A=abacus
+CONFEND
+testrun - -b . export 3<<EOF
+return 255
+*=Error parsing config file ./conf/distributions, line 5, column 11:
+*=Unexpected end of line: name of notifier script missing!
+-v0*=There have been errors!
+EOF
+cat > conf/distributions <<CONFEND
+Codename: A
+Architectures: abacus calculator
+Components: dog cat
+Log: logfile
+ -A=abacus --architecture=coal
+CONFEND
+testrun - -b . export 3<<EOF
+return 255
+*=Repeated notifier option --architecture in ./conf/distributions, line 5, column 12!
+-v0*=There have been errors!
+EOF
+cat > conf/distributions <<CONFEND
+Codename: getmoreatoms
+Architectures: funny coal
+Components: dog
+
+Codename: A
+Architectures: abacus calculator
+Components: dog cat
+Log: logfile
+# -A=nonexistant -C=nocomponent --type=none --withcontrol noscript.sh
+
+Codename: B
+Architectures: abacus source
+Components: dog cat
+Contents: compatsymlink percomponent
+Log: logfile
+CONFEND
+testrun - -b . export B A 3<<EOF
+stdout
+$(odb)
+-v1*=Exporting B...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/B"
+-v2*=Created directory "./dists/B/dog"
+-v2*=Created directory "./dists/B/dog/binary-abacus"
+-v6*= exporting 'B|dog|abacus'...
+-v6*= creating './dists/B/dog/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/B/dog/source"
+-v6*= exporting 'B|dog|source'...
+-v6*= creating './dists/B/dog/source/Sources' (gzipped)
+-v2*=Created directory "./dists/B/cat"
+-v2*=Created directory "./dists/B/cat/binary-abacus"
+-v6*= exporting 'B|cat|abacus'...
+-v2*=Created directory "./dists/B/cat/source"
+-v6*= creating './dists/B/cat/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= exporting 'B|cat|source'...
+-v6*= creating './dists/B/cat/source/Sources' (gzipped)
+-v1*= generating dog/Contents-abacus...
+-v1*= generating cat/Contents-abacus...
+-v1*=Exporting A...
+-v2*=Created directory "./dists/A"
+-v2*=Created directory "./dists/A/dog"
+-v2*=Created directory "./dists/A/dog/binary-abacus"
+-v6*= exporting 'A|dog|abacus'...
+-v6*= creating './dists/A/dog/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/A/dog/binary-calculator"
+-v6*= exporting 'A|dog|calculator'...
+-v6*= creating './dists/A/dog/binary-calculator/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/A/cat"
+-v2*=Created directory "./dists/A/cat/binary-abacus"
+-v6*= exporting 'A|cat|abacus'...
+-v6*= creating './dists/A/cat/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/A/cat/binary-calculator"
+-v6*= exporting 'A|cat|calculator'...
+-v6*= creating './dists/A/cat/binary-calculator/Packages' (uncompressed,gzipped)
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+dodo test -f db/checksums.db
+find dists -type f | LC_ALL=C sort -f > results
+cat > results.expected <<END
+dists/A/cat/binary-abacus/Packages
+dists/A/cat/binary-abacus/Packages.gz
+dists/A/cat/binary-abacus/Release
+dists/A/cat/binary-calculator/Packages
+dists/A/cat/binary-calculator/Packages.gz
+dists/A/cat/binary-calculator/Release
+dists/A/dog/binary-abacus/Packages
+dists/A/dog/binary-abacus/Packages.gz
+dists/A/dog/binary-abacus/Release
+dists/A/dog/binary-calculator/Packages
+dists/A/dog/binary-calculator/Packages.gz
+dists/A/dog/binary-calculator/Release
+dists/A/Release
+dists/B/cat/binary-abacus/Packages
+dists/B/cat/binary-abacus/Packages.gz
+dists/B/cat/binary-abacus/Release
+dists/B/cat/Contents-abacus.gz
+dists/B/cat/source/Release
+dists/B/cat/source/Sources.gz
+dists/B/dog/binary-abacus/Packages
+dists/B/dog/binary-abacus/Packages.gz
+dists/B/dog/binary-abacus/Release
+dists/B/dog/Contents-abacus.gz
+dists/B/dog/source/Release
+dists/B/dog/source/Sources.gz
+dists/B/Release
+END
+dodiff results.expected results
+find dists -type l -printf "%p -> %l" | LC_ALL=C sort -f > results
+cat > results.expected <<END
+dists/B/Contents-abacus.gz -> dog/Contents-abacus.gz
+END
+
+sed -e "s/^Contents: compatsymlink/Contents: allcomponents/" -i conf/distributions
+
+dodiff results.expected results
+testrun - -b . processincoming default 3<<EOF
+returns 254
+stderr
+*=Error opening config file './conf/incoming': No such file or directory(2)
+-v0*=There have been errors!
+stdout
+EOF
+touch conf/incoming
+testrun - -b . processincoming default 3<<EOF
+returns 249
+stderr
+*=No definition for 'default' found in './conf/incoming'!
+-v0*=There have been errors!
+stdout
+EOF
+cat > conf/incoming <<EOF
+Name: bla
+Tempdir: bla
+Incomingdir: bla
+EOF
+testrun - -b . processincoming default 3<<EOF
+returns 249
+stderr
+*=No definition for 'default' found in './conf/incoming'!
+-v0*=There have been errors!
+stdout
+EOF
+cat > conf/incoming <<EOF
+Name: bla
+Tempdir: bla
+Incomingdir: bla
+
+# a comment
+#
+
+Name: default
+
+Name: blub
+EOF
+testrun - -b . processincoming default 3<<EOF
+returns 249
+stderr
+*=Error parsing config file ./conf/incoming, line 9:
+*=Required field 'TempDir' not found in
+*=incoming rule starting in line 8 and ending in line 8.
+-v0*=There have been errors!
+EOF
+cat > conf/incoming <<EOF
+Name: bla
+Tempdir: bla
+Incomingdir: bla
+
+# a comment
+#
+
+Name: default
+TempDir: temp
+
+Name: blub
+EOF
+testrun - -b . processincoming default 3<<EOF
+returns 249
+stderr
+*=Error parsing config file ./conf/incoming, line 10:
+*=Required field 'IncomingDir' not found in
+*=incoming rule starting in line 8 and ending in line 9.
+-v0*=There have been errors!
+EOF
+cat > conf/incoming <<EOF
+# commentary
+Name: bla
+Tempdir: bla
+Incomingdir: bla
+Permit: unused_files bla older_version
+Cleanup: unused_files bla on_deny
+
+# a comment
+#
+
+Name: default
+TempDir: temp
+
+Name: blub
+EOF
+testrun - -b . processincoming default 3<<EOF
+returns 249
+stderr
+*=Warning: ignored error parsing config file ./conf/incoming, line 5, column 22:
+*=Unknown flag in Permit header. (but not within the rule we are interested in.)
+*=Warning: ignored error parsing config file ./conf/incoming, line 6, column 23:
+*=Unknown flag in Cleanup header. (but not within the rule we are interested in.)
+*=Error parsing config file ./conf/incoming, line 13:
+*=Required field 'IncomingDir' not found in
+*=incoming rule starting in line 11 and ending in line 12.
+-v0*=There have been errors!
+EOF
+cat > conf/incoming <<EOF
+Name: bla
+TempDir: bla
+IncomingDir: bla
+
+Name: default
+TempDir: temp
+IncomingDir: i
+
+Name: blub
+TempDir: blub
+IncomingDir: blub
+EOF
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=There is neither an 'Allow' nor a 'Default' definition in rule 'default'
+*=(starting at line 5, ending at line 8 of ./conf/incoming)!
+*=Aborting as nothing would be let in.
+-v0*=There have been errors!
+EOF
+cat > conf/incoming <<EOF
+Name: bla
+TempDir: bla
+IncomingDir: blub
+
+Name: default
+TempDir: temp
+IncomingDir: i
+Allow: A B
+
+Name: blub
+TempDir: bla
+IncomingDir: blub
+EOF
+testrun - -b . processincoming default 3<<EOF
+returns 254
+stderr
+*=Cannot scan './i': No such file or directory
+-v0*=There have been errors!
+stdout
+-v2*=Created directory "./temp"
+EOF
+mkdir i
+testrun "" -b . processincoming default
+(cd i ; PACKAGE=bird EPOCH="" VERSION=1 REVISION="" SECTION="tasty" genpackage.sh)
+echo returned: $?
+DSCMD5S="$(mdandsize i/bird_1.dsc)"
+TARMD5S="$(mdandsize i/bird_1.tar.gz)"
+DSCSHA1S="$(sha1andsize i/bird_1.dsc)"
+TARSHA1S="$(sha1andsize i/bird_1.tar.gz)"
+DSCSHA2S="$(sha2andsize i/bird_1.dsc)"
+TARSHA2S="$(sha2andsize i/bird_1.tar.gz)"
+testrun - -b . processincoming default 3<<EOF
+returns 243
+stderr
+*=No distribution found for 'test.changes'!
+-v0*=There have been errors!
+stdout
+EOF
+sed -i -e 's/test1/A/' i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*='test.changes' lists architecture 'source' not found in distribution 'A'!
+-v0*=There have been errors!
+stdout
+EOF
+sed -i -e 's/Distribution: A/Distribution: B/' i/test.changes
+cp -a i i2
+checknolog logfile
+testrun - -b . processincoming default 3<<EOF
+stdout
+-v9*=Adding reference to 'pool/dog/b/bird/bird_1.dsc' by 'B|dog|source'
+-v9*=Adding reference to 'pool/dog/b/bird/bird_1.tar.gz' by 'B|dog|source'
+-v9*=Adding reference to 'pool/dog/b/bird/bird_1_abacus.deb' by 'B|dog|abacus'
+-v9*=Adding reference to 'pool/dog/b/bird/bird-addons_1_all.deb' by 'B|dog|abacus'
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/dog"
+-v2*=Created directory "./pool/dog/b"
+-v2*=Created directory "./pool/dog/b/bird"
+$(ofa 'pool/dog/b/bird/bird_1.dsc')
+$(ofa 'pool/dog/b/bird/bird_1.tar.gz')
+$(ofa 'pool/dog/b/bird/bird_1_abacus.deb')
+$(ofa 'pool/dog/b/bird/bird-addons_1_all.deb')
+$(opa 'bird' x 'B' 'dog' 'source' 'dsc')
+$(opa 'bird' x 'B' 'dog' 'abacus' 'deb')
+$(opa 'bird-addons' x 'B' 'dog' 'abacus' 'deb')
+-v3*=deleting './i/bird_1.dsc'...
+-v3*=deleting './i/bird_1.tar.gz'...
+-v3*=deleting './i/bird_1_abacus.deb'...
+-v3*=deleting './i/bird-addons_1_all.deb'...
+-v3*=deleting './i/test.changes'...
+-v0*=Exporting indices...
+-v6*= looking for changes in 'B|dog|abacus'...
+-v6*= replacing './dists/B/dog/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'B|dog|source'...
+-v6*= replacing './dists/B/dog/source/Sources' (gzipped)
+-v6*= looking for changes in 'B|cat|abacus'...
+-v6*= looking for changes in 'B|cat|source'...
+-v1*= generating Contents-abacus...
+-v1*= generating dog/Contents-abacus...
+-v4*=Reading filelist for pool/dog/b/bird/bird_1_abacus.deb
+-d1*=db: 'pool/dog/b/bird/bird_1_abacus.deb' added to contents.cache.db(compressedfilelists).
+-v4*=Reading filelist for pool/dog/b/bird/bird-addons_1_all.deb
+-d1*=db: 'pool/dog/b/bird/bird-addons_1_all.deb' added to contents.cache.db(compressedfilelists).
+EOF
+checklog logfile <<EOF
+DATESTR add B dsc dog source bird 1
+DATESTR add B deb dog abacus bird 1
+DATESTR add B deb dog abacus bird-addons 1
+EOF
+find temp -type f > results
+dodiff /dev/null results
+find i -type f > results
+dodiff /dev/null results
+cat > results.expected <<EOF
+x tasty/bird,tasty/bird-addons
+a/1 tasty/bird,tasty/bird-addons
+dir/another tasty/bird,tasty/bird-addons
+dir/file tasty/bird,tasty/bird-addons
+dir/subdir/file tasty/bird,tasty/bird-addons
+EOF
+gunzip -c dists/B/Contents-abacus.gz > results
+dodiff results.expected results
+cat > results.expected <<EOF
+EOF
+gunzip -c dists/B/cat/Contents-abacus.gz > results
+dodiff results.expected results
+cat > results.expected <<EOF
+x tasty/bird,tasty/bird-addons
+a/1 tasty/bird,tasty/bird-addons
+dir/another tasty/bird,tasty/bird-addons
+dir/file tasty/bird,tasty/bird-addons
+dir/subdir/file tasty/bird,tasty/bird-addons
+EOF
+gunzip -c dists/B/dog/Contents-abacus.gz > results
+dodiff results.expected results
+printindexpart pool/dog/b/bird/bird_1_abacus.deb > results.expected
+printindexpart pool/dog/b/bird/bird-addons_1_all.deb >> results.expected
+dodiff results.expected dists/B/dog/binary-abacus/Packages
+withoutchecksums pool/dog/b/bird/bird_1.dsc | sed -e 's/ \+$//' > results.expected
+ed -s results.expected <<EOF
+H
+/^Source:/ m 0
+s/^Source: /Package: /
+/^Files:/ kf
+'f i
+Priority: superfluous
+Section: tasty
+Directory: pool/dog/b/bird
+.
+'f a
+ $DSCMD5S bird_1.dsc
+.
+$ a
+Checksums-Sha1:
+ $DSCSHA1S bird_1.dsc
+ $TARSHA1S bird_1.tar.gz
+Checksums-Sha256:
+ $DSCSHA2S bird_1.dsc
+ $TARSHA2S bird_1.tar.gz
+
+.
+w
+q
+EOF
+gunzip -c dists/B/dog/source/Sources.gz | sed -e 's/ \+$//' > results
+dodiff results.expected results
+
+echo "DebOverride: debo" >> conf/distributions
+echo "DscOverride: dsco" >> conf/distributions
+echo "bird Section cat/tasty" > conf/debo
+echo "bird Priority hungry" >> conf/debo
+echo "bird Task lunch" >> conf/debo
+echo "bird-addons Section cat/ugly" >> conf/debo
+echo "bird Section cat/nest" > conf/dsco
+echo "bird Priority hurry" >> conf/dsco
+echo "bird Homepage gopher://tree" >> conf/dsco
+
+mv i2/* i/
+rmdir i2
+testrun - -b . processincoming default 3<<EOF
+stdout
+-v2*=Created directory "./pool/cat"
+-v2*=Created directory "./pool/cat/b"
+-v2*=Created directory "./pool/cat/b/bird"
+$(ofa 'pool/cat/b/bird/bird_1.dsc')
+$(ofa 'pool/cat/b/bird/bird_1.tar.gz')
+$(ofa 'pool/cat/b/bird/bird_1_abacus.deb')
+$(ofa 'pool/cat/b/bird/bird-addons_1_all.deb')
+$(opa 'bird' x 'B' 'cat' 'source' 'dsc')
+$(opa 'bird' x 'B' 'cat' 'abacus' 'deb')
+$(opa 'bird-addons' x 'B' 'cat' 'abacus' 'deb')
+-v3*=deleting './i/bird_1.dsc'...
+-v3*=deleting './i/bird_1.tar.gz'...
+-v3*=deleting './i/bird_1_abacus.deb'...
+-v3*=deleting './i/bird-addons_1_all.deb'...
+-v3*=deleting './i/test.changes'...
+-v0*=Exporting indices...
+-v6*= looking for changes in 'B|cat|abacus'...
+-v6*= looking for changes in 'B|cat|source'...
+-v6*= looking for changes in 'B|dog|abacus'...
+-v6*= replacing './dists/B/cat/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'B|dog|source'...
+-v6*= replacing './dists/B/cat/source/Sources' (gzipped)
+-v1*= generating cat/Contents-abacus...
+-v1*= generating Contents-abacus...
+-v4*=Reading filelist for pool/cat/b/bird/bird_1_abacus.deb
+-d1*=db: 'pool/cat/b/bird/bird_1_abacus.deb' added to contents.cache.db(compressedfilelists).
+-v4*=Reading filelist for pool/cat/b/bird/bird-addons_1_all.deb
+-d1*=db: 'pool/cat/b/bird/bird-addons_1_all.deb' added to contents.cache.db(compressedfilelists).
+EOF
+checklog logfile <<EOF
+DATESTR add B dsc cat source bird 1
+DATESTR add B deb cat abacus bird 1
+DATESTR add B deb cat abacus bird-addons 1
+EOF
+find temp -type f > results
+dodiff /dev/null results
+find i -type f > results
+dodiff /dev/null results
+cat > results.expected <<EOF
+x tasty/bird,tasty/bird-addons,cat/tasty/bird,cat/ugly/bird-addons
+a/1 tasty/bird,tasty/bird-addons,cat/tasty/bird,cat/ugly/bird-addons
+dir/another tasty/bird,tasty/bird-addons,cat/tasty/bird,cat/ugly/bird-addons
+dir/file tasty/bird,tasty/bird-addons,cat/tasty/bird,cat/ugly/bird-addons
+dir/subdir/file tasty/bird,tasty/bird-addons,cat/tasty/bird,cat/ugly/bird-addons
+EOF
+gunzip -c dists/B/Contents-abacus.gz > results
+dodiff results.expected results
+cat > results.expected <<EOF
+x cat/tasty/bird,cat/ugly/bird-addons
+a/1 cat/tasty/bird,cat/ugly/bird-addons
+dir/another cat/tasty/bird,cat/ugly/bird-addons
+dir/file cat/tasty/bird,cat/ugly/bird-addons
+dir/subdir/file cat/tasty/bird,cat/ugly/bird-addons
+EOF
+gunzip -c dists/B/cat/Contents-abacus.gz > results
+dodiff results.expected results
+cat > results.expected <<EOF
+x tasty/bird,tasty/bird-addons
+a/1 tasty/bird,tasty/bird-addons
+dir/another tasty/bird,tasty/bird-addons
+dir/file tasty/bird,tasty/bird-addons
+dir/subdir/file tasty/bird,tasty/bird-addons
+EOF
+gunzip -c dists/B/dog/Contents-abacus.gz > results
+dodiff results.expected results
+printindexpart pool/cat/b/bird/bird_1_abacus.deb > results.expected
+printindexpart pool/cat/b/bird/bird-addons_1_all.deb >> results.expected
+ed -s results.expected <<EOF
+H
+/^Priority: / s/^Priority: superfluous$/Priority: hungry/
+i
+Task: lunch
+.
+/^Section: / s/^Section: tasty$/Section: cat\/tasty/
+/^Section: tasty/ s/^Section: tasty$/Section: cat\/ugly/
+w
+q
+EOF
+dodiff results.expected dists/B/cat/binary-abacus/Packages
+withoutchecksums pool/cat/b/bird/bird_1.dsc | sed -e 's/ \+$//' > results.expected
+ed -s results.expected <<EOF
+H
+/^Source:/ m 0
+s/^Source: /Package: /
+/^Files:/ kf
+'f i
+Homepage: gopher://tree
+Priority: hurry
+Section: cat/nest
+Directory: pool/cat/b/bird
+.
+'f a
+ $DSCMD5S bird_1.dsc
+.
+$ a
+Checksums-Sha1:
+ $DSCSHA1S bird_1.dsc
+ $TARSHA1S bird_1.tar.gz
+Checksums-Sha256:
+ $DSCSHA2S bird_1.dsc
+ $TARSHA2S bird_1.tar.gz
+
+.
+w
+q
+EOF
+BIRDDSCMD5S="$DSCMD5S"
+BIRDTARMD5S="$TARMD5S"
+BIRDDSCSHA1S="$DSCSHA1S"
+BIRDTARSHA1S="$TARSHA1S"
+BIRDDSCSHA2S="$DSCSHA2S"
+BIRDTARSHA2S="$TARSHA2S"
+gunzip -c dists/B/cat/source/Sources.gz | sed -e 's/ \+$//' > results
+dodiff results.expected results
+
+# now missing: checking what all can go wrong in a .changes or .dsc file...
+mkdir pkg
+mkdir pkg/a
+touch pkg/a/b
+mkdir pkg/DEBIAN
+cat > pkg/DEBIAN/control <<EOF
+Package: indebname
+Version: 1:0versionindeb~1
+Source: sourceindeb (0sourceversionindeb)
+EOF
+dpkg-deb --nocheck -b pkg i/debfilename_debfileversion~2_coal.deb
+DEBMD5="$(md5sum i/debfilename_debfileversion~2_coal.deb | cut -d' ' -f1)"
+DEBSIZE="$(stat -c '%s' i/debfilename_debfileversion~2_coal.deb)"
+DEBMD5S="$DEBMD5 $DEBSIZE"
+cat > i/test.changes <<EOF
+EOF
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Unexpected empty file 'test.changes'!
+-v0*=There have been errors!
+EOF
+echo > i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Could only find spaces within 'test.changes'!
+-v0*=There have been errors!
+EOF
+cat > i/test.changes <<EOF
+-chunk: 1
+
+
+EOF
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+-v0=Data seems not to be signed trying to use directly....
+*=Strange content of 'test.changes': First non-space character is '-',
+*=but it does not begin with '-----BEGIN'.
+-v0*=There have been errors!
+EOF
+#*=First non-space character is a '-' but there is no empty line in
+#*='test.changes'.
+#*=Unable to extract any data from it!
+cat > i/test.changes <<EOF
+-chunk: 1
+
+EOF
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+-v0=Data seems not to be signed trying to use directly....
+*=Strange content of 'test.changes': First non-space character is '-',
+*=but it does not begin with '-----BEGIN'.
+-v0*=There have been errors!
+EOF
+#*=First non-space character is a '-' but there is no empty line in
+#*='test.changes'.
+#*=Unable to extract any data from it!
+cat > i/test.changes <<EOF
+chunk: 1
+
+chunk: 2
+EOF
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+-v0*=There have been errors!
+*=Error parsing 'test.changes': Seems not to be signed but has spurious empty line.
+EOF
+cat > i/test.changes <<EOF
+-----BEGIN FAKE GPG SIGNED MAIL
+type: funny
+
+This is some content
+-----BEGIN FAKE SIGNATURE
+Hahaha!
+-----END FAKE SIGNATURE
+EOF
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+-v0=Data seems not to be signed trying to use directly....
+-v0=Cannot check signatures from 'test.changes' as compiled without support for libgpgme!
+-v0=Extracting the content manually without looking at the signature...
+*=In 'test.changes': Missing 'Source' field!
+-v0*=There have been errors!
+EOF
+cat > i/test.changes <<EOF
+-----BEGIN FAKE GPG SIGNED MAIL
+type: funny
+
+This is some content
+
+-----BEGIN FAKE SIGNATURE
+Hahaha!
+-----END FAKE SIGNATURE
+EOF
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+-v0=Data seems not to be signed trying to use directly....
+-v0=Cannot check signatures from 'test.changes' as compiled without support for libgpgme!
+-v0=Extracting the content manually without looking at the signature...
+*=In 'test.changes': Missing 'Source' field!
+-v0*=There have been errors!
+EOF
+cat > i/test.changes <<EOF
+Format: 1.8
+Dummyfield: test
+EOF
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=In 'test.changes': Missing 'Source' field!
+-v0*=There have been errors!
+EOF
+echo "Source: sourceinchanges" > i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=In 'test.changes': Missing 'Architecture' field!
+-v0*=There have been errors!
+EOF
+echo "Architecture: funny" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=In 'test.changes': Missing 'Version' field!
+-v0*=There have been errors!
+EOF
+echo "Binary: binaryinchanges" >> i/test.changes
+echo "Version: 999:0versioninchanges-0~" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=In 'test.changes': Missing 'Distribution' field!
+-v0*=There have been errors!
+EOF
+echo "Distribution: A" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=In 'test.changes': Missing 'Files' field!
+-v0*=There have been errors!
+EOF
+echo "Files:" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=In 'test.changes': Empty 'Files' section!
+-v0*=There have been errors!
+EOF
+# as it does not look for the file, but scanned the directory
+# and looked for it, there is no problem here, though it might
+# look like one
+echo " ffff 666 - - ../ööü_v_all.deb" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 249
+stderr
+*=In 'test.changes': file '../ööü_v_all.deb' not found in the incoming dir!
+-v0*=There have been errors!
+EOF
+printf '$d\nw\nq\n' | ed -s i/test.changes
+printf ' ffff 666 - - \300\257.\300\257_v_funny.deb\n' >> i/test.changes
+touch "$(printf 'i/\300\257.\300\257_v_funny.deb')"
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*='test.changes' lists architecture 'funny' not found in distribution 'A'!
+-v0*=There have been errors!
+EOF
+printf '$d\nw\nq\n' | ed -s i/test.changes
+printf ' ffff 666 - - \300\257.\300\257_v_all.deb\n' >> i/test.changes
+mv "$(printf 'i/\300\257.\300\257_v_funny.deb')" "$(printf 'i/\300\257.\300\257_v_all.deb')"
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*='all' is not listed in the Architecture header of 'test.changes' but file 'À¯.À¯_v_all.deb' looks like it!
+-v0*=There have been errors!
+EOF
+sed -i -e 's/funny/all/' i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Invalid filename 'À¯.À¯_v_all.deb' listed in 'test.changes': contains 8-bit characters
+-v0*=There have been errors!
+EOF
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " ffff 1 - - debfilename_debfileversion~2_coal.deb" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*='coal' is not listed in the Architecture header of 'test.changes' but file 'debfilename_debfileversion~2_coal.deb' looks like it!
+-v0*=There have been errors!
+EOF
+mv i/debfilename_debfileversion~2_coal.deb i/debfilename_debfileversion~2_all.deb
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " md5sum size - - debfilename_debfileversion~2_all.deb" >> i/test.changes
+# TODO: this error message has to be improved:
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Malformed md5 hash in 'md5sum size - - debfilename_debfileversion~2_all.deb'!
+-v0*=There have been errors!
+EOF
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " ffff 666 - - debfilename_debfileversion~2_all.deb" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 254
+stderr
+*=ERROR: File 'debfilename_debfileversion~2_all.deb' does not match expectations:
+*=md5 expected: ffff, got: $DEBMD5
+*=size expected: 666, got: $DEBSIZE
+-v0*=There have been errors!
+EOF
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DEBMD5S - - debfilename_debfileversion~2_all.deb" >> i/test.changes
+# TODO: these will hopefully change to not divulge the place of the temp dir some day...
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=No Maintainer field in ./temp/debfilename_debfileversion~2_all.deb's control file!
+-v0*=There have been errors!
+EOF
+echo "Maintainer: noone <me@nowhere>" >> pkg/DEBIAN/control
+dpkg-deb --nocheck -b pkg i/debfilename_debfileversion~2_all.deb
+DEBMD5S="$(md5sum i/debfilename_debfileversion~2_all.deb | cut -d' ' -f1) $(stat -c '%s' i/debfilename_debfileversion~2_all.deb)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DEBMD5S - - debfilename_debfileversion~2_all.deb" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=No Description field in ./temp/debfilename_debfileversion~2_all.deb's control file!
+-v0*=There have been errors!
+EOF
+echo ...
+echo "Description: test-package" >> pkg/DEBIAN/control
+echo " a package to test reprepro" >> pkg/DEBIAN/control
+dpkg-deb --nocheck -b pkg i/debfilename_debfileversion~2_all.deb
+DEBMD5S="$(md5sum i/debfilename_debfileversion~2_all.deb | cut -d' ' -f1) $(stat -c '%s' i/debfilename_debfileversion~2_all.deb)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DEBMD5S - - debfilename_debfileversion~2_all.deb" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=No Architecture field in ./temp/debfilename_debfileversion~2_all.deb's control file!
+-v0*=There have been errors!
+EOF
+echo "Architecture: coal" >> pkg/DEBIAN/control
+dpkg-deb -b pkg i/debfilename_debfileversion~2_all.deb
+DEBMD5S="$(md5sum i/debfilename_debfileversion~2_all.deb | cut -d' ' -f1) $(stat -c '%s' i/debfilename_debfileversion~2_all.deb)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DEBMD5S - - debfilename_debfileversion~2_all.deb" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Name part of filename ('debfilename') and name within the file ('indebname') do not match for 'debfilename_debfileversion~2_all.deb' in 'test.changes'!
+-v0*=There have been errors!
+EOF
+mv i/debfilename_debfileversion~2_all.deb i/indebname_debfileversion~2_all.deb
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DEBMD5S - - indebname_debfileversion~2_all.deb" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Architecture 'coal' of 'indebname_debfileversion~2_all.deb' does not match 'all' specified in 'test.changes'!
+-v0*=There have been errors!
+EOF
+sed -i -e "s/^Architecture: coal/Architecture: all/" pkg/DEBIAN/control
+dpkg-deb -b pkg i/indebname_debfileversion~2_all.deb
+DEBMD5S="$(md5sum i/indebname_debfileversion~2_all.deb | cut -d' ' -f1) $(stat -c '%s' i/indebname_debfileversion~2_all.deb)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DEBMD5S - - indebname_debfileversion~2_all.deb" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Source header 'sourceinchanges' of 'test.changes' and source name 'sourceindeb' within the file 'indebname_debfileversion~2_all.deb' do not match!
+-v0*=There have been errors!
+EOF
+sed -i -e 's/sourceinchanges/sourceindeb/' i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Source version '999:0versioninchanges-0~' of 'test.changes' and source version '0sourceversionindeb' within the file 'indebname_debfileversion~2_all.deb' do not match!
+-v0*=There have been errors!
+EOF
+sed -i -e 's/999:0versioninchanges-0~/0sourceversionindeb/' i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Name 'indebname' of binary 'indebname_debfileversion~2_all.deb' is not listed in Binaries header of 'test.changes'!
+*=(use Permit: unlisted_binaries in conf/incoming to ignore this error)
+-v0*=There have been errors!
+EOF
+sed -i -e 's/binaryinchanges/indebname/' i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=No section found for 'indebname' ('indebname_debfileversion~2_all.deb' in 'test.changes')!
+-v0*=There have been errors!
+EOF
+echo "Section: sectiontest" >> pkg/DEBIAN/control
+dpkg-deb -b pkg i/indebname_debfileversion~2_all.deb
+DEBMD5S="$(md5sum i/indebname_debfileversion~2_all.deb | cut -d' ' -f1) $(stat -c '%s' i/indebname_debfileversion~2_all.deb)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DEBMD5S - - indebname_debfileversion~2_all.deb" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=No section found for 'indebname' ('indebname_debfileversion~2_all.deb' in 'test.changes')!
+-v0*=There have been errors!
+EOF
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DEBMD5S test - indebname_debfileversion~2_all.deb" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=No priority found for 'indebname' ('indebname_debfileversion~2_all.deb' in 'test.changes')!
+-v0*=There have been errors!
+EOF
+echo "Priority: survival" >> pkg/DEBIAN/control
+dpkg-deb -b pkg i/indebname_debfileversion~2_all.deb
+DEBMD5S="$(md5sum i/indebname_debfileversion~2_all.deb | cut -d' ' -f1) $(stat -c '%s' i/indebname_debfileversion~2_all.deb)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DEBMD5S test - indebname_debfileversion~2_all.deb" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=No priority found for 'indebname' ('indebname_debfileversion~2_all.deb' in 'test.changes')!
+-v0*=There have been errors!
+EOF
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DEBMD5S section priority indebname_debfileversion~2_all.deb" >> i/test.changes
+checknolog logfile
+testrun - -b . processincoming default 3<<EOF
+returns 0
+stderr
+stdout
+-v2*=Created directory "./pool/dog/s"
+-v2*=Created directory "./pool/dog/s/sourceindeb"
+$(ofa 'pool/dog/s/sourceindeb/indebname_0versionindeb~1_all.deb')
+$(opa 'indebname' x 'A' 'dog' 'abacus' 'deb')
+$(opa 'indebname' x 'A' 'dog' 'calculator' 'deb')
+-v3*=deleting './i/indebname_debfileversion~2_all.deb'...
+-v3*=deleting './i/test.changes'...
+-v0*=Exporting indices...
+-v6*= looking for changes in 'A|cat|abacus'...
+-v6*= replacing './dists/A/dog/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'A|cat|calculator'...
+-v6*= replacing './dists/A/dog/binary-calculator/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'A|dog|abacus'...
+-v6*= looking for changes in 'A|dog|calculator'...
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog logfile <<EOF
+DATESTR add A deb dog abacus indebname 1:0versionindeb~1
+DATESTR add A deb dog calculator indebname 1:0versionindeb~1
+EOF
+find pool/dog/s -type f > results
+echo "pool/dog/s/sourceindeb/indebname_0versionindeb~1_all.deb" > results.expected
+dodiff results.expected results
+
+touch i/dscfilename_fileversion~.dsc
+DSCMD5S="$(md5sum i/dscfilename_fileversion~.dsc | cut -d' ' -f1) $(stat -c '%s' i/dscfilename_fileversion~.dsc)"
+cat > i/test.changes <<EOF
+Format: 1.8
+Source: sourceinchanges
+Binary: nothing
+Architecture: all
+Version: 1:0versioninchanges
+Distribution: A
+Files:
+ ffff 666 - - dscfilename_fileversion~.dsc
+EOF
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*='source' is not listed in the Architecture header of 'test.changes' but file 'dscfilename_fileversion~.dsc' looks like it!
+-v0*=There have been errors!
+EOF
+sed -i -e 's/^Architecture: all$/Architecture: source/' i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*='test.changes' lists architecture 'source' not found in distribution 'A'!
+-v0*=There have been errors!
+EOF
+sed -i -e 's/^Distribution: A$/Distribution: B/' i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 254
+stderr
+*=ERROR: File 'dscfilename_fileversion~.dsc' does not match expectations:
+*=md5 expected: ffff, got: $EMPTYMD5ONLY
+*=size expected: 666, got: 0
+-v0*=There have been errors!
+EOF
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DSCMD5S - - dscfilename_fileversion~.dsc" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Unexpected empty file 'dscfilename_fileversion~.dsc'!
+-v0*=There have been errors!
+EOF
+#*=Could only find spaces within './temp/dscfilename_fileversion~.dsc'!
+echo "Format: " > i/dscfilename_fileversion~.dsc
+DSCMD5S="$(md5sum i/dscfilename_fileversion~.dsc | cut -d' ' -f1) $(stat -c '%s' i/dscfilename_fileversion~.dsc)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DSCMD5S - - dscfilename_fileversion~.dsc" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Missing 'Source' field in dscfilename_fileversion~.dsc!
+-v0*=There have been errors!
+EOF
+echo "Source: nameindsc" > i/dscfilename_fileversion~.dsc
+DSCMD5S="$(md5sum i/dscfilename_fileversion~.dsc | cut -d' ' -f1) $(stat -c '%s' i/dscfilename_fileversion~.dsc)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DSCMD5S - - dscfilename_fileversion~.dsc" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Cannot find 'Format' field in dscfilename_fileversion~.dsc!
+-v0*=There have been errors!
+EOF
+echo "Format: 1.0" >> i/dscfilename_fileversion~.dsc
+DSCMD5S="$(md5sum i/dscfilename_fileversion~.dsc | cut -d' ' -f1) $(stat -c '%s' i/dscfilename_fileversion~.dsc)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DSCMD5S - - dscfilename_fileversion~.dsc" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Cannot find 'Maintainer' field in dscfilename_fileversion~.dsc!
+-v0*=There have been errors!
+EOF
+echo "Maintainer: guess who <me@nowhere>" >> i/dscfilename_fileversion~.dsc
+DSCMD5S="$(md5sum i/dscfilename_fileversion~.dsc | cut -d' ' -f1) $(stat -c '%s' i/dscfilename_fileversion~.dsc)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DSCMD5S - - dscfilename_fileversion~.dsc" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Missing 'Version' field in dscfilename_fileversion~.dsc!
+-v0*=There have been errors!
+EOF
+echo "Standards-Version: 0" >> i/dscfilename_fileversion~.dsc
+DSCMD5S="$(md5sum i/dscfilename_fileversion~.dsc | cut -d' ' -f1) $(stat -c '%s' i/dscfilename_fileversion~.dsc)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DSCMD5S - - dscfilename_fileversion~.dsc" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Missing 'Version' field in dscfilename_fileversion~.dsc!
+-v0*=There have been errors!
+EOF
+echo "Version: 0versionindsc" >> i/dscfilename_fileversion~.dsc
+DSCMD5S="$(md5sum i/dscfilename_fileversion~.dsc | cut -d' ' -f1) $(stat -c '%s' i/dscfilename_fileversion~.dsc)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DSCMD5S - - dscfilename_fileversion~.dsc" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Missing 'Files' field in 'dscfilename_fileversion~.dsc'!
+-v0*=There have been errors!
+EOF
+echo "Files: " >> i/dscfilename_fileversion~.dsc
+DSCMD5S="$(md5sum i/dscfilename_fileversion~.dsc | cut -d' ' -f1) $(stat -c '%s' i/dscfilename_fileversion~.dsc)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DSCMD5S - - dscfilename_fileversion~.dsc" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Name part of filename ('dscfilename') and name within the file ('nameindsc') do not match for 'dscfilename_fileversion~.dsc' in 'test.changes'!
+-v0*=There have been errors!
+EOF
+sed -i 's/^Source: nameindsc$/Source: dscfilename/g' i/dscfilename_fileversion~.dsc
+DSCMD5S="$(md5sum i/dscfilename_fileversion~.dsc | cut -d' ' -f1) $(stat -c '%s' i/dscfilename_fileversion~.dsc)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DSCMD5S - - dscfilename_fileversion~.dsc" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Source header 'sourceinchanges' of 'test.changes' and name 'dscfilename' within the file 'dscfilename_fileversion~.dsc' do not match!
+-v0*=There have been errors!
+EOF
+sed -i 's/^Source: sourceinchanges$/Source: dscfilename/' i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Source version '1:0versioninchanges' of 'test.changes' and version '0versionindsc' within the file 'dscfilename_fileversion~.dsc' do not match!
+-v0*=There have been errors!
+EOF
+sed -i 's/^Version: 1:0versioninchanges$/Version: 0versionindsc/' i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=No section found for 'dscfilename' ('dscfilename_fileversion~.dsc' in 'test.changes')!
+-v0*=There have been errors!
+EOF
+DSCMD5S="$(md5sum i/dscfilename_fileversion~.dsc | cut -d' ' -f1) $(stat -c '%s' i/dscfilename_fileversion~.dsc)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DSCMD5S dummy - dscfilename_fileversion~.dsc" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=No priority found for 'dscfilename' ('dscfilename_fileversion~.dsc' in 'test.changes')!
+-v0*=There have been errors!
+EOF
+printf "g/^Format:/d\nw\nq\n" | ed -s i/dscfilename_fileversion~.dsc
+DSCMD5S="$(md5sum i/dscfilename_fileversion~.dsc | cut -d' ' -f1) $(stat -c '%s' i/dscfilename_fileversion~.dsc)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DSCMD5S dummy can't-live-without dscfilename_fileversion~.dsc" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Cannot find 'Format' field in dscfilename_fileversion~.dsc!
+-v0*=There have been errors!
+EOF
+printf "1i\nFormat: 1.0\n.\nw\nq\n" | ed -s i/dscfilename_fileversion~.dsc
+DSCMD5S="$(mdandsize i/dscfilename_fileversion~.dsc )"
+OLDDSCFILENAMEMD5S="$DSCMD5S"
+OLDDSCFILENAMESHA1S="$(sha1andsize i/dscfilename_fileversion~.dsc)"
+OLDDSCFILENAMESHA2S="$(sha2andsize i/dscfilename_fileversion~.dsc)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DSCMD5S dummy can't-live-without dscfilename_fileversion~.dsc" >> i/test.changes
+checknolog logfile
+testrun - -b . processincoming default 3<<EOF
+returns 0
+stderr
+stdout
+-v2*=Created directory "./pool/dog/d"
+-v2*=Created directory "./pool/dog/d/dscfilename"
+$(ofa 'pool/dog/d/dscfilename/dscfilename_0versionindsc.dsc')
+$(opa 'dscfilename' x 'B' 'dog' 'source' 'dsc')
+-v3*=deleting './i/dscfilename_fileversion~.dsc'...
+-v3*=deleting './i/test.changes'...
+-v0=Exporting indices...
+-v6*= looking for changes in 'B|dog|abacus'...
+-v6*= looking for changes in 'B|dog|source'...
+-v6*= replacing './dists/B/dog/source/Sources' (gzipped)
+-v6*= looking for changes in 'B|cat|abacus'...
+-v6*= looking for changes in 'B|cat|source'...
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog logfile <<EOF
+DATESTR add B dsc dog source dscfilename 0versionindsc
+EOF
+# TODO: check Sources.gz
+cat >i/strangefile <<EOF
+just a line to make it non-empty
+EOF
+cat >i/dscfilename_fileversion~.dsc <<EOF
+Format: 1.0
+Source: dscfilename
+Maintainer: guess who <me@nowhere>
+Standards-Version: 0
+Version: 1:newversion~
+Files:
+ md5sumindsc sizeindsc strangefile
+EOF
+DSCMD5S="$(md5sum i/dscfilename_fileversion~.dsc | cut -d' ' -f1) $(stat -c '%s' i/dscfilename_fileversion~.dsc)"
+cat >i/test.changes <<EOF
+Source: dscfilename
+Binary: nothing
+Architecture: source
+Version: 1:newversion~
+Distribution: B
+Files:
+ $DSCMD5S dummy can't-live-without dscfilename_fileversion~.dsc
+EOF
+# this is a stupid error message, needs to get some context
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Error parsing md5 checksum line ' md5sumindsc sizeindsc strangefile' within 'dscfilename_fileversion~.dsc'
+-v0*=There have been errors!
+EOF
+sed -i "s/ md5sumindsc / dddddddddddddddddddddddddddddddd /" i/dscfilename_fileversion~.dsc
+DSCMD5S="$(md5sum i/dscfilename_fileversion~.dsc | cut -d' ' -f1) $(stat -c '%s' i/dscfilename_fileversion~.dsc)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DSCMD5S dummy unneeded dscfilename_fileversion~.dsc" >> i/test.changes
+# this is a stupid error message, needs to get some context
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=Error parsing md5 checksum line ' dddddddddddddddddddddddddddddddd sizeindsc strangefile' within 'dscfilename_fileversion~.dsc'
+-v0*=There have been errors!
+EOF
+sed -i "s/ sizeindsc / 666 /" i/dscfilename_fileversion~.dsc
+DSCMD5S="$(md5sum i/dscfilename_fileversion~.dsc | cut -d' ' -f1) $(stat -c '%s' i/dscfilename_fileversion~.dsc)"
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " $DSCMD5S dummy unneeded dscfilename_fileversion~.dsc" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=file 'strangefile' is needed for 'dscfilename_fileversion~.dsc', not yet registered in the pool and not found in 'test.changes'
+-v0*=There have been errors!
+EOF
+echo " 11111111111111111111111111111111 666 - - strangefile" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+*=No underscore found in file name in '11111111111111111111111111111111 666 - - strangefile'!
+-v0*=There have been errors!
+EOF
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " 11111111111111111111111111111111 666 - - strangefile_xyz" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 249
+stderr
+=Unknown file type: '11111111111111111111111111111111 666 - - strangefile_xyz', assuming source format...
+*=In 'test.changes': file 'strangefile_xyz' not found in the incoming dir!
+-v0*=There have been errors!
+EOF
+mv i/strangefile i/strangefile_xyz
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+=Unknown file type: '11111111111111111111111111111111 666 - - strangefile_xyz', assuming source format...
+*=file 'strangefile' is needed for 'dscfilename_fileversion~.dsc', not yet registered in the pool and not found in 'test.changes'
+-v0*=There have been errors!
+EOF
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " dddddddddddddddddddddddddddddddd 666 - - strangefile_xyz" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 254
+stderr
+=Unknown file type: 'dddddddddddddddddddddddddddddddd 666 - - strangefile_xyz', assuming source format...
+*=ERROR: File 'strangefile_xyz' does not match expectations:
+*=md5 expected: dddddddddddddddddddddddddddddddd, got: 31a1096ff883d52f0c1f39e652d6336f
+*=size expected: 666, got: 33
+-v0*=There have been errors!
+EOF
+printf '$d\nw\nq\n' | ed -s i/dscfilename_fileversion~.dsc
+echo " 31a1096ff883d52f0c1f39e652d6336f 33 strangefile_xyz" >> i/dscfilename_fileversion~.dsc
+DSCMD5S="$(mdandsize i/dscfilename_fileversion~.dsc)"
+DSCSHA1S="$(sha1andsize i/dscfilename_fileversion~.dsc)"
+DSCSHA2S="$(sha2andsize i/dscfilename_fileversion~.dsc)"
+DSCFILENAMEMD5S="$DSCMD5S"
+DSCFILENAMESHA1S="$DSCSHA1S"
+DSCFILENAMESHA2S="$DSCSHA2S"
+printf '$-1,$d\nw\nq\n' | ed -s i/test.changes
+echo " $DSCMD5S dummy unneeded dscfilename_fileversion~.dsc" >> i/test.changes
+echo " 33a1096ff883d52f0c1f39e652d6336f 33 - - strangefile_xyz" >> i/test.changes
+testrun - -b . processincoming default 3<<EOF
+returns 255
+stderr
+=Unknown file type: '33a1096ff883d52f0c1f39e652d6336f 33 - - strangefile_xyz', assuming source format...
+*=file 'strangefile_xyz' has conflicting checksums listed in 'test.changes' and 'dscfilename_fileversion~.dsc'!
+-v0*=There have been errors!
+EOF
+find pool -type f | LC_ALL=C sort -f > results
+cat > results.expected <<EOF
+pool/cat/b/bird/bird-addons_1_all.deb
+pool/cat/b/bird/bird_1.dsc
+pool/cat/b/bird/bird_1.tar.gz
+pool/cat/b/bird/bird_1_abacus.deb
+pool/dog/b/bird/bird-addons_1_all.deb
+pool/dog/b/bird/bird_1.dsc
+pool/dog/b/bird/bird_1.tar.gz
+pool/dog/b/bird/bird_1_abacus.deb
+pool/dog/d/dscfilename/dscfilename_0versionindsc.dsc
+pool/dog/s/sourceindeb/indebname_0versionindeb~1_all.deb
+EOF
+dodiff results.expected results
+find dists -type f | LC_ALL=C sort -f > results
+cat > results.expected <<EOF
+dists/A/cat/binary-abacus/Packages
+dists/A/cat/binary-abacus/Packages.gz
+dists/A/cat/binary-abacus/Release
+dists/A/cat/binary-calculator/Packages
+dists/A/cat/binary-calculator/Packages.gz
+dists/A/cat/binary-calculator/Release
+dists/A/dog/binary-abacus/Packages
+dists/A/dog/binary-abacus/Packages.gz
+dists/A/dog/binary-abacus/Release
+dists/A/dog/binary-calculator/Packages
+dists/A/dog/binary-calculator/Packages.gz
+dists/A/dog/binary-calculator/Release
+dists/A/Release
+dists/B/cat/binary-abacus/Packages
+dists/B/cat/binary-abacus/Packages.gz
+dists/B/cat/binary-abacus/Release
+dists/B/cat/Contents-abacus.gz
+dists/B/cat/source/Release
+dists/B/cat/source/Sources.gz
+dists/B/Contents-abacus.gz
+dists/B/dog/binary-abacus/Packages
+dists/B/dog/binary-abacus/Packages.gz
+dists/B/dog/binary-abacus/Release
+dists/B/dog/Contents-abacus.gz
+dists/B/dog/source/Release
+dists/B/dog/source/Sources.gz
+dists/B/Release
+EOF
+dodiff results.expected results
+gunzip -c dists/B/dog/source/Sources.gz | sed -e 's/ \+$//' > results
+withoutchecksums pool/dog/b/bird/bird_1.dsc | sed -e 's/ \+$//' >bird.preprocessed
+ed -s bird.preprocessed <<EOF
+H
+/^Source:/ m 0
+s/^Source: /Package: /
+/^Files:/ kf
+'f i
+Priority: superfluous
+Section: tasty
+Directory: pool/dog/b/bird
+.
+'f a
+ $BIRDDSCMD5S bird_1.dsc
+.
+$ a
+Checksums-Sha1:
+ $BIRDDSCSHA1S bird_1.dsc
+ $BIRDTARSHA1S bird_1.tar.gz
+Checksums-Sha256:
+ $BIRDDSCSHA2S bird_1.dsc
+ $BIRDTARSHA2S bird_1.tar.gz
+
+.
+w
+q
+EOF
+cat bird.preprocessed - > results.expected <<EOF
+Package: dscfilename
+Format: 1.0
+Maintainer: guess who <me@nowhere>
+Standards-Version: 0
+Version: 0versionindsc
+Priority: can't-live-without
+Section: dummy
+Directory: pool/dog/d/dscfilename
+Files:
+ $OLDDSCFILENAMEMD5S dscfilename_0versionindsc.dsc
+Checksums-Sha1:
+ $OLDDSCFILENAMESHA1S dscfilename_0versionindsc.dsc
+Checksums-Sha256:
+ $OLDDSCFILENAMESHA2S dscfilename_0versionindsc.dsc
+
+EOF
+dodiff results.expected results
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+printf '$d\nw\nq\n' | ed -s i/test.changes
+echo " 31a1096ff883d52f0c1f39e652d6336f 33 - - strangefile_xyz" >> i/test.changes
+checknolog logfile
+testrun - -b . processincoming default 3<<EOF
+returns 0
+stderr
+=Unknown file type: '31a1096ff883d52f0c1f39e652d6336f 33 - - strangefile_xyz', assuming source format...
+stdout
+$(ofa 'pool/dog/d/dscfilename/dscfilename_newversion~.dsc')
+$(ofa 'pool/dog/d/dscfilename/strangefile_xyz')
+$(opu 'dscfilename' x x 'B' 'dog' 'source' 'dsc')
+-v3*=deleting './i/dscfilename_fileversion~.dsc'...
+-v3*=deleting './i/test.changes'...
+-v3*=deleting './i/strangefile_xyz'...
+-v0*=Exporting indices...
+-v6*= looking for changes in 'B|dog|abacus'...
+-v6*= looking for changes in 'B|dog|source'...
+-v6*= replacing './dists/B/dog/source/Sources' (gzipped)
+-v6*= looking for changes in 'B|cat|abacus'...
+-v6*= looking for changes in 'B|cat|source'...
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/dog/d/dscfilename/dscfilename_0versionindsc.dsc')
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog logfile <<EOF
+DATESTR replace B dsc dog source dscfilename 1:newversion~ 0versionindsc
+EOF
+
+find pool -type f | LC_ALL=C sort -f > results
+cat > results.expected <<EOF
+pool/cat/b/bird/bird-addons_1_all.deb
+pool/cat/b/bird/bird_1.dsc
+pool/cat/b/bird/bird_1.tar.gz
+pool/cat/b/bird/bird_1_abacus.deb
+pool/dog/b/bird/bird-addons_1_all.deb
+pool/dog/b/bird/bird_1.dsc
+pool/dog/b/bird/bird_1.tar.gz
+pool/dog/b/bird/bird_1_abacus.deb
+pool/dog/d/dscfilename/dscfilename_newversion~.dsc
+pool/dog/d/dscfilename/strangefile_xyz
+pool/dog/s/sourceindeb/indebname_0versionindeb~1_all.deb
+EOF
+dodiff results.expected results
+find dists -type f | LC_ALL=C sort -f > results
+cat > results.expected <<EOF
+dists/A/cat/binary-abacus/Packages
+dists/A/cat/binary-abacus/Packages.gz
+dists/A/cat/binary-abacus/Release
+dists/A/cat/binary-calculator/Packages
+dists/A/cat/binary-calculator/Packages.gz
+dists/A/cat/binary-calculator/Release
+dists/A/dog/binary-abacus/Packages
+dists/A/dog/binary-abacus/Packages.gz
+dists/A/dog/binary-abacus/Release
+dists/A/dog/binary-calculator/Packages
+dists/A/dog/binary-calculator/Packages.gz
+dists/A/dog/binary-calculator/Release
+dists/A/Release
+dists/B/cat/binary-abacus/Packages
+dists/B/cat/binary-abacus/Packages.gz
+dists/B/cat/binary-abacus/Release
+dists/B/cat/Contents-abacus.gz
+dists/B/cat/source/Release
+dists/B/cat/source/Sources.gz
+dists/B/Contents-abacus.gz
+dists/B/dog/binary-abacus/Packages
+dists/B/dog/binary-abacus/Packages.gz
+dists/B/dog/binary-abacus/Release
+dists/B/dog/Contents-abacus.gz
+dists/B/dog/source/Release
+dists/B/dog/source/Sources.gz
+dists/B/Release
+EOF
+dodiff results.expected results
+gunzip -c dists/B/dog/source/Sources.gz | sed -e 's/ \+$//' > results
+cat bird.preprocessed - > results.expected <<EOF
+Package: dscfilename
+Format: 1.0
+Maintainer: guess who <me@nowhere>
+Standards-Version: 0
+Version: 1:newversion~
+Priority: unneeded
+Section: dummy
+Directory: pool/dog/d/dscfilename
+Files:
+ $DSCFILENAMEMD5S dscfilename_newversion~.dsc
+ 31a1096ff883d52f0c1f39e652d6336f 33 strangefile_xyz
+Checksums-Sha1:
+ $DSCFILENAMESHA1S dscfilename_newversion~.dsc
+ 4453da6ca46859b207c5b55af6213ff8369cd383 33 strangefile_xyz
+Checksums-Sha256:
+ $DSCFILENAMESHA2S dscfilename_newversion~.dsc
+ c40fcf711220c0ce210159d43b22f1f59274819bf3575e11cc0057ed1988a575 33 strangefile_xyz
+
+EOF
+dodiff results.expected results
+
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+
+rm -r conf db pool dists i pkg logs temp
+rm results.expected results.log.expected results bird.preprocessed
+testsuccess
diff --git a/tests/various2.test b/tests/various2.test
new file mode 100644
index 0000000..c67184e
--- /dev/null
+++ b/tests/various2.test
@@ -0,0 +1,2462 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+echo "Running various other old test..."
+mkdir -p conf logs
+cat > conf/options <<CONFEND
+outhook $SRCDIR/docs/outstore.py
+export changed
+CONFEND
+export REPREPRO_OUT_DB=db.out
+cat > conf/distributions <<CONFEND
+Codename: test1
+Architectures: abacus source
+Components: stupid ugly
+Update: Test2toTest1
+DebIndices: Packages Release . .gz .bz2
+UDebIndices: Packages .gz .bz2
+DscIndices: Sources Release .gz .bz2
+Tracking: keep includechanges includebyhand
+Log: log1
+
+Codename: test2
+Architectures: abacus coal source
+Components: stupid ugly
+Origin: Brain
+Label: Only a test
+Suite: broken
+Version: 9999999.02
+DebIndices: Packages Release . .gz $SRCDIR/docs/bzip.example testhook
+UDebIndices: Packages .gz
+DscIndices: Sources Release . .gz $SRCDIR/docs/bzip.example testhook
+Description: test with all fields set
+DebOverride: binoverride
+DscOverride: srcoverride
+Log: log2
+CONFEND
+
+cat > conf/testhook <<'EOF'
+#!/bin/sh
+echo "testhook got $#: '$1' '$2' '$3' '$4'"
+if test -f "$1/$3.deprecated" ; then
+ echo "$3.deprecated.tobedeleted" >&3
+fi
+echo "super-compressed" > "$1/$3.super.new"
+echo "$3.super.new" >&3
+EOF
+chmod a+x conf/testhook
+
+mkdir -p "dists/test2/stupid/binary-abacus"
+touch "dists/test2/stupid/binary-abacus/Packages.deprecated"
+cat > logs/fake.outlog << EOF
+BEGIN-DISTRIBUTION test2 dists/test2
+DISTFILE dists/test2 stupid/binary-abacus/Packages.deprecated dists/test2/stupid/binary-abacus/Packages.deprecated
+END-DISTRIBUTION test2 dists/test2
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py logs/fake.outlog
+rm logs/fake.outlog
+
+set -v
+checknolog logfile
+testrun - -b . export test1 test2 3<<EOF
+stdout
+*=testhook got 4: './dists/test2' 'stupid/binary-abacus/Packages.new' 'stupid/binary-abacus/Packages' 'new'
+*=testhook got 4: './dists/test2' 'stupid/binary-coal/Packages.new' 'stupid/binary-coal/Packages' 'new'
+*=testhook got 4: './dists/test2' 'stupid/source/Sources.new' 'stupid/source/Sources' 'new'
+*=testhook got 4: './dists/test2' 'ugly/binary-abacus/Packages.new' 'ugly/binary-abacus/Packages' 'new'
+*=testhook got 4: './dists/test2' 'ugly/binary-coal/Packages.new' 'ugly/binary-coal/Packages' 'new'
+*=testhook got 4: './dists/test2' 'ugly/source/Sources.new' 'ugly/source/Sources' 'new'
+$(odb)
+-v1*=Exporting test2...
+-v6*= exporting 'test2|stupid|abacus'...
+-v6*= creating './dists/test2/stupid/binary-abacus/Packages' (uncompressed,gzipped,script: bzip.example,testhook)
+-v11*=Exporthook successfully returned!
+-v2*=Created directory "./dists/test2/stupid/binary-coal"
+-v6*= exporting 'test2|stupid|coal'...
+-v6*= creating './dists/test2/stupid/binary-coal/Packages' (uncompressed,gzipped,script: bzip.example,testhook)
+-v2*=Created directory "./dists/test2/stupid/source"
+-v6*= exporting 'test2|stupid|source'...
+-v6*= creating './dists/test2/stupid/source/Sources' (uncompressed,gzipped,script: bzip.example,testhook)
+-v2*=Created directory "./dists/test2/ugly"
+-v2*=Created directory "./dists/test2/ugly/binary-abacus"
+-v6*= exporting 'test2|ugly|abacus'...
+-v6*= creating './dists/test2/ugly/binary-abacus/Packages' (uncompressed,gzipped,script: bzip.example,testhook)
+-v2*=Created directory "./dists/test2/ugly/binary-coal"
+-v6*= exporting 'test2|ugly|coal'...
+-v6*= creating './dists/test2/ugly/binary-coal/Packages' (uncompressed,gzipped,script: bzip.example,testhook)
+-v2*=Created directory "./dists/test2/ugly/source"
+-v6*= exporting 'test2|ugly|source'...
+-v6*= creating './dists/test2/ugly/source/Sources' (uncompressed,gzipped,script: bzip.example,testhook)
+-v1*=Exporting test1...
+-v2*=Created directory "./dists/test1"
+-v2*=Created directory "./dists/test1/stupid"
+-v2*=Created directory "./dists/test1/stupid/binary-abacus"
+-v6*= exporting 'test1|stupid|abacus'...
+-v6*= creating './dists/test1/stupid/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v2*=Created directory "./dists/test1/stupid/source"
+-v6*= exporting 'test1|stupid|source'...
+-v6*= creating './dists/test1/stupid/source/Sources' (gzipped,bzip2ed)
+-v2*=Created directory "./dists/test1/ugly"
+-v2*=Created directory "./dists/test1/ugly/binary-abacus"
+-v6*= exporting 'test1|ugly|abacus'...
+-v6*= creating './dists/test1/ugly/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v2*=Created directory "./dists/test1/ugly/source"
+-v6*= exporting 'test1|ugly|source'...
+-v6*= creating './dists/test1/ugly/source/Sources' (gzipped,bzip2ed)
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+dodo test '!' -e "dists/test2/stupid/binary-abacus/Packages.deprecated"
+test -f dists/test1/Release
+test -f dists/test2/Release
+
+cat > dists/test1/stupid/binary-abacus/Release.expected <<END
+Component: stupid
+Architecture: abacus
+END
+dodiff dists/test1/stupid/binary-abacus/Release.expected dists/test1/stupid/binary-abacus/Release
+rm dists/test1/stupid/binary-abacus/Release.expected
+cat > dists/test1/ugly/binary-abacus/Release.expected <<END
+Component: ugly
+Architecture: abacus
+END
+dodiff dists/test1/ugly/binary-abacus/Release.expected dists/test1/ugly/binary-abacus/Release
+rm dists/test1/ugly/binary-abacus/Release.expected
+
+echo "super-compressed" > "fakesuper"
+FAKESUPERMD5="$(mdandsize fakesuper)"
+FAKESUPERSHA1="$(sha1andsize fakesuper)"
+FAKESUPERSHA2="$(sha2andsize fakesuper)"
+
+cat > Release.test1.expected <<END
+Codename: test1
+Date: normalized
+Architectures: abacus
+Components: stupid ugly
+MD5Sum:
+ $EMPTYMD5 stupid/binary-abacus/Packages
+ $EMPTYGZMD5 stupid/binary-abacus/Packages.gz
+ $EMPTYBZ2MD5 stupid/binary-abacus/Packages.bz2
+ $(mdandsize dists/test1/stupid/binary-abacus/Release) stupid/binary-abacus/Release
+ $EMPTYMD5 stupid/source/Sources
+ $EMPTYGZMD5 stupid/source/Sources.gz
+ $EMPTYBZ2MD5 stupid/source/Sources.bz2
+ e38c7da133734e1fd68a7e344b94fe96 39 stupid/source/Release
+ $EMPTYMD5 ugly/binary-abacus/Packages
+ $EMPTYGZMD5 ugly/binary-abacus/Packages.gz
+ $EMPTYBZ2MD5 ugly/binary-abacus/Packages.bz2
+ $(mdandsize dists/test1/ugly/binary-abacus/Release) ugly/binary-abacus/Release
+ $EMPTYMD5 ugly/source/Sources
+ $EMPTYGZMD5 ugly/source/Sources.gz
+ $EMPTYBZ2MD5 ugly/source/Sources.bz2
+ ed4ee9aa5d080f67926816133872fd02 37 ugly/source/Release
+SHA1:
+ $(sha1andsize dists/test1/stupid/binary-abacus/Packages) stupid/binary-abacus/Packages
+ $EMPTYGZSHA1 stupid/binary-abacus/Packages.gz
+ $EMPTYBZ2SHA1 stupid/binary-abacus/Packages.bz2
+ $(sha1andsize dists/test1/stupid/binary-abacus/Release) stupid/binary-abacus/Release
+ $EMPTYSHA1 stupid/source/Sources
+ $EMPTYGZSHA1 stupid/source/Sources.gz
+ $EMPTYBZ2SHA1 stupid/source/Sources.bz2
+ ff71705a4cadaec55de5a6ebbfcd726caf2e2606 39 stupid/source/Release
+ $EMPTYSHA1 ugly/binary-abacus/Packages
+ $EMPTYGZSHA1 ugly/binary-abacus/Packages.gz
+ $EMPTYBZ2SHA1 ugly/binary-abacus/Packages.bz2
+ $(sha1andsize dists/test1/ugly/binary-abacus/Release) ugly/binary-abacus/Release
+ $EMPTYSHA1 ugly/source/Sources
+ $EMPTYGZSHA1 ugly/source/Sources.gz
+ $EMPTYBZ2SHA1 ugly/source/Sources.bz2
+ b297876e9d6ee3ee6083160003755047ede22a96 37 ugly/source/Release
+SHA256:
+ $(sha2andsize dists/test1/stupid/binary-abacus/Packages) stupid/binary-abacus/Packages
+ $EMPTYGZSHA2 stupid/binary-abacus/Packages.gz
+ $EMPTYBZ2SHA2 stupid/binary-abacus/Packages.bz2
+ $(sha2andsize dists/test1/stupid/binary-abacus/Release) stupid/binary-abacus/Release
+ $EMPTYSHA2 stupid/source/Sources
+ $EMPTYGZSHA2 stupid/source/Sources.gz
+ $EMPTYBZ2SHA2 stupid/source/Sources.bz2
+ b88352d8e0227a133e2236c3a8961581562ee285980fc20bb79626d0d208aa51 39 stupid/source/Release
+ $EMPTYSHA2 ugly/binary-abacus/Packages
+ $EMPTYGZSHA2 ugly/binary-abacus/Packages.gz
+ $EMPTYBZ2SHA2 ugly/binary-abacus/Packages.bz2
+ $(sha2andsize dists/test1/ugly/binary-abacus/Release) ugly/binary-abacus/Release
+ $EMPTYSHA2 ugly/source/Sources
+ $EMPTYGZSHA2 ugly/source/Sources.gz
+ $EMPTYBZ2SHA2 ugly/source/Sources.bz2
+ edb5450a3f98a140b938c8266b8b998ba8f426c80ac733fe46423665d5770d9f 37 ugly/source/Release
+END
+cat > dists/test2/stupid/binary-abacus/Release.expected <<END
+Archive: broken
+Version: 9999999.02
+Component: stupid
+Origin: Brain
+Label: Only a test
+Architecture: abacus
+Description: test with all fields set
+END
+dodiff dists/test2/stupid/binary-abacus/Release.expected dists/test2/stupid/binary-abacus/Release
+rm dists/test2/stupid/binary-abacus/Release.expected
+cat > dists/test2/ugly/binary-abacus/Release.expected <<END
+Archive: broken
+Version: 9999999.02
+Component: ugly
+Origin: Brain
+Label: Only a test
+Architecture: abacus
+Description: test with all fields set
+END
+dodiff dists/test2/ugly/binary-abacus/Release.expected dists/test2/ugly/binary-abacus/Release
+rm dists/test2/ugly/binary-abacus/Release.expected
+cat > Release.test2.expected <<END
+Origin: Brain
+Label: Only a test
+Suite: broken
+Codename: test2
+Version: 9999999.02
+Date: normalized
+Architectures: abacus coal
+Components: stupid ugly
+Description: test with all fields set
+MD5Sum:
+ $EMPTYMD5 stupid/binary-abacus/Packages
+ $EMPTYGZMD5 stupid/binary-abacus/Packages.gz
+ $EMPTYBZ2MD5 stupid/binary-abacus/Packages.bz2
+ $FAKESUPERMD5 stupid/binary-abacus/Packages.super
+ $(mdandsize dists/test2/stupid/binary-abacus/Release) stupid/binary-abacus/Release
+ $EMPTYMD5 stupid/binary-coal/Packages
+ $EMPTYGZMD5 stupid/binary-coal/Packages.gz
+ $EMPTYBZ2MD5 stupid/binary-coal/Packages.bz2
+ $FAKESUPERMD5 stupid/binary-coal/Packages.super
+ 10ae2f283e1abdd3facfac6ed664035d 144 stupid/binary-coal/Release
+ $EMPTYMD5 stupid/source/Sources
+ $EMPTYGZMD5 stupid/source/Sources.gz
+ $EMPTYBZ2MD5 stupid/source/Sources.bz2
+ $FAKESUPERMD5 stupid/source/Sources.super
+ b923b3eb1141e41f0b8bb74297ac8a36 146 stupid/source/Release
+ $EMPTYMD5 ugly/binary-abacus/Packages
+ $EMPTYGZMD5 ugly/binary-abacus/Packages.gz
+ $EMPTYBZ2MD5 ugly/binary-abacus/Packages.bz2
+ $FAKESUPERMD5 ugly/binary-abacus/Packages.super
+ $(mdandsize dists/test2/ugly/binary-abacus/Release) ugly/binary-abacus/Release
+ $EMPTYMD5 ugly/binary-coal/Packages
+ $EMPTYGZMD5 ugly/binary-coal/Packages.gz
+ $EMPTYBZ2MD5 ugly/binary-coal/Packages.bz2
+ $FAKESUPERMD5 ugly/binary-coal/Packages.super
+ 7a05de3b706d08ed06779d0ec2e234e9 142 ugly/binary-coal/Release
+ $EMPTYMD5 ugly/source/Sources
+ $EMPTYGZMD5 ugly/source/Sources.gz
+ $EMPTYBZ2MD5 ugly/source/Sources.bz2
+ $FAKESUPERMD5 ugly/source/Sources.super
+ e73a8a85315766763a41ad4dc6744bf5 144 ugly/source/Release
+SHA1:
+ $EMPTYSHA1 stupid/binary-abacus/Packages
+ $EMPTYGZSHA1 stupid/binary-abacus/Packages.gz
+ $EMPTYBZ2SHA1 stupid/binary-abacus/Packages.bz2
+ $FAKESUPERSHA1 stupid/binary-abacus/Packages.super
+ $(sha1andsize dists/test2/stupid/binary-abacus/Release) stupid/binary-abacus/Release
+ $EMPTYSHA1 stupid/binary-coal/Packages
+ $EMPTYGZSHA1 stupid/binary-coal/Packages.gz
+ $EMPTYBZ2SHA1 stupid/binary-coal/Packages.bz2
+ $FAKESUPERSHA1 stupid/binary-coal/Packages.super
+ $(sha1andsize dists/test2/stupid/binary-coal/Release) stupid/binary-coal/Release
+ $EMPTYSHA1 stupid/source/Sources
+ $EMPTYGZSHA1 stupid/source/Sources.gz
+ $EMPTYBZ2SHA1 stupid/source/Sources.bz2
+ $FAKESUPERSHA1 stupid/source/Sources.super
+ $(sha1andsize dists/test2/stupid/source/Release) stupid/source/Release
+ $EMPTYSHA1 ugly/binary-abacus/Packages
+ $EMPTYGZSHA1 ugly/binary-abacus/Packages.gz
+ $EMPTYBZ2SHA1 ugly/binary-abacus/Packages.bz2
+ $FAKESUPERSHA1 ugly/binary-abacus/Packages.super
+ $(sha1andsize dists/test2/ugly/binary-abacus/Release) ugly/binary-abacus/Release
+ $EMPTYSHA1 ugly/binary-coal/Packages
+ $EMPTYGZSHA1 ugly/binary-coal/Packages.gz
+ $EMPTYBZ2SHA1 ugly/binary-coal/Packages.bz2
+ $FAKESUPERSHA1 ugly/binary-coal/Packages.super
+ $(sha1andsize dists/test2/ugly/binary-coal/Release) ugly/binary-coal/Release
+ $EMPTYSHA1 ugly/source/Sources
+ $EMPTYGZSHA1 ugly/source/Sources.gz
+ $EMPTYBZ2SHA1 ugly/source/Sources.bz2
+ $FAKESUPERSHA1 ugly/source/Sources.super
+ $(sha1andsize dists/test2/ugly/source/Release) ugly/source/Release
+SHA256:
+ $EMPTYSHA2 stupid/binary-abacus/Packages
+ $EMPTYGZSHA2 stupid/binary-abacus/Packages.gz
+ $EMPTYBZ2SHA2 stupid/binary-abacus/Packages.bz2
+ $FAKESUPERSHA2 stupid/binary-abacus/Packages.super
+ $(sha2andsize dists/test2/stupid/binary-abacus/Release) stupid/binary-abacus/Release
+ $EMPTYSHA2 stupid/binary-coal/Packages
+ $EMPTYGZSHA2 stupid/binary-coal/Packages.gz
+ $EMPTYBZ2SHA2 stupid/binary-coal/Packages.bz2
+ $FAKESUPERSHA2 stupid/binary-coal/Packages.super
+ $(sha2andsize dists/test2/stupid/binary-coal/Release) stupid/binary-coal/Release
+ $EMPTYSHA2 stupid/source/Sources
+ $EMPTYGZSHA2 stupid/source/Sources.gz
+ $EMPTYBZ2SHA2 stupid/source/Sources.bz2
+ $FAKESUPERSHA2 stupid/source/Sources.super
+ $(sha2andsize dists/test2/stupid/source/Release) stupid/source/Release
+ $EMPTYSHA2 ugly/binary-abacus/Packages
+ $EMPTYGZSHA2 ugly/binary-abacus/Packages.gz
+ $EMPTYBZ2SHA2 ugly/binary-abacus/Packages.bz2
+ $FAKESUPERSHA2 ugly/binary-abacus/Packages.super
+ $(sha2andsize dists/test2/ugly/binary-abacus/Release) ugly/binary-abacus/Release
+ $EMPTYSHA2 ugly/binary-coal/Packages
+ $EMPTYGZSHA2 ugly/binary-coal/Packages.gz
+ $EMPTYBZ2SHA2 ugly/binary-coal/Packages.bz2
+ $FAKESUPERSHA2 ugly/binary-coal/Packages.super
+ $(sha2andsize dists/test2/ugly/binary-coal/Release) ugly/binary-coal/Release
+ $EMPTYSHA2 ugly/source/Sources
+ $EMPTYGZSHA2 ugly/source/Sources.gz
+ $EMPTYBZ2SHA2 ugly/source/Sources.bz2
+ $FAKESUPERSHA2 ugly/source/Sources.super
+ $(sha2andsize dists/test2/ugly/source/Release) ugly/source/Release
+END
+normalizerelease dists/test1/Release > dists/test1/Release.normalized
+normalizerelease dists/test2/Release > dists/test2/Release.normalized
+dodiff Release.test1.expected dists/test1/Release.normalized
+dodiff Release.test2.expected dists/test2/Release.normalized
+rm dists/*/Release.normalized
+
+PACKAGE=simple EPOCH="" VERSION=1 REVISION="" SECTION="stupid/base" genpackage.sh
+checknolog log1
+testrun - -b . include test1 test.changes 3<<EOF
+stdout
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/stupid"
+-v2*=Created directory "./pool/stupid/s"
+-v2*=Created directory "./pool/stupid/s/simple"
+$(ofa 'pool/stupid/s/simple/simple-addons_1_all.deb')
+$(ofa 'pool/stupid/s/simple/simple_1_abacus.deb')
+$(ofa 'pool/stupid/s/simple/simple_1.tar.gz')
+$(ofa 'pool/stupid/s/simple/simple_1.dsc')
+$(ofa 'pool/stupid/s/simple/simple_1_source+all+abacus.changes')
+$(opa 'simple-addons' x 'test1' 'stupid' 'abacus' 'deb')
+$(opa 'simple' x 'test1' 'stupid' 'abacus' 'deb')
+$(opa 'simple' unset 'test1' 'stupid' 'source' 'dsc')
+$(ota 'test1' 'simple')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= replacing './dists/test1/stupid/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= replacing './dists/test1/stupid/source/Sources' (gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= looking for changes in 'test1|ugly|source'...
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+echo returned: $?
+checklog log1 << EOF
+DATESTR add test1 deb stupid abacus simple-addons 1
+DATESTR add test1 deb stupid abacus simple 1
+DATESTR add test1 dsc stupid source simple 1
+EOF
+
+PACKAGE=bloat+-0a9z.app EPOCH=99: VERSION=0.9-A:Z+a:z REVISION=-0+aA.9zZ SECTION="ugly/base" genpackage.sh
+testrun - -b . include test1 test.changes 3<<EOF
+stdout
+-v2*=Created directory "./pool/ugly"
+-v2*=Created directory "./pool/ugly/b"
+-v2*=Created directory "./pool/ugly/b/bloat+-0a9z.app"
+$(ofa 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_0.9-A:Z+a:z-0+aA.9zZ_all.deb')
+$(ofa 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ_abacus.deb')
+$(ofa 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.tar.gz')
+$(ofa 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.dsc')
+$(ofa 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_99:0.9-A:Z+a:z-0+aA.9zZ_source+all+abacus.changes')
+$(opa 'bloat+-0a9z.app-addons' x 'test1' 'ugly' 'abacus' 'deb')
+$(opa 'bloat+-0a9z.app' x 'test1' 'ugly' 'abacus' 'deb')
+$(opa 'bloat+-0a9z.app' unset 'test1' 'ugly' 'source' 'dsc')
+$(ota 'test1' 'bloat+-0a9z.app')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= replacing './dists/test1/ugly/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|ugly|source'...
+-v6*= replacing './dists/test1/ugly/source/Sources' (gzipped,bzip2ed)
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+echo returned: $?
+checklog log1 <<EOF
+DATESTR add test1 deb ugly abacus bloat+-0a9z.app-addons 99:0.9-A:Z+a:z-0+aA.9zZ
+DATESTR add test1 deb ugly abacus bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ
+DATESTR add test1 dsc ugly source bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ
+EOF
+
+testrun - -b . -Tdsc remove test1 simple 3<<EOF
+stdout
+$(opd 'simple' unset test1 stupid source dsc)
+=[tracking_get test1 simple 1]
+=[tracking_get found test1 simple 1]
+=[tracking_save test1 simple 1]
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= replacing './dists/test1/stupid/source/Sources' (gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= looking for changes in 'test1|ugly|source'...
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log1 <<EOF
+DATESTR remove test1 dsc stupid source simple 1
+EOF
+testrun - -b . -Tdeb remove test1 bloat+-0a9z.app 3<<EOF
+stdout
+$(opd 'bloat+-0a9z.app' unset test1 ugly abacus deb)
+=[tracking_get test1 bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ]
+=[tracking_get found test1 bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ]
+=[tracking_save test1 bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ]
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= replacing './dists/test1/ugly/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|ugly|source'...
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log1 <<EOF
+DATESTR remove test1 deb ugly abacus bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ
+EOF
+testrun - -b . -A source remove test1 bloat+-0a9z.app 3<<EOF
+stdout
+$(opd 'bloat+-0a9z.app' unset test1 ugly source dsc)
+=[tracking_get test1 bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ]
+=[tracking_get found test1 bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ]
+=[tracking_save test1 bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ]
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= looking for changes in 'test1|ugly|source'...
+-v6*= replacing './dists/test1/ugly/source/Sources' (gzipped,bzip2ed)
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log1 <<EOF
+DATESTR remove test1 dsc ugly source bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ
+EOF
+testrun - -b . -A abacus remove test1 simple 3<<EOF
+stdout
+$(opd 'simple' unset test1 stupid abacus deb)
+=[tracking_get test1 simple 1]
+=[tracking_get found test1 simple 1]
+=[tracking_save test1 simple 1]
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= replacing './dists/test1/stupid/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= looking for changes in 'test1|ugly|source'...
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log1 <<EOF
+DATESTR remove test1 deb stupid abacus simple 1
+EOF
+testrun - -b . -C ugly remove test1 bloat+-0a9z.app-addons 3<<EOF
+stdout
+$(opd 'bloat+-0a9z.app-addons' unset test1 ugly abacus deb)
+=[tracking_get test1 bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ]
+=[tracking_get found test1 bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ]
+=[tracking_save test1 bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ]
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= replacing './dists/test1/ugly/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|ugly|source'...
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log1 <<EOF
+DATESTR remove test1 deb ugly abacus bloat+-0a9z.app-addons 99:0.9-A:Z+a:z-0+aA.9zZ
+EOF
+testrun - -b . -C stupid remove test1 simple-addons 3<<EOF
+stdout
+$(opd 'simple-addons' unset test1 stupid abacus deb)
+=[tracking_get test1 simple 1]
+=[tracking_get found test1 simple 1]
+=[tracking_save test1 simple 1]
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= replacing './dists/test1/stupid/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= looking for changes in 'test1|ugly|source'...
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log1 <<EOF
+DATESTR remove test1 deb stupid abacus simple-addons 1
+EOF
+CURDATE="`TZ=GMT LC_ALL=C date +'%a, %d %b %Y %H:%M:%S UTC'`"
+normalizerelease dists/test1/Release > Release.test1.normalized
+dodiff Release.test1.expected Release.test1.normalized
+rm Release.test1.normalized
+
+cat > conf/srcoverride <<END
+simple Section ugly/games
+simple Priority optional
+simple Maintainer simple.source.maintainer
+bloat+-0a9z.app Section stupid/X11
+bloat+-0a9z.app Priority optional
+bloat+-0a9z.app X-addition totally-unsupported
+bloat+-0a9z.app Maintainer bloat.source.maintainer
+END
+cat > conf/binoverride <<END
+simple Maintainer simple.maintainer
+simple Section ugly/base
+simple Priority optional
+simple-addons Section ugly/addons
+simple-addons Priority optional
+simple-addons Maintainer simple.add.maintainer
+bloat+-0a9z.app Maintainer bloat.maintainer
+bloat+-0a9z.app Section stupid/base
+bloat+-0a9z.app Priority optional
+bloat+-0a9z.app-addons Section stupid/addons
+bloat+-0a9z.app-addons Maintainer bloat.add.maintainer
+bloat+-0a9z.app-addons Priority optional
+END
+
+testrun - -b . -Tdsc -A source includedsc test2 simple_1.dsc 3<<EOF
+stderr
+-v1=simple_1.dsc: component guessed as 'ugly'
+stdout
+*=testhook got 4: './dists/test2' 'stupid/binary-abacus/Packages.new' 'stupid/binary-abacus/Packages' 'old'
+*=testhook got 4: './dists/test2' 'stupid/binary-coal/Packages.new' 'stupid/binary-coal/Packages' 'old'
+*=testhook got 4: './dists/test2' 'stupid/source/Sources.new' 'stupid/source/Sources' 'old'
+*=testhook got 4: './dists/test2' 'ugly/binary-abacus/Packages.new' 'ugly/binary-abacus/Packages' 'old'
+*=testhook got 4: './dists/test2' 'ugly/binary-coal/Packages.new' 'ugly/binary-coal/Packages' 'old'
+*=testhook got 4: './dists/test2' 'ugly/source/Sources.new' 'ugly/source/Sources' 'change'
+-v2*=Created directory "./pool/ugly/s"
+-v2*=Created directory "./pool/ugly/s/simple"
+$(ofa 'pool/ugly/s/simple/simple_1.dsc')
+$(ofa 'pool/ugly/s/simple/simple_1.tar.gz')
+$(opa 'simple' unset 'test2' 'ugly' 'source' 'dsc')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test2|stupid|abacus'...
+-v11*=Exporthook successfully returned!
+-v6*= looking for changes in 'test2|stupid|coal'...
+-v6*= looking for changes in 'test2|stupid|source'...
+-v6*= looking for changes in 'test2|ugly|abacus'...
+-v6*= looking for changes in 'test2|ugly|coal'...
+-v6*= looking for changes in 'test2|ugly|source'...
+-v6*= replacing './dists/test2/ugly/source/Sources' (uncompressed,gzipped,script: bzip.example,testhook)
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log2 <<EOF
+DATESTR add test2 dsc ugly source simple 1
+EOF
+testrun - -b . -Tdsc -A source includedsc test2 bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.dsc 3<<EOF
+stderr
+-v1=bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.dsc: component guessed as 'stupid'
+stdout
+-v2*=Created directory "./pool/stupid/b"
+-v2*=Created directory "./pool/stupid/b/bloat+-0a9z.app"
+$(ofa 'pool/stupid/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.dsc')
+$(ofa 'pool/stupid/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.tar.gz')
+$(opa 'bloat+-0a9z.app' unset 'test2' 'stupid' 'source' 'dsc')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test2|stupid|abacus'...
+-v11*=Exporthook successfully returned!
+-v6*= looking for changes in 'test2|stupid|coal'...
+-v6*= looking for changes in 'test2|stupid|source'...
+-v6*= replacing './dists/test2/stupid/source/Sources' (uncompressed,gzipped,script: bzip.example,testhook)
+-v6*= looking for changes in 'test2|ugly|abacus'...
+-v6*= looking for changes in 'test2|ugly|coal'...
+-v6*= looking for changes in 'test2|ugly|source'...
+*=testhook got 4: './dists/test2' 'stupid/binary-abacus/Packages.new' 'stupid/binary-abacus/Packages' 'old'
+*=testhook got 4: './dists/test2' 'stupid/binary-coal/Packages.new' 'stupid/binary-coal/Packages' 'old'
+*=testhook got 4: './dists/test2' 'stupid/source/Sources.new' 'stupid/source/Sources' 'change'
+*=testhook got 4: './dists/test2' 'ugly/binary-abacus/Packages.new' 'ugly/binary-abacus/Packages' 'old'
+*=testhook got 4: './dists/test2' 'ugly/binary-coal/Packages.new' 'ugly/binary-coal/Packages' 'old'
+*=testhook got 4: './dists/test2' 'ugly/source/Sources.new' 'ugly/source/Sources' 'old'
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log2 <<EOF
+DATESTR add test2 dsc stupid source bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ
+EOF
+testrun - -b . -Tdeb -A abacus includedeb test2 simple_1_abacus.deb 3<<EOF
+stderr
+-v1=simple_1_abacus.deb: component guessed as 'ugly'
+stdout
+$(ofa 'pool/ugly/s/simple/simple_1_abacus.deb')
+$(opa 'simple' x 'test2' 'ugly' 'abacus' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test2|stupid|abacus'...
+-v11*=Exporthook successfully returned!
+-v6*= looking for changes in 'test2|stupid|coal'...
+-v6*= looking for changes in 'test2|stupid|source'...
+-v6*= looking for changes in 'test2|ugly|abacus'...
+-v6*= replacing './dists/test2/ugly/binary-abacus/Packages' (uncompressed,gzipped,script: bzip.example,testhook)
+-v6*= looking for changes in 'test2|ugly|coal'...
+-v6*= looking for changes in 'test2|ugly|source'...
+*=testhook got 4: './dists/test2' 'stupid/binary-abacus/Packages.new' 'stupid/binary-abacus/Packages' 'old'
+*=testhook got 4: './dists/test2' 'stupid/binary-coal/Packages.new' 'stupid/binary-coal/Packages' 'old'
+*=testhook got 4: './dists/test2' 'stupid/source/Sources.new' 'stupid/source/Sources' 'old'
+*=testhook got 4: './dists/test2' 'ugly/binary-abacus/Packages.new' 'ugly/binary-abacus/Packages' 'change'
+*=testhook got 4: './dists/test2' 'ugly/binary-coal/Packages.new' 'ugly/binary-coal/Packages' 'old'
+*=testhook got 4: './dists/test2' 'ugly/source/Sources.new' 'ugly/source/Sources' 'old'
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log2 <<EOF
+DATESTR add test2 deb ugly abacus simple 1
+EOF
+testrun - -b . -Tdeb -A coal includedeb test2 simple-addons_1_all.deb 3<<EOF
+stderr
+-v1=simple-addons_1_all.deb: component guessed as 'ugly'
+stdout
+$(ofa 'pool/ugly/s/simple/simple-addons_1_all.deb')
+$(opa 'simple-addons' x 'test2' 'ugly' 'coal' 'deb')
+-v0=Exporting indices...
+-v6*= looking for changes in 'test2|stupid|abacus'...
+-v11*=Exporthook successfully returned!
+-v6*= looking for changes in 'test2|stupid|coal'...
+-v6*= looking for changes in 'test2|stupid|source'...
+-v6*= looking for changes in 'test2|ugly|abacus'...
+-v6*= looking for changes in 'test2|ugly|coal'...
+-v6*= replacing './dists/test2/ugly/binary-coal/Packages' (uncompressed,gzipped,script: bzip.example,testhook)
+-v6*= looking for changes in 'test2|ugly|source'...
+*=testhook got 4: './dists/test2' 'stupid/binary-abacus/Packages.new' 'stupid/binary-abacus/Packages' 'old'
+*=testhook got 4: './dists/test2' 'stupid/binary-coal/Packages.new' 'stupid/binary-coal/Packages' 'old'
+*=testhook got 4: './dists/test2' 'stupid/source/Sources.new' 'stupid/source/Sources' 'old'
+*=testhook got 4: './dists/test2' 'ugly/binary-abacus/Packages.new' 'ugly/binary-abacus/Packages' 'old'
+*=testhook got 4: './dists/test2' 'ugly/binary-coal/Packages.new' 'ugly/binary-coal/Packages' 'change'
+*=testhook got 4: './dists/test2' 'ugly/source/Sources.new' 'ugly/source/Sources' 'old'
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log2 <<EOF
+DATESTR add test2 deb ugly coal simple-addons 1
+EOF
+testrun - -b . -Tdeb -A abacus includedeb test2 bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ_abacus.deb 3<<EOF
+stderr
+-v1=bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ_abacus.deb: component guessed as 'stupid'
+stdout
+$(ofa 'pool/stupid/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ_abacus.deb')
+$(opa 'bloat+-0a9z.app' x 'test2' 'stupid' 'abacus' 'deb')
+-v0=Exporting indices...
+-v6*= looking for changes in 'test2|stupid|abacus'...
+-v6*= replacing './dists/test2/stupid/binary-abacus/Packages' (uncompressed,gzipped,script: bzip.example,testhook)
+-v11*=Exporthook successfully returned!
+-v6*= looking for changes in 'test2|stupid|coal'...
+-v6*= looking for changes in 'test2|stupid|source'...
+-v6*= looking for changes in 'test2|ugly|abacus'...
+-v6*= looking for changes in 'test2|ugly|coal'...
+-v6*= looking for changes in 'test2|ugly|source'...
+*=testhook got 4: './dists/test2' 'stupid/binary-abacus/Packages.new' 'stupid/binary-abacus/Packages' 'change'
+*=testhook got 4: './dists/test2' 'stupid/binary-coal/Packages.new' 'stupid/binary-coal/Packages' 'old'
+*=testhook got 4: './dists/test2' 'stupid/source/Sources.new' 'stupid/source/Sources' 'old'
+*=testhook got 4: './dists/test2' 'ugly/binary-abacus/Packages.new' 'ugly/binary-abacus/Packages' 'old'
+*=testhook got 4: './dists/test2' 'ugly/binary-coal/Packages.new' 'ugly/binary-coal/Packages' 'old'
+*=testhook got 4: './dists/test2' 'ugly/source/Sources.new' 'ugly/source/Sources' 'old'
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log2 <<EOF
+DATESTR add test2 deb stupid abacus bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ
+EOF
+testrun - -b . -Tdeb -A coal includedeb test2 bloat+-0a9z.app-addons_0.9-A:Z+a:z-0+aA.9zZ_all.deb 3<<EOF
+stderr
+-v1=bloat+-0a9z.app-addons_0.9-A:Z+a:z-0+aA.9zZ_all.deb: component guessed as 'stupid'
+stdout
+$(ofa 'pool/stupid/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_0.9-A:Z+a:z-0+aA.9zZ_all.deb')
+$(opa 'bloat+-0a9z.app-addons' x 'test2' 'stupid' 'coal' 'deb')
+-v0=Exporting indices...
+-v6*= looking for changes in 'test2|stupid|abacus'...
+-v11*=Exporthook successfully returned!
+-v6*= looking for changes in 'test2|stupid|coal'...
+-v6*= replacing './dists/test2/stupid/binary-coal/Packages' (uncompressed,gzipped,script: bzip.example,testhook)
+-v6*= looking for changes in 'test2|stupid|source'...
+-v6*= looking for changes in 'test2|ugly|abacus'...
+-v6*= looking for changes in 'test2|ugly|coal'...
+-v6*= looking for changes in 'test2|ugly|source'...
+*=testhook got 4: './dists/test2' 'stupid/binary-abacus/Packages.new' 'stupid/binary-abacus/Packages' 'old'
+*=testhook got 4: './dists/test2' 'stupid/binary-coal/Packages.new' 'stupid/binary-coal/Packages' 'change'
+*=testhook got 4: './dists/test2' 'stupid/source/Sources.new' 'stupid/source/Sources' 'old'
+*=testhook got 4: './dists/test2' 'ugly/binary-abacus/Packages.new' 'ugly/binary-abacus/Packages' 'old'
+*=testhook got 4: './dists/test2' 'ugly/binary-coal/Packages.new' 'ugly/binary-coal/Packages' 'old'
+*=testhook got 4: './dists/test2' 'ugly/source/Sources.new' 'ugly/source/Sources' 'old'
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log2 <<EOF
+DATESTR add test2 deb stupid coal bloat+-0a9z.app-addons 99:0.9-A:Z+a:z-0+aA.9zZ
+EOF
+find dists/test2/ \( -name "Packages.gz" -o -name "Sources.gz" \) -print0 | xargs -0 zgrep '^\(Package\|Maintainer\|Section\|Priority\): ' | sort > results
+cat >results.expected <<END
+dists/test2/stupid/binary-abacus/Packages.gz:Maintainer: bloat.maintainer
+dists/test2/stupid/binary-abacus/Packages.gz:Package: bloat+-0a9z.app
+dists/test2/stupid/binary-abacus/Packages.gz:Priority: optional
+dists/test2/stupid/binary-abacus/Packages.gz:Section: stupid/base
+dists/test2/stupid/binary-coal/Packages.gz:Maintainer: bloat.add.maintainer
+dists/test2/stupid/binary-coal/Packages.gz:Package: bloat+-0a9z.app-addons
+dists/test2/stupid/binary-coal/Packages.gz:Priority: optional
+dists/test2/stupid/binary-coal/Packages.gz:Section: stupid/addons
+dists/test2/stupid/source/Sources.gz:Maintainer: bloat.source.maintainer
+dists/test2/stupid/source/Sources.gz:Package: bloat+-0a9z.app
+dists/test2/stupid/source/Sources.gz:Priority: optional
+dists/test2/stupid/source/Sources.gz:Section: stupid/X11
+dists/test2/ugly/binary-abacus/Packages.gz:Maintainer: simple.maintainer
+dists/test2/ugly/binary-abacus/Packages.gz:Package: simple
+dists/test2/ugly/binary-abacus/Packages.gz:Priority: optional
+dists/test2/ugly/binary-abacus/Packages.gz:Section: ugly/base
+dists/test2/ugly/binary-coal/Packages.gz:Maintainer: simple.add.maintainer
+dists/test2/ugly/binary-coal/Packages.gz:Package: simple-addons
+dists/test2/ugly/binary-coal/Packages.gz:Priority: optional
+dists/test2/ugly/binary-coal/Packages.gz:Section: ugly/addons
+dists/test2/ugly/source/Sources.gz:Maintainer: simple.source.maintainer
+dists/test2/ugly/source/Sources.gz:Package: simple
+dists/test2/ugly/source/Sources.gz:Priority: optional
+dists/test2/ugly/source/Sources.gz:Section: ugly/games
+END
+dodiff results.expected results
+rm results
+testout "" -b . listfilter test2 'Source(==simple)|(!Source,Package(==simple))'
+ls -la results
+cat > results.expected << END
+test2|ugly|abacus: simple 1
+test2|ugly|coal: simple-addons 1
+test2|ugly|source: simple 1
+END
+dodiff results.expected results
+testout "" -b . listfilter test2 'Source(==bloat+-0a9z.app)|(!Source,Package(==bloat+-0a9z.app))'
+cat > results.expected << END
+test2|stupid|abacus: bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ
+test2|stupid|coal: bloat+-0a9z.app-addons 99:0.9-A:Z+a:z-0+aA.9zZ
+test2|stupid|source: bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ
+END
+dodiff results.expected results
+
+cat >conf/updates <<END
+Name: Test2toTest1
+Method: copy:$WORKDIR
+VerifyRelease: blindtrust
+Suite: test2
+Architectures: coal>abacus abacus source
+FilterFormula: Priority(==optional),Package(>=alpha),Package(<=zeta)
+FilterList: error list
+ListHook: /bin/cp
+END
+
+cat >conf/list <<END
+simple-addons install
+bloat+-0a9z.app install
+simple install
+bloat+-0a9z.app-addons install
+END
+
+cp dists/test2/Release Release.test2.safe
+ed -s dists/test2/Release <<EOF
+g/stupid.source.Sources/s/^ ................................ / ffffffffffffffffffffffffffffffff /
+w
+q
+EOF
+
+testrun - -b . update test1 3<<EOF
+returns 254
+stderr
+=WARNING: Single-Instance not yet supported!
+=aptmethod error receiving 'copy:$WORKDIR/dists/test2/InRelease':
+='Failed to stat - stat (2: No such file or directory)'
+-v6*=aptmethod start 'copy:$WORKDIR/dists/test2/Release'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/test2/Release'
+-v6*=aptmethod start 'copy:$WORKDIR/dists/test2/ugly/source/Sources.bz2'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/test2/ugly/source/Sources.bz2'
+-v2*=Uncompress './lists/Test2toTest1_test2_ugly_Sources.bz2' into './lists/Test2toTest1_test2_ugly_Sources' using '/bin/bunzip2'...
+-v6*=aptmethod start 'copy:$WORKDIR/dists/test2/ugly/binary-abacus/Packages.bz2'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/test2/ugly/binary-abacus/Packages.bz2'
+-v2*=Uncompress './lists/Test2toTest1_test2_ugly_abacus_Packages.bz2' into './lists/Test2toTest1_test2_ugly_abacus_Packages' using '/bin/bunzip2'...
+-v6*=aptmethod start 'copy:$WORKDIR/dists/test2/ugly/binary-coal/Packages.bz2'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/test2/ugly/binary-coal/Packages.bz2'
+-v2*=Uncompress './lists/Test2toTest1_test2_ugly_coal_Packages.bz2' into './lists/Test2toTest1_test2_ugly_coal_Packages' using '/bin/bunzip2'...
+-v6*=aptmethod start 'copy:$WORKDIR/dists/test2/stupid/source/Sources.bz2'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/test2/stupid/source/Sources.bz2'
+*=Wrong checksum during receive of 'copy:$WORKDIR/dists/test2/stupid/source/Sources.bz2':
+*=md5 expected: ffffffffffffffffffffffffffffffff, got: $(md5 dists/test2/stupid/source/Sources.bz2)
+-v6*=aptmethod start 'copy:$WORKDIR/dists/test2/stupid/binary-abacus/Packages.bz2'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/test2/stupid/binary-abacus/Packages.bz2'
+-v2*=Uncompress './lists/Test2toTest1_test2_stupid_abacus_Packages.bz2' into './lists/Test2toTest1_test2_stupid_abacus_Packages' using '/bin/bunzip2'...
+-v6*=aptmethod start 'copy:$WORKDIR/dists/test2/stupid/binary-coal/Packages.bz2'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/test2/stupid/binary-coal/Packages.bz2'
+-v2*=Uncompress './lists/Test2toTest1_test2_stupid_coal_Packages.bz2' into './lists/Test2toTest1_test2_stupid_coal_Packages' using '/bin/bunzip2'...
+-v0*=There have been errors!
+stdout
+-v2*=Created directory "./lists"
+EOF
+cp Release.test2.safe dists/test2/Release
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+ed -s dists/test2/Release <<EOF
+g/stupid.source.Sources/s/^ ........................................ / 1111111111111111111111111111111111111111 /
+w
+q
+EOF
+
+testrun - -b . update test1 3<<EOF
+returns 254
+stderr
+=WARNING: Single-Instance not yet supported!
+=aptmethod error receiving 'copy:$WORKDIR/dists/test2/InRelease':
+='Failed to stat - stat (2: No such file or directory)'
+-v6*=aptmethod start 'copy:$WORKDIR/dists/test2/Release'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/test2/Release'
+-v6*=aptmethod start 'copy:$WORKDIR/dists/test2/stupid/source/Sources.bz2'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/test2/stupid/source/Sources.bz2'
+*=Wrong checksum during receive of 'copy:$WORKDIR/dists/test2/stupid/source/Sources.bz2':
+*=sha1 expected: 1111111111111111111111111111111111111111, got: $(sha1 dists/test2/stupid/source/Sources.bz2)
+-v0*=There have been errors!
+stdout
+EOF
+cp Release.test2.safe dists/test2/Release
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+ed -s dists/test2/Release <<EOF
+g/stupid.source.Sources/s/^ ................................................................ / 9999999999999999999999999999999999999999999999999999999999999999 /
+w
+q
+EOF
+
+testrun - -b . update test1 3<<EOF
+returns 254
+stderr
+=WARNING: Single-Instance not yet supported!
+=aptmethod error receiving 'copy:$WORKDIR/dists/test2/InRelease':
+='Failed to stat - stat (2: No such file or directory)'
+-v6*=aptmethod start 'copy:$WORKDIR/dists/test2/Release'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/test2/Release'
+-v6*=aptmethod start 'copy:$WORKDIR/dists/test2/stupid/source/Sources.bz2'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/test2/stupid/source/Sources.bz2'
+*=Wrong checksum during receive of 'copy:$WORKDIR/dists/test2/stupid/source/Sources.bz2':
+*=sha256 expected: 9999999999999999999999999999999999999999999999999999999999999999, got: $(sha256 dists/test2/stupid/source/Sources.bz2)
+-v0*=There have been errors!
+stdout
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+
+cp conf/updates conf/updates.safe
+cat >> conf/updates <<EOF
+IgnoreHashes: sha2
+EOF
+
+testrun - -b . update test1 3<<EOF
+returns 248
+stderr
+*=Error parsing config file ./conf/updates, line 9, column 15:
+*=Unknown flag in IgnoreHashes header.(allowed values: md5, sha1 and sha256)
+*=To ignore unknown fields use --ignore=unknownfield
+-v0*=There have been errors!
+stdout
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+
+cp conf/updates.safe conf/updates
+cat >> conf/updates <<EOF
+IgnoreHashes: sha1
+EOF
+
+testrun - -b . update test1 3<<EOF
+returns 254
+stderr
+=WARNING: Single-Instance not yet supported!
+=aptmethod error receiving 'copy:$WORKDIR/dists/test2/InRelease':
+='Failed to stat - stat (2: No such file or directory)'
+-v6*=aptmethod start 'copy:$WORKDIR/dists/test2/Release'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/test2/Release'
+-v6*=aptmethod start 'copy:$WORKDIR/dists/test2/stupid/source/Sources.bz2'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/test2/stupid/source/Sources.bz2'
+*=Wrong checksum during receive of 'copy:$WORKDIR/dists/test2/stupid/source/Sources.bz2':
+*=sha256 expected: 9999999999999999999999999999999999999999999999999999999999999999, got: $(sha256 dists/test2/stupid/source/Sources.bz2)
+-v0*=There have been errors!
+stdout
+EOF
+
+cp conf/updates.safe conf/updates
+cat >> conf/updates <<EOF
+IgnoreHashes: sha256
+EOF
+
+testrun - -b . update test1 3<<EOF
+stderr
+=WARNING: Single-Instance not yet supported!
+=aptmethod error receiving 'copy:$WORKDIR/dists/test2/InRelease':
+='Failed to stat - stat (2: No such file or directory)'
+-v6*=aptmethod start 'copy:$WORKDIR/dists/test2/Release'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/test2/Release'
+-v2*=Uncompress './lists/Test2toTest1_test2_stupid_Sources.bz2' into './lists/Test2toTest1_test2_stupid_Sources'...
+-v6*=Called /bin/cp './lists/Test2toTest1_test2_ugly_Sources' './lists/_test1_ugly_source_Test2toTest1_Test2toTest1_test2_ugly_Sources'
+-v6*=Listhook successfully returned!
+-v6*=Called /bin/cp './lists/Test2toTest1_test2_ugly_abacus_Packages' './lists/_test1_ugly_abacus_Test2toTest1_Test2toTest1_test2_ugly_abacus_Packages'
+-v6*=Called /bin/cp './lists/Test2toTest1_test2_ugly_coal_Packages' './lists/_test1_ugly_abacus_Test2toTest1_Test2toTest1_test2_ugly_coal_Packages'
+-v6*=Called /bin/cp './lists/Test2toTest1_test2_stupid_Sources' './lists/_test1_stupid_source_Test2toTest1_Test2toTest1_test2_stupid_Sources'
+-v6*=Called /bin/cp './lists/Test2toTest1_test2_stupid_abacus_Packages' './lists/_test1_stupid_abacus_Test2toTest1_Test2toTest1_test2_stupid_abacus_Packages'
+-v6*=Called /bin/cp './lists/Test2toTest1_test2_stupid_coal_Packages' './lists/_test1_stupid_abacus_Test2toTest1_Test2toTest1_test2_stupid_coal_Packages'
+stdout
+-v0*=Calculating packages to get...
+-v3*= processing updates for 'test1|ugly|source'
+-v5*= reading './lists/_test1_ugly_source_Test2toTest1_Test2toTest1_test2_ugly_Sources'
+-v3*= processing updates for 'test1|ugly|abacus'
+-v5*= reading './lists/_test1_ugly_abacus_Test2toTest1_Test2toTest1_test2_ugly_abacus_Packages'
+-v5*= reading './lists/_test1_ugly_abacus_Test2toTest1_Test2toTest1_test2_ugly_coal_Packages'
+-v3*= processing updates for 'test1|stupid|source'
+-v5*= reading './lists/_test1_stupid_source_Test2toTest1_Test2toTest1_test2_stupid_Sources'
+-v3*= processing updates for 'test1|stupid|abacus'
+-v5*= reading './lists/_test1_stupid_abacus_Test2toTest1_Test2toTest1_test2_stupid_abacus_Packages'
+-v5*= reading './lists/_test1_stupid_abacus_Test2toTest1_Test2toTest1_test2_stupid_coal_Packages'
+-v0*=Getting packages...
+-v1=Freeing some memory...
+-v1*=Shutting down aptmethods...
+-v0*=Installing (and possibly deleting) packages...
+$(opa 'simple' unset 'test1' 'ugly' 'source' 'dsc')
+$(opa 'simple' x 'test1' 'ugly' 'abacus' 'deb')
+$(opa 'simple-addons' x 'test1' 'ugly' 'abacus' 'deb')
+$(opa 'bloat+-0a9z.app' unset 'test1' 'stupid' 'source' 'dsc')
+$(opa 'bloat+-0a9z.app' x 'test1' 'stupid' 'abacus' 'deb')
+$(opa 'bloat+-0a9z.app-addons' x 'test1' 'stupid' 'abacus' 'deb')
+-v1*=Retracking test1...
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= replacing './dists/test1/stupid/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= replacing './dists/test1/stupid/source/Sources' (gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= replacing './dists/test1/ugly/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|ugly|source'...
+-v6*= replacing './dists/test1/ugly/source/Sources' (gzipped,bzip2ed)
+EOF
+mv Release.test2.safe dists/test2/Release
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+mv conf/updates.safe conf/updates
+
+checklog log1 <<EOF
+DATESTR add test1 dsc ugly source simple 1
+DATESTR add test1 deb ugly abacus simple 1
+DATESTR add test1 deb ugly abacus simple-addons 1
+DATESTR add test1 dsc stupid source bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ
+DATESTR add test1 deb stupid abacus bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ
+DATESTR add test1 deb stupid abacus bloat+-0a9z.app-addons 99:0.9-A:Z+a:z-0+aA.9zZ
+EOF
+checknolog log1
+checknolog log2
+testrun - -b . update test1 3<<EOF
+=WARNING: Single-Instance not yet supported!
+=aptmethod error receiving 'copy:$WORKDIR/dists/test2/InRelease':
+='Failed to stat - stat (2: No such file or directory)'
+-v6*=aptmethod start 'copy:$WORKDIR/dists/test2/Release'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/test2/Release'
+stdout
+-v0*=Nothing to do found. (Use --noskipold to force processing)
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log1 < /dev/null
+checknolog log2
+testrun - --nolistsdownload --noskipold -b . update test1 3<<EOF
+=WARNING: Single-Instance not yet supported!
+-v6*=Called /bin/cp './lists/Test2toTest1_test2_ugly_Sources' './lists/_test1_ugly_source_Test2toTest1_Test2toTest1_test2_ugly_Sources'
+-v6*=Listhook successfully returned!
+-v6*=Called /bin/cp './lists/Test2toTest1_test2_ugly_abacus_Packages' './lists/_test1_ugly_abacus_Test2toTest1_Test2toTest1_test2_ugly_abacus_Packages'
+-v6*=Called /bin/cp './lists/Test2toTest1_test2_ugly_coal_Packages' './lists/_test1_ugly_abacus_Test2toTest1_Test2toTest1_test2_ugly_coal_Packages'
+-v6*=Called /bin/cp './lists/Test2toTest1_test2_stupid_Sources' './lists/_test1_stupid_source_Test2toTest1_Test2toTest1_test2_stupid_Sources'
+-v6*=Called /bin/cp './lists/Test2toTest1_test2_stupid_abacus_Packages' './lists/_test1_stupid_abacus_Test2toTest1_Test2toTest1_test2_stupid_abacus_Packages'
+-v6*=Called /bin/cp './lists/Test2toTest1_test2_stupid_coal_Packages' './lists/_test1_stupid_abacus_Test2toTest1_Test2toTest1_test2_stupid_coal_Packages'
+stdout
+-v0*=Calculating packages to get...
+-v3*= processing updates for 'test1|ugly|source'
+-v5*= reading './lists/_test1_ugly_source_Test2toTest1_Test2toTest1_test2_ugly_Sources'
+-v3*= processing updates for 'test1|ugly|abacus'
+-v5*= reading './lists/_test1_ugly_abacus_Test2toTest1_Test2toTest1_test2_ugly_abacus_Packages'
+-v5*= reading './lists/_test1_ugly_abacus_Test2toTest1_Test2toTest1_test2_ugly_coal_Packages'
+-v3*= processing updates for 'test1|stupid|source'
+-v5*= reading './lists/_test1_stupid_source_Test2toTest1_Test2toTest1_test2_stupid_Sources'
+-v3*= processing updates for 'test1|stupid|abacus'
+-v5*= reading './lists/_test1_stupid_abacus_Test2toTest1_Test2toTest1_test2_stupid_abacus_Packages'
+-v5*= reading './lists/_test1_stupid_abacus_Test2toTest1_Test2toTest1_test2_stupid_coal_Packages'
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log1 < /dev/null
+checknolog log2
+
+find dists/test2/ \( -name "Packages.gz" -o -name "Sources.gz" \) -print0 | xargs -0 zgrep '^Package: ' | sed -e 's/test2/test1/' -e "s/coal/abacus/" | sort > test2
+find dists/test1/ \( -name "Packages.gz" -o -name "Sources.gz" \) -print0 | xargs -0 zgrep '^Package: ' | sort > test1
+dodiff test2 test1
+
+testrun - -b . check test1 test2 3<<EOF
+stdout
+-v1*=Checking test2...
+-x1*=Checking packages in 'test2|stupid|abacus'...
+-x1*=Checking packages in 'test2|stupid|coal'...
+-x1*=Checking packages in 'test2|stupid|source'...
+-x1*=Checking packages in 'test2|ugly|abacus'...
+-x1*=Checking packages in 'test2|ugly|coal'...
+-x1*=Checking packages in 'test2|ugly|source'...
+-v1*=Checking test1...
+-x1*=Checking packages in 'test1|stupid|abacus'...
+-x1*=Checking packages in 'test1|stupid|source'...
+-x1*=Checking packages in 'test1|ugly|abacus'...
+-x1*=Checking packages in 'test1|ugly|source'...
+EOF
+testrun "" -b . checkpool
+testrun - -b . rereference test1 test2 3<<EOF
+stdout
+-v1*=Referencing test2...
+-v2=Rereferencing test2|stupid|abacus...
+-v2=Rereferencing test2|stupid|coal...
+-v2=Rereferencing test2|stupid|source...
+-v2=Rereferencing test2|ugly|abacus...
+-v2=Rereferencing test2|ugly|coal...
+-v2=Rereferencing test2|ugly|source...
+-v3*=Unlocking dependencies of test2|stupid|abacus...
+-v3*=Referencing test2|stupid|abacus...
+-v3*=Unlocking dependencies of test2|stupid|coal...
+-v3*=Referencing test2|stupid|coal...
+-v3*=Unlocking dependencies of test2|stupid|source...
+-v3*=Referencing test2|stupid|source...
+-v3*=Unlocking dependencies of test2|ugly|abacus...
+-v3*=Referencing test2|ugly|abacus...
+-v3*=Unlocking dependencies of test2|ugly|coal...
+-v3*=Referencing test2|ugly|coal...
+-v3*=Unlocking dependencies of test2|ugly|source...
+-v3*=Referencing test2|ugly|source...
+-v1*=Referencing test1...
+-v2=Rereferencing test1|stupid|abacus...
+-v2=Rereferencing test1|stupid|source...
+-v2=Rereferencing test1|ugly|abacus...
+-v2=Rereferencing test1|ugly|source...
+-v3*=Unlocking dependencies of test1|stupid|abacus...
+-v3*=Referencing test1|stupid|abacus...
+-v3*=Unlocking dependencies of test1|stupid|source...
+-v3*=Referencing test1|stupid|source...
+-v3*=Unlocking dependencies of test1|ugly|abacus...
+-v3*=Referencing test1|ugly|abacus...
+-v3*=Unlocking dependencies of test1|ugly|source...
+-v3*=Referencing test1|ugly|source...
+EOF
+testrun - -b . check test1 test2 3<<EOF
+stdout
+-v1*=Checking test1...
+-x1*=Checking packages in 'test2|stupid|abacus'...
+-x1*=Checking packages in 'test2|stupid|coal'...
+-x1*=Checking packages in 'test2|stupid|source'...
+-x1*=Checking packages in 'test2|ugly|abacus'...
+-x1*=Checking packages in 'test2|ugly|coal'...
+-x1*=Checking packages in 'test2|ugly|source'...
+-v1*=Checking test2...
+-x1*=Checking packages in 'test1|stupid|abacus'...
+-x1*=Checking packages in 'test1|stupid|source'...
+-x1*=Checking packages in 'test1|ugly|abacus'...
+-x1*=Checking packages in 'test1|ugly|source'...
+EOF
+
+testout "" -b . dumptracks
+cat >results.expected <<END
+Distribution: test1
+Source: bloat+-0a9z.app
+Version: 99:0.9-A:Z+a:z-0+aA.9zZ
+Files:
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.dsc s 0
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.tar.gz s 0
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ_abacus.deb b 0
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_0.9-A:Z+a:z-0+aA.9zZ_all.deb a 0
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_99:0.9-A:Z+a:z-0+aA.9zZ_source+all+abacus.changes c 0
+ pool/stupid/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ_abacus.deb b 1
+ pool/stupid/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_0.9-A:Z+a:z-0+aA.9zZ_all.deb a 1
+ pool/stupid/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.dsc s 1
+ pool/stupid/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.tar.gz s 1
+
+Distribution: test1
+Source: simple
+Version: 1
+Files:
+ pool/stupid/s/simple/simple_1.dsc s 0
+ pool/stupid/s/simple/simple_1.tar.gz s 0
+ pool/stupid/s/simple/simple_1_abacus.deb b 0
+ pool/stupid/s/simple/simple-addons_1_all.deb a 0
+ pool/stupid/s/simple/simple_1_source+all+abacus.changes c 0
+ pool/ugly/s/simple/simple_1_abacus.deb b 1
+ pool/ugly/s/simple/simple-addons_1_all.deb a 1
+ pool/ugly/s/simple/simple_1.dsc s 1
+ pool/ugly/s/simple/simple_1.tar.gz s 1
+
+END
+dodiff results.expected results
+
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+testrun - -b . removealltracks test2 test1 3<<EOF
+stdout
+stderr
+*=Error: Requested removing of all tracks of distribution 'test1',
+*=which still has tracking enabled. Use --delete to delete anyway.
+-v0*=There have been errors!
+returns 255
+EOF
+testrun - --delete -b . removealltracks test2 test1 3<<EOF
+stdout
+-v0*=Deleting all tracks for test2...
+-v0*=Deleting all tracks for test1...
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/stupid/s/simple/simple-addons_1_all.deb')
+$(ofd 'pool/stupid/s/simple/simple_1.dsc')
+$(ofd 'pool/stupid/s/simple/simple_1.tar.gz')
+$(ofd 'pool/stupid/s/simple/simple_1_abacus.deb')
+$(ofd 'pool/stupid/s/simple/simple_1_source+all+abacus.changes')
+-v2*=removed now empty directory ./pool/stupid/s/simple
+-v2*=removed now empty directory ./pool/stupid/s
+$(ofd 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_0.9-A:Z+a:z-0+aA.9zZ_all.deb')
+$(ofd 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.dsc')
+$(ofd 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.tar.gz')
+$(ofd 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ_abacus.deb')
+$(ofd 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_99:0.9-A:Z+a:z-0+aA.9zZ_source+all+abacus.changes')
+-v2*=removed now empty directory ./pool/ugly/b/bloat+-0a9z.app
+-v2*=removed now empty directory ./pool/ugly/b
+EOF
+echo returned: $?
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+testrun - -b . include test1 test.changes 3<<EOF
+stdout
+-v2*=Created directory "./pool/ugly/b"
+-v2*=Created directory "./pool/ugly/b/bloat+-0a9z.app"
+$(ofa 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_0.9-A:Z+a:z-0+aA.9zZ_all.deb')
+$(ofa 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ_abacus.deb')
+$(ofa 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.tar.gz')
+$(ofa 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.dsc')
+$(ofa 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_99:0.9-A:Z+a:z-0+aA.9zZ_source+all+abacus.changes')
+$(opa 'bloat+-0a9z.app-addons' x 'test1' 'ugly' 'abacus' 'deb')
+$(opa 'bloat+-0a9z.app' x 'test1' 'ugly' 'abacus' 'deb')
+$(opa 'bloat+-0a9z.app' unset 'test1' 'ugly' 'source' 'dsc')
+$(ota 'test1' 'bloat+-0a9z.app')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= replacing './dists/test1/ugly/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|ugly|source'...
+-v6*= replacing './dists/test1/ugly/source/Sources' (gzipped,bzip2ed)
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log1 <<EOF
+DATESTR add test1 deb ugly abacus bloat+-0a9z.app-addons 99:0.9-A:Z+a:z-0+aA.9zZ
+DATESTR add test1 deb ugly abacus bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ
+DATESTR add test1 dsc ugly source bloat+-0a9z.app 99:0.9-A:Z+a:z-0+aA.9zZ
+EOF
+echo returned: $?
+OUTPUT=test2.changes PACKAGE=bloat+-0a9z.app EPOCH=99: VERSION=9.0-A:Z+a:z REVISION=-0+aA.9zZ SECTION="ugly/extra" genpackage.sh
+testrun - -b . include test1 test2.changes 3<<EOF
+stdout
+$(ofa 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_9.0-A:Z+a:z-0+aA.9zZ_all.deb')
+$(ofa 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ_abacus.deb')
+$(ofa 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ.tar.gz')
+$(ofa 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ.dsc')
+$(ofa 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_99:9.0-A:Z+a:z-0+aA.9zZ_source+all+abacus.changes')
+$(opu 'bloat+-0a9z.app-addons' x x 'test1' 'ugly' 'abacus' 'deb')
+$(opu 'bloat+-0a9z.app' x x 'test1' 'ugly' 'abacus' 'deb')
+$(opu 'bloat+-0a9z.app' x x 'test1' 'ugly' 'source' 'dsc')
+$(ota 'test1' 'bloat+-0a9z.app')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= replacing './dists/test1/ugly/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|ugly|source'...
+-v6*= replacing './dists/test1/ugly/source/Sources' (gzipped,bzip2ed)
+EOF
+echo returned: $?
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log1 <<EOF
+DATESTR replace test1 deb ugly abacus bloat+-0a9z.app-addons 99:9.0-A:Z+a:z-0+aA.9zZ 99:0.9-A:Z+a:z-0+aA.9zZ
+DATESTR replace test1 deb ugly abacus bloat+-0a9z.app 99:9.0-A:Z+a:z-0+aA.9zZ 99:0.9-A:Z+a:z-0+aA.9zZ
+DATESTR replace test1 dsc ugly source bloat+-0a9z.app 99:9.0-A:Z+a:z-0+aA.9zZ 99:0.9-A:Z+a:z-0+aA.9zZ
+EOF
+testrun - -b . -S sectiontest -P prioritytest includedeb test1 simple_1_abacus.deb 3<<EOF
+stderr
+-v1*=simple_1_abacus.deb: component guessed as 'stupid'
+stdout
+-v2*=Created directory "./pool/stupid/s"
+-v2*=Created directory "./pool/stupid/s/simple"
+$(ofa 'pool/stupid/s/simple/simple_1_abacus.deb')
+$(opa 'simple' x 'test1' 'stupid' 'abacus' 'deb')
+$(ota 'test1' 'simple')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= replacing './dists/test1/stupid/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= looking for changes in 'test1|ugly|source'...
+EOF
+echo returned: $?
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+dodo zgrep '^Section: sectiontest' dists/test1/stupid/binary-abacus/Packages.gz
+dodo zgrep '^Priority: prioritytest' dists/test1/stupid/binary-abacus/Packages.gz
+checklog log1 <<EOF
+DATESTR add test1 deb stupid abacus simple 1
+EOF
+testrun - -b . -S sectiontest -P prioritytest includedsc test1 simple_1.dsc 3<<EOF
+stderr
+-v1*=simple_1.dsc: component guessed as 'stupid'
+stdout
+$(ofa 'pool/stupid/s/simple/simple_1.dsc')
+$(ofa 'pool/stupid/s/simple/simple_1.tar.gz')
+$(opa 'simple' unset 'test1' 'stupid' 'source' 'dsc')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= replacing './dists/test1/stupid/source/Sources' (gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= looking for changes in 'test1|ugly|source'...
+EOF
+echo returned: $?
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+dodo zgrep '^Section: sectiontest' dists/test1/stupid/source/Sources.gz
+dodo zgrep '^Priority: prioritytest' dists/test1/stupid/source/Sources.gz
+checklog log1 <<EOF
+DATESTR add test1 dsc stupid source simple 1
+EOF
+
+testout "" -b . dumptracks
+cat >results.expected <<END
+Distribution: test1
+Source: bloat+-0a9z.app
+Version: 99:0.9-A:Z+a:z-0+aA.9zZ
+Files:
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.dsc s 0
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.tar.gz s 0
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ_abacus.deb b 0
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_0.9-A:Z+a:z-0+aA.9zZ_all.deb a 0
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_99:0.9-A:Z+a:z-0+aA.9zZ_source+all+abacus.changes c 0
+
+Distribution: test1
+Source: bloat+-0a9z.app
+Version: 99:9.0-A:Z+a:z-0+aA.9zZ
+Files:
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ.dsc s 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ.tar.gz s 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ_abacus.deb b 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_9.0-A:Z+a:z-0+aA.9zZ_all.deb a 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_99:9.0-A:Z+a:z-0+aA.9zZ_source+all+abacus.changes c 0
+
+Distribution: test1
+Source: simple
+Version: 1
+Files:
+ pool/stupid/s/simple/simple_1_abacus.deb b 1
+ pool/stupid/s/simple/simple_1.dsc s 1
+ pool/stupid/s/simple/simple_1.tar.gz s 1
+
+END
+dodiff results.expected results
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+
+echo "now testing .orig.tar.gz handling"
+tar -czf test_1.orig.tar.gz test.changes
+PACKAGE=test EPOCH="" VERSION=1 REVISION="-2" SECTION="stupid/base" genpackage.sh -sd
+testrun - -b . include test1 test.changes 3<<EOF
+returns 249
+stderr
+*=Unable to find pool/stupid/t/test/test_1.orig.tar.gz needed by test_1-2.dsc!
+*=Perhaps you forgot to give dpkg-buildpackage the -sa option,
+*= or you could try --ignore=missingfile to guess possible files to use.
+-v0*=There have been errors!
+stdout
+-v2*=Created directory "./pool/stupid/t"
+-v2*=Created directory "./pool/stupid/t/test"
+$(ofa 'pool/stupid/t/test/test-addons_1-2_all.deb')
+$(ofa 'pool/stupid/t/test/test_1-2_abacus.deb')
+$(ofa 'pool/stupid/t/test/test_1-2.diff.gz')
+$(ofa 'pool/stupid/t/test/test_1-2.dsc')
+-v0*=Deleting files just added to the pool but not used.
+-v0*=(to avoid use --keepunusednewfiles next time)
+$(ofd 'pool/stupid/t/test/test-addons_1-2_all.deb')
+$(ofd 'pool/stupid/t/test/test_1-2_abacus.deb')
+$(ofd 'pool/stupid/t/test/test_1-2.diff.gz')
+$(ofd 'pool/stupid/t/test/test_1-2.dsc')
+-v2*=removed now empty directory ./pool/stupid/t/test
+-v2*=removed now empty directory ./pool/stupid/t
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checknolog log1
+checknolog log2
+testrun - -b . --ignore=missingfile include test1 test.changes 3<<EOF
+stderr
+*=Unable to find pool/stupid/t/test/test_1.orig.tar.gz!
+*=Perhaps you forgot to give dpkg-buildpackage the -sa option.
+*=--ignore=missingfile was given, searching for file...
+stdout
+-v2*=Created directory "./pool/stupid/t"
+-v2*=Created directory "./pool/stupid/t/test"
+$(ofa 'pool/stupid/t/test/test-addons_1-2_all.deb')
+$(ofa 'pool/stupid/t/test/test_1-2_abacus.deb')
+$(ofa 'pool/stupid/t/test/test_1-2.diff.gz')
+$(ofa 'pool/stupid/t/test/test_1-2.dsc')
+$(ofa 'pool/stupid/t/test/test_1.orig.tar.gz')
+$(ofa 'pool/stupid/t/test/test_1-2_source+all+abacus.changes')
+$(opa 'test-addons' x 'test1' 'stupid' 'abacus' 'deb')
+$(opa 'test' x 'test1' 'stupid' 'abacus' 'deb')
+$(opa 'test' unset 'test1' 'stupid' 'source' 'dsc')
+$(ota 'test1' 'test')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= replacing './dists/test1/stupid/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= replacing './dists/test1/stupid/source/Sources' (gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= looking for changes in 'test1|ugly|source'...
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log1 <<EOF
+DATESTR add test1 deb stupid abacus test-addons 1-2
+DATESTR add test1 deb stupid abacus test 1-2
+DATESTR add test1 dsc stupid source test 1-2
+EOF
+dodo zgrep test_1-2.dsc dists/test1/stupid/source/Sources.gz
+
+tar -czf testb_2.orig.tar.gz test.changes
+PACKAGE=testb EPOCH="1:" VERSION=2 REVISION="-2" SECTION="stupid/base" genpackage.sh -sa
+testrun - -b . include test1 test.changes 3<<EOF
+stdout
+-v2*=Created directory "./pool/stupid/t/testb"
+$(ofa 'pool/stupid/t/testb/testb-addons_2-2_all.deb')
+$(ofa 'pool/stupid/t/testb/testb_2-2_abacus.deb')
+$(ofa 'pool/stupid/t/testb/testb_2-2.diff.gz')
+$(ofa 'pool/stupid/t/testb/testb_2-2.dsc')
+$(ofa 'pool/stupid/t/testb/testb_2.orig.tar.gz')
+$(ofa 'pool/stupid/t/testb/testb_1:2-2_source+all+abacus.changes')
+$(opa 'testb-addons' x 'test1' 'stupid' 'abacus' 'deb')
+$(opa 'testb' x 'test1' 'stupid' 'abacus' 'deb')
+$(opa 'testb' unset 'test1' 'stupid' 'source' 'dsc')
+$(ota 'test1' 'testb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= replacing './dists/test1/stupid/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= replacing './dists/test1/stupid/source/Sources' (gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= looking for changes in 'test1|ugly|source'...
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log1 <<EOF
+DATESTR add test1 deb stupid abacus testb-addons 1:2-2
+DATESTR add test1 deb stupid abacus testb 1:2-2
+DATESTR add test1 dsc stupid source testb 1:2-2
+EOF
+dodo zgrep testb_2-2.dsc dists/test1/stupid/source/Sources.gz
+rm test2.changes
+PACKAGE=testb EPOCH="1:" VERSION=2 REVISION="-3" SECTION="stupid/base" OUTPUT="test2.changes" genpackage.sh -sd
+testrun - -b . include test1 test2.changes 3<<EOF
+stdout
+$(ofa 'pool/stupid/t/testb/testb-addons_2-3_all.deb')
+$(ofa 'pool/stupid/t/testb/testb_2-3_abacus.deb')
+$(ofa 'pool/stupid/t/testb/testb_2-3.diff.gz')
+$(ofa 'pool/stupid/t/testb/testb_2-3.dsc')
+$(ofa 'pool/stupid/t/testb/testb_1:2-3_source+all+abacus.changes')
+$(opu 'testb-addons' x x 'test1' 'stupid' 'abacus' 'deb')
+$(opu 'testb' x x 'test1' 'stupid' 'abacus' 'deb')
+$(opu 'testb' x x 'test1' 'stupid' 'source' 'dsc')
+$(ota 'test1' 'testb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= replacing './dists/test1/stupid/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= replacing './dists/test1/stupid/source/Sources' (gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= looking for changes in 'test1|ugly|source'...
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log1 <<EOF
+DATESTR replace test1 deb stupid abacus testb-addons 1:2-3 1:2-2
+DATESTR replace test1 deb stupid abacus testb 1:2-3 1:2-2
+DATESTR replace test1 dsc stupid source testb 1:2-3 1:2-2
+EOF
+dodo zgrep testb_2-3.dsc dists/test1/stupid/source/Sources.gz
+
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+
+echo "now testing some error messages:"
+PACKAGE=4test EPOCH="1:" VERSION=0b.1 REVISION="-1" SECTION="stupid/base" genpackage.sh
+testrun - -b . include test1 test.changes 3<<EOF
+stdout
+-v2*=Created directory "./pool/stupid/4"
+-v2*=Created directory "./pool/stupid/4/4test"
+$(ofa 'pool/stupid/4/4test/4test-addons_0b.1-1_all.deb')
+$(ofa 'pool/stupid/4/4test/4test_0b.1-1_abacus.deb')
+$(ofa 'pool/stupid/4/4test/4test_0b.1-1.tar.gz')
+$(ofa 'pool/stupid/4/4test/4test_0b.1-1.dsc')
+$(ofa 'pool/stupid/4/4test/4test_1:0b.1-1_source+all+abacus.changes')
+$(opa '4test-addons' x 'test1' 'stupid' 'abacus' 'deb')
+$(opa '4test' x 'test1' 'stupid' 'abacus' 'deb')
+$(opa '4test' unset 'test1' 'stupid' 'source' 'dsc')
+$(ota 'test1' '4test')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= replacing './dists/test1/stupid/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= replacing './dists/test1/stupid/source/Sources' (gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= looking for changes in 'test1|ugly|source'...
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log1 <<EOF
+DATESTR add test1 deb stupid abacus 4test-addons 1:0b.1-1
+DATESTR add test1 deb stupid abacus 4test 1:0b.1-1
+DATESTR add test1 dsc stupid source 4test 1:0b.1-1
+EOF
+
+cat >includeerror.rules <<EOF
+returns 255
+stderr
+-v0*=There have been errors!
+*=Error: Too few arguments for command 'include'!
+*=Syntax: reprepro [--delete] include <distribution> <.changes-file>
+EOF
+testrun includeerror -b . include unknown 3<<EOF
+testrun includeerror -b . include unknown test.changes test2.changes
+testrun - -b . include unknown test.changes 3<<EOF
+stderr
+-v0*=There have been errors!
+*=No distribution definition of 'unknown' found in './conf/distributions'!
+returns 249
+EOF
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+
+testout "" -b . dumptracks
+# TODO: check those if they are really expected...
+cat > results.expected <<EOF
+Distribution: test1
+Source: 4test
+Version: 1:0b.1-1
+Files:
+ pool/stupid/4/4test/4test_0b.1-1.dsc s 1
+ pool/stupid/4/4test/4test_0b.1-1.tar.gz s 1
+ pool/stupid/4/4test/4test_0b.1-1_abacus.deb b 1
+ pool/stupid/4/4test/4test-addons_0b.1-1_all.deb a 1
+ pool/stupid/4/4test/4test_1:0b.1-1_source+all+abacus.changes c 0
+
+Distribution: test1
+Source: bloat+-0a9z.app
+Version: 99:0.9-A:Z+a:z-0+aA.9zZ
+Files:
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.dsc s 0
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.tar.gz s 0
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ_abacus.deb b 0
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_0.9-A:Z+a:z-0+aA.9zZ_all.deb a 0
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_99:0.9-A:Z+a:z-0+aA.9zZ_source+all+abacus.changes c 0
+
+Distribution: test1
+Source: bloat+-0a9z.app
+Version: 99:9.0-A:Z+a:z-0+aA.9zZ
+Files:
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ.dsc s 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ.tar.gz s 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ_abacus.deb b 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_9.0-A:Z+a:z-0+aA.9zZ_all.deb a 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_99:9.0-A:Z+a:z-0+aA.9zZ_source+all+abacus.changes c 0
+
+Distribution: test1
+Source: simple
+Version: 1
+Files:
+ pool/stupid/s/simple/simple_1_abacus.deb b 1
+ pool/stupid/s/simple/simple_1.dsc s 1
+ pool/stupid/s/simple/simple_1.tar.gz s 1
+
+Distribution: test1
+Source: test
+Version: 1-2
+Files:
+ pool/stupid/t/test/test_1-2.dsc s 1
+ pool/stupid/t/test/test_1.orig.tar.gz s 1
+ pool/stupid/t/test/test_1-2.diff.gz s 1
+ pool/stupid/t/test/test_1-2_abacus.deb b 1
+ pool/stupid/t/test/test-addons_1-2_all.deb a 1
+ pool/stupid/t/test/test_1-2_source+all+abacus.changes c 0
+
+Distribution: test1
+Source: testb
+Version: 1:2-2
+Files:
+ pool/stupid/t/testb/testb_2-2.dsc s 0
+ pool/stupid/t/testb/testb_2.orig.tar.gz s 0
+ pool/stupid/t/testb/testb_2-2.diff.gz s 0
+ pool/stupid/t/testb/testb_2-2_abacus.deb b 0
+ pool/stupid/t/testb/testb-addons_2-2_all.deb a 0
+ pool/stupid/t/testb/testb_1:2-2_source+all+abacus.changes c 0
+
+Distribution: test1
+Source: testb
+Version: 1:2-3
+Files:
+ pool/stupid/t/testb/testb_2-3.dsc s 1
+ pool/stupid/t/testb/testb_2.orig.tar.gz s 1
+ pool/stupid/t/testb/testb_2-3.diff.gz s 1
+ pool/stupid/t/testb/testb_2-3_abacus.deb b 1
+ pool/stupid/t/testb/testb-addons_2-3_all.deb a 1
+ pool/stupid/t/testb/testb_1:2-3_source+all+abacus.changes c 0
+
+EOF
+dodiff results.expected results
+testrun - -b . tidytracks 3<<EOF
+stdout
+-v0*=Looking for old tracks in test1...
+EOF
+testout "" -b . dumptracks
+dodiff results.expected results
+sed -i -e 's/^Tracking: keep/Tracking: all/' conf/distributions
+testrun - -b . tidytracks 3<<EOF
+stdout
+-v0*=Looking for old tracks in test1...
+$(otd 'testb' '1:2-2' 'test1')
+$(otd 'bloat+-0a9z.app' '99:0.9-A:Z+a:z-0+aA.9zZ' 'test1')
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_0.9-A:Z+a:z-0+aA.9zZ_all.deb')
+$(ofd 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ_abacus.deb')
+$(ofd 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.dsc')
+$(ofd 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.tar.gz')
+$(ofd 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_99:0.9-A:Z+a:z-0+aA.9zZ_source+all+abacus.changes')
+$(ofd 'pool/stupid/t/testb/testb-addons_2-2_all.deb')
+$(ofd 'pool/stupid/t/testb/testb_2-2_abacus.deb')
+$(ofd 'pool/stupid/t/testb/testb_2-2.dsc')
+$(ofd 'pool/stupid/t/testb/testb_2-2.diff.gz')
+$(ofd 'pool/stupid/t/testb/testb_1:2-2_source+all+abacus.changes')
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+cp db/tracking.db db/saved2tracking.db
+cp db/references.db db/saved2references.db
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+testout "" -b . dumptracks
+cat > results.expected <<EOF
+Distribution: test1
+Source: 4test
+Version: 1:0b.1-1
+Files:
+ pool/stupid/4/4test/4test_0b.1-1.dsc s 1
+ pool/stupid/4/4test/4test_0b.1-1.tar.gz s 1
+ pool/stupid/4/4test/4test_0b.1-1_abacus.deb b 1
+ pool/stupid/4/4test/4test-addons_0b.1-1_all.deb a 1
+ pool/stupid/4/4test/4test_1:0b.1-1_source+all+abacus.changes c 0
+
+Distribution: test1
+Source: bloat+-0a9z.app
+Version: 99:9.0-A:Z+a:z-0+aA.9zZ
+Files:
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ.dsc s 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ.tar.gz s 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ_abacus.deb b 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_9.0-A:Z+a:z-0+aA.9zZ_all.deb a 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_99:9.0-A:Z+a:z-0+aA.9zZ_source+all+abacus.changes c 0
+
+Distribution: test1
+Source: simple
+Version: 1
+Files:
+ pool/stupid/s/simple/simple_1_abacus.deb b 1
+ pool/stupid/s/simple/simple_1.dsc s 1
+ pool/stupid/s/simple/simple_1.tar.gz s 1
+
+Distribution: test1
+Source: test
+Version: 1-2
+Files:
+ pool/stupid/t/test/test_1-2.dsc s 1
+ pool/stupid/t/test/test_1.orig.tar.gz s 1
+ pool/stupid/t/test/test_1-2.diff.gz s 1
+ pool/stupid/t/test/test_1-2_abacus.deb b 1
+ pool/stupid/t/test/test-addons_1-2_all.deb a 1
+ pool/stupid/t/test/test_1-2_source+all+abacus.changes c 0
+
+Distribution: test1
+Source: testb
+Version: 1:2-3
+Files:
+ pool/stupid/t/testb/testb_2-3.dsc s 1
+ pool/stupid/t/testb/testb_2.orig.tar.gz s 1
+ pool/stupid/t/testb/testb_2-3.diff.gz s 1
+ pool/stupid/t/testb/testb_2-3_abacus.deb b 1
+ pool/stupid/t/testb/testb-addons_2-3_all.deb a 1
+ pool/stupid/t/testb/testb_1:2-3_source+all+abacus.changes c 0
+
+EOF
+dodiff results.expected results
+sed -i -e 's/^Tracking: all/Tracking: minimal/' conf/distributions
+testrun - -b . tidytracks 3<<EOF
+stdout
+-v0*=Looking for old tracks in test1...
+EOF
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+testout "" -b . dumptracks
+dodiff results.expected results
+sed -i -e 's/^Tracking: minimal includechanges/Tracking: minimal/' conf/distributions
+testrun - -b . tidytracks 3<<EOF
+stdout
+-v0*=Looking for old tracks in test1...
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/stupid/4/4test/4test_1:0b.1-1_source+all+abacus.changes')
+$(ofd 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_99:9.0-A:Z+a:z-0+aA.9zZ_source+all+abacus.changes')
+$(ofd 'pool/stupid/t/test/test_1-2_source+all+abacus.changes')
+$(ofd 'pool/stupid/t/testb/testb_1:2-3_source+all+abacus.changes')
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+testout "" -b . dumptracks
+cat > results.expected <<EOF
+Distribution: test1
+Source: 4test
+Version: 1:0b.1-1
+Files:
+ pool/stupid/4/4test/4test_0b.1-1.dsc s 1
+ pool/stupid/4/4test/4test_0b.1-1.tar.gz s 1
+ pool/stupid/4/4test/4test_0b.1-1_abacus.deb b 1
+ pool/stupid/4/4test/4test-addons_0b.1-1_all.deb a 1
+
+Distribution: test1
+Source: bloat+-0a9z.app
+Version: 99:9.0-A:Z+a:z-0+aA.9zZ
+Files:
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ.dsc s 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ.tar.gz s 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ_abacus.deb b 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_9.0-A:Z+a:z-0+aA.9zZ_all.deb a 1
+
+Distribution: test1
+Source: simple
+Version: 1
+Files:
+ pool/stupid/s/simple/simple_1_abacus.deb b 1
+ pool/stupid/s/simple/simple_1.dsc s 1
+ pool/stupid/s/simple/simple_1.tar.gz s 1
+
+Distribution: test1
+Source: test
+Version: 1-2
+Files:
+ pool/stupid/t/test/test_1-2.dsc s 1
+ pool/stupid/t/test/test_1.orig.tar.gz s 1
+ pool/stupid/t/test/test_1-2.diff.gz s 1
+ pool/stupid/t/test/test_1-2_abacus.deb b 1
+ pool/stupid/t/test/test-addons_1-2_all.deb a 1
+
+Distribution: test1
+Source: testb
+Version: 1:2-3
+Files:
+ pool/stupid/t/testb/testb_2-3.dsc s 1
+ pool/stupid/t/testb/testb_2.orig.tar.gz s 1
+ pool/stupid/t/testb/testb_2-3.diff.gz s 1
+ pool/stupid/t/testb/testb_2-3_abacus.deb b 1
+ pool/stupid/t/testb/testb-addons_2-3_all.deb a 1
+
+EOF
+dodiff results.expected results
+testrun - -b . tidytracks 3<<EOF
+stdout
+-v0*=Looking for old tracks in test1...
+EOF
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+# Earlier update rules made this tracking data outdated.
+# so copy it, so it can be replayed so that also outdated data
+# is tested to be handled correctly.
+mv db/tracking.db db/savedtracking.db
+mv db/references.db db/savedreferences.db
+# Try this with .changes files still listed
+mv db/saved2tracking.db db/tracking.db
+mv db/saved2references.db db/references.db
+sed -i -e 's/^Tracking: minimal/Tracking: minimal includechanges/' conf/distributions
+testrun - -b . retrack 3<<EOF
+stdout
+-v1*=Retracking test1...
+$(ota 'test1' 'bloat+-0a9z.app')
+-x1*= Tracking test1|stupid|abacus...
+-x1*= Tracking test1|stupid|source...
+-x1*= Tracking test1|ugly|abacus...
+-x1*= Tracking test1|ugly|source...
+EOF
+testout "" -b . dumptracks
+cat > results.expected <<EOF
+Distribution: test1
+Source: 4test
+Version: 1:0b.1-1
+Files:
+ pool/stupid/4/4test/4test_0b.1-1.dsc s 1
+ pool/stupid/4/4test/4test_0b.1-1.tar.gz s 1
+ pool/stupid/4/4test/4test_0b.1-1_abacus.deb b 1
+ pool/stupid/4/4test/4test-addons_0b.1-1_all.deb a 1
+ pool/stupid/4/4test/4test_1:0b.1-1_source+all+abacus.changes c 0
+
+Distribution: test1
+Source: bloat+-0a9z.app
+Version: 99:0.9-A:Z+a:z-0+aA.9zZ
+Files:
+ pool/stupid/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ_abacus.deb b 1
+ pool/stupid/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_0.9-A:Z+a:z-0+aA.9zZ_all.deb a 1
+ pool/stupid/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.dsc s 1
+ pool/stupid/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.tar.gz s 1
+
+Distribution: test1
+Source: bloat+-0a9z.app
+Version: 99:9.0-A:Z+a:z-0+aA.9zZ
+Files:
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ.dsc s 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ.tar.gz s 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ_abacus.deb b 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_9.0-A:Z+a:z-0+aA.9zZ_all.deb a 1
+ pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_99:9.0-A:Z+a:z-0+aA.9zZ_source+all+abacus.changes c 0
+
+Distribution: test1
+Source: simple
+Version: 1
+Files:
+ pool/stupid/s/simple/simple_1_abacus.deb b 1
+ pool/stupid/s/simple/simple_1.dsc s 1
+ pool/stupid/s/simple/simple_1.tar.gz s 1
+ pool/ugly/s/simple/simple_1_abacus.deb b 1
+ pool/ugly/s/simple/simple-addons_1_all.deb a 1
+ pool/ugly/s/simple/simple_1.dsc s 1
+ pool/ugly/s/simple/simple_1.tar.gz s 1
+
+Distribution: test1
+Source: test
+Version: 1-2
+Files:
+ pool/stupid/t/test/test_1-2.dsc s 1
+ pool/stupid/t/test/test_1.orig.tar.gz s 1
+ pool/stupid/t/test/test_1-2.diff.gz s 1
+ pool/stupid/t/test/test_1-2_abacus.deb b 1
+ pool/stupid/t/test/test-addons_1-2_all.deb a 1
+ pool/stupid/t/test/test_1-2_source+all+abacus.changes c 0
+
+Distribution: test1
+Source: testb
+Version: 1:2-3
+Files:
+ pool/stupid/t/testb/testb_2-3.dsc s 1
+ pool/stupid/t/testb/testb_2.orig.tar.gz s 1
+ pool/stupid/t/testb/testb_2-3.diff.gz s 1
+ pool/stupid/t/testb/testb_2-3_abacus.deb b 1
+ pool/stupid/t/testb/testb-addons_2-3_all.deb a 1
+ pool/stupid/t/testb/testb_1:2-3_source+all+abacus.changes c 0
+
+EOF
+dodiff results.expected results
+
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+testout "" -b . dumpreferences
+sort results > results.expected
+testrun - -b . rereference 3<<EOF
+stdout
+-v1*=Referencing test1...
+-v3*=Unlocking dependencies of test1|stupid|abacus...
+=Rereferencing test1|stupid|abacus...
+-v3*=Referencing test1|stupid|abacus...
+-v3*=Unlocking dependencies of test1|stupid|source...
+=Rereferencing test1|stupid|source...
+-v3*=Referencing test1|stupid|source...
+-v3*=Unlocking dependencies of test1|ugly|abacus...
+=Rereferencing test1|ugly|abacus...
+-v3*=Referencing test1|ugly|abacus...
+-v3*=Unlocking dependencies of test1|ugly|source...
+=Rereferencing test1|ugly|source...
+-v3*=Referencing test1|ugly|source...
+-v1*=Referencing test2...
+-v3*=Unlocking dependencies of test2|stupid|abacus...
+=Rereferencing test2|stupid|abacus...
+-v3*=Referencing test2|stupid|abacus...
+-v3*=Unlocking dependencies of test2|stupid|coal...
+=Rereferencing test2|stupid|coal...
+-v3*=Referencing test2|stupid|coal...
+-v3*=Unlocking dependencies of test2|stupid|source...
+=Rereferencing test2|stupid|source...
+-v3*=Referencing test2|stupid|source...
+-v3*=Unlocking dependencies of test2|ugly|abacus...
+=Rereferencing test2|ugly|abacus...
+-v3*=Referencing test2|ugly|abacus...
+-v3*=Unlocking dependencies of test2|ugly|coal...
+=Rereferencing test2|ugly|coal...
+-v3*=Referencing test2|ugly|coal...
+-v3*=Unlocking dependencies of test2|ugly|source...
+=Rereferencing test2|ugly|source...
+-v3*=Referencing test2|ugly|source...
+EOF
+testout "" -b . dumpreferences
+sort results > results.sorted
+dodiff results.expected results.sorted
+rm db/references.db
+testrun - -b . rereference 3<<EOF
+stdout
+-v1*=Referencing test1...
+-v3*=Unlocking dependencies of test1|stupid|abacus...
+=Rereferencing test1|stupid|abacus...
+-v3*=Referencing test1|stupid|abacus...
+-v3*=Unlocking dependencies of test1|stupid|source...
+=Rereferencing test1|stupid|source...
+-v3*=Referencing test1|stupid|source...
+-v3*=Unlocking dependencies of test1|ugly|abacus...
+=Rereferencing test1|ugly|abacus...
+-v3*=Referencing test1|ugly|abacus...
+-v3*=Unlocking dependencies of test1|ugly|source...
+=Rereferencing test1|ugly|source...
+-v3*=Referencing test1|ugly|source...
+-v1*=Referencing test2...
+-v3*=Unlocking dependencies of test2|stupid|abacus...
+=Rereferencing test2|stupid|abacus...
+-v3*=Referencing test2|stupid|abacus...
+-v3*=Unlocking dependencies of test2|stupid|coal...
+=Rereferencing test2|stupid|coal...
+-v3*=Referencing test2|stupid|coal...
+-v3*=Unlocking dependencies of test2|stupid|source...
+=Rereferencing test2|stupid|source...
+-v3*=Referencing test2|stupid|source...
+-v3*=Unlocking dependencies of test2|ugly|abacus...
+=Rereferencing test2|ugly|abacus...
+-v3*=Referencing test2|ugly|abacus...
+-v3*=Unlocking dependencies of test2|ugly|coal...
+=Rereferencing test2|ugly|coal...
+-v3*=Referencing test2|ugly|coal...
+-v3*=Unlocking dependencies of test2|ugly|source...
+=Rereferencing test2|ugly|source...
+-v3*=Referencing test2|ugly|source...
+EOF
+testout "" -b . dumpreferences
+sort results > results.sorted
+dodiff results.expected results.sorted
+testout "" -b . dumpreferences
+sort results > results.sorted
+dodiff results.expected results.sorted
+
+sed -i -e 's/^Tracking: minimal/Tracking: keep includechanges/' conf/distributions
+mv db/savedtracking.db db/tracking.db
+mv db/savedreferences.db db/references.db
+
+mkdir conf2
+testrun - -b . --confdir ./conf2 update 3<<EOF
+returns 254
+stderr
+*=Error opening config file './conf2/distributions': No such file or directory(2)
+=(Have you forgotten to specify a basedir by -b?
+=To only set the conf/ dir use --confdir)
+-v0*=There have been errors!
+EOF
+touch conf2/distributions
+testrun - -b . --confdir ./conf2 update 3<<EOF
+returns 249
+stderr
+*=No distribution definitions found in ./conf2/distributions!
+-v0*=There have been errors!
+EOF
+echo 'Codename: foo' > conf2/distributions
+testrun - -b . --confdir ./conf2 update 3<<EOF
+stderr
+*=Error parsing config file ./conf2/distributions, line 2:
+*=Required field 'Architectures' not found in
+*=distribution definition starting in line 1 and ending in line 1.
+-v0*=There have been errors!
+returns 249
+EOF
+echo "Architectures: abacus fingers" >> conf2/distributions
+testrun - -b . --confdir ./conf2 update 3<<EOF
+*=Error parsing config file ./conf2/distributions, line 3:
+*=Required field 'Components' not found in
+*=distribution definition starting in line 1 and ending in line 2.
+-v0*=There have been errors!
+returns 249
+EOF
+undefinedtargeterror() {
+cat <<'EOF'
+*=This usually means you removed some component, architecture or even
+*=a whole distribution from conf/distributions.
+*=In that case you most likely want to call reprepro clearvanished to get rid
+*=of the databases belonging to those removed parts.
+*=(Another reason to get this error is using conf/ and db/ directories
+*= belonging to different reprepro repositories).
+EOF
+if $1 ; then
+cat << 'EOF'
+*=To ignore use --ignore=undefinedtarget.
+EOF
+else
+cat << 'EOF'
+*=Ignoring as --ignore=undefinedtarget given.
+EOF
+fi
+}
+echo 'Components: unneeded bloated i386' >> conf2/distributions
+testrun - -b . --confdir ./conf2 update 3<<EOF
+*=Error: packages database contains unused 'test1|stupid|abacus' database.
+$(undefinedtargeterror true)
+-v0*=There have been errors!
+returns 255
+EOF
+testrun - -b . --confdir ./conf2 --ignore=undefinedtarget update 3<<EOF
+*=Error: packages database contains unused 'test1|stupid|abacus' database.
+$(undefinedtargeterror false)
+*=Error: packages database contains unused 'test1|ugly|abacus' database.
+*=Error: packages database contains unused 'test1|ugly|source' database.
+*=Error: packages database contains unused 'test1|stupid|source' database.
+*=Error: packages database contains unused 'test2|stupid|abacus' database.
+*=Error: packages database contains unused 'test2|stupid|coal' database.
+*=Error: packages database contains unused 'test2|stupid|source' database.
+*=Error: packages database contains unused 'test2|ugly|abacus' database.
+*=Error: packages database contains unused 'test2|ugly|coal' database.
+*=Error: packages database contains unused 'test2|ugly|source' database.
+*=Error: tracking database contains unused 'test1' database.
+*=This either means you removed a distribution from the distributions config
+*=file without calling clearvanished (or at least removealltracks), you
+*=experienced a bug in retrack in versions < 3.0.0, you found a new bug or your
+*=config does not belong to this database.
+*=To ignore use --ignore=undefinedtracking.
+-v0*=There have been errors!
+returns 255
+EOF
+testrun - -b . --confdir ./conf2 --ignore=undefinedtarget --ignore=undefinedtracking update 3<<EOF
+*=Error: packages database contains unused 'test1|stupid|abacus' database.
+$(undefinedtargeterror false)
+*=Error: tracking database contains unused 'test1' database.
+*=This either means you removed a distribution from the distributions config
+*=file without calling clearvanished (or at least removealltracks), you
+*=experienced a bug in retrack in versions < 3.0.0, you found a new bug or your
+*=config does not belong to this database.
+*=Ignoring as --ignore=undefinedtracking given.
+*=Error: packages database contains unused 'test1|ugly|abacus' database.
+*=Error: packages database contains unused 'test1|ugly|source' database.
+*=Error: packages database contains unused 'test1|stupid|source' database.
+*=Error: packages database contains unused 'test2|stupid|abacus' database.
+*=Error: packages database contains unused 'test2|stupid|coal' database.
+*=Error: packages database contains unused 'test2|stupid|source' database.
+*=Error: packages database contains unused 'test2|ugly|abacus' database.
+*=Error: packages database contains unused 'test2|ugly|coal' database.
+*=Error: packages database contains unused 'test2|ugly|source' database.
+*=Error opening config file './conf2/updates': No such file or directory(2)
+-v0*=There have been errors!
+returns 254
+EOF
+touch conf2/updates
+testrun - -b . --confdir ./conf2 --ignore=undefinedtarget --ignore=undefinedtracking --noskipold update 3<<EOF
+stderr
+*=Error: packages database contains unused 'test1|stupid|abacus' database.
+$(undefinedtargeterror false)
+*=Error: packages database contains unused 'test1|ugly|abacus' database.
+*=Error: packages database contains unused 'test1|ugly|source' database.
+*=Error: packages database contains unused 'test1|stupid|source' database.
+*=Error: packages database contains unused 'test2|stupid|abacus' database.
+*=Error: packages database contains unused 'test2|stupid|coal' database.
+*=Error: packages database contains unused 'test2|stupid|source' database.
+*=Error: packages database contains unused 'test2|ugly|abacus' database.
+*=Error: packages database contains unused 'test2|ugly|coal' database.
+*=Error: packages database contains unused 'test2|ugly|source' database.
+*=Error: tracking database contains unused 'test1' database.
+*=This either means you removed a distribution from the distributions config
+*=file without calling clearvanished (or at least removealltracks), you
+*=experienced a bug in retrack in versions < 3.0.0, you found a new bug or your
+*=config does not belong to this database.
+*=Ignoring as --ignore=undefinedtracking given.
+*=Nothing to do, because no distribution has an Update: field.
+EOF
+testrun - -b . clearvanished 3<<EOF
+stdout
+*=Deleting vanished identifier 'foo|bloated|abacus'.
+*=Deleting vanished identifier 'foo|bloated|fingers'.
+*=Deleting vanished identifier 'foo|i386|abacus'.
+*=Deleting vanished identifier 'foo|i386|fingers'.
+*=Deleting vanished identifier 'foo|unneeded|abacus'.
+*=Deleting vanished identifier 'foo|unneeded|fingers'.
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+echo "Format: 2.0" > broken.changes
+testrun - -b . include test2 broken.changes 3<<EOF
+*=In 'broken.changes': Missing 'Date' field!
+=To ignore use --ignore=missingfield.
+-v0*=There have been errors!
+returns 255
+EOF
+echo "Date: today" >> broken.changes
+testrun - -b . include test2 broken.changes 3<<EOF
+*=In 'broken.changes': Missing 'Source' field
+-v0*=There have been errors!
+returns 255
+EOF
+echo "Source: nowhere" >> broken.changes
+testrun - -b . include test2 broken.changes 3<<EOF
+*=In 'broken.changes': Missing 'Architecture' field
+-v0*=There have been errors!
+returns 255
+EOF
+echo "Architecture: brain" >> broken.changes
+testrun - -b . include test2 broken.changes 3<<EOF
+*=In 'broken.changes': Missing 'Version' field
+-v0*=There have been errors!
+returns 255
+EOF
+echo "Version: 0old" >> broken.changes
+testrun - -b . include test2 broken.changes 3<<EOF
+*=In 'broken.changes': Missing 'Distribution' field
+-v0*=There have been errors!
+returns 255
+EOF
+echo "Distribution: old" >> broken.changes
+testrun - -b . include test2 broken.changes 3<<EOF
+*=In 'broken.changes': Missing 'Maintainer' field!
+=To ignore use --ignore=missingfield.
+-v0*=There have been errors!
+returns 255
+EOF
+echo "Distribution: old" >> broken.changes
+testrun - -b . --ignore=missingfield include test2 broken.changes 3<<EOF
+*=In 'broken.changes': Missing 'Maintainer' field!
+=Ignoring as --ignore=missingfield given.
+*=In 'broken.changes': Missing 'Files' field!
+-v0*=There have been errors!
+returns 255
+EOF
+echo "Files:" >> broken.changes
+testrun - -b . --ignore=missingfield include test2 broken.changes 3<<EOF
+*=In 'broken.changes': Missing 'Maintainer' field!
+*=broken.changes: Not enough files in .changes!
+=Ignoring as --ignore=missingfield given.
+-v0*=There have been errors!
+returns 255
+EOF
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+echo " $EMPTYMD5 section priority filename_version.tar.gz" >> broken.changes
+testrun - -b . --ignore=missingfield include test2 broken.changes 3<<EOF
+=In 'broken.changes': Missing 'Maintainer' field!
+=Ignoring as --ignore=missingfield given.
+*=Warning: File 'filename_version.tar.gz' looks like source but does not start with 'nowhere_'!
+=I hope you know what you do.
+# grr, this message has really to improve...
+*=.changes put in a distribution not listed within it!
+=To ignore use --ignore=wrongdistribution.
+-v0*=There have been errors!
+returns 255
+EOF
+cp conf/distributions conf/distributions.old
+cat >> conf/distributions <<EOF
+
+Codename: getmoreatoms
+Architectures: brain
+Components: test
+EOF
+testrun - -b . --ignore=unusedarch --ignore=surprisingarch --ignore=wrongdistribution --ignore=missingfield include test2 broken.changes 3<<EOF
+=Ignoring as --ignore=missingfield given.
+=In 'broken.changes': Missing 'Maintainer' field!
+=Warning: File 'filename_version.tar.gz' looks like source but does not start with 'nowhere_'!
+=I hope you know what you do.
+*=.changes put in a distribution not listed within it!
+*=Ignoring as --ignore=wrongdistribution given.
+*='filename_version.tar.gz' looks like part of an source package, but no dsc file listed in the .changes file!
+-v0*=There have been errors!
+returns 255
+EOF
+
+echo " $EMPTYMD5 section priority nowhere_0old.dsc" >> broken.changes
+touch nowhere_0old.dsc
+
+testrun - -b . --ignore=unusedarch --ignore=surprisingarch --ignore=wrongdistribution --ignore=missingfield include test2 broken.changes 3<<EOF
+=Ignoring as --ignore=missingfield given.
+=In 'broken.changes': Missing 'Maintainer' field!
+=Warning: File 'filename_version.tar.gz' looks like source but does not start with 'nowhere_'!
+=I hope you know what you do.
+*=.changes put in a distribution not listed within it!
+*=Ignoring as --ignore=wrongdistribution given.
+*=Architecture header lists architecture 'brain', but no files for it!
+*=Ignoring as --ignore=unusedarch given.
+*='filename_version.tar.gz' looks like architecture 'source', but this is not listed in the Architecture-Header!
+*='nowhere_0old.dsc' looks like architecture 'source', but this is not listed in the Architecture-Header!
+*=Ignoring as --ignore=surprisingarch given.
+*=Cannot find file './filename_version.tar.gz' needed by 'broken.changes'!
+-v0*=There have been errors!
+returns 249
+EOF
+
+touch filename_version.tar.gz
+testrun - -b . --ignore=unusedarch --ignore=surprisingarch --ignore=wrongdistribution --ignore=missingfield include test2 broken.changes 3<<EOF
+=Ignoring as --ignore=missingfield given.
+=In 'broken.changes': Missing 'Maintainer' field!
+=Warning: File 'filename_version.tar.gz' looks like source but does not start with 'nowhere_'!
+=Warning: File 'nowhere_0old.dsc' looks like source but does not start with 'nowhere_'!
+=Warning: File 'nowhere_0old.dsc' looks like source but does not start with 'nowhere_'!
+=I hope you know what you do.
+*=.changes put in a distribution not listed within it!
+*=Ignoring as --ignore=wrongdistribution given.
+*=Architecture header lists architecture 'brain', but no files for it!
+*=Ignoring as --ignore=unusedarch given.
+*='filename_version.tar.gz' looks like architecture 'source', but this is not listed in the Architecture-Header!
+*='nowhere_0old.dsc' looks like architecture 'source', but this is not listed in the Architecture-Header!
+*=Ignoring as --ignore=surprisingarch given.
+stdout
+-v2*=Created directory "./pool/stupid/n"
+-v2*=Created directory "./pool/stupid/n/nowhere"
+$(ofa 'pool/stupid/n/nowhere/filename_version.tar.gz')
+$(ofa 'pool/stupid/n/nowhere/nowhere_0old.dsc')
+stderr
+*=Unexpected empty file './pool/stupid/n/nowhere/nowhere_0old.dsc'!
+-v0*=There have been errors!
+returns 255
+stdout
+-v0*=Deleting files just added to the pool but not used.
+-v0*=(to avoid use --keepunusednewfiles next time)
+$(ofd 'pool/stupid/n/nowhere/filename_version.tar.gz')
+$(ofd 'pool/stupid/n/nowhere/nowhere_0old.dsc')
+-v2*=removed now empty directory ./pool/stupid/n/nowhere
+-v2*=removed now empty directory ./pool/stupid/n
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+rm nowhere_0old.dsc
+mv conf/distributions.old conf/distributions
+testrun - -b . clearvanished 3<<EOF
+stderr
+stdout
+*=Deleting vanished identifier 'getmoreatoms|test|brain'.
+EOF
+mkdir -p pool/stupid/n/nowhere
+dodo test ! -f pool/stupid/n/nowhere/filename_version.tar.gz
+cp filename_version.tar.gz pool/stupid/n/nowhere/filename_version.tar.gz
+testrun - -b . _detect pool/stupid/n/nowhere/filename_version.tar.gz 3<<EOF
+stdout
+$(ofa 'pool/stupid/n/nowhere/filename_version.tar.gz')
+-v0*=1 files were added but not used.
+-v0*=The next deleteunreferenced call will delete them.
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+testout "" -b . dumpunreferenced
+cat >results.expected <<EOF
+pool/stupid/n/nowhere/filename_version.tar.gz
+EOF
+dodiff results.expected results
+testrun - -b . deleteunreferenced 3<<EOF
+stdout
+$(ofd 'pool/stupid/n/nowhere/filename_version.tar.gz')
+-v2*=removed now empty directory ./pool/stupid/n/nowhere
+-v2*=removed now empty directory ./pool/stupid/n
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+testout "" -b . dumpreferences
+# first remove file, then try to remove the package
+testrun - -b . _forget pool/ugly/s/simple/simple_1_abacus.deb 3<<EOF
+stdout
+$(ofd 'pool/ugly/s/simple/simple_1_abacus.deb' false)
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+testrun - -b . remove test1 simple 3<<EOF
+# ???
+=Warning: tracking database of test1 missed files for simple_1.
+stdout
+$(opd 'simple' unset test1 stupid abacus deb)
+$(opd 'simple' unset test1 stupid source dsc)
+$(opd 'simple' unset test1 ugly abacus deb)
+$(opd 'simple' unset test1 ugly source dsc)
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test1|stupid|abacus'...
+-v6*= replacing './dists/test1/stupid/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|stupid|source'...
+-v6*= replacing './dists/test1/stupid/source/Sources' (gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|ugly|abacus'...
+-v6*= replacing './dists/test1/ugly/binary-abacus/Packages' (uncompressed,gzipped,bzip2ed)
+-v6*= looking for changes in 'test1|ugly|source'...
+-v6*= replacing './dists/test1/ugly/source/Sources' (gzipped,bzip2ed)
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log1 <<EOF
+DATESTR remove test1 deb stupid abacus simple 1
+DATESTR remove test1 dsc stupid source simple 1
+DATESTR remove test1 deb ugly abacus simple 1
+DATESTR remove test1 dsc ugly source simple 1
+EOF
+testrun - -b . remove test2 simple 3<<EOF
+*=Unable to forget unknown filekey 'pool/ugly/s/simple/simple_1_abacus.deb'.
+-v0*=There have been errors!
+stdout
+$(opd 'simple' unset test2 ugly abacus deb)
+$(opd 'simple' unset test2 ugly source dsc)
+-v0=Exporting indices...
+-v6*= looking for changes in 'test2|stupid|abacus'...
+-v6*= looking for changes in 'test2|stupid|coal'...
+-v6*= looking for changes in 'test2|stupid|source'...
+-v6*= looking for changes in 'test2|ugly|abacus'...
+-v6*= replacing './dists/test2/ugly/binary-abacus/Packages' (uncompressed,gzipped,script: bzip.example,testhook)
+-v6*= looking for changes in 'test2|ugly|coal'...
+-v6*= looking for changes in 'test2|ugly|source'...
+-v6*= replacing './dists/test2/ugly/source/Sources' (uncompressed,gzipped,script: bzip.example,testhook)
+*=testhook got 4: './dists/test2' 'stupid/binary-abacus/Packages.new' 'stupid/binary-abacus/Packages' 'old'
+*=testhook got 4: './dists/test2' 'stupid/binary-coal/Packages.new' 'stupid/binary-coal/Packages' 'old'
+*=testhook got 4: './dists/test2' 'stupid/source/Sources.new' 'stupid/source/Sources' 'old'
+*=testhook got 4: './dists/test2' 'ugly/binary-abacus/Packages.new' 'ugly/binary-abacus/Packages' 'change'
+*=testhook got 4: './dists/test2' 'ugly/binary-coal/Packages.new' 'ugly/binary-coal/Packages' 'old'
+*=testhook got 4: './dists/test2' 'ugly/source/Sources.new' 'ugly/source/Sources' 'change'
+-v0=Deleting files no longer referenced...
+$(ofd 'pool/ugly/s/simple/simple_1.dsc')
+$(ofd 'pool/ugly/s/simple/simple_1.tar.gz')
+-v1*=deleting and forgetting pool/ugly/s/simple/simple_1_abacus.deb
+returns 249
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log2 <<EOF
+DATESTR remove test2 deb ugly abacus simple 1
+DATESTR remove test2 dsc ugly source simple 1
+EOF
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+
+cat > broken.changes <<EOF
+Format: -1.0
+Date: yesterday
+Source: differently
+Version: 0another
+Architecture: source abacus
+Urgency: super-hyper-duper-important
+Maintainer: still me <guess@who>
+Description: missing
+Changes: missing
+Binary: none and nothing
+Distribution: test2
+Files:
+ `md5sum 4test_0b.1-1.dsc| cut -d" " -f 1` `stat -c%s 4test_0b.1-1.dsc` a b differently_0another.dsc
+ `md5sum 4test_0b.1-1_abacus.deb| cut -d" " -f 1` `stat -c%s 4test_0b.1-1_abacus.deb` a b 4test_0b.1-1_abacus.deb
+EOF
+#todo: make it work without this..
+cp 4test_0b.1-1.dsc differently_0another.dsc
+testrun - -b . include test2 broken.changes 3<<EOF
+=Looks like source but does not start with 'differently_' as I would have guessed!
+=I hope you know what you do.
+*=I don't know what to do having a .dsc without a .diff.gz or .tar.gz in 'broken.changes'!
+-v0*=There have been errors!
+returns 255
+EOF
+cat >> broken.changes <<EOF
+ `md5sum 4test_0b.1-1.tar.gz| cut -d" " -f 1` `stat -c%s 4test_0b.1-1.tar.gz` a b 4test_0b.1-1.tar.gz
+EOF
+testrun - -b . include test2 broken.changes 3<<EOF
+*=Warning: File '4test_0b.1-1.tar.gz' looks like source but does not start with 'differently_'!
+=I hope you know what you do.
+*='./pool/stupid/d/differently/4test_0b.1-1_abacus.deb' has packagename '4test' not listed in the .changes file!
+*=To ignore use --ignore=surprisingbinary.
+-v0*=There have been errors!
+stdout
+-v2*=Created directory "./pool/stupid/d"
+-v2*=Created directory "./pool/stupid/d/differently"
+$(ofa 'pool/stupid/d/differently/4test_0b.1-1.tar.gz')
+$(ofa 'pool/stupid/d/differently/4test_0b.1-1_abacus.deb')
+$(ofa 'pool/stupid/d/differently/differently_0another.dsc')
+-v0*=Deleting files just added to the pool but not used.
+-v0*=(to avoid use --keepunusednewfiles next time)
+$(ofd 'pool/stupid/d/differently/4test_0b.1-1.tar.gz')
+$(ofd 'pool/stupid/d/differently/4test_0b.1-1_abacus.deb')
+$(ofd 'pool/stupid/d/differently/differently_0another.dsc')
+-v2*=removed now empty directory ./pool/stupid/d/differently
+-v2*=removed now empty directory ./pool/stupid/d
+returns 255
+EOF
+testrun - -b . --ignore=surprisingbinary include test2 broken.changes 3<<EOF
+*=Warning: File '4test_0b.1-1.tar.gz' looks like source but does not start with 'differently_'!
+=I hope you know what you do.
+*='./pool/stupid/d/differently/4test_0b.1-1_abacus.deb' has packagename '4test' not listed in the .changes file!
+*=Ignoring as --ignore=surprisingbinary given.
+*='./pool/stupid/d/differently/4test_0b.1-1_abacus.deb' lists source package '4test', but .changes says it is 'differently'!
+-v0*=There have been errors!
+stdout
+-v2*=Created directory "./pool/stupid/d"
+-v2*=Created directory "./pool/stupid/d/differently"
+$(ofa 'pool/stupid/d/differently/4test_0b.1-1.tar.gz')
+$(ofa 'pool/stupid/d/differently/4test_0b.1-1_abacus.deb')
+$(ofa 'pool/stupid/d/differently/differently_0another.dsc')
+-v0*=Deleting files just added to the pool but not used.
+-v0*=(to avoid use --keepunusednewfiles next time)
+$(ofd 'pool/stupid/d/differently/4test_0b.1-1.tar.gz')
+$(ofd 'pool/stupid/d/differently/4test_0b.1-1_abacus.deb')
+$(ofd 'pool/stupid/d/differently/differently_0another.dsc')
+-v2*=removed now empty directory ./pool/stupid/d/differently
+-v2*=removed now empty directory ./pool/stupid/d
+returns 255
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+cat > broken.changes <<EOF
+Format: -1.0
+Date: yesterday
+Source: 4test
+Version: 0orso
+Architecture: source abacus
+Urgency: super-hyper-duper-important
+Maintainer: still me <guess@who>
+Description: missing
+Changes: missing
+Binary: 4test
+Distribution: test2
+Files:
+ `md5sum 4test_0b.1-1.dsc| cut -d" " -f 1` `stat -c%s 4test_0b.1-1.dsc` a b 4test_0orso.dsc
+ `md5sum 4test_0b.1-1_abacus.deb| cut -d" " -f 1` `stat -c%s 4test_0b.1-1_abacus.deb` a b 4test_0b.1-1_abacus.deb
+ `md5sum 4test_0b.1-1.tar.gz| cut -d" " -f 1` `stat -c%s 4test_0b.1-1.tar.gz` a b 4test_0b.1-1.tar.gz
+EOF
+cp 4test_0b.1-1.dsc 4test_0orso.dsc
+testrun - -b . include test2 broken.changes 3<<EOF
+*='./pool/stupid/4/4test/4test_0b.1-1_abacus.deb' lists source version '1:0b.1-1', but .changes says it is '0orso'!
+*=To ignore use --ignore=wrongsourceversion.
+-v0*=There have been errors!
+stdout
+$(ofa 'pool/stupid/4/4test/4test_0orso.dsc')
+-v0*=Deleting files just added to the pool but not used.
+-v0*=(to avoid use --keepunusednewfiles next time)
+$(ofd 'pool/stupid/4/4test/4test_0orso.dsc')
+returns 255
+EOF
+testrun - -b . --ignore=wrongsourceversion include test2 broken.changes 3<<EOF
+*='./pool/stupid/4/4test/4test_0b.1-1_abacus.deb' lists source version '1:0b.1-1', but .changes says it is '0orso'!
+*=Ignoring as --ignore=wrongsourceversion given.
+*='4test_0orso.dsc' says it is version '1:0b.1-1', while .changes file said it is '0orso'
+*=To ignore use --ignore=wrongversion.
+-v0*=There have been errors!
+stdout
+$(ofa 'pool/stupid/4/4test/4test_0orso.dsc')
+-v0*=Deleting files just added to the pool but not used.
+-v0*=(to avoid use --keepunusednewfiles next time)
+$(ofd 'pool/stupid/4/4test/4test_0orso.dsc')
+returns 255
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checknolog log1
+checknolog log2
+testrun - -b . --ignore=wrongsourceversion --ignore=wrongversion include test2 broken.changes 3<<EOF
+*='./pool/stupid/4/4test/4test_0b.1-1_abacus.deb' lists source version '1:0b.1-1', but .changes says it is '0orso'!
+*=Ignoring as --ignore=wrongsourceversion given.
+*='4test_0orso.dsc' says it is version '1:0b.1-1', while .changes file said it is '0orso'
+*=Ignoring as --ignore=wrongversion given.
+stdout
+$(ofa 'pool/stupid/4/4test/4test_0orso.dsc')
+$(opa '4test' x 'test2' 'stupid' 'abacus' 'deb')
+$(opa '4test' unset 'test2' 'stupid' 'source' 'dsc')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test2|stupid|abacus'...
+-v6*= replacing './dists/test2/stupid/binary-abacus/Packages' (uncompressed,gzipped,script: bzip.example,testhook)
+-v6*= looking for changes in 'test2|stupid|coal'...
+-v6*= looking for changes in 'test2|stupid|source'...
+-v6*= replacing './dists/test2/stupid/source/Sources' (uncompressed,gzipped,script: bzip.example,testhook)
+-v6*= looking for changes in 'test2|ugly|abacus'...
+-v6*= looking for changes in 'test2|ugly|coal'...
+-v6*= looking for changes in 'test2|ugly|source'...
+*=testhook got 4: './dists/test2' 'stupid/binary-abacus/Packages.new' 'stupid/binary-abacus/Packages' 'change'
+*=testhook got 4: './dists/test2' 'stupid/binary-coal/Packages.new' 'stupid/binary-coal/Packages' 'old'
+*=testhook got 4: './dists/test2' 'stupid/source/Sources.new' 'stupid/source/Sources' 'change'
+*=testhook got 4: './dists/test2' 'ugly/binary-abacus/Packages.new' 'ugly/binary-abacus/Packages' 'old'
+*=testhook got 4: './dists/test2' 'ugly/binary-coal/Packages.new' 'ugly/binary-coal/Packages' 'old'
+*=testhook got 4: './dists/test2' 'ugly/source/Sources.new' 'ugly/source/Sources' 'old'
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log2 <<EOF
+DATESTR add test2 deb stupid abacus 4test 1:0b.1-1
+DATESTR add test2 dsc stupid source 4test 1:0b.1-1
+EOF
+testrun - -b . remove test2 4test 3<<EOF
+stdout
+$(opd '4test' unset test2 stupid abacus deb)
+$(opd '4test' unset test2 stupid source dsc)
+-v0*=Exporting indices...
+-v6*= looking for changes in 'test2|stupid|abacus'...
+-v6*= replacing './dists/test2/stupid/binary-abacus/Packages' (uncompressed,gzipped,script: bzip.example,testhook)
+-v6*= looking for changes in 'test2|stupid|coal'...
+-v6*= looking for changes in 'test2|stupid|source'...
+-v6*= replacing './dists/test2/stupid/source/Sources' (uncompressed,gzipped,script: bzip.example,testhook)
+-v6*= looking for changes in 'test2|ugly|abacus'...
+-v6*= looking for changes in 'test2|ugly|coal'...
+-v6*= looking for changes in 'test2|ugly|source'...
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/stupid/4/4test/4test_0orso.dsc')
+*=testhook got 4: './dists/test2' 'stupid/binary-abacus/Packages.new' 'stupid/binary-abacus/Packages' 'change'
+*=testhook got 4: './dists/test2' 'stupid/binary-coal/Packages.new' 'stupid/binary-coal/Packages' 'old'
+*=testhook got 4: './dists/test2' 'stupid/source/Sources.new' 'stupid/source/Sources' 'change'
+*=testhook got 4: './dists/test2' 'ugly/binary-abacus/Packages.new' 'ugly/binary-abacus/Packages' 'old'
+*=testhook got 4: './dists/test2' 'ugly/binary-coal/Packages.new' 'ugly/binary-coal/Packages' 'old'
+*=testhook got 4: './dists/test2' 'ugly/source/Sources.new' 'ugly/source/Sources' 'old'
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+checklog log2 <<EOF
+DATESTR remove test2 deb stupid abacus 4test 1:0b.1-1
+DATESTR remove test2 dsc stupid source 4test 1:0b.1-1
+EOF
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+
+checknolog log1
+checknolog log2
+
+testout "" -b . dumptracks
+# TODO: check here for what should be here,
+# check the othe stuff, too
+#dodiff /dev/null results
+cat > conf/distributions <<EOF
+Codename: X
+Architectures: none
+Components: test
+EOF
+testrun - -b . --delete clearvanished 3<<EOF
+stderr
+-v4*=Strange, 'X|test|none' does not appear in packages.db yet.
+stdout
+*=Deleting vanished identifier 'test1|stupid|abacus'.
+*=Deleting vanished identifier 'test1|stupid|source'.
+*=Deleting vanished identifier 'test1|ugly|abacus'.
+*=Deleting vanished identifier 'test1|ugly|source'.
+*=Deleting vanished identifier 'test2|stupid|abacus'.
+*=Deleting vanished identifier 'test2|stupid|coal'.
+*=Deleting vanished identifier 'test2|stupid|source'.
+*=Deleting vanished identifier 'test2|ugly|abacus'.
+*=Deleting vanished identifier 'test2|ugly|coal'.
+*=Deleting vanished identifier 'test2|ugly|source'.
+*=Deleting tracking data for vanished distribution 'test1'.
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/stupid/4/4test/4test-addons_0b.1-1_all.deb')
+$(ofd 'pool/stupid/4/4test/4test_0b.1-1_abacus.deb')
+$(ofd 'pool/stupid/4/4test/4test_0b.1-1.dsc')
+$(ofd 'pool/stupid/4/4test/4test_0b.1-1.tar.gz')
+$(ofd 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_9.0-A:Z+a:z-0+aA.9zZ_all.deb')
+$(ofd 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ_abacus.deb')
+$(ofd 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ.dsc')
+$(ofd 'pool/ugly/b/bloat+-0a9z.app/bloat+-0a9z.app_9.0-A:Z+a:z-0+aA.9zZ.tar.gz')
+$(ofd 'pool/stupid/b/bloat+-0a9z.app/bloat+-0a9z.app-addons_0.9-A:Z+a:z-0+aA.9zZ_all.deb')
+$(ofd 'pool/stupid/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ_abacus.deb')
+$(ofd 'pool/stupid/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.dsc')
+$(ofd 'pool/stupid/b/bloat+-0a9z.app/bloat+-0a9z.app_0.9-A:Z+a:z-0+aA.9zZ.tar.gz')
+$(ofd 'pool/stupid/s/simple/simple_1_abacus.deb')
+$(ofd 'pool/stupid/s/simple/simple_1.dsc')
+$(ofd 'pool/stupid/s/simple/simple_1.tar.gz')
+$(ofd 'pool/stupid/t/test/test-addons_1-2_all.deb')
+$(ofd 'pool/stupid/t/test/test_1-2_abacus.deb')
+$(ofd 'pool/stupid/t/test/test_1-2.dsc')
+$(ofd 'pool/stupid/t/test/test_1.orig.tar.gz')
+$(ofd 'pool/stupid/t/test/test_1-2.diff.gz')
+$(ofd 'pool/stupid/t/testb/testb-addons_2-3_all.deb')
+$(ofd 'pool/stupid/t/testb/testb_2-3_abacus.deb')
+$(ofd 'pool/stupid/t/testb/testb_2-3.dsc')
+$(ofd 'pool/stupid/t/testb/testb_2.orig.tar.gz')
+$(ofd 'pool/stupid/t/testb/testb_2-3.diff.gz')
+$(ofd 'pool/ugly/s/simple/simple-addons_1_all.deb')
+-v2*=removed now empty directory ./pool/stupid/4/4test
+-v2*=removed now empty directory ./pool/stupid/4
+-v2*=removed now empty directory ./pool/stupid/b/bloat+-0a9z.app
+-v2*=removed now empty directory ./pool/stupid/b
+-v2*=removed now empty directory ./pool/stupid/s/simple
+-v2*=removed now empty directory ./pool/stupid/s
+-v2*=removed now empty directory ./pool/stupid/t/testb
+-v2*=removed now empty directory ./pool/stupid/t/test
+-v2*=removed now empty directory ./pool/stupid/t
+-v2*=removed now empty directory ./pool/stupid
+-v2*=removed now empty directory ./pool/ugly/b/bloat+-0a9z.app
+-v2*=removed now empty directory ./pool/ugly/b
+-v2*=removed now empty directory ./pool/ugly/s/simple
+-v2*=removed now empty directory ./pool/ugly/s
+-v2*=removed now empty directory ./pool/ugly
+-v2*=removed now empty directory ./pool
+EOF
+REPREPRO_OUT_DIR=. "$SRCDIR"/docs/outstore.py --check
+
+checknolog logfile
+checknolog log1
+checknolog log2
+
+testout "" -b . dumptracks
+dodiff /dev/null results
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+
+rm -r dists db conf conf2 logs lists
+rm 4test* bloat* simple* test_* test-* testb* differently* filename_version.tar.gz
+rm test1 test2 test2.changes broken.changes test.changes fakesuper db.out*
+rm results results.expected results.log.expected includeerror.rules results.sorted
+dodo test ! -d pool
+
+testsuccess
diff --git a/tests/various3.test b/tests/various3.test
new file mode 100644
index 0000000..53fab19
--- /dev/null
+++ b/tests/various3.test
@@ -0,0 +1,982 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+dodo test ! -e dists
+mkdir conf db logs lists
+
+for tracking in true false ; do
+if $tracking ; then
+echo "this is the test variant with tracking on"
+else
+echo "this is the test variant with tracking off"
+fi
+
+if $tracking ; then
+cat >> conf/distributions <<EOF
+
+Codename: a
+Architectures: abacus source
+Components: all
+Tracking: minimal
+Log: logab
+
+Codename: b
+Architectures: abacus
+Components: all
+Pull: froma
+Log: logab
+EOF
+if test x"${REPREPROOPTIONS#*--verbosedb}" != x"$REPREPROOPTIONS" ; then
+ TRACKINGTESTOPTIONS="-D t=1 -D u=1"
+else
+ TRACKINGTESTOPTIONS="-D t=0 -D u=1"
+fi
+else
+cat >> conf/distributions <<EOF
+
+Codename: a
+Architectures: abacus source
+Components: all
+Log: logab
+
+Codename: b
+Architectures: abacus
+Components: all
+Pull: froma
+Log: logab
+EOF
+TRACKINGTESTOPTIONS="-D t=0 -D u=0"
+fi
+
+checknolog logab
+cat > conf/pulls <<EOF
+Name: froma
+From: a
+Architectures: froma>toa froma>toa2 froma2>toa2
+Components: c1 c2
+UDebComponents: u1 u2
+EOF
+testrun - -b . --export=changed pull a b 3<<EOF
+stderr
+*=Error parsing ./conf/pulls, line 3, column 16: Unknown architecture 'froma' in Architectures.
+-v0*=There have been errors!
+return 255
+EOF
+cp conf/distributions conf/distributions.old
+cat >> conf/distributions <<EOF
+
+Codename: moreatoms
+Architectures: froma froma2 toa toa2
+Components: c1 c2 u1 u2
+EOF
+
+testrun - -b . --export=changed pull a b 3<<EOF
+stderr
+*=(This will simply be ignored and is not even checked when using --fast).
+*=Warning: pull rule 'froma' wants to get something from architecture 'froma',
+*=Warning: pull rule 'froma' wants to get something from architecture 'froma2',
+*=but there is no such architecture in distribution 'a'.
+*=Warning: pull rule 'froma' wants to get something from component 'c1',
+*=Warning: pull rule 'froma' wants to get something from component 'c2',
+*=but there is no such component in distribution 'a'.
+*=Warning: pull rule 'froma' wants to get something from udeb component 'u1',
+*=Warning: pull rule 'froma' wants to get something from udeb component 'u2',
+*=but there is no such udeb component in distribution 'a'.
+*=Warning: pull rule 'froma' wants to put something into architecture 'toa',
+*=but no distribution using this has such an architecture.
+*=Warning: pull rule 'froma' wants to put something into architecture 'toa2',
+*=Warning: pull rule 'froma' wants to put something into component 'c1',
+*=but no distribution using this has such an component.
+*=Warning: pull rule 'froma' wants to put something into component 'c2',
+*=Warning: pull rule 'froma' wants to put something into udeb component 'u1',
+*=but no distribution using this has such an udeb component.
+*=Warning: pull rule 'froma' wants to put something into udeb component 'u2',
+stdout
+-v0*=Calculating packages to pull...
+-v3*= pulling into 'b|all|abacus'
+-v0*=Installing (and possibly deleting) packages...
+EOF
+mv conf/distributions.old conf/distributions
+testrun - -b . clearvanished 3<<EOF
+stderr
+stdout
+*=Deleting vanished identifier 'moreatoms|c1|froma'.
+*=Deleting vanished identifier 'moreatoms|c1|froma2'.
+*=Deleting vanished identifier 'moreatoms|c1|toa'.
+*=Deleting vanished identifier 'moreatoms|c1|toa2'.
+*=Deleting vanished identifier 'moreatoms|c2|froma'.
+*=Deleting vanished identifier 'moreatoms|c2|froma2'.
+*=Deleting vanished identifier 'moreatoms|c2|toa'.
+*=Deleting vanished identifier 'moreatoms|c2|toa2'.
+*=Deleting vanished identifier 'moreatoms|u1|froma'.
+*=Deleting vanished identifier 'moreatoms|u1|froma2'.
+*=Deleting vanished identifier 'moreatoms|u1|toa'.
+*=Deleting vanished identifier 'moreatoms|u1|toa2'.
+*=Deleting vanished identifier 'moreatoms|u2|froma'.
+*=Deleting vanished identifier 'moreatoms|u2|froma2'.
+*=Deleting vanished identifier 'moreatoms|u2|toa'.
+*=Deleting vanished identifier 'moreatoms|u2|toa2'.
+EOF
+cat > conf/pulls <<EOF
+Name: froma
+From: a
+EOF
+testrun - -b . --export=changed pull a b 3<<EOF
+stderr
+stdout
+-v0*=Calculating packages to pull...
+-v3*= pulling into 'b|all|abacus'
+-v5*= looking what to get from 'a|all|abacus'
+-v0*=Installing (and possibly deleting) packages...
+EOF
+checklog logab < /dev/null
+test ! -d dists/a
+test ! -d dists/b
+testrun - -b . --export=lookedat pull b 3<<EOF
+stdout
+-v0*=Calculating packages to pull...
+-v3*= pulling into 'b|all|abacus'
+-v5*= looking what to get from 'a|all|abacus'
+-v0*=Installing (and possibly deleting) packages...
+-v0*=Exporting indices...
+-v2*=Created directory "./dists"
+-v2*=Created directory "./dists/b"
+-v2*=Created directory "./dists/b/all"
+-v2*=Created directory "./dists/b/all/binary-abacus"
+-v6*= looking for changes in 'b|all|abacus'...
+-v6*= creating './dists/b/all/binary-abacus/Packages' (uncompressed,gzipped)
+EOF
+checklog logab < /dev/null
+test ! -d dists/a
+test -d dists/b
+testrun - -b . --export=lookedat pull a b 3<<EOF
+stdout
+-v0*=Calculating packages to pull...
+-v3*= pulling into 'b|all|abacus'
+-v5*= looking what to get from 'a|all|abacus'
+-v0*=Installing (and possibly deleting) packages...
+-v0*=Exporting indices...
+-v6*= looking for changes in 'b|all|abacus'...
+-v2*=Created directory "./dists/a"
+-v2*=Created directory "./dists/a/all"
+-v2*=Created directory "./dists/a/all/binary-abacus"
+-v6*= looking for changes in 'a|all|abacus'...
+-v6*= creating './dists/a/all/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/a/all/source"
+-v6*= looking for changes in 'a|all|source'...
+-v6*= creating './dists/a/all/source/Sources' (gzipped)
+EOF
+checklog logab < /dev/null
+test -d dists/a
+test -d dists/b
+rm -r dists/a dists/b
+DISTRI=a PACKAGE=aa EPOCH="" VERSION=1 REVISION="-1" SECTION="stupid/base" genpackage.sh
+testrun - -b . --export=never --delete --delete include a test.changes 3<<EOF
+*=Warning: database 'a|all|abacus' was modified but no index file was exported.
+*=Warning: database 'a|all|source' was modified but no index file was exported.
+*=Changes will only be visible after the next 'export'!
+stdout
+-v2*=Created directory "./pool"
+-v2*=Created directory "./pool/all"
+-v2*=Created directory "./pool/all/a"
+-v2*=Created directory "./pool/all/a/aa"
+$(ofa 'pool/all/a/aa/aa-addons_1-1_all.deb')
+$(ofa 'pool/all/a/aa/aa_1-1_abacus.deb')
+$(ofa 'pool/all/a/aa/aa_1-1.tar.gz')
+$(ofa 'pool/all/a/aa/aa_1-1.dsc')
+$(opa 'aa-addons' x 'a' 'all' 'abacus' 'deb')
+$(opa 'aa' x 'a' 'all' 'abacus' 'deb')
+$(opa 'aa' x 'a' 'all' 'source' 'dsc')
+$(otta 'a' 'aa')
+-v5*=Deleting 'test.changes'.
+EOF
+checklog logab << EOF
+DATESTR add a deb all abacus aa-addons 1-1
+DATESTR add a deb all abacus aa 1-1
+DATESTR add a dsc all source aa 1-1
+EOF
+test ! -d dists/a
+test ! -d dists/b
+test ! -f test.changes
+test ! -f aa_1-1_abacus.deb
+test ! -f aa_1-1.dsc
+test ! -f aa_1-1.tar.gz
+test ! -f aa-addons_1-1_all.deb
+test -f pool/all/a/aa/aa-addons_1-1_all.deb
+test -f pool/all/a/aa/aa_1-1_abacus.deb
+test -f pool/all/a/aa/aa_1-1.dsc
+test -f pool/all/a/aa/aa_1-1.tar.gz
+testout "" -b . dumptracks a
+cat >results.expected <<END
+Distribution: a
+Source: aa
+Version: 1-1
+Files:
+ pool/all/a/aa/aa_1-1.dsc s 1
+ pool/all/a/aa/aa_1-1.tar.gz s 1
+ pool/all/a/aa/aa_1-1_abacus.deb b 1
+ pool/all/a/aa/aa-addons_1-1_all.deb a 1
+
+END
+if $tracking; then dodiff results.expected results ; else dodiff /dev/null results ; fi
+testrun - -b . export a 3<<EOF
+stdout
+-v1*=Exporting a...
+-v2*=Created directory "./dists/a"
+-v2*=Created directory "./dists/a/all"
+-v2*=Created directory "./dists/a/all/binary-abacus"
+-v6*= exporting 'a|all|abacus'...
+-v6*= creating './dists/a/all/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/a/all/source"
+-v6*= exporting 'a|all|source'...
+-v6*= creating './dists/a/all/source/Sources' (gzipped)
+EOF
+checknolog logab
+dogrep "Version: 1-1" dists/a/all/binary-abacus/Packages
+rm -r dists/a
+testout - -b . dumppull b 3<<EOF
+stderr
+EOF
+cat > results.expected <<EOF
+Updates needed for 'b|all|abacus':
+add 'aa' - '1-1' 'froma'
+add 'aa-addons' - '1-1' 'froma'
+EOF
+dodiff results results.expected
+testrun - -b . --export=changed pull a b 3<<EOF
+stdout
+-v0*=Calculating packages to pull...
+-v3*= pulling into 'b|all|abacus'
+-v5*= looking what to get from 'a|all|abacus'
+-v0*=Installing (and possibly deleting) packages...
+$(opa 'aa' x 'b' 'all' 'abacus' 'deb')
+$(opa 'aa-addons' x 'b' 'all' 'abacus' 'deb')
+-v0*=Exporting indices...
+-v2*=Created directory "./dists/b"
+-v2*=Created directory "./dists/b/all"
+-v2*=Created directory "./dists/b/all/binary-abacus"
+-v6*= looking for changes in 'b|all|abacus'...
+-v6*= creating './dists/b/all/binary-abacus/Packages' (uncompressed,gzipped)
+EOF
+checklog logab << EOF
+DATESTR add b deb all abacus aa 1-1
+DATESTR add b deb all abacus aa-addons 1-1
+EOF
+test ! -d dists/a
+test -d dists/b
+dogrep "Version: 1-1" dists/b/all/binary-abacus/Packages
+DISTRI=a PACKAGE=aa EPOCH="" VERSION=1 REVISION="-2" SECTION="stupid/base" genpackage.sh
+testrun - -b . --export=changed --delete include a test.changes 3<<EOF
+stdout
+$(ofa 'pool/all/a/aa/aa-addons_1-2_all.deb')
+$(ofa 'pool/all/a/aa/aa_1-2_abacus.deb')
+$(ofa 'pool/all/a/aa/aa_1-2.tar.gz')
+$(ofa 'pool/all/a/aa/aa_1-2.dsc')
+$(opu 'aa-addons' x x 'a' 'all' 'abacus' 'deb')
+$(opu 'aa' x x 'a' 'all' 'abacus' 'deb')
+$(opu 'aa' x x 'a' 'all' 'source' 'dsc')
+$(otta 'a' 'aa')
+$(ottd 'aa' '1-1' 'a')
+-v0*=Exporting indices...
+-v2*=Created directory "./dists/a"
+-v2*=Created directory "./dists/a/all"
+-v2*=Created directory "./dists/a/all/binary-abacus"
+-v6*= looking for changes in 'a|all|abacus'...
+-v6*= creating './dists/a/all/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/a/all/source"
+-v6*= looking for changes in 'a|all|source'...
+-v6*= creating './dists/a/all/source/Sources' (gzipped)
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/all/a/aa/aa_1-1.dsc')
+$(ofd 'pool/all/a/aa/aa_1-1.tar.gz')
+EOF
+checklog logab << EOF
+DATESTR replace a deb all abacus aa-addons 1-2 1-1
+DATESTR replace a deb all abacus aa 1-2 1-1
+DATESTR replace a dsc all source aa 1-2 1-1
+EOF
+test -f test.changes
+test ! -f aa_1-2_abacus.deb
+test ! -f aa_1-2.dsc
+test ! -f aa_1-2.tar.gz
+test ! -f aa-addons_1-2_all.deb
+test -d dists/a
+dogrep "Version: 1-2" dists/a/all/binary-abacus/Packages
+dogrep "Version: 1-1" dists/b/all/binary-abacus/Packages
+testout "" -b . dumptracks a
+cat >results.expected <<END
+Distribution: a
+Source: aa
+Version: 1-2
+Files:
+ pool/all/a/aa/aa_1-2.dsc s 1
+ pool/all/a/aa/aa_1-2.tar.gz s 1
+ pool/all/a/aa/aa_1-2_abacus.deb b 1
+ pool/all/a/aa/aa-addons_1-2_all.deb a 1
+
+END
+if $tracking; then dodiff results.expected results ; else dodiff /dev/null results ; fi
+rm -r dists/a dists/b
+testout - -b . dumppull b 3<<EOF
+stderr
+EOF
+cat > results.expected <<EOF
+Updates needed for 'b|all|abacus':
+update 'aa' '1-1' '1-2' 'froma'
+update 'aa-addons' '1-1' '1-2' 'froma'
+EOF
+dodiff results results.expected
+testrun - -b . --export=changed pull a b 3<<EOF
+stderr
+stdout
+-v0*=Calculating packages to pull...
+-v3*= pulling into 'b|all|abacus'
+-v5*= looking what to get from 'a|all|abacus'
+-v0*=Installing (and possibly deleting) packages...
+$(opu 'aa' x x 'b' 'all' 'abacus' 'deb')
+$(opu 'aa-addons' x x 'b' 'all' 'abacus' 'deb')
+-v0=Exporting indices...
+-v2*=Created directory "./dists/b"
+-v2*=Created directory "./dists/b/all"
+-v2*=Created directory "./dists/b/all/binary-abacus"
+-v6*= looking for changes in 'b|all|abacus'...
+-v6*= creating './dists/b/all/binary-abacus/Packages' (uncompressed,gzipped)
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/all/a/aa/aa_1-1_abacus.deb')
+$(ofd 'pool/all/a/aa/aa-addons_1-1_all.deb')
+EOF
+checklog logab << EOF
+DATESTR replace b deb all abacus aa 1-2 1-1
+DATESTR replace b deb all abacus aa-addons 1-2 1-1
+EOF
+test ! -d dists/a
+test -d dists/b
+dogrep "Version: 1-2" dists/b/all/binary-abacus/Packages
+DISTRI=a PACKAGE=aa EPOCH="" VERSION=1 REVISION="-3" SECTION="stupid/base" genpackage.sh
+testrun - -b . --export=never include a test.changes 3<<EOF
+*=Warning: database 'a|all|abacus' was modified but no index file was exported.
+*=Warning: database 'a|all|source' was modified but no index file was exported.
+*=Changes will only be visible after the next 'export'!
+stdout
+$(ofa 'pool/all/a/aa/aa-addons_1-3_all.deb')
+$(ofa 'pool/all/a/aa/aa_1-3_abacus.deb')
+$(ofa 'pool/all/a/aa/aa_1-3.tar.gz')
+$(ofa 'pool/all/a/aa/aa_1-3.dsc')
+$(opu 'aa-addons' x x 'a' 'all' 'abacus' 'deb')
+$(opu 'aa' x x 'a' 'all' 'abacus' 'deb')
+$(opu 'aa' x x 'a' 'all' 'source' 'dsc')
+$(otta 'a' 'aa')
+$(ottd 'aa' '1-2' 'a')
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/all/a/aa/aa_1-2.dsc')
+$(ofd 'pool/all/a/aa/aa_1-2.tar.gz')
+EOF
+checklog logab << EOF
+DATESTR replace a deb all abacus aa-addons 1-3 1-2
+DATESTR replace a deb all abacus aa 1-3 1-2
+DATESTR replace a dsc all source aa 1-3 1-2
+EOF
+test -f test.changes
+test -f aa_1-3_abacus.deb
+test -f aa_1-3.dsc
+test -f aa_1-3.tar.gz
+test -f aa-addons_1-3_all.deb
+test ! -f pool/all/a/aa/aa_1-2.dsc
+test -f pool/all/a/aa/aa_1-2_abacus.deb # still in b
+testout "" -b . dumptracks a
+cat >results.expected <<END
+Distribution: a
+Source: aa
+Version: 1-3
+Files:
+ pool/all/a/aa/aa_1-3.dsc s 1
+ pool/all/a/aa/aa_1-3.tar.gz s 1
+ pool/all/a/aa/aa_1-3_abacus.deb b 1
+ pool/all/a/aa/aa-addons_1-3_all.deb a 1
+
+END
+if $tracking; then dodiff results.expected results ; else dodiff /dev/null results ; fi
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+DISTRI=a PACKAGE=ab EPOCH="" VERSION=2 REVISION="-1" SECTION="stupid/base" genpackage.sh
+testrun - -b . --delete --delete --export=never include a test.changes 3<<EOF
+stderr
+*=Warning: database 'a|all|abacus' was modified but no index file was exported.
+*=Warning: database 'a|all|source' was modified but no index file was exported.
+=Changes will only be visible after the next 'export'!
+stdout
+-v2*=Created directory "./pool/all/a/ab"
+$(ofa 'pool/all/a/ab/ab-addons_2-1_all.deb')
+$(ofa 'pool/all/a/ab/ab_2-1_abacus.deb')
+$(ofa 'pool/all/a/ab/ab_2-1.tar.gz')
+$(ofa 'pool/all/a/ab/ab_2-1.dsc')
+$(opa 'ab-addons' x 'a' 'all' 'abacus' 'deb')
+$(opa 'ab' x 'a' 'all' 'abacus' 'deb')
+$(opa 'ab' x 'a' 'all' 'source' 'dsc')
+$(otta 'a' 'ab')
+-v5*=Deleting 'test.changes'.
+EOF
+checklog logab << EOF
+DATESTR add a deb all abacus ab-addons 2-1
+DATESTR add a deb all abacus ab 2-1
+DATESTR add a dsc all source ab 2-1
+EOF
+testout - -b . dumppull b 3<<EOF
+stderr
+EOF
+cat > results.expected <<EOF
+Updates needed for 'b|all|abacus':
+update 'aa' '1-2' '1-3' 'froma'
+update 'aa-addons' '1-2' '1-3' 'froma'
+add 'ab' - '2-1' 'froma'
+add 'ab-addons' - '2-1' 'froma'
+EOF
+dodiff results results.expected
+
+testrun - -b . --export=changed pull b 3<<EOF
+stderr
+stdout
+-v0*=Calculating packages to pull...
+-v3*= pulling into 'b|all|abacus'
+-v5*= looking what to get from 'a|all|abacus'
+-v0*=Installing (and possibly deleting) packages...
+$(opu 'aa' x x 'b' 'all' 'abacus' 'deb')
+$(opu 'aa-addons' x x 'b' 'all' 'abacus' 'deb')
+$(opa 'ab' x 'b' 'all' 'abacus' 'deb')
+$(opa 'ab-addons' x 'b' 'all' 'abacus' 'deb')
+-v0=Exporting indices...
+-v6*= looking for changes in 'b|all|abacus'...
+-v6*= replacing './dists/b/all/binary-abacus/Packages' (uncompressed,gzipped)
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/all/a/aa/aa_1-2_abacus.deb')
+$(ofd 'pool/all/a/aa/aa-addons_1-2_all.deb')
+EOF
+checklog logab << EOF
+DATESTR replace b deb all abacus aa 1-3 1-2
+DATESTR replace b deb all abacus aa-addons 1-3 1-2
+DATESTR add b deb all abacus ab 2-1
+DATESTR add b deb all abacus ab-addons 2-1
+EOF
+testout - -b . dumppull b 3<<EOF
+stderr
+EOF
+cat > results.expected <<EOF
+Updates needed for 'b|all|abacus':
+keep 'aa' '1-3' '1-3'
+keep 'aa-addons' '1-3' '1-3'
+keep 'ab' '2-1' '2-1'
+keep 'ab-addons' '2-1' '2-1'
+EOF
+dodiff results results.expected
+dogrep "Version: 1-3" dists/b/all/binary-abacus/Packages
+dogrep "Version: 2-1" dists/b/all/binary-abacus/Packages
+test ! -f pool/all/a/aa/aa_1-2_abacus.deb
+test -f pool/all/a/aa/aa_1-3_abacus.deb
+DISTRI=a PACKAGE=ab EPOCH="" VERSION=3 REVISION="-1" SECTION="stupid/base" genpackage.sh
+grep -v '\.tar\.gz' test.changes > broken.changes
+testrun - -b . --delete --delete include a broken.changes 3<<EOF
+*=I don't know what to do having a .dsc without a .diff.gz or .tar.gz in 'broken.changes'!
+-v0*=There have been errors!
+returns 255
+EOF
+checknolog logab
+echo " $EMPTYMD5 stupid/base superfluous ab_3-1.diff.gz" >> broken.changes
+testrun - -b . --delete --delete include a broken.changes 3<<EOF
+*=Cannot find file './ab_3-1.diff.gz' needed by 'broken.changes'!
+-v0*=There have been errors!
+returns 249
+EOF
+checknolog logab
+test -f broken.changes
+test ! -f ab_3-1.diff.gz
+test -f ab-addons_3-1_all.deb
+test -f ab_3-1_abacus.deb
+test -f ab_3-1.dsc
+test ! -f pool/all/a/ab/ab_3-1.diff.gz
+test ! -f pool/all/a/ab/ab-addons_3-1_all.deb
+test ! -f pool/all/a/ab/ab_3-1_abacus.deb
+test ! -f pool/all/a/ab/ab_3-1.dsc
+touch ab_3-1.diff.gz
+testrun - -b . --delete -T deb include a broken.changes 3<<EOF
+stdout
+$(ofa 'pool/all/a/ab/ab-addons_3-1_all.deb')
+$(ofa 'pool/all/a/ab/ab_3-1_abacus.deb')
+$(opu 'ab-addons' x x 'a' 'all' 'abacus' 'deb')
+$(opu 'ab' x x 'a' 'all' 'abacus' 'deb')
+$(otta 'a' 'ab')
+-v0*=Exporting indices...
+-v2*=Created directory "./dists/a"
+-v2*=Created directory "./dists/a/all"
+-v2*=Created directory "./dists/a/all/binary-abacus"
+-v6*= looking for changes in 'a|all|abacus'...
+-v6*= creating './dists/a/all/binary-abacus/Packages' (uncompressed,gzipped)
+-v2*=Created directory "./dists/a/all/source"
+-v6*= looking for changes in 'a|all|source'...
+-v6*= creating './dists/a/all/source/Sources' (gzipped)
+EOF
+checklog logab <<EOF
+DATESTR replace a deb all abacus ab-addons 3-1 2-1
+DATESTR replace a deb all abacus ab 3-1 2-1
+EOF
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+test -f broken.changes
+test -f ab_3-1.diff.gz
+test ! -f ab-addons_3-1_all.deb
+test ! -f ab_3-1_abacus.deb
+test -f ab_3-1.dsc
+test ! -f pool/all/a/ab/ab_3-1.diff.gz
+test -f pool/all/a/ab/ab-addons_3-1_all.deb
+test -f pool/all/a/ab/ab_3-1_abacus.deb
+test ! -f pool/all/a/ab/ab_3-1.dsc
+testout "" -b . dumptracks a
+cat >results.expected <<END
+Distribution: a
+Source: aa
+Version: 1-3
+Files:
+ pool/all/a/aa/aa_1-3.dsc s 1
+ pool/all/a/aa/aa_1-3.tar.gz s 1
+ pool/all/a/aa/aa_1-3_abacus.deb b 1
+ pool/all/a/aa/aa-addons_1-3_all.deb a 1
+
+Distribution: a
+Source: ab
+Version: 2-1
+Files:
+ pool/all/a/ab/ab_2-1.dsc s 1
+ pool/all/a/ab/ab_2-1.tar.gz s 1
+
+Distribution: a
+Source: ab
+Version: 3-1
+Files:
+ pool/all/a/ab/ab_3-1_abacus.deb b 1
+ pool/all/a/ab/ab-addons_3-1_all.deb a 1
+
+END
+if $tracking; then dodiff results.expected results ; else dodiff /dev/null results ; fi
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+testrun - -b . --delete --delete include a broken.changes 3<<EOF
+*=Unable to find pool/all/a/ab/ab_3-1.tar.gz needed by ab_3-1.dsc!
+*=Perhaps you forgot to give dpkg-buildpackage the -sa option,
+= or you could try --ignore=missingfile to guess possible files to use.
+-v0*=There have been errors!
+stdout
+$(ofa 'pool/all/a/ab/ab_3-1.dsc')
+$(ofa 'pool/all/a/ab/ab_3-1.diff.gz')
+-v0*=Deleting files just added to the pool but not used.
+-v0*=(to avoid use --keepunusednewfiles next time)
+$(ofd 'pool/all/a/ab/ab_3-1.diff.gz')
+$(ofd 'pool/all/a/ab/ab_3-1.dsc')
+returns 249
+EOF
+test -f broken.changes
+test -f ab_3-1.diff.gz
+test ! -f ab-addons_3-1_all.deb
+test ! -f ab_3-1_abacus.deb
+test -f ab_3-1.dsc
+test ! -f pool/all/a/ab/ab_3-1.diff.gz
+test -f pool/all/a/ab/ab-addons_3-1_all.deb
+test -f pool/all/a/ab/ab_3-1_abacus.deb
+test ! -f pool/all/a/ab/ab_3-1.dsc
+cat broken.changes
+testrun - -b . -T dsc --delete --delete --ignore=missingfile include a broken.changes 3<<EOF
+*=Unable to find pool/all/a/ab/ab_3-1.tar.gz!
+*=Perhaps you forgot to give dpkg-buildpackage the -sa option.
+*=--ignore=missingfile was given, searching for file...
+stdout
+$(ofa 'pool/all/a/ab/ab_3-1.tar.gz')
+$(ofa 'pool/all/a/ab/ab_3-1.diff.gz')
+$(ofa 'pool/all/a/ab/ab_3-1.dsc')
+$(opu 'ab' x x 'a' 'all' 'source' 'dsc')
+$(ottd 'ab' '2-1' 'a')
+-v0*=Deleting files just added to the pool but not used.
+-v0*=(to avoid use --keepunusednewfiles next time)
+$(ofd 'pool/all/a/ab/ab_3-1.diff.gz')
+-v5*=Deleting 'broken.changes'.
+-v0*=Exporting indices...
+-v6*= looking for changes in 'a|all|abacus'...
+-v6*= looking for changes in 'a|all|source'...
+-v6*= replacing './dists/a/all/source/Sources' (gzipped)
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/all/a/ab/ab_2-1.dsc')
+$(ofd 'pool/all/a/ab/ab_2-1.tar.gz')
+EOF
+checklog logab <<EOF
+DATESTR replace a dsc all source ab 3-1 2-1
+EOF
+test ! -f broken.changes
+test ! -f ab_3-1.diff.gz
+test ! -f ab-addons_3-1_all.deb
+test ! -f ab_3-1_abacus.deb
+test ! -f ab_3-1.dsc
+test ! -f pool/all/a/ab/ab_3-1.diff.gz
+test -f pool/all/a/ab/ab-addons_3-1_all.deb
+test -f pool/all/a/ab/ab_3-1_abacus.deb
+test -f pool/all/a/ab/ab_3-1.dsc
+testout "" -b . dumpunreferenced
+cat > results.expected << EOF
+pool/all/a/ab/ab_3-1.diff.gz
+EOF
+dodiff /dev/null results || dodiff results.expected results
+testrun - -b . deleteunreferenced 3<<EOF
+stdout
+$(ofd 'pool/all/a/ab/ab_3-1.diff.gz' true '')
+EOF
+
+DISTRI=b PACKAGE=ac EPOCH="" VERSION=1 REVISION="-1" SECTION="stupid/base" genpackage.sh
+testrun - -b . -A abacus --delete --delete --ignore=missingfile include b test.changes 3<<EOF
+stderr
+-v2*=Skipping 'ac_1-1.dsc' as architecture 'source' is not in the requested set.
+-v2*=Skipping 'ac_1-1.tar.gz' as architecture 'source' is not in the requested set.
+-v3*=Limiting 'ac-addons_1-1_all.deb' to architectures abacus as requested.
+stdout
+-v2*=Created directory "./pool/all/a/ac"
+$(ofa 'pool/all/a/ac/ac-addons_1-1_all.deb')
+$(ofa 'pool/all/a/ac/ac_1-1_abacus.deb')
+$(opa 'ac-addons' x 'b' 'all' 'abacus' 'deb')
+$(opa 'ac' x 'b' 'all' 'abacus' 'deb')
+-v5*=Deleting 'test.changes'.
+-v0*=Exporting indices...
+-v6*= looking for changes in 'b|all|abacus'...
+-v6*= replacing './dists/b/all/binary-abacus/Packages' (uncompressed,gzipped)
+EOF
+checklog logab <<EOF
+DATESTR add b deb all abacus ac-addons 1-1
+DATESTR add b deb all abacus ac 1-1
+EOF
+dogrep '^Package: aa$' dists/b/all/binary-abacus/Packages
+dogrep '^Package: aa-addons$' dists/b/all/binary-abacus/Packages
+dogrep '^Package: ab$' dists/b/all/binary-abacus/Packages
+dogrep '^Package: ab-addons$' dists/b/all/binary-abacus/Packages
+dogrep '^Package: ac$' dists/b/all/binary-abacus/Packages
+dogrep '^Package: ac-addons$' dists/b/all/binary-abacus/Packages
+echo "Update: - froma" >> conf/distributions
+cat >conf/updates <<END
+Name: froma
+Method: copy:$WORKDIR
+VerifyRelease: blindtrust
+Suite: a
+GetInRelease: no
+ListHook: /bin/cp
+END
+testout - -b . dumpupdate b 3<<EOF
+-v6*=aptmethod start 'copy:$WORKDIR/dists/a/Release'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/a/Release'
+-v6*=aptmethod start 'copy:$WORKDIR/dists/a/all/binary-abacus/Packages.gz'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/a/all/binary-abacus/Packages.gz'
+-v2*=Uncompress './lists/froma_a_all_abacus_Packages.gz' into './lists/froma_a_all_abacus_Packages' using '/bin/gunzip'...
+-v6*=Called /bin/cp './lists/froma_a_all_abacus_Packages' './lists/_b_all_abacus_froma_froma_a_all_abacus_Packages'
+-v6*=Listhook successfully returned!
+EOF
+cat > results.expected <<EOF
+Updates needed for 'b|all|abacus':
+keep 'aa' '1-3' '1-3'
+keep 'aa-addons' '1-3' '1-3'
+update 'ab' '2-1' '3-1' 'froma'
+update 'ab-addons' '2-1' '3-1' 'froma'
+delete 'ac' '1-1'
+delete 'ac-addons' '1-1'
+EOF
+dodiff results.expected results
+testrun - -b . predelete b 3<<EOF
+=WARNING: Single-Instance not yet supported!
+-v6*=aptmethod start 'copy:$WORKDIR/dists/a/Release'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/a/Release'
+-v6*=Called /bin/cp './lists/froma_a_all_abacus_Packages' './lists/_b_all_abacus_froma_froma_a_all_abacus_Packages'
+-v6*=Listhook successfully returned!
+stdout
+-v0*=Removing obsolete or to be replaced packages...
+-v3*= processing updates for 'b|all|abacus'
+-v5*= marking everything to be deleted
+-v5*= reading './lists/_b_all_abacus_froma_froma_a_all_abacus_Packages'
+$(opd 'ab' x b all abacus deb)
+$(opd 'ab-addons' x b all abacus deb)
+$(opd 'ac' x b all abacus deb)
+$(opd 'ac-addons' x b all abacus deb)
+-v0*=Exporting indices...
+-v6*= looking for changes in 'b|all|abacus'...
+-v6*= replacing './dists/b/all/binary-abacus/Packages' (uncompressed,gzipped)
+-v1*=Shutting down aptmethods...
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/all/a/ab/ab_2-1_abacus.deb')
+$(ofd 'pool/all/a/ab/ab-addons_2-1_all.deb')
+$(ofd 'pool/all/a/ac/ac_1-1_abacus.deb')
+$(ofd 'pool/all/a/ac/ac-addons_1-1_all.deb')
+-v2*=removed now empty directory ./pool/all/a/ac
+EOF
+testout - -b . dumpupdate b 3<<EOF
+-v6*=aptmethod start 'copy:$WORKDIR/dists/a/Release'
+-v1*=aptmethod got 'copy:$WORKDIR/dists/a/Release'
+-v6*=Called /bin/cp './lists/froma_a_all_abacus_Packages' './lists/_b_all_abacus_froma_froma_a_all_abacus_Packages'
+-v6*=Listhook successfully returned!
+EOF
+cat > results.expected <<EOF
+Updates needed for 'b|all|abacus':
+keep 'aa' '1-3' '1-3'
+keep 'aa-addons' '1-3' '1-3'
+add 'ab' - '3-1' 'froma'
+add 'ab-addons' - '3-1' 'froma'
+EOF
+dodiff results.expected results
+checklog logab <<EOF
+DATESTR remove b deb all abacus ab 2-1
+DATESTR remove b deb all abacus ab-addons 2-1
+DATESTR remove b deb all abacus ac 1-1
+DATESTR remove b deb all abacus ac-addons 1-1
+EOF
+dogrep '^Package: aa$' dists/b/all/binary-abacus/Packages
+dogrep '^Package: aa-addons$' dists/b/all/binary-abacus/Packages
+dongrep '^Package: ab$' dists/b/all/binary-abacus/Packages
+dongrep '^Package: ab-addons$' dists/b/all/binary-abacus/Packages
+dongrep '^Package: ac$' dists/b/all/binary-abacus/Packages
+dongrep '^Package: ac-addons$' dists/b/all/binary-abacus/Packages
+test ! -f pool/all/a/ac/ac-addons_1-1_all.deb
+test ! -f pool/all/a/ab/ab_2-1_abacus.deb
+test -f pool/all/a/aa/aa_1-3_abacus.deb
+testrun - -b . copy b a ab ac 3<<EOF
+stderr
+-v0*=Will not copy as not found: ac.
+stdout
+-v9*=Adding reference to 'pool/all/a/ab/ab_3-1_abacus.deb' by 'b|all|abacus'
+-v1*=Adding 'ab' '3-1' to 'b|all|abacus'.
+-v3*=Not looking into 'a|all|source' as no matching target in 'b'!
+$(opa 'ab' x 'b' 'all' 'abacus' 'deb')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'b|all|abacus'...
+-v6*= replacing './dists/b/all/binary-abacus/Packages' (uncompressed,gzipped)
+EOF
+# readd?
+#-v3*=No instance of 'ab' found in 'a|all|source'!
+#-v3*=No instance of 'ac' found in 'a|all|abacus'!
+#-v3*=No instance of 'ac' found in 'a|all|source'!
+checklog logab <<EOF
+DATESTR add b deb all abacus ab 3-1
+EOF
+if $tracking ; then
+testout "" -b . dumptracks
+cat > results.expected <<EOF
+Distribution: a
+Source: aa
+Version: 1-3
+Files:
+ pool/all/a/aa/aa_1-3.dsc s 1
+ pool/all/a/aa/aa_1-3.tar.gz s 1
+ pool/all/a/aa/aa_1-3_abacus.deb b 1
+ pool/all/a/aa/aa-addons_1-3_all.deb a 1
+
+Distribution: a
+Source: ab
+Version: 3-1
+Files:
+ pool/all/a/ab/ab_3-1_abacus.deb b 1
+ pool/all/a/ab/ab-addons_3-1_all.deb a 1
+ pool/all/a/ab/ab_3-1.dsc s 1
+ pool/all/a/ab/ab_3-1.tar.gz s 1
+
+EOF
+dodiff results.expected results
+testout "" -b . dumpreferences
+sort results > results.sorted
+cat > results.expected <<EOF
+a aa 1-3 pool/all/a/aa/aa-addons_1-3_all.deb
+a aa 1-3 pool/all/a/aa/aa_1-3.dsc
+a aa 1-3 pool/all/a/aa/aa_1-3.tar.gz
+a aa 1-3 pool/all/a/aa/aa_1-3_abacus.deb
+a ab 3-1 pool/all/a/ab/ab-addons_3-1_all.deb
+a ab 3-1 pool/all/a/ab/ab_3-1.dsc
+a ab 3-1 pool/all/a/ab/ab_3-1.tar.gz
+a ab 3-1 pool/all/a/ab/ab_3-1_abacus.deb
+a|all|abacus pool/all/a/aa/aa-addons_1-3_all.deb
+a|all|abacus pool/all/a/aa/aa_1-3_abacus.deb
+a|all|abacus pool/all/a/ab/ab-addons_3-1_all.deb
+a|all|abacus pool/all/a/ab/ab_3-1_abacus.deb
+a|all|source pool/all/a/aa/aa_1-3.dsc
+a|all|source pool/all/a/aa/aa_1-3.tar.gz
+a|all|source pool/all/a/ab/ab_3-1.dsc
+a|all|source pool/all/a/ab/ab_3-1.tar.gz
+b|all|abacus pool/all/a/aa/aa-addons_1-3_all.deb
+b|all|abacus pool/all/a/aa/aa_1-3_abacus.deb
+b|all|abacus pool/all/a/ab/ab_3-1_abacus.deb
+EOF
+dodiff results.expected results.sorted
+fi
+rm -r -f db2
+cp -a db db2
+echo tracking is $tracking
+testrun - --keepunreferenced --dbdir ./db2 -b . removesrc a unknown 3<<EOF
+stderr
+-u1*=Nothing about source package 'unknown' found in the tracking data of 'a'!
+-u1*=This either means nothing from this source in this version is there,
+-u1*=or the tracking information might be out of date.
+stdout
+EOF
+testrun - --keepunreferenced --dbdir ./db2 -b . removesrc a ab 3-1 3<<EOF
+stdout
+$(opd 'ab-addons' x a all abacus deb)
+$(opd 'ab' x a all abacus deb)
+$(opd 'ab' x a all source dsc)
+$(ottd 'ab' '3-1' 'a')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'a|all|abacus'...
+-v6*= replacing './dists/a/all/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'a|all|source'...
+-v6*= replacing './dists/a/all/source/Sources' (gzipped)
+-v1*=3 files lost their last reference.
+-v1*=(dumpunreferenced lists such files, use deleteunreferenced to delete them.)
+EOF
+if $tracking ; then
+checklog logab <<EOF
+DATESTR remove a deb all abacus ab-addons 3-1
+DATESTR remove a deb all abacus ab 3-1
+DATESTR remove a dsc all source ab 3-1
+EOF
+else
+checklog logab <<EOF
+DATESTR remove a deb all abacus ab 3-1
+DATESTR remove a deb all abacus ab-addons 3-1
+DATESTR remove a dsc all source ab 3-1
+EOF
+fi
+rm -r db2
+cp -a db db2
+testrun - --keepunreferenced --dbdir ./db2 -b . removesrc a ab 3<<EOF
+stdout
+$(opd 'ab-addons' unset a all abacus deb)
+$(opd 'ab' unset a all abacus deb)
+$(opd 'ab' unset a all source deb)
+$(ottd 'ab' '3-1' 'a')
+-v0*=Exporting indices...
+-v6*= looking for changes in 'a|all|abacus'...
+-v6*= replacing './dists/a/all/binary-abacus/Packages' (uncompressed,gzipped)
+-v6*= looking for changes in 'a|all|source'...
+-v6*= replacing './dists/a/all/source/Sources' (gzipped)
+-v1*=3 files lost their last reference.
+-v1*=(dumpunreferenced lists such files, use deleteunreferenced to delete them.)
+EOF
+if $tracking ; then
+checklog logab <<EOF
+DATESTR remove a deb all abacus ab-addons 3-1
+DATESTR remove a deb all abacus ab 3-1
+DATESTR remove a dsc all source ab 3-1
+EOF
+else
+checklog logab <<EOF
+DATESTR remove a deb all abacus ab 3-1
+DATESTR remove a deb all abacus ab-addons 3-1
+DATESTR remove a dsc all source ab 3-1
+EOF
+fi
+testout "" --keepunreferenced --dbdir ./db2 dumppull
+cat > results.expected <<EOF
+Updates needed for 'b|all|abacus':
+keep 'aa' '1-3' '1-3'
+keep 'aa-addons' '1-3' '1-3'
+keep 'ab' '3-1' unavailable
+EOF
+dodiff results.expected results
+testrun - --keepunreferenced --dbdir ./db2 -b . removefilter b "Version (== 1-3), Package (>> aa)" 3<<EOF
+stdout
+$(opd 'aa-addons' unset b all abacus deb)
+-v0*=Exporting indices...
+-v6*= looking for changes in 'b|all|abacus'...
+-v6*= replacing './dists/b/all/binary-abacus/Packages' (uncompressed,gzipped)
+EOF
+checklog logab <<EOF
+DATESTR remove b deb all abacus aa-addons 1-3
+EOF
+testout "" --keepunreferenced --dbdir ./db2 dumppull
+cat > results.expected <<EOF
+Updates needed for 'b|all|abacus':
+keep 'aa' '1-3' '1-3'
+add 'aa-addons' - '1-3' 'froma'
+keep 'ab' '3-1' unavailable
+EOF
+dodiff results.expected results
+if $tracking ; then
+testrun - -b . --delete removealltracks a 3<<EOF
+stdout
+-v0*=Deleting all tracks for a...
+EOF
+testout "" -b . dumptracks
+dodiff /dev/null results
+fi
+testout "" -b . dumpreferences
+sort results > results.sorted
+cat > results.expected <<EOF
+a|all|abacus pool/all/a/aa/aa-addons_1-3_all.deb
+a|all|abacus pool/all/a/aa/aa_1-3_abacus.deb
+a|all|abacus pool/all/a/ab/ab-addons_3-1_all.deb
+a|all|abacus pool/all/a/ab/ab_3-1_abacus.deb
+a|all|source pool/all/a/aa/aa_1-3.dsc
+a|all|source pool/all/a/aa/aa_1-3.tar.gz
+a|all|source pool/all/a/ab/ab_3-1.dsc
+a|all|source pool/all/a/ab/ab_3-1.tar.gz
+b|all|abacus pool/all/a/aa/aa-addons_1-3_all.deb
+b|all|abacus pool/all/a/aa/aa_1-3_abacus.deb
+b|all|abacus pool/all/a/ab/ab_3-1_abacus.deb
+EOF
+dodiff results.expected results.sorted
+cat > conf/distributions <<EOF
+Codename: X
+Architectures: none
+Components: test
+EOF
+checknolog logab
+if $tracking ; then
+testrun - -b . --delete clearvanished 3<<EOF
+-v4*=Strange, 'X|test|none' does not appear in packages.db yet.
+stdout
+*=Deleting vanished identifier 'a|all|abacus'.
+*=Deleting vanished identifier 'a|all|source'.
+*=Deleting vanished identifier 'b|all|abacus'.
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/all/a/aa/aa-addons_1-3_all.deb')
+$(ofd 'pool/all/a/aa/aa_1-3.dsc')
+$(ofd 'pool/all/a/aa/aa_1-3.tar.gz')
+$(ofd 'pool/all/a/aa/aa_1-3_abacus.deb')
+-v2*=removed now empty directory ./pool/all/a/aa
+$(ofd 'pool/all/a/ab/ab-addons_3-1_all.deb')
+$(ofd 'pool/all/a/ab/ab_3-1.dsc')
+$(ofd 'pool/all/a/ab/ab_3-1.tar.gz')
+$(ofd 'pool/all/a/ab/ab_3-1_abacus.deb')
+-v2*=removed now empty directory ./pool/all/a/ab
+-v2*=removed now empty directory ./pool/all/a
+-v2*=removed now empty directory ./pool/all
+-v2*=removed now empty directory ./pool
+EOF
+else
+testrun - -b . --delete clearvanished 3<<EOF
+# -v4*=Strange, 'X|test|none' does not appear in packages.db yet.
+stdout
+*=Deleting vanished identifier 'a|all|abacus'.
+*=Deleting vanished identifier 'a|all|source'.
+*=Deleting vanished identifier 'b|all|abacus'.
+-v0*=Deleting files no longer referenced...
+$(ofd 'pool/all/a/aa/aa-addons_1-3_all.deb')
+$(ofd 'pool/all/a/aa/aa_1-3.dsc')
+$(ofd 'pool/all/a/aa/aa_1-3.tar.gz')
+$(ofd 'pool/all/a/aa/aa_1-3_abacus.deb')
+-v2*=removed now empty directory ./pool/all/a/aa
+$(ofd 'pool/all/a/ab/ab-addons_3-1_all.deb')
+$(ofd 'pool/all/a/ab/ab_3-1.dsc')
+$(ofd 'pool/all/a/ab/ab_3-1.tar.gz')
+$(ofd 'pool/all/a/ab/ab_3-1_abacus.deb')
+-v2*=removed now empty directory ./pool/all/a/ab
+-v2*=removed now empty directory ./pool/all/a
+-v2*=removed now empty directory ./pool/all
+-v2*=removed now empty directory ./pool
+EOF
+fi
+checknolog logab
+testout "" -b . dumptracks
+dodiff /dev/null results
+testout "" -b . dumpunreferenced
+dodiff /dev/null results
+rm -r dists
+done
+rm -r db db2 conf lists logs
+rm aa* ab* ac* results.log.expected results.expected results results.sorted
+testsuccess
diff --git a/tests/verify.test b/tests/verify.test
new file mode 100644
index 0000000..949e25d
--- /dev/null
+++ b/tests/verify.test
@@ -0,0 +1,437 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+mkdir gpgtestdir
+chmod go-rwx gpgtestdir
+export GNUPGHOME="`pwd`/gpgtestdir"
+gpg --import $TESTSDIR/good.key $TESTSDIR/evil.key $TESTSDIR/expired.key $TESTSDIR/revoked.key $TESTSDIR/expiredwithsubkey-working.key $TESTSDIR/withsubkeys-works.key
+
+CURDATE="$(date +"%Y-%m-%d")"
+
+mkdir conf lists
+cat > conf/distributions <<CONFEND
+Codename: Test
+Architectures: source
+Components: everything
+Update: rule otherrule
+CONFEND
+cat > conf/updates <<CONFEND
+Name: commonbase
+Method: file:$WORKDIR/test
+VerifyRelease: 111
+Suite: test
+
+Name: rule
+From: commonbase
+
+Name: otherrule
+From: commonbase
+CONFEND
+
+testrun - -b . update Test 3<<EOF
+return 255
+stdout
+$(odb)
+stderr
+*=Error: Too short key id '111' in VerifyRelease condition '111'!
+-v0*=There have been errors!
+EOF
+
+cat > conf/updates <<CONFEND
+Name: commonbase
+Method: file:$WORKDIR/test
+VerifyRelease: 11111111 22222222
+Suite: test
+
+Name: rule
+From: commonbase
+
+Name: otherrule
+From: commonbase
+CONFEND
+
+testrun - -b . update Test 3<<EOF
+return 255
+stdout
+stderr
+*=Error: Space separated key-ids in VerifyRelease condition '11111111 22222222'!
+*=(Alternate keys can be separated with '|'. Do not put spaces in key-ids.)
+-v0*=There have been errors!
+EOF
+
+cat > conf/updates <<CONFEND
+Name: commonbase
+Method: file:$WORKDIR/test
+VerifyRelease: 11111111
+Suite: test
+
+Name: rule
+From: commonbase
+
+Name: otherrule
+From: commonbase
+CONFEND
+
+testrun - -b . update Test 3<<EOF
+return 249
+stdout
+stderr
+*=Error: unknown key '11111111'!
+-v0*=There have been errors!
+EOF
+
+cat > conf/updates <<CONFEND
+Name: commonbase
+Method: file:$WORKDIR/test
+VerifyRelease: 11111111
+
+Name: rule
+From: commonbase
+VerifyRelease: DC3C29B8|685AF714
+Suite: test
+
+Name: otherrule
+From: commonbase
+VerifyRelease: 685AF714|D04DD3D6
+Suite: test
+CONFEND
+
+mkdir test
+mkdir test/dists
+mkdir test/dists/test
+cat > test/dists/test/Release <<EOF
+Codename: test
+Components: everything
+Architectures: coal
+EOF
+
+gpg --list-secret-keys
+gpg --expert --sign --clearsign -u 60DDED5B -u D7A5D887 -u revoked@nowhere.tld --output test/dists/test/InRelease test/dists/test/Release
+gpg --expert --sign --clearsign -u 60DDED5B -u D7A5D887 -u good@nowhere.tld --output test/dists/test/InRelease.good test/dists/test/Release
+gpg --expert -a --sign --clearsign -u evil@nowhere.tld --output test/dists/test/InRelease.evil test/dists/test/Release
+
+rm -r gpgtestdir
+mkdir gpgtestdir
+chmod go-rwx gpgtestdir
+gpg --import $TESTSDIR/good.key $TESTSDIR/evil.key $TESTSDIR/expired.key $TESTSDIR/revoked.key $TESTSDIR/revoked.pkey $TESTSDIR/expiredwithsubkey.key $TESTSDIR/withsubkeys.key
+gpg --list-keys
+
+testrun - -b . update Test 3<<EOF
+return 255
+stderr
+*=VerifyRelease condition 'DC3C29B8|685AF714' lists revoked key '72F1D61F685AF714'.
+*=(To use it anyway, append it with a '!' to force usage).
+-v0*=There have been errors!
+stdout
+EOF
+
+sed -e 's/685AF714/&!/' -i conf/updates
+
+testrun - -b . update Test 3<<EOF
+return 255
+stderr
+*=VerifyRelease condition '685AF714!|D04DD3D6' lists expired key '894FA29DD04DD3D6'.
+*=(To use it anyway, append it with a '!' to force usage).
+-v0*=There have been errors!
+stdout
+EOF
+
+sed -e 's/D04DD3D6/&!/' -i conf/updates
+
+testrun - -b . update Test 3<<EOF
+return 250
+stderr
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/test/InRelease'
+-v2*=Copy file '${WORKDIR}/test/dists/test/InRelease' to './lists/commonbase_test_InRelease'...
+*=Not accepting valid signature in './lists/commonbase_test_InRelease' with REVOKED '12D6C95C8C737389EAAF535972F1D61F685AF714'
+*=(To ignore it append a ! to the key and run reprepro with --ignore=revokedkey)
+*=ERROR: Condition '685AF714!|D04DD3D6!' not fulfilled for './lists/commonbase_test_InRelease'.
+*=Signatures in './lists/commonbase_test_InRelease':
+*='DCAD3A286F5178E2F4B09330A573FEB160DDED5B' (signed ${CURDATE}): expired key
+*='236B4B98B5087AF4B621CB14D8A28B7FD7A5D887' (signed ${CURDATE}): valid
+*='12D6C95C8C737389EAAF535972F1D61F685AF714' (signed ${CURDATE}): key revoced
+*=Error: Not enough signatures found for remote repository commonbase (file:${WORKDIR}/test test)!
+-v0*=There have been errors!
+stdout
+EOF
+
+testrun - --ignore=revokedkey -b . update Test 3<<EOF
+return 255
+stderr
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/test/InRelease'
+-v2*=Copy file '${WORKDIR}/test/dists/test/InRelease' to './lists/commonbase_test_InRelease'...
+*=WARNING: valid signature in './lists/commonbase_test_InRelease' with revoked '12D6C95C8C737389EAAF535972F1D61F685AF714' is accepted as requested!
+*=Missing checksums in Release file './lists/commonbase_test_InRelease'!
+-v0*=There have been errors!
+stdout
+EOF
+
+cp test/dists/test/InRelease.good test/dists/test/InRelease
+
+testrun - -b . update Test 3<<EOF
+return 250
+stderr
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/test/InRelease'
+-v2*=Copy file '${WORKDIR}/test/dists/test/InRelease' to './lists/commonbase_test_InRelease'...
+*=ERROR: Condition '685AF714!|D04DD3D6!' not fulfilled for './lists/commonbase_test_InRelease'.
+*=Signatures in './lists/commonbase_test_InRelease':
+*='DCAD3A286F5178E2F4B09330A573FEB160DDED5B' (signed ${CURDATE}): expired key
+*='236B4B98B5087AF4B621CB14D8A28B7FD7A5D887' (signed ${CURDATE}): valid
+*='12E94E82B6D7A883AF6EC8E980F4C43EDC3C29B8' (signed ${CURDATE}): valid
+*=Error: Not enough signatures found for remote repository commonbase (file:${WORKDIR}/test test)!
+-v0*=There have been errors!
+stdout
+EOF
+
+# different order
+cat > conf/updates <<CONFEND
+Name: commonbase
+Method: file:$WORKDIR/test
+VerifyRelease: 11111111
+
+Name: rule
+From: commonbase
+VerifyRelease: 685AF714!|D04DD3D6!
+Suite: test
+
+Name: otherrule
+From: commonbase
+VerifyRelease: DC3C29B8|685AF714!
+Suite: test
+CONFEND
+
+testrun - -b . update Test 3<<EOF
+return 250
+stderr
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/test/InRelease'
+-v2*=Copy file '${WORKDIR}/test/dists/test/InRelease' to './lists/commonbase_test_InRelease'...
+*=ERROR: Condition '685AF714!|D04DD3D6!' not fulfilled for './lists/commonbase_test_InRelease'.
+*=Signatures in './lists/commonbase_test_InRelease':
+*='DCAD3A286F5178E2F4B09330A573FEB160DDED5B' (signed ${CURDATE}): expired key
+*='236B4B98B5087AF4B621CB14D8A28B7FD7A5D887' (signed ${CURDATE}): valid
+*='12E94E82B6D7A883AF6EC8E980F4C43EDC3C29B8' (signed ${CURDATE}): valid
+*=Error: Not enough signatures found for remote repository commonbase (file:${WORKDIR}/test test)!
+-v0*=There have been errors!
+stdout
+EOF
+
+# now subkeys:
+cat > conf/updates <<CONFEND
+Name: commonbase
+Method: file:$WORKDIR/test
+VerifyRelease: F62C6D3B
+
+Name: rule
+From: commonbase
+VerifyRelease: D7A5D887
+Suite: test
+
+Name: otherrule
+From: commonbase
+Suite: test
+CONFEND
+
+testrun - -b . update Test 3<<EOF
+return 250
+stderr
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/test/InRelease'
+-v2*=Copy file '${WORKDIR}/test/dists/test/InRelease' to './lists/commonbase_test_InRelease'...
+*=ERROR: Condition 'F62C6D3B' not fulfilled for './lists/commonbase_test_InRelease'.
+*=Signatures in './lists/commonbase_test_InRelease':
+*='DCAD3A286F5178E2F4B09330A573FEB160DDED5B' (signed ${CURDATE}): expired key
+*='236B4B98B5087AF4B621CB14D8A28B7FD7A5D887' (signed ${CURDATE}): valid
+*='12E94E82B6D7A883AF6EC8E980F4C43EDC3C29B8' (signed ${CURDATE}): valid
+*=Error: Not enough signatures found for remote repository commonbase (file:${WORKDIR}/test test)!
+-v0*=There have been errors!
+stdout
+EOF
+
+sed -e 's/F62C6D3B/F62C6D3B+/' -i conf/updates
+
+testrun - -b . update Test 3<<EOF
+return 255
+stderr
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/test/InRelease'
+-v2*=Copy file '${WORKDIR}/test/dists/test/InRelease' to './lists/commonbase_test_InRelease'...
+*=Missing checksums in Release file './lists/commonbase_test_InRelease'!
+-v0*=There have been errors!
+stdout
+EOF
+
+# now subkey of an expired key
+cat > conf/updates <<CONFEND
+Name: commonbase
+Method: file:$WORKDIR/test
+VerifyRelease: 60DDED5B!
+
+Name: rule
+From: commonbase
+Suite: test
+
+Name: otherrule
+From: commonbase
+Suite: test
+CONFEND
+
+# gpgme no longer seems to distinguish expired and parent-expired:
+testrun - -b . update Test 3<<EOF
+return 250
+stderr
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/test/InRelease'
+-v2*=Copy file '${WORKDIR}/test/dists/test/InRelease' to './lists/commonbase_test_InRelease'...
+*=Not accepting valid signature in './lists/commonbase_test_InRelease' with EXPIRED 'DCAD3A286F5178E2F4B09330A573FEB160DDED5B'
+*=(To ignore it append a ! to the key and run reprepro with --ignore=expiredkey)
+*=ERROR: Condition '60DDED5B!' not fulfilled for './lists/commonbase_test_InRelease'.
+*=Signatures in './lists/commonbase_test_InRelease':
+*='DCAD3A286F5178E2F4B09330A573FEB160DDED5B' (signed ${CURDATE}): expired key
+*='236B4B98B5087AF4B621CB14D8A28B7FD7A5D887' (signed ${CURDATE}): valid
+*='12E94E82B6D7A883AF6EC8E980F4C43EDC3C29B8' (signed ${CURDATE}): valid
+*=Error: Not enough signatures found for remote repository commonbase (file:${WORKDIR}/test test)!
+-v0*=There have been errors!
+stdout
+EOF
+
+# now listing the expired key, of which we use an non-expired subkey
+cat > conf/updates <<CONFEND
+Name: commonbase
+Method: file:$WORKDIR/test
+VerifyRelease: A260449A!+
+
+Name: rule
+From: commonbase
+Suite: test
+
+Name: otherrule
+From: commonbase
+Suite: test
+CONFEND
+
+# gpgme no longer seems to distinguish expired and parent-expired:
+testrun - -b . update Test 3<<EOF
+return 250
+stderr
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/test/InRelease'
+-v2*=Copy file '${WORKDIR}/test/dists/test/InRelease' to './lists/commonbase_test_InRelease'...
+*=Not accepting valid signature in './lists/commonbase_test_InRelease' with EXPIRED 'DCAD3A286F5178E2F4B09330A573FEB160DDED5B'
+*=(To ignore it append a ! to the key and run reprepro with --ignore=expiredkey)
+*=ERROR: Condition 'A260449A!+' not fulfilled for './lists/commonbase_test_InRelease'.
+*=Signatures in './lists/commonbase_test_InRelease':
+*='DCAD3A286F5178E2F4B09330A573FEB160DDED5B' (signed ${CURDATE}): expired key
+*='236B4B98B5087AF4B621CB14D8A28B7FD7A5D887' (signed ${CURDATE}): valid
+*='12E94E82B6D7A883AF6EC8E980F4C43EDC3C29B8' (signed ${CURDATE}): valid
+*=Error: Not enough signatures found for remote repository commonbase (file:${WORKDIR}/test test)!
+-v0*=There have been errors!
+stdout
+EOF
+
+# Now testing what happens when only signed with a totally different key:
+cp test/dists/test/InRelease.evil test/dists/test/InRelease
+
+testrun - -b . update Test 3<<EOF
+return 250
+stderr
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/test/InRelease'
+-v2*=Copy file '${WORKDIR}/test/dists/test/InRelease' to './lists/commonbase_test_InRelease'...
+*=ERROR: Condition 'A260449A!+' not fulfilled for './lists/commonbase_test_InRelease'.
+*=Signatures in './lists/commonbase_test_InRelease':
+*='FDC7D039CCC83CC4921112A09FA943670C672A4A' (signed ${CURDATE}): valid
+*=Error: Not enough signatures found for remote repository commonbase (file:${WORKDIR}/test test)!
+-v0*=There have been errors!
+stdout
+EOF
+
+# Now testing an expired signature:
+cat > conf/updates <<CONFEND
+Name: commonbase
+Method: file:$WORKDIR/test
+VerifyRelease: F62C6D3B+
+
+Name: rule
+From: commonbase
+VerifyRelease: F62C6D3B
+Suite: test
+
+Name: otherrule
+From: commonbase
+Suite: test
+CONFEND
+
+# expired signatures are not that easy to fake, so cat it:
+cat > test/dists/test/InRelease <<'EOF'
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+Codename: test
+Components: everything
+Architectures: coal
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.12 (GNU/Linux)
+
+iKIEAQECAAwFAk+6EiEFgwABUYAACgkQFU9je/YsbTv4LgP8DkaRBhBG7+JDD1N1
+GANCsth4rzKDfpyMrttFjW6Ra9QegDdnHyLz09IL5Hyzmst4s8DQ69q2LyZaQt3+
+0C2OG9iQ2GjQt8xvppDufvymFpqTbqnGn/LeG6KjP542Su8XZxptFPT2DyPNCe0W
+Vz5f8yupwc67sAWj/qhmBEpZp9E=
+=025V
+-----END PGP SIGNATURE-----
+EOF
+
+testrun - -b . update Test 3<<EOF
+return 250
+stderr
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/test/InRelease'
+-v2*=Copy file '${WORKDIR}/test/dists/test/InRelease' to './lists/commonbase_test_InRelease'...
+*=Not accepting valid but EXPIRED signature in './lists/commonbase_test_InRelease' with '2938A0D8CD4E20437CAE9CE4154F637BF62C6D3B'
+*=(To ignore it append a ! to the key and run reprepro with --ignore=expiredsignature)
+*=ERROR: Condition 'F62C6D3B+' not fulfilled for './lists/commonbase_test_InRelease'.
+*=Signatures in './lists/commonbase_test_InRelease':
+*='2938A0D8CD4E20437CAE9CE4154F637BF62C6D3B' (signed 2012-05-21): expired signature (since 2012-05-22)
+*=Error: Not enough signatures found for remote repository commonbase (file:${WORKDIR}/test test)!
+-v0*=There have been errors!
+stdout
+EOF
+
+testrun - --ignore=expiredsignature -b . update Test 3<<EOF
+return 250
+stderr
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/test/InRelease'
+-v2*=Copy file '${WORKDIR}/test/dists/test/InRelease' to './lists/commonbase_test_InRelease'...
+*=Not accepting valid but EXPIRED signature in './lists/commonbase_test_InRelease' with '2938A0D8CD4E20437CAE9CE4154F637BF62C6D3B'
+*=(To ignore it append a ! to the key and run reprepro with --ignore=expiredsignature)
+*=ERROR: Condition 'F62C6D3B+' not fulfilled for './lists/commonbase_test_InRelease'.
+*=Signatures in './lists/commonbase_test_InRelease':
+*='2938A0D8CD4E20437CAE9CE4154F637BF62C6D3B' (signed 2012-05-21): expired signature (since 2012-05-22)
+*=Error: Not enough signatures found for remote repository commonbase (file:${WORKDIR}/test test)!
+-v0*=There have been errors!
+stdout
+EOF
+
+sed -e 's/F62C6D3B/&!/' -i conf/updates
+
+testrun - --ignore=expiredsignature -b . update Test 3<<EOF
+return 255
+stderr
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/test/InRelease'
+-v2*=Copy file '${WORKDIR}/test/dists/test/InRelease' to './lists/commonbase_test_InRelease'...
+*=WARNING: valid but expired signature in './lists/commonbase_test_InRelease' with '2938A0D8CD4E20437CAE9CE4154F637BF62C6D3B' is accepted as requested!
+*=Missing checksums in Release file './lists/commonbase_test_InRelease'!
+-v0*=There have been errors!
+stdout
+EOF
+
+#empty file:
+cat > test/dists/test/InRelease <<EOF
+EOF
+
+testrun - -b . update Test 3<<EOF
+return 250
+stderr
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/test/InRelease'
+-v2*=Copy file '${WORKDIR}/test/dists/test/InRelease' to './lists/commonbase_test_InRelease'...
+*=Error: Not enough signatures found for remote repository commonbase (file:$WORKDIR/test test)!
+-v0*=There have been errors!
+stdout
+EOF
+
+rm -rf db conf gpgtestdir gpgtestdir lists test
+
+testsuccess
diff --git a/tests/withsubkeys-works.key b/tests/withsubkeys-works.key
new file mode 100644
index 0000000..792e01f
--- /dev/null
+++ b/tests/withsubkeys-works.key
@@ -0,0 +1,52 @@
+-----BEGIN PGP PRIVATE KEY BLOCK-----
+Version: GnuPG v1.4.9 (GNU/Linux)
+
+lQHXBEnjCPkBBADbdIK4D+1lbjq1wzZSIfyHJFWKMpy26iwhS2KJqkBNcN1n3Ute
+ND9WHNuhj+n3k1saFjj7yi/18PwM7weqDPAnzp5dpSVl6OXZU0Oaf4hdk/K7hxkM
+AaW8sGxJc2OMssffU/ZIGde/62kgQSwhqK0S3BnDORdWE2eIShGkC7Ws4QARAQAB
+AAP4gjfE3ynpm1JfUzIg8RVR/9KDUOtJmHz541n8jBTzycLlznKNasZY5yGN3B9w
+tUZxo8weNLeTveID3mve+8uM/UDwcgOVJlMJXXCDCMGYontTR8yAdN2k9mh09Ejx
+ihL+KrFXY+L42YFa6CUQgzNrxvG5nG3T+NFjDKHew44LWQIA26zeTY9Qvu/+tbIa
+YaLYHbNHMCABAPV7zHdhAsgPKII6nO1Ic9e6OobNRRn89vFyWxopYFT3sjvV1ZEc
++gqKKwIA/75SuKR+INGfY/7OZBjI5tOtWW0jBSxKHHf9LbCm1uW9KNtv2yhZ88oJ
+MboLNXTNeIdAgjsxUEZnTtbumTbbIwH9FxIhrIj9q1Pb7FZ8ZP2xLSkpHsNlvHYI
++pEcGcNPfpl9D9KKK3tbyG633CAIrMtmTjioliQH0H1kyF2mxhsjOaWvtFJSZXBy
+ZXBybyBUZXN0c3VpdGUgS2V5IDYgKEZPUiBVU0UgV0lUSElOIFRFU1RTVUlURSBP
+TkxZKSA8d2l0aHN1YmtleXNAbm93aGVyZS50bGQ+iLYEEwECACAFAknjCPkCGwMG
+CwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRAVT2N79ixtO5xmA/0SkijX92Wupoyu
+zJbQfRBkPVG7TN8fkmQkKdUZCmu8CrVelZynDGmLhikdMncNv6wMaXP6+/0z3AX/
+KwuH8X66xH3nouodM/eueTMbJY3d+b3Re1vEg4xZU7h66/2zE9iXcPoHR2j2l63d
+jCZOR6Q27kBXXih1j2TAALDpFXW3sp0BuwRJ4wl1EQQAzBhaIj9XtwloZZeo5ZKE
+dahIHXOJTt8fXvtpUs+kBEje7aKFxYEZgDSkYBBjxRXII/p/Ab7dLRCMgPcRSGrg
+SXdlVSlMG8mQLm1tIelgkz/7GnMErbFeYClK7ohfWZBrW79Q5quCNlrV+qetJXJR
+D8lstf4e5r9gQDouCNSjx3MAoJh3s4vRjiXvo1lxp75zZdGtouB3BADLrg5965Vf
+GySW/MKGbIK1Rm9CextGUxd01GL1uoR4Hi9oHNW7+/QZ9ixOMKA5ggqomfp7pgEe
+s4wvhHsFIpDpNAWOKlkxlERY33x7R5XxKsgSJS/IfQct5AlbajVDFukFgKW8CWnM
+A9AD+slO9VoOKgHEDevt9Mfhur1dMoWVowP/U5f7N16vJLckL8uk2DiiHXXtNq0C
+ucLXhykPAzmw66e9y+0LHd9sj1WzB7WKYOFCR4SGuSRhfUn8HCzaOSRZYI4XVX7z
+0mq/ZvenSJm+7mBxOm5rkxCgpwEuFojz1589qFDugKhM+JfGW2H4fpevxyHmpfvK
+0oyqOc/6t39Oe/EAAKCQOt2SvprOCp9vDGQrL/O6Wg+mLwnMiOcEGAECAAkFAknj
+CXUCGwIAUgkQFU9je/YsbTtHIAQZEQIABgUCSeMJdQAKCRB0ti0y57+nom/bAJ9b
+NNsPYuDYI1twxdYLxenOoZtqWACeNAHK4UssY9o72IvPktAYzxXHcWx2lwP+MPdu
+UJBlGJGQJDqO//tdtsa8VNOg06SgGTBNDBlbGY3VVSRTxlOy4/Ubrgr9rLBA7TXo
+XvnE2wgPeNiXF17/K+E7uenSStZJCjkAYa9bBJywlxRHGatxIM08QZDuH35i+Bz9
+/FpFAfiuLKuK75ApnVNP7KSUhAtUXsIx5aP402CdAdgESeMJsQEEAOTIv3NxcTHc
+zP6iijUVIj99QHi1VPnATlBoZRpxf7mYMALiY1CKNFzx6EXiCi9XCHojspnfcSQq
+CgtB7EixxRQSCT8WR7w5Q79dtYDSlVLmqjlAll2ea8BxYAqScyDiLA5PAI7Y/ey/
+tAL0bM0qe57pZ64xHFWXIlP0faKUVPbbABEBAAEAA/0cYK4mop6YwbuHph+gf/OU
+jnOtxUg6BllwbdKEmilumurxoKUS+2GNWdAmwufigVgi1kS0A1wkUTaXuOCXD73T
+CHPcKMRp7YLZzg9jy/XlDgbPn4qRl1qa7RHPvAV5a4j4upcw+EzP2B+3z7e/zlQk
+FOuKdSYj/zgBidRwxRs9kQIA8HngrqvrRNC03IzQLZqYhRFV7AxlK2XlikFdEj0x
+XAy6ep4svwsBtHnUUfmXZL/cG4A6MNp1in4XK6WNuBmmyQIA842mH8nV/vmIwm+l
+fDTs1Y5BMoV2g9VhOixJ3WO2HQVGbYB42tBd3cw+tp5urSPESFN9rcq8U2+XE+wP
+ZRiugwIA0aBXyLN73fhkTUduTJhYOgtEl1yormrsEZHwYiNI7zLjc71p3aMZsXpA
+ZV3lcgPV83O7ESgC3z+Pbux6tA8+k6R7iQE9BBgBAgAJBQJJ4wmxAhsCAKgJEBVP
+Y3v2LG07nSAEGQECAAYFAknjCbEACgkQ2KKLf9el2Ie2bQP/T8ThPu2Seq5tR8aG
+xJJ1w0U6szTT2UIyXu8gBO3SM8wLVcBuIXdkxOshUP2Xua758tLmns5XaoDiK8am
+9E22zX1BXyjVmK/74of6yjsf+VxJJtTlgpxeFH+zI1zZxIA1TlRg2TvVIHC5oD1i
+5v1P2xugtzby4aGHTXdi8pUMKGLMegP/U61Kg6OcqEA2C6288UhsNWZzReY9mMOl
+C8z+TET6IfHnP5hd4+hZxKDWKgj0V95vbWzA/XkZIiK09wjjht6Oqw5tqq4R38D5
+kkFUr9yLlwTxMw+jipVTTFlbjjWhsnEoH16QZRQr0PT0FlSnn3CGy+sdSdq+vMpQ
+sIh1h85JVQI=
+=NWLh
+-----END PGP PRIVATE KEY BLOCK-----
diff --git a/tests/withsubkeys.key b/tests/withsubkeys.key
new file mode 100644
index 0000000..823680b
--- /dev/null
+++ b/tests/withsubkeys.key
@@ -0,0 +1,52 @@
+-----BEGIN PGP PRIVATE KEY BLOCK-----
+Version: GnuPG v1.4.9 (GNU/Linux)
+
+lQHXBEnjCPkBBADbdIK4D+1lbjq1wzZSIfyHJFWKMpy26iwhS2KJqkBNcN1n3Ute
+ND9WHNuhj+n3k1saFjj7yi/18PwM7weqDPAnzp5dpSVl6OXZU0Oaf4hdk/K7hxkM
+AaW8sGxJc2OMssffU/ZIGde/62kgQSwhqK0S3BnDORdWE2eIShGkC7Ws4QARAQAB
+AAP4gjfE3ynpm1JfUzIg8RVR/9KDUOtJmHz541n8jBTzycLlznKNasZY5yGN3B9w
+tUZxo8weNLeTveID3mve+8uM/UDwcgOVJlMJXXCDCMGYontTR8yAdN2k9mh09Ejx
+ihL+KrFXY+L42YFa6CUQgzNrxvG5nG3T+NFjDKHew44LWQIA26zeTY9Qvu/+tbIa
+YaLYHbNHMCABAPV7zHdhAsgPKII6nO1Ic9e6OobNRRn89vFyWxopYFT3sjvV1ZEc
++gqKKwIA/75SuKR+INGfY/7OZBjI5tOtWW0jBSxKHHf9LbCm1uW9KNtv2yhZ88oJ
+MboLNXTNeIdAgjsxUEZnTtbumTbbIwH9FxIhrIj9q1Pb7FZ8ZP2xLSkpHsNlvHYI
++pEcGcNPfpl9D9KKK3tbyG633CAIrMtmTjioliQH0H1kyF2mxhsjOaWvtFJSZXBy
+ZXBybyBUZXN0c3VpdGUgS2V5IDYgKEZPUiBVU0UgV0lUSElOIFRFU1RTVUlURSBP
+TkxZKSA8d2l0aHN1YmtleXNAbm93aGVyZS50bGQ+iLYEEwECACAFAknjCPkCGwMG
+CwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRAVT2N79ixtO5xmA/0SkijX92Wupoyu
+zJbQfRBkPVG7TN8fkmQkKdUZCmu8CrVelZynDGmLhikdMncNv6wMaXP6+/0z3AX/
+KwuH8X66xH3nouodM/eueTMbJY3d+b3Re1vEg4xZU7h66/2zE9iXcPoHR2j2l63d
+jCZOR6Q27kBXXih1j2TAALDpFXW3sp0BuwRJ4wl1EQQAzBhaIj9XtwloZZeo5ZKE
+dahIHXOJTt8fXvtpUs+kBEje7aKFxYEZgDSkYBBjxRXII/p/Ab7dLRCMgPcRSGrg
+SXdlVSlMG8mQLm1tIelgkz/7GnMErbFeYClK7ohfWZBrW79Q5quCNlrV+qetJXJR
+D8lstf4e5r9gQDouCNSjx3MAoJh3s4vRjiXvo1lxp75zZdGtouB3BADLrg5965Vf
+GySW/MKGbIK1Rm9CextGUxd01GL1uoR4Hi9oHNW7+/QZ9ixOMKA5ggqomfp7pgEe
+s4wvhHsFIpDpNAWOKlkxlERY33x7R5XxKsgSJS/IfQct5AlbajVDFukFgKW8CWnM
+A9AD+slO9VoOKgHEDevt9Mfhur1dMoWVowP/U5f7N16vJLckL8uk2DiiHXXtNq0C
+ucLXhykPAzmw66e9y+0LHd9sj1WzB7WKYOFCR4SGuSRhfUn8HCzaOSRZYI4XVX7z
+0mq/ZvenSJm+7mBxOm5rkxCgpwEuFojz1589qFDugKhM+JfGW2H4fpevxyHmpfvK
+0oyqOc/6t39Oe/EAAKCQOt2SvprOCp9vDGQrL/O6Wg+mLwnMiO0EGAECAA8CGwIF
+AknjCfcFCQABUgAAUkcgBBkRAgAGBQJJ4wl1AAoJEHS2LTLnv6eib9sAn1miRieV
++l3MMRA0mHQlPF89CIRrAJ94g4sj4qIJQQMQ2zJwFLYmtluSuwkQFU9je/YsbTtF
+sgQAtaP0bMzn7wmyGAWif9LUxdV2RjfEvrA3jj4V+GeoMT0V4no0eoDKuj2o2tBZ
+bWWrCXdseJ8UWoftmCErCetWy4zrsr26hwtcMB5NQIXsYzlagejMIv/89AkdnbAN
+3B70PEeIpuTZSYRP4598dSrGDQqoSpKWVCemMXEoYl0pMMWdAdgESeMJsQEEAOTI
+v3NxcTHczP6iijUVIj99QHi1VPnATlBoZRpxf7mYMALiY1CKNFzx6EXiCi9XCHoj
+spnfcSQqCgtB7EixxRQSCT8WR7w5Q79dtYDSlVLmqjlAll2ea8BxYAqScyDiLA5P
+AI7Y/ey/tAL0bM0qe57pZ64xHFWXIlP0faKUVPbbABEBAAEAA/0cYK4mop6YwbuH
+ph+gf/OUjnOtxUg6BllwbdKEmilumurxoKUS+2GNWdAmwufigVgi1kS0A1wkUTaX
+uOCXD73TCHPcKMRp7YLZzg9jy/XlDgbPn4qRl1qa7RHPvAV5a4j4upcw+EzP2B+3
+z7e/zlQkFOuKdSYj/zgBidRwxRs9kQIA8HngrqvrRNC03IzQLZqYhRFV7AxlK2Xl
+ikFdEj0xXAy6ep4svwsBtHnUUfmXZL/cG4A6MNp1in4XK6WNuBmmyQIA842mH8nV
+/vmIwm+lfDTs1Y5BMoV2g9VhOixJ3WO2HQVGbYB42tBd3cw+tp5urSPESFN9rcq8
+U2+XE+wPZRiugwIA0aBXyLN73fhkTUduTJhYOgtEl1yormrsEZHwYiNI7zLjc71p
+3aMZsXpAZV3lcgPV83O7ESgC3z+Pbux6tA8+k6R7iQE9BBgBAgAJBQJJ4wmxAhsC
+AKgJEBVPY3v2LG07nSAEGQECAAYFAknjCbEACgkQ2KKLf9el2Ie2bQP/T8ThPu2S
+eq5tR8aGxJJ1w0U6szTT2UIyXu8gBO3SM8wLVcBuIXdkxOshUP2Xua758tLmns5X
+aoDiK8am9E22zX1BXyjVmK/74of6yjsf+VxJJtTlgpxeFH+zI1zZxIA1TlRg2TvV
+IHC5oD1i5v1P2xugtzby4aGHTXdi8pUMKGLMegP/U61Kg6OcqEA2C6288UhsNWZz
+ReY9mMOlC8z+TET6IfHnP5hd4+hZxKDWKgj0V95vbWzA/XkZIiK09wjjht6Oqw5t
+qq4R38D5kkFUr9yLlwTxMw+jipVTTFlbjjWhsnEoH16QZRQr0PT0FlSnn3CGy+sd
+Sdq+vMpQsIh1h85JVQI=
+=+Gnh
+-----END PGP PRIVATE KEY BLOCK-----
diff --git a/tests/wrongarch.test b/tests/wrongarch.test
new file mode 100644
index 0000000..ab1abf7
--- /dev/null
+++ b/tests/wrongarch.test
@@ -0,0 +1,86 @@
+set -u
+. "$TESTSDIR"/test.inc
+
+mkdir conf
+cat > conf/distributions <<EOF
+Codename: test
+Architectures: a1 a2 source
+Components: main
+Update: update
+EOF
+cat > conf/updates <<EOF
+Name: update
+Architectures: a>a2 source
+Suite: test
+Method: file:${WORKDIR}/test
+IgnoreRelease: yes
+EOF
+mkdir test
+mkdir test/dists
+mkdir test/dists/test
+mkdir test/dists/test/main
+mkdir test/dists/test/main/binary-a
+mkdir test/dists/test/main/source
+
+cat > test/dists/test/main/binary-a/Packages <<EOF
+Package: fake1
+Version: 0a
+Architecture: a
+Filename: filename
+Size: 1
+MD5sum: 1111111111111111
+
+Package: fake2
+Version: 2all
+Architecture: all
+Filename: filename
+Size: 1
+MD5sum: 1111111111111111
+EOF
+cat > test/dists/test/main/source/Sources <<EOF
+Package: fake1
+Version: 0s
+Files:
+ 1111111111111111 1 somefile
+
+Package: fake2
+Version: 2s
+Files:
+ 1111111111111111 1 somefile
+EOF
+
+testrun - dumpupdate 3<<EOF
+stderr
+-v6=aptmethod start 'file:${WORKDIR}/test/dists/test/main/binary-a/Packages.gz'
+*=aptmethod error receiving 'file:${WORKDIR}/test/dists/test/main/binary-a/Packages.gz':
+='<File not there, apt-method suggests '${WORKDIR}/test/dists/test/main/binary-a/Packages' instead>'
+='File not found'
+='File not found - ${WORKDIR}/test/dists/test/main/binary-a/Packages.gz (2: No such file or directory)'
+-v6=aptmethod start 'file:${WORKDIR}/test/dists/test/main/binary-a/Packages.bz2'
+*=aptmethod error receiving 'file:${WORKDIR}/test/dists/test/main/binary-a/Packages.bz2':
+='File not found - ${WORKDIR}/test/dists/test/main/binary-a/Packages.bz2 (2: No such file or directory)'
+-v6=aptmethod start 'file:${WORKDIR}/test/dists/test/main/source/Sources.gz'
+*=aptmethod error receiving 'file:${WORKDIR}/test/dists/test/main/source/Sources.gz':
+='File not found - ${WORKDIR}/test/dists/test/main/source/Sources.gz (2: No such file or directory)'
+='<File not there, apt-method suggests '${WORKDIR}/test/dists/test/main/source/Sources' instead>'
+-v6=aptmethod start 'file:${WORKDIR}/test/dists/test/main/source/Sources.bz2'
+*=aptmethod error receiving 'file:${WORKDIR}/test/dists/test/main/source/Sources.bz2':
+='File not found - ${WORKDIR}/test/dists/test/main/source/Sources.bz2 (2: No such file or directory)'
+-v6=aptmethod start 'file:${WORKDIR}/test/dists/test/main/binary-a/Packages'
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/test/main/binary-a/Packages'
+-v2*=Copy file '${WORKDIR}/test/dists/test/main/binary-a/Packages' to './lists/update_test_main_a_Packages'...
+-v6=aptmethod start 'file:${WORKDIR}/test/dists/test/main/source/Sources'
+-v1*=aptmethod got 'file:${WORKDIR}/test/dists/test/main/source/Sources'
+-v2*=Copy file '${WORKDIR}/test/dists/test/main/source/Sources' to './lists/update_test_main_Sources'...
+stdout
+$(odb)
+-v2*=Created directory "./lists"
+*=Updates needed for 'test|main|source':
+*=add 'fake1' - '0s' 'update'
+*=add 'fake2' - '2s' 'update'
+*=Updates needed for 'test|main|a2':
+*=add 'fake2' - '2all' 'update'
+EOF
+
+rm -r conf lists test db
+testsuccess