From c204d1482e085f5453c0d99ee5a9a8e99ca90e38 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Tue, 17 Apr 2012 23:45:52 +0200
Subject: ensure that not --assert-multi-arch supporting dpkg's do not generate
output in the testcases by redirecting to /dev/null
---
test/integration/framework | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'test')
diff --git a/test/integration/framework b/test/integration/framework
index 0670d6a78..b80b02922 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -151,7 +151,7 @@ setupenvironment() {
echo "DPKG::options:: \"--root=${TMPWORKINGDIRECTORY}/rootdir\";" >> aptconfig.conf
echo "DPKG::options:: \"--force-not-root\";" >> aptconfig.conf
echo "DPKG::options:: \"--force-bad-path\";" >> aptconfig.conf
- if ! $(which dpkg) --assert-multi-arch; then
+ if ! $(which dpkg) --assert-multi-arch 2>&1 > /dev/null; then
echo "DPKG::options:: \"--force-architecture\";" >> aptconfig.conf # Added to test multiarch before dpkg is ready for it…
fi
echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf
@@ -199,7 +199,7 @@ configdpkg() {
echo -n > rootdir/var/lib/dpkg/status
fi
fi
- if $(which dpkg) --assert-multi-arch; then
+ if $(which dpkg) --assert-multi-arch 2>&1 > /dev/null; then
local ARCHS="$(getarchitectures)"
if echo "$ARCHS" | grep -E -q '[^ ]+ [^ ]+'; then
DPKGARCH="$(dpkg --print-architecture)"
--
cgit v1.2.3-70-g09d2
From 04d24dbdcc2eabf616b26878084d3b8790e30086 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Thu, 19 Apr 2012 10:29:02 +0200
Subject: ignore the order used for the 'apt' package as long as it is valid
either way
---
...-ubuntu-bug-835625-multiarch-lockstep-installed-first | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
(limited to 'test')
diff --git a/test/integration/test-ubuntu-bug-835625-multiarch-lockstep-installed-first b/test/integration/test-ubuntu-bug-835625-multiarch-lockstep-installed-first
index a9a4069cf..269038d0f 100755
--- a/test/integration/test-ubuntu-bug-835625-multiarch-lockstep-installed-first
+++ b/test/integration/test-ubuntu-bug-835625-multiarch-lockstep-installed-first
@@ -14,7 +14,7 @@ insertpackage 'unstable' 'apt' 'i386' '2' 'Depends: libsame (= 2)'
setupaptarchive
-testequal 'Reading package lists...
+testequalor2 'Reading package lists...
Building dependency tree...
The following extra packages will be installed:
apt:i386 libsame:i386
@@ -28,4 +28,18 @@ Inst libsame (2 unstable [amd64]) [apt:i386 ]
Conf libsame:i386 (2 unstable [i386]) [apt:i386 ]
Conf libsame (2 unstable [amd64]) [apt:i386 ]
Inst apt:i386 [1] (2 unstable [i386])
+Conf apt:i386 (2 unstable [i386])' 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+ apt:i386 libsame:i386
+The following NEW packages will be installed:
+ libsame
+The following packages will be upgraded:
+ apt:i386 libsame:i386
+2 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst apt:i386 [1] (2 unstable [i386]) []
+Inst libsame:i386 [1] (2 unstable [i386])
+Inst libsame (2 unstable [amd64])
+Conf libsame:i386 (2 unstable [i386])
+Conf libsame (2 unstable [amd64])
Conf apt:i386 (2 unstable [i386])' aptget install libsame:amd64 -s
--
cgit v1.2.3-70-g09d2
From f0633b216cd019ac0c508a46440943c91f07f65d Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Thu, 19 Apr 2012 22:41:25 +0200
Subject: add a very simple testcase for the lp#985852 fix in the previous
commit
---
...-ubuntu-bug-985852-pre-depends-or-group-ordering | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100755 test/integration/test-ubuntu-bug-985852-pre-depends-or-group-ordering
(limited to 'test')
diff --git a/test/integration/test-ubuntu-bug-985852-pre-depends-or-group-ordering b/test/integration/test-ubuntu-bug-985852-pre-depends-or-group-ordering
new file mode 100755
index 000000000..462acad00
--- /dev/null
+++ b/test/integration/test-ubuntu-bug-985852-pre-depends-or-group-ordering
@@ -0,0 +1,21 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64'
+
+insertinstalledpackage 'custom' 'amd64' '1.0' 'Pre-Depends: grub-pc | grub'
+insertinstalledpackage 'grub' 'amd64' '1.0'
+insertpackage 'unstable' 'custom' 'amd64' '2.0' 'Pre-Depends: grub-pc | grub'
+
+setupaptarchive
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be upgraded:
+ custom
+1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+Inst custom [1.0] (2.0 unstable [amd64])
+Conf custom (2.0 unstable [amd64])' aptget dist-upgrade -s
--
cgit v1.2.3-70-g09d2
From e6a12579e9e5d5735eda450cf2bb3986d828ab65 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Fri, 20 Apr 2012 10:13:17 +0200
Subject: * apt-pkg/cacheset.cc: - actually return to the fallback modifier
if we have detected we should for packagenames which look like modifiers
(Closes: #669591)
---
apt-pkg/cacheset.cc | 7 +++++--
debian/changelog | 5 ++++-
test/integration/test-bug-593360-modifiers-in-names | 5 +++++
3 files changed, 14 insertions(+), 3 deletions(-)
(limited to 'test')
diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc
index b892ab4bf..e2dbe0e57 100644
--- a/apt-pkg/cacheset.cc
+++ b/apt-pkg/cacheset.cc
@@ -217,6 +217,7 @@ bool PackageContainerInterface::FromModifierCommandLine(unsigned short &modID, P
pkgCacheFile &Cache, const char * cmdline,
std::list const &mods, CacheSetHelper &helper) {
std::string str = cmdline;
+ unsigned short fallback = modID;
bool modifierPresent = false;
for (std::list::const_iterator mod = mods.begin();
mod != mods.end(); ++mod) {
@@ -243,6 +244,7 @@ bool PackageContainerInterface::FromModifierCommandLine(unsigned short &modID, P
helper.showErrors(errors);
if (Pkg.end() == false) {
pci->insert(Pkg);
+ modID = fallback;
return true;
}
}
@@ -281,13 +283,14 @@ bool VersionContainerInterface::FromModifierCommandLine(unsigned short &modID,
modifierPresent = true;
break;
}
-
if (modifierPresent == true) {
bool const errors = helper.showErrors(false);
bool const found = VersionContainerInterface::FromString(vci, Cache, cmdline, select, helper, true);
helper.showErrors(errors);
- if (found == true)
+ if (found == true) {
+ modID = fallback;
return true;
+ }
}
return FromString(vci, Cache, str, select, helper);
}
diff --git a/debian/changelog b/debian/changelog
index 4d4d6a70e..18242e081 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,9 @@ apt (0.9.2) unstable; urgency=low
- do not use the input data directly but memcpy it instead as
it could be unaligned as in the http-transport which causes
a sigbus error on sparc (Closes: #669061)
+ * apt-pkg/cacheset.cc:
+ - actually return to the fallback modifier if we have detected we
+ should for packagenames which look like modifiers (Closes: #669591)
[ Malcolm Scott ]
@@ -19,7 +22,7 @@ apt (0.9.2) unstable; urgency=low
- iterate over all pre-depends or-group member instead of looping
endlessly over the first member in SmartUnpack (LP: #985852)
- -- David Kalnischkies Fri, 20 Apr 2012 09:52:21 +0200
+ -- David Kalnischkies Fri, 20 Apr 2012 10:11:24 +0200
apt (0.9.1) unstable; urgency=low
diff --git a/test/integration/test-bug-593360-modifiers-in-names b/test/integration/test-bug-593360-modifiers-in-names
index 83a3cfabf..74826cbdb 100755
--- a/test/integration/test-bug-593360-modifiers-in-names
+++ b/test/integration/test-bug-593360-modifiers-in-names
@@ -15,6 +15,11 @@ The following NEW packages will be installed:
Inst g++ (4:4.4.5-1 localhost [i386])
Conf g++ (4:4.4.5-1 localhost [i386])' aptget install g++ -s
+testequal "Reading package lists...
+Building dependency tree...
+Package 'g++' is not installed, so not removed
+0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget remove g++ -s
+
testequal 'Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
--
cgit v1.2.3-70-g09d2
From 074da0970c68879d548b6b4f64d0da7f38151248 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Mon, 23 Apr 2012 17:46:11 +0200
Subject: * apt-pkg/depcache.cc: - clearly separate 'positive' and 'negative'
dependencies and their upgrade-resolution tries in MarkInstall and
especially don't treat Conflicts differently compared to Breaks here
---
apt-pkg/depcache.cc | 25 ++--
debian/changelog | 6 +-
.../test-ignore-provides-if-versioned-breaks | 150 +++++++++++++++++++++
.../test-ignore-provides-if-versioned-conflicts | 150 +++++++++++++++++++++
4 files changed, 318 insertions(+), 13 deletions(-)
create mode 100755 test/integration/test-ignore-provides-if-versioned-breaks
create mode 100755 test/integration/test-ignore-provides-if-versioned-conflicts
(limited to 'test')
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 1eea55560..daf7c8c4d 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -1152,9 +1152,8 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
}
/* This bit is for processing the possibilty of an install/upgrade
- fixing the problem */
- if (Start->Type != Dep::DpkgBreaks &&
- (DepState[Start->ID] & DepCVer) == DepCVer)
+ fixing the problem for "positive" dependencies */
+ if (Start.IsNegative() == false && (DepState[Start->ID] & DepCVer) == DepCVer)
{
APT::VersionList verlist;
pkgCache::VerIterator Cand = PkgState[Start.TargetPkg()->ID].CandidateVerIter(*this);
@@ -1198,13 +1197,13 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
}
continue;
}
-
- /* For conflicts we just de-install the package and mark as auto,
- Conflicts may not have or groups. For dpkg's Breaks we try to
- upgrade the package. */
- if (Start.IsNegative() == true)
+ /* Negative dependencies have no or-group
+ If the dependency isn't versioned, we try if an upgrade might solve the problem.
+ Otherwise we remove the offender if needed */
+ else if (Start.IsNegative() == true && Start->Type != pkgCache::Dep::Obsoletes)
{
SPtrArray List = Start.AllTargets();
+ pkgCache::PkgIterator TrgPkg = Start.TargetPkg();
for (Version **I = List; *I != 0; I++)
{
VerIterator Ver(*this,*I);
@@ -1215,15 +1214,17 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
if (PkgState[Pkg->ID].InstallVer == 0)
continue;
- if (PkgState[Pkg->ID].CandidateVer != *I &&
- Start->Type == Dep::DpkgBreaks &&
+ if ((Start->Version != 0 || TrgPkg != Pkg) &&
+ PkgState[Pkg->ID].CandidateVer != PkgState[Pkg->ID].InstallVer &&
+ PkgState[Pkg->ID].CandidateVer != *I &&
MarkInstall(Pkg,true,Depth + 1, false, ForceImportantDeps) == true)
continue;
- else if (MarkDelete(Pkg,false,Depth + 1, false) == false)
+ else if ((Start->Type == pkgCache::Dep::Conflicts || Start->Type == pkgCache::Dep::DpkgBreaks) &&
+ MarkDelete(Pkg,false,Depth + 1, false) == false)
break;
}
continue;
- }
+ }
}
return Dep.end() == true;
diff --git a/debian/changelog b/debian/changelog
index 145da311e..e585530ff 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,8 +12,12 @@ apt (0.9.3) unstable; urgency=low
- implement --empty and --format option for dump
* apt-pkg/cdrom.cc:
- use Dump() to generate the configuration output
+ * apt-pkg/depcache.cc:
+ - clearly separate 'positive' and 'negative' dependencies and
+ their upgrade-resolution tries in MarkInstall and especially don't
+ treat Conflicts differently compared to Breaks here
- -- David Kalnischkies Sun, 22 Apr 2012 13:01:04 +0200
+ -- David Kalnischkies Mon, 23 Apr 2012 17:43:53 +0200
apt (0.9.2) unstable; urgency=low
diff --git a/test/integration/test-ignore-provides-if-versioned-breaks b/test/integration/test-ignore-provides-if-versioned-breaks
new file mode 100755
index 000000000..f8b4544a0
--- /dev/null
+++ b/test/integration/test-ignore-provides-if-versioned-breaks
@@ -0,0 +1,150 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'i386' 'amd64'
+
+insertpackage 'unstable' 'unrlated' 'all' '1.0'
+
+insertinstalledpackage 'foo' 'i386' '2.0'
+insertpackage 'unstable' 'foo' 'i386' '4.0'
+insertpackage 'unstable' 'foo-provider' 'i386' '1.0' 'Provides: foo'
+insertpackage 'unstable' 'foo-breaker-3' 'i386' '1.0' 'Breaks: foo (<< 3.0)'
+insertpackage 'unstable' 'foo-breaker-2' 'i386' '1.0' 'Breaks: foo (<< 2.0)'
+insertpackage 'unstable' 'foo-breaker-none' 'i386' '1.0' 'Breaks: foo'
+
+insertinstalledpackage 'foo-foreign' 'amd64' '2.0' 'Multi-Arch: foreign'
+insertpackage 'unstable' 'foo-foreign' 'amd64' '4.0' 'Multi-Arch: foreign'
+insertpackage 'unstable' 'foo-foreign-provider' 'i386' '1.0' 'Provides: foo-foreign'
+insertpackage 'unstable' 'foo-foreign-breaker-3' 'i386' '1.0' 'Breaks: foo-foreign (<< 3.0)'
+insertpackage 'unstable' 'foo-foreign-breaker-2' 'i386' '1.0' 'Breaks: foo-foreign (<< 2.0)'
+insertpackage 'unstable' 'foo-foreign-breaker-none' 'i386' '1.0' 'Breaks: foo-foreign'
+
+insertinstalledpackage 'foo-same' 'i386,amd64' '2.0' 'Multi-Arch: same'
+insertpackage 'unstable' 'foo-same' 'i386,amd64' '4.0' 'Multi-Arch: same'
+insertpackage 'unstable' 'foo-same-provider' 'i386' '1.0' 'Provides: foo-same'
+insertpackage 'unstable' 'foo-same-breaker-3' 'i386' '1.0' 'Breaks: foo-same (<< 3.0)'
+insertpackage 'unstable' 'foo-same-breaker-2' 'i386' '1.0' 'Breaks: foo-same (<< 2.0)'
+insertpackage 'unstable' 'foo-same-breaker-none' 'i386' '1.0' 'Breaks: foo-same'
+
+
+
+setupaptarchive
+
+testequal 'Reading package lists...
+Building dependency tree...
+Some packages could not be installed. This may mean that you have
+requested an impossible situation or if you are using the unstable
+distribution that some required packages have not yet been created
+or been moved out of Incoming.
+The following information may help to resolve the situation:
+
+The following packages have unmet dependencies:
+ foo-breaker-none : Breaks: foo
+E: Unable to correct problems, you have held broken packages.' aptget install foo-provider foo-breaker-none -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ foo-breaker-2 foo-provider
+0 upgraded, 2 newly installed, 0 to remove and 4 not upgraded.
+Inst foo-breaker-2 (1.0 unstable [i386])
+Inst foo-provider (1.0 unstable [i386])
+Conf foo-breaker-2 (1.0 unstable [i386])
+Conf foo-provider (1.0 unstable [i386])' aptget install foo-provider foo-breaker-2 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+ foo
+The following NEW packages will be installed:
+ foo-breaker-3 foo-provider
+The following packages will be upgraded:
+ foo
+1 upgraded, 2 newly installed, 0 to remove and 3 not upgraded.
+Inst foo [2.0] (4.0 unstable [i386])
+Inst foo-breaker-3 (1.0 unstable [i386])
+Inst foo-provider (1.0 unstable [i386])
+Conf foo (4.0 unstable [i386])
+Conf foo-breaker-3 (1.0 unstable [i386])
+Conf foo-provider (1.0 unstable [i386])' aptget install foo-provider foo-breaker-3 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+Some packages could not be installed. This may mean that you have
+requested an impossible situation or if you are using the unstable
+distribution that some required packages have not yet been created
+or been moved out of Incoming.
+The following information may help to resolve the situation:
+
+The following packages have unmet dependencies:
+ foo-foreign-breaker-none : Breaks: foo-foreign
+E: Unable to correct problems, you have held broken packages.' aptget install foo-foreign-provider foo-foreign-breaker-none -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ foo-foreign-breaker-2 foo-foreign-provider
+0 upgraded, 2 newly installed, 0 to remove and 4 not upgraded.
+Inst foo-foreign-breaker-2 (1.0 unstable [i386])
+Inst foo-foreign-provider (1.0 unstable [i386])
+Conf foo-foreign-breaker-2 (1.0 unstable [i386])
+Conf foo-foreign-provider (1.0 unstable [i386])' aptget install foo-foreign-provider foo-foreign-breaker-2 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+ foo-foreign:amd64
+The following NEW packages will be installed:
+ foo-foreign-breaker-3 foo-foreign-provider
+The following packages will be upgraded:
+ foo-foreign:amd64
+1 upgraded, 2 newly installed, 0 to remove and 3 not upgraded.
+Inst foo-foreign:amd64 [2.0] (4.0 unstable [amd64])
+Inst foo-foreign-breaker-3 (1.0 unstable [i386])
+Inst foo-foreign-provider (1.0 unstable [i386])
+Conf foo-foreign:amd64 (4.0 unstable [amd64])
+Conf foo-foreign-breaker-3 (1.0 unstable [i386])
+Conf foo-foreign-provider (1.0 unstable [i386])' aptget install foo-foreign-provider foo-foreign-breaker-3 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+Some packages could not be installed. This may mean that you have
+requested an impossible situation or if you are using the unstable
+distribution that some required packages have not yet been created
+or been moved out of Incoming.
+The following information may help to resolve the situation:
+
+The following packages have unmet dependencies:
+ foo-same-breaker-none : Breaks: foo-same
+E: Unable to correct problems, you have held broken packages.' aptget install foo-same-provider foo-same-breaker-none -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ foo-same-breaker-2 foo-same-provider
+0 upgraded, 2 newly installed, 0 to remove and 4 not upgraded.
+Inst foo-same-breaker-2 (1.0 unstable [i386])
+Inst foo-same-provider (1.0 unstable [i386])
+Conf foo-same-breaker-2 (1.0 unstable [i386])
+Conf foo-same-provider (1.0 unstable [i386])' aptget install foo-same-provider foo-same-breaker-2 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+ foo-same:amd64 foo-same
+The following NEW packages will be installed:
+ foo-same-breaker-3 foo-same-provider
+The following packages will be upgraded:
+ foo-same:amd64 foo-same
+2 upgraded, 2 newly installed, 0 to remove and 2 not upgraded.
+Inst foo-same:amd64 [2.0] (4.0 unstable [amd64]) [foo-same:amd64 on foo-same:i386] [foo-same:i386 on foo-same:amd64] [foo-same:i386 ]
+Inst foo-same [2.0] (4.0 unstable [i386])
+Conf foo-same:amd64 (4.0 unstable [amd64])
+Conf foo-same (4.0 unstable [i386])
+Inst foo-same-breaker-3 (1.0 unstable [i386])
+Inst foo-same-provider (1.0 unstable [i386])
+Conf foo-same-breaker-3 (1.0 unstable [i386])
+Conf foo-same-provider (1.0 unstable [i386])' aptget install foo-same-provider foo-same-breaker-3 -s
diff --git a/test/integration/test-ignore-provides-if-versioned-conflicts b/test/integration/test-ignore-provides-if-versioned-conflicts
new file mode 100755
index 000000000..44eafcff1
--- /dev/null
+++ b/test/integration/test-ignore-provides-if-versioned-conflicts
@@ -0,0 +1,150 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'i386' 'amd64'
+
+insertpackage 'unstable' 'unrlated' 'all' '1.0'
+
+insertinstalledpackage 'foo' 'i386' '2.0'
+insertpackage 'unstable' 'foo' 'i386' '4.0'
+insertpackage 'unstable' 'foo-provider' 'i386' '1.0' 'Provides: foo'
+insertpackage 'unstable' 'foo-breaker-3' 'i386' '1.0' 'Conflicts: foo (<< 3.0)'
+insertpackage 'unstable' 'foo-breaker-2' 'i386' '1.0' 'Conflicts: foo (<< 2.0)'
+insertpackage 'unstable' 'foo-breaker-none' 'i386' '1.0' 'Conflicts: foo'
+
+insertinstalledpackage 'foo-foreign' 'amd64' '2.0' 'Multi-Arch: foreign'
+insertpackage 'unstable' 'foo-foreign' 'amd64' '4.0' 'Multi-Arch: foreign'
+insertpackage 'unstable' 'foo-foreign-provider' 'i386' '1.0' 'Provides: foo-foreign'
+insertpackage 'unstable' 'foo-foreign-breaker-3' 'i386' '1.0' 'Conflicts: foo-foreign (<< 3.0)'
+insertpackage 'unstable' 'foo-foreign-breaker-2' 'i386' '1.0' 'Conflicts: foo-foreign (<< 2.0)'
+insertpackage 'unstable' 'foo-foreign-breaker-none' 'i386' '1.0' 'Conflicts: foo-foreign'
+
+insertinstalledpackage 'foo-same' 'i386,amd64' '2.0' 'Multi-Arch: same'
+insertpackage 'unstable' 'foo-same' 'i386,amd64' '4.0' 'Multi-Arch: same'
+insertpackage 'unstable' 'foo-same-provider' 'i386' '1.0' 'Provides: foo-same'
+insertpackage 'unstable' 'foo-same-breaker-3' 'i386' '1.0' 'Conflicts: foo-same (<< 3.0)'
+insertpackage 'unstable' 'foo-same-breaker-2' 'i386' '1.0' 'Conflicts: foo-same (<< 2.0)'
+insertpackage 'unstable' 'foo-same-breaker-none' 'i386' '1.0' 'Conflicts: foo-same'
+
+
+
+setupaptarchive
+
+testequal 'Reading package lists...
+Building dependency tree...
+Some packages could not be installed. This may mean that you have
+requested an impossible situation or if you are using the unstable
+distribution that some required packages have not yet been created
+or been moved out of Incoming.
+The following information may help to resolve the situation:
+
+The following packages have unmet dependencies:
+ foo-breaker-none : Conflicts: foo
+E: Unable to correct problems, you have held broken packages.' aptget install foo-provider foo-breaker-none -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ foo-breaker-2 foo-provider
+0 upgraded, 2 newly installed, 0 to remove and 4 not upgraded.
+Inst foo-breaker-2 (1.0 unstable [i386])
+Inst foo-provider (1.0 unstable [i386])
+Conf foo-breaker-2 (1.0 unstable [i386])
+Conf foo-provider (1.0 unstable [i386])' aptget install foo-provider foo-breaker-2 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+ foo
+The following NEW packages will be installed:
+ foo-breaker-3 foo-provider
+The following packages will be upgraded:
+ foo
+1 upgraded, 2 newly installed, 0 to remove and 3 not upgraded.
+Inst foo [2.0] (4.0 unstable [i386])
+Inst foo-breaker-3 (1.0 unstable [i386])
+Inst foo-provider (1.0 unstable [i386])
+Conf foo (4.0 unstable [i386])
+Conf foo-breaker-3 (1.0 unstable [i386])
+Conf foo-provider (1.0 unstable [i386])' aptget install foo-provider foo-breaker-3 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+Some packages could not be installed. This may mean that you have
+requested an impossible situation or if you are using the unstable
+distribution that some required packages have not yet been created
+or been moved out of Incoming.
+The following information may help to resolve the situation:
+
+The following packages have unmet dependencies:
+ foo-foreign-breaker-none : Conflicts: foo-foreign
+E: Unable to correct problems, you have held broken packages.' aptget install foo-foreign-provider foo-foreign-breaker-none -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ foo-foreign-breaker-2 foo-foreign-provider
+0 upgraded, 2 newly installed, 0 to remove and 4 not upgraded.
+Inst foo-foreign-breaker-2 (1.0 unstable [i386])
+Inst foo-foreign-provider (1.0 unstable [i386])
+Conf foo-foreign-breaker-2 (1.0 unstable [i386])
+Conf foo-foreign-provider (1.0 unstable [i386])' aptget install foo-foreign-provider foo-foreign-breaker-2 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+ foo-foreign:amd64
+The following NEW packages will be installed:
+ foo-foreign-breaker-3 foo-foreign-provider
+The following packages will be upgraded:
+ foo-foreign:amd64
+1 upgraded, 2 newly installed, 0 to remove and 3 not upgraded.
+Inst foo-foreign:amd64 [2.0] (4.0 unstable [amd64])
+Inst foo-foreign-breaker-3 (1.0 unstable [i386])
+Inst foo-foreign-provider (1.0 unstable [i386])
+Conf foo-foreign:amd64 (4.0 unstable [amd64])
+Conf foo-foreign-breaker-3 (1.0 unstable [i386])
+Conf foo-foreign-provider (1.0 unstable [i386])' aptget install foo-foreign-provider foo-foreign-breaker-3 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+Some packages could not be installed. This may mean that you have
+requested an impossible situation or if you are using the unstable
+distribution that some required packages have not yet been created
+or been moved out of Incoming.
+The following information may help to resolve the situation:
+
+The following packages have unmet dependencies:
+ foo-same-breaker-none : Conflicts: foo-same
+E: Unable to correct problems, you have held broken packages.' aptget install foo-same-provider foo-same-breaker-none -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ foo-same-breaker-2 foo-same-provider
+0 upgraded, 2 newly installed, 0 to remove and 4 not upgraded.
+Inst foo-same-breaker-2 (1.0 unstable [i386])
+Inst foo-same-provider (1.0 unstable [i386])
+Conf foo-same-breaker-2 (1.0 unstable [i386])
+Conf foo-same-provider (1.0 unstable [i386])' aptget install foo-same-provider foo-same-breaker-2 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+ foo-same:amd64 foo-same
+The following NEW packages will be installed:
+ foo-same-breaker-3 foo-same-provider
+The following packages will be upgraded:
+ foo-same:amd64 foo-same
+2 upgraded, 2 newly installed, 0 to remove and 2 not upgraded.
+Inst foo-same:amd64 [2.0] (4.0 unstable [amd64]) [foo-same:amd64 on foo-same:i386] [foo-same:i386 on foo-same:amd64] [foo-same:i386 ]
+Inst foo-same [2.0] (4.0 unstable [i386])
+Conf foo-same:amd64 (4.0 unstable [amd64])
+Conf foo-same (4.0 unstable [i386])
+Inst foo-same-breaker-3 (1.0 unstable [i386])
+Inst foo-same-provider (1.0 unstable [i386])
+Conf foo-same-breaker-3 (1.0 unstable [i386])
+Conf foo-same-provider (1.0 unstable [i386])' aptget install foo-same-provider foo-same-breaker-3 -s
--
cgit v1.2.3-70-g09d2
From ec76891fa17c77f8fd28b9b6e11ef2d7547afe7e Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Mon, 23 Apr 2012 19:11:11 +0200
Subject: normalize a bit by replacing // and /./ with / in FindFile
---
apt-pkg/contrib/configuration.cc | 68 ++++++++++++++++++++++-----------------
debian/changelog | 3 +-
test/libapt/configuration_test.cc | 13 ++++++++
3 files changed, 53 insertions(+), 31 deletions(-)
(limited to 'test')
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index ff80dfaf8..ce02f1bd2 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -171,48 +171,56 @@ string Configuration::Find(const char *Name,const char *Default) const
string Configuration::FindFile(const char *Name,const char *Default) const
{
const Item *RootItem = Lookup("RootDir");
- std::string rootDir = (RootItem == 0) ? "" : RootItem->Value;
- if(rootDir.size() > 0 && rootDir[rootDir.size() - 1] != '/')
- rootDir.push_back('/');
+ std::string result = (RootItem == 0) ? "" : RootItem->Value;
+ if(result.empty() == false && result[result.size() - 1] != '/')
+ result.push_back('/');
const Item *Itm = Lookup(Name);
if (Itm == 0 || Itm->Value.empty() == true)
{
- if (Default == 0)
- return rootDir;
- else
- return rootDir + Default;
+ if (Default != 0)
+ result.append(Default);
}
-
- string val = Itm->Value;
- while (Itm->Parent != 0)
+ else
{
- if (Itm->Parent->Value.empty() == true)
+ string val = Itm->Value;
+ while (Itm->Parent != 0)
{
- Itm = Itm->Parent;
- continue;
- }
+ if (Itm->Parent->Value.empty() == true)
+ {
+ Itm = Itm->Parent;
+ continue;
+ }
- // Absolute
- if (val.length() >= 1 && val[0] == '/')
- break;
+ // Absolute
+ if (val.length() >= 1 && val[0] == '/')
+ break;
- // ~/foo or ./foo
- if (val.length() >= 2 && (val[0] == '~' || val[0] == '.') && val[1] == '/')
- break;
-
- // ../foo
- if (val.length() >= 3 && val[0] == '.' && val[1] == '.' && val[2] == '/')
- break;
-
- if (Itm->Parent->Value.end()[-1] != '/')
- val.insert(0, "/");
+ // ~/foo or ./foo
+ if (val.length() >= 2 && (val[0] == '~' || val[0] == '.') && val[1] == '/')
+ break;
+
+ // ../foo
+ if (val.length() >= 3 && val[0] == '.' && val[1] == '.' && val[2] == '/')
+ break;
+
+ if (Itm->Parent->Value.end()[-1] != '/')
+ val.insert(0, "/");
- val.insert(0, Itm->Parent->Value);
- Itm = Itm->Parent;
+ val.insert(0, Itm->Parent->Value);
+ Itm = Itm->Parent;
+ }
+ result.append(val);
}
- return rootDir + val;
+ // do some normalisation by removing // and /./ from the path
+ size_t found = string::npos;
+ while ((found = result.find("/./")) != string::npos)
+ result.replace(found, 3, "/");
+ while ((found = result.find("//")) != string::npos)
+ result.replace(found, 2, "/");
+
+ return result;
}
/*}}}*/
// Configuration::FindDir - Find a directory name /*{{{*/
diff --git a/debian/changelog b/debian/changelog
index 27747e23f..dc331dc55 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,7 @@ apt (0.9.3) unstable; urgency=low
- remove the message size limit from ioprintf and strprintf
* apt-pkg/contrib/configuration.cc:
- add a more versatile Dump() method
+ - normalize a bit by replacing // and /./ with / in FindFile
* apt-pkg/acquire-worker.cc:
- use Dump() to generate the configuration message for sending
* cmdline/apt-config.cc:
@@ -20,7 +21,7 @@ apt (0.9.3) unstable; urgency=low
- check with RealFileExists for scenario file as otherwise a directory
like one provided with RootDir triggers the usage of EDSP
- -- David Kalnischkies Mon, 23 Apr 2012 18:23:10 +0200
+ -- David Kalnischkies Mon, 23 Apr 2012 19:10:13 +0200
apt (0.9.2) unstable; urgency=low
diff --git a/test/libapt/configuration_test.cc b/test/libapt/configuration_test.cc
index 9a3e2c118..6b657a70c 100644
--- a/test/libapt/configuration_test.cc
+++ b/test/libapt/configuration_test.cc
@@ -80,6 +80,19 @@ int main(int argc,const char *argv[]) {
equals(Cnf.FindFile("Dir::State"), "/srv/sid/var/lib/apt");
equals(Cnf.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude");
+ Cnf.Set("RootDir", "/");
+ equals(Cnf.FindFile("Dir::State"), "/srv/sid/var/lib/apt");
+ equals(Cnf.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude");
+ Cnf.Set("RootDir", "//./////.////");
+ equals(Cnf.FindFile("Dir::State"), "/srv/sid/var/lib/apt");
+ equals(Cnf.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude");
+ Cnf.Set("RootDir", "/rootdir");
+ equals(Cnf.FindFile("Dir::State"), "/rootdir/srv/sid/var/lib/apt");
+ equals(Cnf.FindFile("Dir::Aptitude::State"), "/rootdir/srv/sid/var/lib/aptitude");
+ Cnf.Set("RootDir", "/rootdir/");
+ equals(Cnf.FindFile("Dir::State"), "/rootdir/srv/sid/var/lib/apt");
+ equals(Cnf.FindFile("Dir::Aptitude::State"), "/rootdir/srv/sid/var/lib/aptitude");
+
//FIXME: Test for configuration file parsing;
// currently only integration/ tests test them implicitly
--
cgit v1.2.3-70-g09d2
From af13d1437cbcb383de89f126b316c02587e4b691 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Mon, 23 Apr 2012 19:33:32 +0200
Subject: /dev/null is a special absolute path as it has no subdirectories
---
apt-pkg/contrib/configuration.cc | 9 +++++++++
debian/changelog | 3 ++-
test/libapt/configuration_test.cc | 5 +++++
3 files changed, 16 insertions(+), 1 deletion(-)
(limited to 'test')
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index ce02f1bd2..4de17e3e1 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -194,7 +194,11 @@ string Configuration::FindFile(const char *Name,const char *Default) const
// Absolute
if (val.length() >= 1 && val[0] == '/')
+ {
+ if (val.compare(0, 9, "/dev/null") == 0)
+ val.erase(9);
break;
+ }
// ~/foo or ./foo
if (val.length() >= 2 && (val[0] == '~' || val[0] == '.') && val[1] == '/')
@@ -230,7 +234,12 @@ string Configuration::FindDir(const char *Name,const char *Default) const
{
string Res = FindFile(Name,Default);
if (Res.end()[-1] != '/')
+ {
+ size_t const found = Res.rfind("/dev/null");
+ if (found != string::npos && found == Res.size() - 9)
+ return Res; // /dev/null returning
return Res + '/';
+ }
return Res;
}
/*}}}*/
diff --git a/debian/changelog b/debian/changelog
index dc331dc55..558677345 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,7 @@ apt (0.9.3) unstable; urgency=low
* apt-pkg/contrib/configuration.cc:
- add a more versatile Dump() method
- normalize a bit by replacing // and /./ with / in FindFile
+ - /dev/null is a special absolute path as it has no subdirectories
* apt-pkg/acquire-worker.cc:
- use Dump() to generate the configuration message for sending
* cmdline/apt-config.cc:
@@ -21,7 +22,7 @@ apt (0.9.3) unstable; urgency=low
- check with RealFileExists for scenario file as otherwise a directory
like one provided with RootDir triggers the usage of EDSP
- -- David Kalnischkies Mon, 23 Apr 2012 19:10:13 +0200
+ -- David Kalnischkies Mon, 23 Apr 2012 19:32:29 +0200
apt (0.9.2) unstable; urgency=low
diff --git a/test/libapt/configuration_test.cc b/test/libapt/configuration_test.cc
index 6b657a70c..87d5699ef 100644
--- a/test/libapt/configuration_test.cc
+++ b/test/libapt/configuration_test.cc
@@ -93,6 +93,11 @@ int main(int argc,const char *argv[]) {
equals(Cnf.FindFile("Dir::State"), "/rootdir/srv/sid/var/lib/apt");
equals(Cnf.FindFile("Dir::Aptitude::State"), "/rootdir/srv/sid/var/lib/aptitude");
+ Cnf.Set("Dir::State", "/dev/null");
+ Cnf.Set("Dir::State::lists", "lists/");
+ equals(Cnf.FindDir("Dir::State"), "/rootdir/dev/null");
+ equals(Cnf.FindDir("Dir::State::lists"), "/rootdir/dev/null");
+
//FIXME: Test for configuration file parsing;
// currently only integration/ tests test them implicitly
--
cgit v1.2.3-70-g09d2
From 9a4ffe576267539ae5549f0c77cc8ab37c2516fb Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Wed, 2 May 2012 23:13:26 +0200
Subject: add a simple test for HashSumValue classes
---
test/libapt/hashsums_test.cc | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
(limited to 'test')
diff --git a/test/libapt/hashsums_test.cc b/test/libapt/hashsums_test.cc
index 396e4cf6b..e2d0aec5b 100644
--- a/test/libapt/hashsums_test.cc
+++ b/test/libapt/hashsums_test.cc
@@ -42,6 +42,28 @@ template void TestMill(const char *Out)
int main(int argc, char** argv)
{
+ // test HashSumValue which doesn't calculate but just stores sums
+ {
+ string md5sum = argv[2];
+ MD5SumValue md5(md5sum);
+ equals(md5.Value(), md5sum);
+ }
+ {
+ string sha1sum = argv[3];
+ SHA1SumValue sha1(sha1sum);
+ equals(sha1.Value(), sha1sum);
+ }
+ {
+ string sha2sum = argv[4];
+ SHA256SumValue sha2(sha2sum);
+ equals(sha2.Value(), sha2sum);
+ }
+ {
+ string sha2sum = argv[5];
+ SHA512SumValue sha2(sha2sum);
+ equals(sha2.Value(), sha2sum);
+ }
+
// From FIPS PUB 180-1
Test("","da39a3ee5e6b4b0d3255bfef95601890afd80709");
Test("abc","a9993e364706816aba3e25717850c26c9cd0d89d");
--
cgit v1.2.3-70-g09d2
From 3fa950f16cb2997bccd97475f75c5f3e37609dd3 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Thu, 10 May 2012 18:47:51 +0200
Subject: add a small wrapper to call gdb in the framework setting
---
test/integration/framework | 4 ++++
1 file changed, 4 insertions(+)
(limited to 'test')
diff --git a/test/integration/framework b/test/integration/framework
index b80b02922..5a0e1070f 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -107,6 +107,10 @@ aptitude() {
LD_LIBRARY_PATH=${BUILDDIRECTORY} $(which aptitude) $*
fi
}
+gdb() {
+ echo "gdb: run »$*«"
+ APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $(which gdb) ${BUILDDIRECTORY}/$1
+}
addtrap() {
CURRENTTRAP="$CURRENTTRAP $1"
--
cgit v1.2.3-70-g09d2
From e4bc41c765f2b9fec55faa747e8330130c987678 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Mon, 14 May 2012 14:39:15 +0200
Subject: - separate manpages from the rest of the doc building - make apt
and apt-utils packages depend on manpages instead of full doc
---
Makefile | 4 ++--
buildlib/defaults.mak | 2 +-
buildlib/manpage.mak | 3 ++-
debian/changelog | 2 ++
debian/rules | 14 ++++++++++----
doc/makefile | 26 ++++++++++++++++++--------
test/Makefile | 2 +-
7 files changed, 36 insertions(+), 17 deletions(-)
(limited to 'test')
diff --git a/Makefile b/Makefile
index a35ad1d37..24f5b3e2b 100644
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,7 @@ endif
default: startup all
.PHONY: headers library clean veryclean all binary program doc test update-po
-all headers library clean veryclean binary program doc test update-po startup dirs:
+all headers library clean veryclean binary program doc manpages test update-po startup dirs:
$(MAKE) -C apt-pkg $@
$(MAKE) -C apt-inst $@
$(MAKE) -C methods $@
@@ -21,7 +21,7 @@ all headers library clean veryclean binary program doc test update-po startup di
$(MAKE) -C po $@
$(MAKE) -C test $@
-all headers library clean veryclean binary program doc test update-po: startup dirs
+all headers library clean veryclean binary program doc manpages test update-po: startup dirs
dirs: startup
diff --git a/buildlib/defaults.mak b/buildlib/defaults.mak
index c10813e9d..7b084f4b9 100644
--- a/buildlib/defaults.mak
+++ b/buildlib/defaults.mak
@@ -121,7 +121,7 @@ MKDIRS := $(BIN)
all: dirs binary doc
binary: library program
maintainer-clean dist-clean distclean pristine sanity: veryclean
-startup headers library clean veryclean program test update-po:
+startup headers library clean veryclean program test update-po manpages:
veryclean:
echo Very Clean done for $(SUBDIR)
diff --git a/buildlib/manpage.mak b/buildlib/manpage.mak
index 6cdf73ccf..063841d86 100644
--- a/buildlib/manpage.mak
+++ b/buildlib/manpage.mak
@@ -14,7 +14,8 @@ LOCAL := manpage-$(firstword $(SOURCE))
$(LOCAL)-LIST := $(addprefix $(DOC)/,$(SOURCE))
# Install generation hooks
-doc: $($(LOCAL)-LIST)
+doc: manpages
+manpages: $($(LOCAL)-LIST)
veryclean: veryclean/$(LOCAL)
MKDIRS += $(DOC)
diff --git a/debian/changelog b/debian/changelog
index 12097ca6f..3de297513 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,10 +6,12 @@ apt (0.9.4) UNRELEASED; urgency=low
as we don't need a symbol for it as it is not in a header
* Makefile, buildlib/*.mak:
- reshuffle dependencies so that parallel building seems to work
+ - separate manpages from the rest of the doc building
* prepare-release:
- apt-inst version isn't apt versions, so don't override variable
* debian/rules:
- apt-utils packages manpages, so it should depend on build-doc
+ - make apt and apt-utils packages depend on manpages instead of full doc
-- David Kalnischkies Fri, 11 May 2012 23:26:59 +0200
diff --git a/debian/rules b/debian/rules
index fcdff9d01..7b221fc2a 100755
--- a/debian/rules
+++ b/debian/rules
@@ -67,7 +67,8 @@ LIBAPT_INST=libapt-inst$(LIBAPTINST_MAJOR)
export DPKG_GENSYMBOLS_CHECK_LEVEL=0
build: build/build-stamp
-build-doc: build/build-doc-stamp
+build-doc: build-manpages build/build-doc-stamp
+build-manpages: build/build-manpages-stamp
# Note that this is unconditionally done first as part of loading environment.mak
# The true is needed to force make to reload environment.mak after running
@@ -97,11 +98,16 @@ else
endif
touch $@
-build/build-doc-stamp: build/configure-stamp
+build/build-doc-stamp: build/build-manpages-stamp build/configure-stamp
# Add here commands to compile the package.
$(MAKE) doc
touch $@
+build/build-manpages-stamp: build/configure-stamp
+ # Add here commands to compile the package.
+ $(MAKE) manpages
+ touch $@
+
clean:
dh_testdir
@@ -167,7 +173,7 @@ apt-doc: build-doc
binary-arch: $(LIBAPT_PKG) $(LIBAPT_INST) apt libapt-pkg-dev apt-utils apt-transport-https
apt_MANPAGES = apt-cache apt-cdrom apt-config apt-get apt-key apt-mark apt-secure apt apt.conf apt_preferences sources.list
-apt: build build-doc
+apt: build build-manpages
dh_testdir -p$@
dh_testroot -p$@
dh_prep -p$@
@@ -231,7 +237,7 @@ libapt-pkg-dev: build debian/libapt-pkg-dev.install
dh_builddeb -p$@
apt-utils_MANPAGES = apt-sortpkgs apt-ftparchive apt-extracttemplates
-apt-utils: build build-doc
+apt-utils: build build-manpages
dh_testdir -p$@
dh_testroot -p$@
dh_prep -p$@
diff --git a/doc/makefile b/doc/makefile
index df2ddb25f..f52586935 100644
--- a/doc/makefile
+++ b/doc/makefile
@@ -11,6 +11,11 @@ SOURCE = $(wildcard *.sgml)
DEBIANDOC_HTML_OPTIONS=-l en.UTF-8
include $(DEBIANDOC_H)
+MANPAGEPO = $(patsubst %.po,%,$(notdir $(wildcard po/*.po)))
+MANPAGEPOLIST = $(patsubst %,manpages-translation-%,$(MANPAGEPO))
+
+doc: manpages
+
# Do not use XMLTO, build the manpages directly with XSLTPROC
ifdef XSLTPROC
# generate a list of accepted man page translations
@@ -22,15 +27,26 @@ LOCAL := manpage-$(firstword $(SOURCE))
$(LOCAL)-LIST := $(SOURCE)
# Install generation hooks
-doc: $($(LOCAL)-LIST)
-veryclean: veryclean/$(LOCAL)
+manpages: $(MANPAGEPOLIST) $($(LOCAL)-LIST)
$($(LOCAL)-LIST) :: % : %.xml $(INCLUDES)
echo Creating man page $@
$(XSLTPROC) -o $@ $(STYLESHEET) $<
+$(MANPAGEPOLIST) :: manpages-translation-% : %/makefile po4a
+ $(MAKE) -C $(dir $<) doc
+
+.PHONY: manpages dirs-manpage-subdirs $(MANPAGEPOLIST)
+dirs: dirs-manpage-subdirs
+dirs-manpage-subdirs:
+ for i in $(MANPAGEPO); do \
+ test -d $$i || mkdir $$i; \
+ test -f $$i/makefile || sed "s#@@LANG@@#$$i#" lang.makefile > $$i/makefile; \
+ done
+
# Clean rule
.PHONY: veryclean/$(LOCAL)
+veryclean: veryclean/$(LOCAL)
veryclean/$(LOCAL):
-rm -rf $($(@F)-LIST)
@@ -47,12 +63,6 @@ TARGET = binary
include $(COPY_H)
.PHONY: clean clean-subdirs veryclean veryclean-subdirs all binary doc
-doc:
- for i in $(shell ls po/*.po | sed -r 's#po/([a-z]+[A-Z_]*).po#\1#'); do \
- test -d $$i || mkdir $$i; \
- test -f $$i/makefile || sed "s#@@LANG@@#$$i#" lang.makefile > $$i/makefile; \
- $(MAKE) -C $$i $@; \
- done
clean: clean-subdirs
veryclean: veryclean-subdirs
diff --git a/test/Makefile b/test/Makefile
index b42a90b25..8207ebdab 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -7,7 +7,7 @@ ifndef NOISY
endif
.PHONY: startup headers library clean veryclean all binary program doc test update-po
-startup all clean veryclean binary program dirs test update-po:
+startup all clean veryclean binary program dirs test update-po manpages:
$(MAKE) -C libapt $@
$(MAKE) -C interactive-helper $@
--
cgit v1.2.3-70-g09d2
From 57194e03a40d2ff323588acb8353eef2b881e5b2 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Mon, 14 May 2012 18:07:34 +0200
Subject: adapt manual testcase to check redirects of dists/, too
---
test/integration/skip-bug-602412-dequote-redirect | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
(limited to 'test')
diff --git a/test/integration/skip-bug-602412-dequote-redirect b/test/integration/skip-bug-602412-dequote-redirect
index a63d36246..689b671ce 100755
--- a/test/integration/skip-bug-602412-dequote-redirect
+++ b/test/integration/skip-bug-602412-dequote-redirect
@@ -19,18 +19,20 @@ echo "server.modules = ( \"mod_redirect\" )
server.document-root = \"$(readlink -f ./aptarchive)\"
server.port = 8080
server.stat-cache-engine = \"disable\"
-url.redirect = ( \"^/pool/(.*)$\" => \"/newpool/\$1\" )" > lighttpd.conf
+url.redirect = ( \"^/pool/(.*)$\" => \"/newpool/\$1\",
+ \"^/dists/(.*)$\" => \"/newdists/\$1\" )" > lighttpd.conf
mv aptarchive/pool aptarchive/newpool
+mv aptarchive/dists aptarchive/newdists
+
lighttpd -t -f lighttpd.conf >/dev/null || msgdie 'Can not change to webserver: our lighttpd config is invalid'
lighttpd -D -f lighttpd.conf 2>/dev/null >/dev/null &
addtrap "kill $!;"
-local APTARCHIVE="file://$(readlink -f ./aptarchive)"
+APTARCHIVE="file://$(readlink -f ./aptarchive)"
for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
sed -i $LIST -e "s#$APTARCHIVE#http://localhost:8080/#"
done
-aptget update -qq || msgdie 'apt-get update failed'
-aptget install unrelated --download-only -qq || msgdie 'downloading package failed'
-
+aptget update || msgdie 'apt-get update failed'
+aptget install unrelated --download-only || msgdie 'downloading package failed'
--
cgit v1.2.3-70-g09d2
From 65f9983436be310c768c4c42531ceea1e3a6d4ac Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Wed, 16 May 2012 16:44:15 +0200
Subject: * cmdline/apt-get.cc: - use the host architecture, not the build
architecture for matching of [architecture restrictions] in Build-Depends
(Closes: #672927) *
---
apt-pkg/srcrecords.h | 1 +
cmdline/apt-get.cc | 14 ++++-
debian/changelog | 6 ++
.../test-bug-632221-cross-dependency-satisfaction | 66 ++++++++++++++--------
4 files changed, 61 insertions(+), 26 deletions(-)
(limited to 'test')
diff --git a/apt-pkg/srcrecords.h b/apt-pkg/srcrecords.h
index 06f0dce6c..ed69d0d72 100644
--- a/apt-pkg/srcrecords.h
+++ b/apt-pkg/srcrecords.h
@@ -71,6 +71,7 @@ class pkgSrcRecords
virtual std::string Section() const = 0;
virtual const char **Binaries() = 0; // Ownership does not transfer
+ //FIXME: Add a parameter to specify which architecture to use for [wildcard] matching
virtual bool BuildDepends(std::vector &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) = 0;
static const char *BuildDepType(unsigned char const &Type);
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index dd9313bff..c996017b8 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -2789,8 +2789,18 @@ bool DoBuildDep(CommandLine &CmdL)
// Process the build-dependencies
vector BuildDeps;
- if (Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only", false), StripMultiArch) == false)
- return _error->Error(_("Unable to get build-dependency information for %s"),Src.c_str());
+ // FIXME: Can't specify architecture to use for [wildcard] matching, so switch default arch temporary
+ if (hostArch.empty() == false)
+ {
+ std::string nativeArch = _config->Find("APT::Architecture");
+ _config->Set("APT::Architecture", hostArch);
+ bool Success = Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only", false), StripMultiArch);
+ _config->Set("APT::Architecture", nativeArch);
+ if (Success == false)
+ return _error->Error(_("Unable to get build-dependency information for %s"),Src.c_str());
+ }
+ else if (Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only", false), StripMultiArch) == false)
+ return _error->Error(_("Unable to get build-dependency information for %s"),Src.c_str());
// Also ensure that build-essential packages are present
Configuration::Item const *Opts = _config->Tree("APT::Build-Essential");
diff --git a/debian/changelog b/debian/changelog
index 922c0720b..64af5bf60 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -24,6 +24,9 @@ apt (0.9.4) UNRELEASED; urgency=low
* apt-pkg/contrib/fileutl.cc:
- ensure that we close compressed fds, wait for forks and such even if
the FileFd itself is set to not autoclose the given Fd
+ * cmdline/apt-get.cc:
+ - use the host architecture, not the build architecture for matching
+ of [architecture restrictions] in Build-Depends (Closes: #672927)
[ Raphael Geissert ]
* apt-pkg/acquire*.cc:
@@ -39,6 +42,9 @@ apt (0.9.4) UNRELEASED; urgency=low
* apt-pkg/algorithms.cc:
- fix memory leak of Flags in pkgSimulate by a proper destructor
+ [ David Kalnischkies ]
+ *
+
-- David Kalnischkies Fri, 11 May 2012 23:26:59 +0200
apt (0.9.3) unstable; urgency=low
diff --git a/test/integration/test-bug-632221-cross-dependency-satisfaction b/test/integration/test-bug-632221-cross-dependency-satisfaction
index 30df48604..a128366c5 100755
--- a/test/integration/test-bug-632221-cross-dependency-satisfaction
+++ b/test/integration/test-bug-632221-cross-dependency-satisfaction
@@ -18,8 +18,10 @@ insertpackage 'unstable' 'libfwibble-dev' 'amd64,armel' '1.0' 'Depends: libfwibb
insertpackage 'unstable' 'cool' 'amd64,armel' '1.0' 'Multi-Arch: allowed'
insertpackage 'unstable' 'amdboot' 'amd64' '1.0'
insertpackage 'unstable' 'foreigner' 'amd64,armel' '1.0' 'Multi-Arch: foreign'
+insertpackage 'unstable' 'arm-stuff' 'armel' '1.0'
+insertpackage 'unstable' 'linux-stuff' 'amd64,armel' '1.0'
-insertsource 'unstable' 'apt' 'any' '0.8.15' 'Build-Depends: doxygen, libc6-dev, libc6-dev:native, cool:any, amdboot:amd64, foreigner, libfwibble-dev'
+insertsource 'unstable' 'apt' 'any' '0.8.15' 'Build-Depends: doxygen, libc6-dev, libc6-dev:native, cool:any, amdboot:amd64, foreigner, libfwibble-dev, arm-stuff [any-arm] | linux-stuff [ linux-any]'
setupaptarchive
@@ -27,7 +29,8 @@ testequal 'Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
amdboot cool doxygen foreigner libc6 libc6-dev libfwibble-dev libfwibble1
-0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
+ linux-stuff
+0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Inst amdboot (1.0 unstable [amd64])
Inst cool (1.0 unstable [amd64])
Inst doxygen (1.0 unstable [amd64])
@@ -36,6 +39,7 @@ Inst libc6 (1.0 unstable [amd64])
Inst libc6-dev (1.0 unstable [amd64])
Inst libfwibble1 (1.0 unstable [amd64])
Inst libfwibble-dev (1.0 unstable [amd64])
+Inst linux-stuff (1.0 unstable [amd64])
Conf amdboot (1.0 unstable [amd64])
Conf cool (1.0 unstable [amd64])
Conf doxygen (1.0 unstable [amd64])
@@ -43,15 +47,17 @@ Conf foreigner (1.0 unstable [amd64])
Conf libc6 (1.0 unstable [amd64])
Conf libc6-dev (1.0 unstable [amd64])
Conf libfwibble1 (1.0 unstable [amd64])
-Conf libfwibble-dev (1.0 unstable [amd64])' aptget build-dep apt -s
+Conf libfwibble-dev (1.0 unstable [amd64])
+Conf linux-stuff (1.0 unstable [amd64])' aptget build-dep apt -s
testequal 'Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
- amdboot cool doxygen foreigner libc6 libc6:armel libc6-dev libc6-dev:armel
- libfwibble-dev:armel libfwibble1:armel
-0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
+ amdboot arm-stuff:armel cool doxygen foreigner libc6 libc6:armel libc6-dev
+ libc6-dev:armel libfwibble-dev:armel libfwibble1:armel
+0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Inst amdboot (1.0 unstable [amd64])
+Inst arm-stuff:armel (1.0 unstable [armel])
Inst cool (1.0 unstable [amd64])
Inst doxygen (1.0 unstable [amd64])
Inst foreigner (1.0 unstable [amd64])
@@ -62,6 +68,7 @@ Inst libc6-dev:armel (1.0 unstable [armel])
Inst libfwibble1:armel (1.0 unstable [armel])
Inst libfwibble-dev:armel (1.0 unstable [armel])
Conf amdboot (1.0 unstable [amd64])
+Conf arm-stuff:armel (1.0 unstable [armel])
Conf cool (1.0 unstable [amd64])
Conf doxygen (1.0 unstable [amd64])
Conf foreigner (1.0 unstable [amd64])
@@ -77,10 +84,11 @@ configarchitecture 'armel' 'amd64'
testequal 'Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
- amdboot:amd64 cool doxygen foreigner libc6 libc6-dev libfwibble-dev
- libfwibble1
-0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
+ amdboot:amd64 arm-stuff cool doxygen foreigner libc6 libc6-dev
+ libfwibble-dev libfwibble1
+0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Inst amdboot:amd64 (1.0 unstable [amd64])
+Inst arm-stuff (1.0 unstable [armel])
Inst cool (1.0 unstable [armel])
Inst doxygen (1.0 unstable [armel])
Inst foreigner (1.0 unstable [armel])
@@ -89,6 +97,7 @@ Inst libc6-dev (1.0 unstable [armel])
Inst libfwibble1 (1.0 unstable [armel])
Inst libfwibble-dev (1.0 unstable [armel])
Conf amdboot:amd64 (1.0 unstable [amd64])
+Conf arm-stuff (1.0 unstable [armel])
Conf cool (1.0 unstable [armel])
Conf doxygen (1.0 unstable [armel])
Conf foreigner (1.0 unstable [armel])
@@ -101,8 +110,8 @@ testequal 'Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
amdboot:amd64 cool doxygen foreigner libc6:amd64 libc6 libc6-dev:amd64
- libc6-dev libfwibble-dev:amd64 libfwibble1:amd64
-0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
+ libc6-dev libfwibble-dev:amd64 libfwibble1:amd64 linux-stuff:amd64
+0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Inst amdboot:amd64 (1.0 unstable [amd64])
Inst cool (1.0 unstable [armel])
Inst doxygen (1.0 unstable [armel])
@@ -113,6 +122,7 @@ Inst libc6-dev:amd64 (1.0 unstable [amd64])
Inst libc6-dev (1.0 unstable [armel])
Inst libfwibble1:amd64 (1.0 unstable [amd64])
Inst libfwibble-dev:amd64 (1.0 unstable [amd64])
+Inst linux-stuff:amd64 (1.0 unstable [amd64])
Conf amdboot:amd64 (1.0 unstable [amd64])
Conf cool (1.0 unstable [armel])
Conf doxygen (1.0 unstable [armel])
@@ -122,7 +132,8 @@ Conf libc6 (1.0 unstable [armel])
Conf libc6-dev:amd64 (1.0 unstable [amd64])
Conf libc6-dev (1.0 unstable [armel])
Conf libfwibble1:amd64 (1.0 unstable [amd64])
-Conf libfwibble-dev:amd64 (1.0 unstable [amd64])' aptget build-dep apt -s -a amd64
+Conf libfwibble-dev:amd64 (1.0 unstable [amd64])
+Conf linux-stuff:amd64 (1.0 unstable [amd64])' aptget build-dep apt -s -a amd64
configarchitecture 'amd64' 'armel'
@@ -132,28 +143,31 @@ insertinstalledpackage 'foreigner' 'armel' '0.5'
testequal 'Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
- amdboot doxygen libc6 libc6-dev libfwibble-dev libfwibble1
-0 upgraded, 6 newly installed, 0 to remove and 2 not upgraded.
+ amdboot doxygen libc6 libc6-dev libfwibble-dev libfwibble1 linux-stuff
+0 upgraded, 7 newly installed, 0 to remove and 2 not upgraded.
Inst amdboot (1.0 unstable [amd64])
Inst doxygen (1.0 unstable [amd64])
Inst libc6 (1.0 unstable [amd64])
Inst libc6-dev (1.0 unstable [amd64])
Inst libfwibble1 (1.0 unstable [amd64])
Inst libfwibble-dev (1.0 unstable [amd64])
+Inst linux-stuff (1.0 unstable [amd64])
Conf amdboot (1.0 unstable [amd64])
Conf doxygen (1.0 unstable [amd64])
Conf libc6 (1.0 unstable [amd64])
Conf libc6-dev (1.0 unstable [amd64])
Conf libfwibble1 (1.0 unstable [amd64])
-Conf libfwibble-dev (1.0 unstable [amd64])' aptget build-dep apt -s
+Conf libfwibble-dev (1.0 unstable [amd64])
+Conf linux-stuff (1.0 unstable [amd64])' aptget build-dep apt -s
testequal 'Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
- amdboot doxygen libc6 libc6:armel libc6-dev libc6-dev:armel
+ amdboot arm-stuff:armel doxygen libc6 libc6:armel libc6-dev libc6-dev:armel
libfwibble-dev:armel libfwibble1:armel
-0 upgraded, 8 newly installed, 0 to remove and 2 not upgraded.
+0 upgraded, 9 newly installed, 0 to remove and 2 not upgraded.
Inst amdboot (1.0 unstable [amd64])
+Inst arm-stuff:armel (1.0 unstable [armel])
Inst doxygen (1.0 unstable [amd64])
Inst libc6 (1.0 unstable [amd64])
Inst libc6:armel (1.0 unstable [armel])
@@ -162,6 +176,7 @@ Inst libc6-dev:armel (1.0 unstable [armel])
Inst libfwibble1:armel (1.0 unstable [armel])
Inst libfwibble-dev:armel (1.0 unstable [armel])
Conf amdboot (1.0 unstable [amd64])
+Conf arm-stuff:armel (1.0 unstable [armel])
Conf doxygen (1.0 unstable [amd64])
Conf libc6 (1.0 unstable [amd64])
Conf libc6:armel (1.0 unstable [armel])
@@ -178,10 +193,12 @@ Building dependency tree...
The following packages will be REMOVED:
cool:amd64
The following NEW packages will be installed:
- amdboot:amd64 cool doxygen libc6 libc6-dev libfwibble-dev libfwibble1
-0 upgraded, 7 newly installed, 1 to remove and 1 not upgraded.
+ amdboot:amd64 arm-stuff cool doxygen libc6 libc6-dev libfwibble-dev
+ libfwibble1
+0 upgraded, 8 newly installed, 1 to remove and 1 not upgraded.
Remv cool:amd64 [0.5]
Inst amdboot:amd64 (1.0 unstable [amd64])
+Inst arm-stuff (1.0 unstable [armel])
Inst cool (1.0 unstable [armel])
Inst doxygen (1.0 unstable [armel])
Inst libc6 (1.0 unstable [armel])
@@ -189,6 +206,7 @@ Inst libc6-dev (1.0 unstable [armel])
Inst libfwibble1 (1.0 unstable [armel])
Inst libfwibble-dev (1.0 unstable [armel])
Conf amdboot:amd64 (1.0 unstable [amd64])
+Conf arm-stuff (1.0 unstable [armel])
Conf cool (1.0 unstable [armel])
Conf doxygen (1.0 unstable [armel])
Conf libc6 (1.0 unstable [armel])
@@ -200,8 +218,8 @@ testequal 'Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
amdboot:amd64 doxygen libc6:amd64 libc6 libc6-dev:amd64 libc6-dev
- libfwibble-dev:amd64 libfwibble1:amd64
-0 upgraded, 8 newly installed, 0 to remove and 2 not upgraded.
+ libfwibble-dev:amd64 libfwibble1:amd64 linux-stuff:amd64
+0 upgraded, 9 newly installed, 0 to remove and 2 not upgraded.
Inst amdboot:amd64 (1.0 unstable [amd64])
Inst doxygen (1.0 unstable [armel])
Inst libc6:amd64 (1.0 unstable [amd64])
@@ -210,6 +228,7 @@ Inst libc6-dev:amd64 (1.0 unstable [amd64])
Inst libc6-dev (1.0 unstable [armel])
Inst libfwibble1:amd64 (1.0 unstable [amd64])
Inst libfwibble-dev:amd64 (1.0 unstable [amd64])
+Inst linux-stuff:amd64 (1.0 unstable [amd64])
Conf amdboot:amd64 (1.0 unstable [amd64])
Conf doxygen (1.0 unstable [armel])
Conf libc6:amd64 (1.0 unstable [amd64])
@@ -217,6 +236,5 @@ Conf libc6 (1.0 unstable [armel])
Conf libc6-dev:amd64 (1.0 unstable [amd64])
Conf libc6-dev (1.0 unstable [armel])
Conf libfwibble1:amd64 (1.0 unstable [amd64])
-Conf libfwibble-dev:amd64 (1.0 unstable [amd64])' aptget build-dep apt -s -a amd64
-
-
+Conf libfwibble-dev:amd64 (1.0 unstable [amd64])
+Conf linux-stuff:amd64 (1.0 unstable [amd64])' aptget build-dep apt -s -a amd64
--
cgit v1.2.3-70-g09d2
From 177645edb5775337ccf6d3971835a122b12318d4 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Sat, 19 May 2012 23:07:30 +0200
Subject: * apt-pkg/packagemanager.cc: - do not run into loop on
new-pre-depends-breaks (Closes: #673536)
---
apt-pkg/packagemanager.cc | 2 +-
debian/changelog | 2 ++
.../test-673536-pre-depends-breaks-loop | 23 ++++++++++++++++++++++
3 files changed, 26 insertions(+), 1 deletion(-)
create mode 100755 test/integration/test-673536-pre-depends-breaks-loop
(limited to 'test')
diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index 06151a165..46fc499c6 100644
--- a/apt-pkg/packagemanager.cc
+++ b/apt-pkg/packagemanager.cc
@@ -785,7 +785,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
VerIterator V(Cache,*I);
PkgIterator P = V.ParentPkg();
// we are checking for installation as an easy 'protection' against or-groups and (unchosen) providers
- if (P->CurrentVer == 0 || P != Pkg || (P.CurrentVer() != V && Cache[P].InstallVer != V))
+ if (P != Pkg || (P.CurrentVer() != V && Cache[P].InstallVer != V))
continue;
circle = true;
break;
diff --git a/debian/changelog b/debian/changelog
index d419f9986..196b94c8e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -33,6 +33,8 @@ apt (0.9.4) UNRELEASED; urgency=low
to get the correct section titles provided by docbook
* doc/po/de.po:
- updated german manpage translation by Chris Leick, thanks!
+ * apt-pkg/packagemanager.cc:
+ - do not run into loop on new-pre-depends-breaks (Closes: #673536)
[ Raphael Geissert ]
* apt-pkg/acquire*.cc:
diff --git a/test/integration/test-673536-pre-depends-breaks-loop b/test/integration/test-673536-pre-depends-breaks-loop
new file mode 100755
index 000000000..e9d3c4de6
--- /dev/null
+++ b/test/integration/test-673536-pre-depends-breaks-loop
@@ -0,0 +1,23 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'native'
+
+buildsimplenativepackage 'basic' 'native' '1' 'stable'
+buildsimplenativepackage 'basic' 'native' '2' 'unstable' 'Pre-Depends: common'
+buildsimplenativepackage 'common' 'native' '2' 'unstable' 'Breaks: basic (<= 1)'
+
+setupaptarchive
+
+# we check with 'real' packages here as the simulation reports a 'Conf broken'
+# which is technical correct for the simulation, but testing errormsg is ugly
+
+aptget install basic=1 -qq > /dev/null
+testdpkginstalled basic
+testdpkgnotinstalled common
+
+aptget dist-upgrade -qq > /dev/null
+testdpkginstalled basic common
--
cgit v1.2.3-70-g09d2
From 527df5a20dbe8ce98fcbf1ffe28bb37ff2257a97 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Sun, 20 May 2012 18:58:37 +0200
Subject: * apt-pkg/aptconfiguration.cc: - longcode Translation files are
saved with encoded underscore, so make sure to pick these files up as
well for Acquire::Languages
---
apt-pkg/aptconfiguration.cc | 2 +-
debian/changelog | 3 +++
test/libapt/assert.h | 21 +++++++++++++++++++++
test/libapt/getlanguages_test.cc | 15 +++++++++++----
test/libapt/run-tests | 3 ++-
5 files changed, 38 insertions(+), 6 deletions(-)
(limited to 'test')
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc
index 0fd470ed5..d763546f8 100644
--- a/apt-pkg/aptconfiguration.cc
+++ b/apt-pkg/aptconfiguration.cc
@@ -144,7 +144,7 @@ std::vector const Configuration::getLanguages(bool const &All,
if (D != 0) {
builtin.push_back("none");
for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D)) {
- string const name = Ent->d_name;
+ string const name = SubstVar(Ent->d_name, "%5f", "_");
size_t const foundDash = name.rfind("-");
size_t const foundUnderscore = name.rfind("_", foundDash);
if (foundDash == string::npos || foundUnderscore == string::npos ||
diff --git a/debian/changelog b/debian/changelog
index c4bf881ca..5d4f8720c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -38,6 +38,9 @@ apt (0.9.4) UNRELEASED; urgency=low
* doc/*.xml:
- add a few translator notes and reword some paragraphs to ensure that
translators and users alike can better understand them (Closes: #669409)
+ * apt-pkg/aptconfiguration.cc:
+ - longcode Translation files are saved with encoded underscore,
+ so make sure to pick these files up as well for Acquire::Languages
[ Raphael Geissert ]
* apt-pkg/acquire*.cc:
diff --git a/test/libapt/assert.h b/test/libapt/assert.h
index a07be4b57..fdf6740c6 100644
--- a/test/libapt/assert.h
+++ b/test/libapt/assert.h
@@ -1,6 +1,7 @@
#include
#define equals(x,y) assertEquals(y, x, __LINE__)
+#define equalsNot(x,y) assertEqualsNot(y, x, __LINE__)
template < typename X, typename Y >
void OutputAssertEqual(X expect, char const* compare, Y get, unsigned long const &line) {
@@ -14,6 +15,13 @@ void assertEquals(X expect, Y get, unsigned long const &line) {
OutputAssertEqual(expect, "==", get, line);
}
+template < typename X, typename Y >
+void assertEqualsNot(X expect, Y get, unsigned long const &line) {
+ if (expect != get)
+ return;
+ OutputAssertEqual(expect, "!=", get, line);
+}
+
void assertEquals(unsigned int const &expect, int const &get, unsigned long const &line) {
if (get < 0)
OutputAssertEqual(expect, "==", get, line);
@@ -80,6 +88,19 @@ void assertEqualsOr3(X expect1, X expect2, X expect3, Y get, unsigned long const
OutputAssertEqualOr3(expect1, expect2, expect3, "==", get, line);
}
+#define equalsOr4(v,w,x,y,z) assertEqualsOr4(w, x, y, z, v, __LINE__)
+
+template < typename X, typename Y >
+void OutputAssertEqualOr4(X expect1, X expect2, X expect3, X expect4, char const* compare, Y get, unsigned long const &line) {
+ std::cerr << "Test FAILED: »" << expect1 << "« or »" << expect2 << "« or »" << expect3 << "« or »" << expect4 << "« " << compare << " »" << get << "« at line " << line << std::endl;
+}
+
+template < typename X, typename Y >
+void assertEqualsOr4(X expect1, X expect2, X expect3, X expect4, Y get, unsigned long const &line) {
+ if (expect1 == get || expect2 == get || expect3 == get || expect4 == get)
+ return;
+ OutputAssertEqualOr4(expect1, expect2, expect3, expect4, "==", get, line);
+}
// simple helper to quickly output a vectors
template < typename X >
diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc
index a1c801ea2..274cf4aa4 100644
--- a/test/libapt/getlanguages_test.cc
+++ b/test/libapt/getlanguages_test.cc
@@ -126,14 +126,21 @@ int main(int argc,char *argv[])
_config->Set("Dir::State::lists", argv[1]);
vec = APT::Configuration::getLanguages(true, false, env);
- equals(vec.size(), 7);
+ equals(vec.size(), 8);
equals(vec[0], "de_DE");
equals(vec[1], "de");
equals(vec[2], "en");
equals(vec[3], "none");
- equalsOr3(vec[4], "pt", "tr", "ast_DE");
- equalsOr3(vec[5], "tr", "pt", "ast_DE");
- equalsOr3(vec[6], "tr", "pt", "ast_DE");
+ equalsOr4(vec[4], "pt", "tr", "ast_DE", "tlh_DE");
+ equalsOr4(vec[5], "tr", "pt", "ast_DE", "tlh_DE");
+ equalsOr4(vec[6], "tr", "pt", "ast_DE", "tlh_DE");
+ equalsOr4(vec[7], "tr", "pt", "ast_DE", "tlh_DE");
+ equalsNot(vec[4], vec[5]);
+ equalsNot(vec[4], vec[6]);
+ equalsNot(vec[4], vec[7]);
+ equalsNot(vec[5], vec[6]);
+ equalsNot(vec[5], vec[7]);
+ equalsNot(vec[6], vec[7]);
_config->Set("Acquire::Languages", "none");
vec = APT::Configuration::getLanguages(true, false, env);
diff --git a/test/libapt/run-tests b/test/libapt/run-tests
index 4ea9a916d..45a3157f7 100755
--- a/test/libapt/run-tests
+++ b/test/libapt/run-tests
@@ -65,7 +65,8 @@ do
"${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-pt" \
"${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-se~" \
"${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-st.bak" \
- "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-ast_DE"
+ "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-ast_DE" \
+ "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tlh%5fDE"
elif [ $name = "HashSums${EXT}" ]; then
TMP="$(readlink -f "./${0}")"
echo -n "Testing with ${NAME} "
--
cgit v1.2.3-70-g09d2
From ae2be086c6996e6ed02b7d828fdcac38248a964d Mon Sep 17 00:00:00 2001
From: Daniel Hartwig
Date: Sat, 9 Jun 2012 22:49:37 +0200
Subject: * apt-pkg/contrib/cmdline.cc: - apply patch from Daniel Hartwig to
fix a segfault in case the LongOpt is empty (Closes: #676331)
---
apt-pkg/contrib/cmndline.cc | 5 +++--
debian/changelog | 3 +++
test/libapt/commandline_test.cc | 21 +++++++++++++++++++++
test/libapt/makefile | 6 ++++++
4 files changed, 33 insertions(+), 2 deletions(-)
create mode 100644 test/libapt/commandline_test.cc
(limited to 'test')
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index 159f330a1..b8c7f7984 100644
--- a/apt-pkg/contrib/cmndline.cc
+++ b/apt-pkg/contrib/cmndline.cc
@@ -92,8 +92,9 @@ bool CommandLine::Parse(int argc,const char **argv)
// Match up to a = against the list
Args *A;
const char *OptEnd = strchrnul(Opt, '=');
- for (A = ArgList; A->end() == false &&
- stringcasecmp(Opt,OptEnd,A->LongOpt) != 0; A++);
+ for (A = ArgList; A->end() == false &&
+ (A->LongOpt == 0 || stringcasecmp(Opt,OptEnd,A->LongOpt) != 0);
+ ++A);
// Failed, look for a word after the first - (no-foo)
bool PreceedMatch = false;
diff --git a/debian/changelog b/debian/changelog
index 9a135db01..33b1732a6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -19,6 +19,9 @@ apt (0.9.5.2) UNRELEASED; urgency=low
as we do in the manpage and as the debian-installer does
* doc/apt-get.8.xml:
- use apt-utils as package example instead of libc6
+ * apt-pkg/contrib/cmdline.cc:
+ - apply patch from Daniel Hartwig to fix a segfault in case
+ the LongOpt is empty (Closes: #676331)
[ Justin B Rye ]
* doc/apt-cdrom.8.xml:
diff --git a/test/libapt/commandline_test.cc b/test/libapt/commandline_test.cc
new file mode 100644
index 000000000..a37fb0220
--- /dev/null
+++ b/test/libapt/commandline_test.cc
@@ -0,0 +1,21 @@
+#include
+
+#include "assert.h"
+
+int main()
+{
+ CommandLine::Args Args[] = {
+ { 't', 0, "Test::Worked", 0 },
+ { 'z', "zero", "Test::Zero", 0 },
+ {0,0,0,0}
+ };
+
+ CommandLine CmdL(Args,_config);
+ char const * argv[] = { "test", "--zero", "-t" };
+ CmdL.Parse(3 , argv);
+
+ equals(true, _config->FindB("Test::Worked", false));
+ equals(true, _config->FindB("Test::Zero", false));
+
+ return 0;
+}
diff --git a/test/libapt/makefile b/test/libapt/makefile
index 1952051e2..b2e6db2dd 100644
--- a/test/libapt/makefile
+++ b/test/libapt/makefile
@@ -33,6 +33,12 @@ SLIBS = -lapt-pkg
SOURCE = getlistoffilesindir_test.cc
include $(PROGRAM_H)
+# Program for testing CommandLine reconstruction
+PROGRAM = Commandline${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = commandline_test.cc
+include $(PROGRAM_H)
+
# Program for testing CommandLine reconstruction
PROGRAM = CommandlineAsString${BASENAME}
SLIBS = -lapt-pkg
--
cgit v1.2.3-70-g09d2
From 7a6d9076595b2acc164d6f057f609c96c359ea08 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Sat, 9 Jun 2012 22:55:51 +0200
Subject: fix segfault with empty LongOpt in --no-* branch
---
apt-pkg/contrib/cmndline.cc | 3 ++-
debian/changelog | 1 +
test/libapt/commandline_test.cc | 15 +++++++++++++--
3 files changed, 16 insertions(+), 3 deletions(-)
(limited to 'test')
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index b8c7f7984..75d02cad4 100644
--- a/apt-pkg/contrib/cmndline.cc
+++ b/apt-pkg/contrib/cmndline.cc
@@ -106,7 +106,8 @@ bool CommandLine::Parse(int argc,const char **argv)
Opt++;
for (A = ArgList; A->end() == false &&
- stringcasecmp(Opt,OptEnd,A->LongOpt) != 0; A++);
+ (A->LongOpt == 0 || stringcasecmp(Opt,OptEnd,A->LongOpt) != 0);
+ ++A);
// Failed again..
if (A->end() == true && OptEnd - Opt != 1)
diff --git a/debian/changelog b/debian/changelog
index 33b1732a6..b263002ae 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -22,6 +22,7 @@ apt (0.9.5.2) UNRELEASED; urgency=low
* apt-pkg/contrib/cmdline.cc:
- apply patch from Daniel Hartwig to fix a segfault in case
the LongOpt is empty (Closes: #676331)
+ - fix segfault with empty LongOpt in --no-* branch
[ Justin B Rye ]
* doc/apt-cdrom.8.xml:
diff --git a/test/libapt/commandline_test.cc b/test/libapt/commandline_test.cc
index a37fb0220..de8a30bd6 100644
--- a/test/libapt/commandline_test.cc
+++ b/test/libapt/commandline_test.cc
@@ -9,13 +9,24 @@ int main()
{ 'z', "zero", "Test::Zero", 0 },
{0,0,0,0}
};
-
CommandLine CmdL(Args,_config);
+
char const * argv[] = { "test", "--zero", "-t" };
CmdL.Parse(3 , argv);
-
equals(true, _config->FindB("Test::Worked", false));
equals(true, _config->FindB("Test::Zero", false));
+ _config->Clear("Test");
+ equals(false, _config->FindB("Test::Worked", false));
+ equals(false, _config->FindB("Test::Zero", false));
+
+ _config->Set("Test::Zero", true);
+ equals(true, _config->FindB("Test::Zero", false));
+
+ char const * argv2[] = { "test", "--no-zero", "-t" };
+ CmdL.Parse(3 , argv2);
+ equals(true, _config->FindB("Test::Worked", false));
+ equals(false, _config->FindB("Test::Zero", false));
+
return 0;
}
--
cgit v1.2.3-70-g09d2
From a98b6615254f8f7251d43c52de8f1f605c821ed7 Mon Sep 17 00:00:00 2001
From: Daniel Hartwig
Date: Sun, 10 Jun 2012 00:18:19 +0200
Subject: * cmdline/apt-get.cc: - print URIs for all changelogs in case of
--print-uris, thanks to Daniel Hartwig for the patch! (Closes: #674897)
---
cmdline/apt-get.cc | 6 +++++-
debian/changelog | 2 ++
test/integration/test-apt-get-changelog | 3 +++
3 files changed, 10 insertions(+), 1 deletion(-)
(limited to 'test')
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 6ef046089..0636489cb 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -3244,9 +3244,13 @@ bool DoChangelog(CommandLine &CmdL)
pkgAcquire Fetcher;
if (_config->FindB("APT::Get::Print-URIs", false) == true)
+ {
+ bool Success = true;
for (APT::VersionList::const_iterator Ver = verset.begin();
Ver != verset.end(); ++Ver)
- return DownloadChangelog(Cache, Fetcher, Ver, "");
+ Success &= DownloadChangelog(Cache, Fetcher, Ver, "");
+ return Success;
+ }
AcqTextStatus Stat(ScreenWidth, _config->FindI("quiet",0));
Fetcher.Setup(&Stat);
diff --git a/debian/changelog b/debian/changelog
index 3a8ae4002..d8adba89a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,8 @@ apt (0.9.5.2) UNRELEASED; urgency=low
* cmdline/apt-get.cc:
- do not show 'list of broken packages' header if no package
is broken as it happens e.g. for external resolver errors
+ - print URIs for all changelogs in case of --print-uris,
+ thanks to Daniel Hartwig for the patch! (Closes: #674897)
* debian/apt-utils.links:
- the internal resolver 'apt' is now directly installed in
/usr/lib/apt/solvers, so don't instruct dh to create a broken link
diff --git a/test/integration/test-apt-get-changelog b/test/integration/test-apt-get-changelog
index 0a80cc08c..d013cc458 100755
--- a/test/integration/test-apt-get-changelog
+++ b/test/integration/test-apt-get-changelog
@@ -17,6 +17,9 @@ echo 'Apt::Changelogs::Server "http://localhost:8080/";' >> ./aptconfig.conf
testequal "'http://localhost:8080//pool/apt_1.0/changelog'" aptget changelog apt --print-uris
+testequal "'http://localhost:8080//pool/apt_1.0/changelog'
+'http://localhost:8080//pool/apt_1.0/changelog'" aptget changelog apt apt --print-uris
+
aptget changelog apt -qq > apt.changelog
testfileequal 'apt.changelog' "$(cat aptarchive/pool/apt_1.0/changelog)"
rm apt.changelog
--
cgit v1.2.3-70-g09d2
From f87fab03bade8a049b318df68dfa4c361fab944c Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Sun, 10 Jun 2012 00:40:55 +0200
Subject: * apt-pkg/aptconfiguration.cc: - if APT::Languages=none save "none"
in allCodes so that the detected configuration is cached as intended
(Closes: #674690, LP: #1004947)
---
apt-pkg/aptconfiguration.cc | 26 +++++++++++++++-----------
debian/changelog | 3 +++
test/libapt/getlanguages_test.cc | 6 ++++--
3 files changed, 22 insertions(+), 13 deletions(-)
(limited to 'test')
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc
index d763546f8..d31ccb642 100644
--- a/apt-pkg/aptconfiguration.cc
+++ b/apt-pkg/aptconfiguration.cc
@@ -234,17 +234,21 @@ std::vector const Configuration::getLanguages(bool const &All,
// override the configuration settings vector of languages.
string const forceLang = _config->Find("Acquire::Languages","");
if (forceLang.empty() == false) {
- if (forceLang == "environment") {
- codes = environment;
- } else if (forceLang != "none")
- codes.push_back(forceLang);
- else //if (forceLang == "none")
- builtin.clear();
- allCodes = codes;
- for (std::vector::const_iterator b = builtin.begin();
- b != builtin.end(); ++b)
- if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
- allCodes.push_back(*b);
+ if (forceLang == "none") {
+ codes.clear();
+ allCodes.clear();
+ allCodes.push_back("none");
+ } else {
+ if (forceLang == "environment")
+ codes = environment;
+ else
+ codes.push_back(forceLang);
+ allCodes = codes;
+ for (std::vector::const_iterator b = builtin.begin();
+ b != builtin.end(); ++b)
+ if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
+ allCodes.push_back(*b);
+ }
if (All == true)
return allCodes;
else
diff --git a/debian/changelog b/debian/changelog
index d8adba89a..adcf0d956 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -32,6 +32,9 @@ apt (0.9.5.2) UNRELEASED; urgency=low
- set pkgCacheGen::Essential to "all" again (Closes: #675449)
* apt-pkg/algorithms.cc:
- force install only for one essential package out of a group
+ * apt-pkg/aptconfiguration.cc:
+ - if APT::Languages=none save "none" in allCodes so that the detected
+ configuration is cached as intended (Closes: #674690, LP: #1004947)
[ Justin B Rye ]
* doc/apt-cdrom.8.xml:
diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc
index 274cf4aa4..cef89bde6 100644
--- a/test/libapt/getlanguages_test.cc
+++ b/test/libapt/getlanguages_test.cc
@@ -144,7 +144,8 @@ int main(int argc,char *argv[])
_config->Set("Acquire::Languages", "none");
vec = APT::Configuration::getLanguages(true, false, env);
- equals(vec.size(), 0);
+ equals(vec.size(), 1);
+ equals(vec[0], "none");
_config->Set("Acquire::Languages", "");
_config->Set("Dir::State::lists", "/non-existing-dir");
@@ -168,7 +169,8 @@ int main(int argc,char *argv[])
_config->Set("Acquire::Languages", "none");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(true, false, env);
- equals(vec.size(), 0);
+ equals(vec.size(), 1);
+ equals(vec[0], "none");
_config->Set("Acquire::Languages", "");
//FIXME: Remove support for this deprecated setting
--
cgit v1.2.3-70-g09d2
From d5dea0bed00ff1811fac1b56c2046d63c937a3f6 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Mon, 11 Jun 2012 00:16:51 +0200
Subject: check build-dep candidate if install is forbidden
---
cmdline/apt-get.cc | 58 +++++++++++++++-------
debian/changelog | 1 +
test/integration/framework | 3 +-
.../test-bug-632221-cross-dependency-satisfaction | 14 ++++++
4 files changed, 56 insertions(+), 20 deletions(-)
(limited to 'test')
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index a4fd3cfb9..870c77280 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -2889,33 +2889,42 @@ bool DoBuildDep(CommandLine &CmdL)
else
Pkg = Cache->FindPkg(D->Package);
- // We need to decide if host or build arch, so find a version we can look at
- pkgCache::VerIterator Ver;
-
// a bad version either is invalid or doesn't satify dependency
- #define BADVER(Ver) Ver.end() == true || \
- (Ver.end() == false && D->Version.empty() == false && \
- Cache->VS().CheckDep(Ver.VerStr(),D->Op,D->Version.c_str()) == false)
+ #define BADVER(Ver) (Ver.end() == true || \
+ (D->Version.empty() == false && \
+ Cache->VS().CheckDep(Ver.VerStr(),D->Op,D->Version.c_str()) == false))
+ APT::VersionList verlist;
if (Pkg.end() == false)
{
- Ver = (*Cache)[Pkg].InstVerIter(*Cache);
- if (BADVER(Ver))
- Ver = (*Cache)[Pkg].CandidateVerIter(*Cache);
+ pkgCache::VerIterator Ver = (*Cache)[Pkg].InstVerIter(*Cache);
+ if (BADVER(Ver) == false)
+ verlist.insert(Ver);
+ Ver = (*Cache)[Pkg].CandidateVerIter(*Cache);
+ if (BADVER(Ver) == false)
+ verlist.insert(Ver);
}
- if (BADVER(Ver))
+ if (verlist.empty() == true)
{
pkgCache::PkgIterator HostPkg = Cache->FindPkg(D->Package, hostArch);
if (HostPkg.end() == false)
{
- Ver = (*Cache)[HostPkg].InstVerIter(*Cache);
- if (BADVER(Ver))
- Ver = (*Cache)[HostPkg].CandidateVerIter(*Cache);
+ pkgCache::VerIterator Ver = (*Cache)[HostPkg].InstVerIter(*Cache);
+ if (BADVER(Ver) == false)
+ verlist.insert(Ver);
+ Ver = (*Cache)[HostPkg].CandidateVerIter(*Cache);
+ if (BADVER(Ver) == false)
+ verlist.insert(Ver);
}
}
- if ((BADVER(Ver)) == false)
+ #undef BADVER
+
+ string forbidden;
+ // We need to decide if host or build arch, so find a version we can look at
+ APT::VersionList::const_iterator Ver = verlist.begin();
+ for (; Ver != verlist.end(); ++Ver)
{
- string forbidden;
+ forbidden.clear();
if (Ver->MultiArch == pkgCache::Version::None || Ver->MultiArch == pkgCache::Version::All)
{
if (colon == string::npos)
@@ -2953,10 +2962,24 @@ bool DoBuildDep(CommandLine &CmdL)
}
// native gets buildArch
}
+
if (forbidden.empty() == false)
{
if (_config->FindB("Debug::BuildDeps",false) == true)
- cout << D->Package.substr(colon, string::npos) << " is not allowed from " << forbidden << " package " << (*D).Package << endl;
+ cout << D->Package.substr(colon, string::npos) << " is not allowed from " << forbidden << " package " << (*D).Package << " (" << Ver.VerStr() << ")" << endl;
+ continue;
+ }
+
+ //we found a good version
+ break;
+ }
+ if (Ver == verlist.end())
+ {
+ if (_config->FindB("Debug::BuildDeps",false) == true)
+ cout << " No multiarch info as we have no satisfying installed nor candidate for " << D->Package << " on build or host arch" << endl;
+
+ if (forbidden.empty() == false)
+ {
if (hasAlternatives)
continue;
return _error->Error(_("%s dependency for %s can't be satisfied "
@@ -2965,9 +2988,6 @@ bool DoBuildDep(CommandLine &CmdL)
D->Package.c_str(), forbidden.c_str());
}
}
- else if (_config->FindB("Debug::BuildDeps",false) == true)
- cout << " No multiarch info as we have no satisfying installed nor candidate for " << D->Package << " on build or host arch" << endl;
- #undef BADVER
}
else
Pkg = Cache->FindPkg(D->Package);
diff --git a/debian/changelog b/debian/changelog
index 720b07273..ee108b059 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,7 @@ apt (0.9.5.2) UNRELEASED; urgency=low
- print URIs for all changelogs in case of --print-uris,
thanks to Daniel Hartwig for the patch! (Closes: #674897)
- show 'bzr branch' as 'bzr get' is deprecated (LP: #1011032)
+ - check build-dep candidate if install is forbidden
* debian/apt-utils.links:
- the internal resolver 'apt' is now directly installed in
/usr/lib/apt/solvers, so don't instruct dh to create a broken link
diff --git a/test/integration/framework b/test/integration/framework
index 5a0e1070f..dba8c0162 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -508,7 +508,8 @@ Architecture: $ARCH" >> $FILE
test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
echo "Files:
d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.dsc
- d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.tar.gz" >> $FILE
+ d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.tar.gz
+" >> $FILE
}
insertinstalledpackage() {
diff --git a/test/integration/test-bug-632221-cross-dependency-satisfaction b/test/integration/test-bug-632221-cross-dependency-satisfaction
index a128366c5..93cc153e6 100755
--- a/test/integration/test-bug-632221-cross-dependency-satisfaction
+++ b/test/integration/test-bug-632221-cross-dependency-satisfaction
@@ -23,8 +23,22 @@ insertpackage 'unstable' 'linux-stuff' 'amd64,armel' '1.0'
insertsource 'unstable' 'apt' 'any' '0.8.15' 'Build-Depends: doxygen, libc6-dev, libc6-dev:native, cool:any, amdboot:amd64, foreigner, libfwibble-dev, arm-stuff [any-arm] | linux-stuff [ linux-any]'
+insertsource 'unstable' 'forbidden-none' 'any' '1' 'Build-Depends: amdboot:any'
+insertsource 'unstable' 'forbidden-same' 'any' '1' 'Build-Depends: libc6:any'
+insertsource 'unstable' 'forbidden-foreign' 'any' '1' 'Build-Depends: doxygen:any'
+
setupaptarchive
+testequal "Reading package lists...
+Building dependency tree...
+E: Build-Depends dependency for forbidden-none can't be satisfied because amdboot:any is not allowed on 'Multi-Arch: none' packages" aptget build-dep forbidden-none -s -a armel
+testequal "Reading package lists...
+Building dependency tree...
+E: Build-Depends dependency for forbidden-same can't be satisfied because libc6:any is not allowed on 'Multi-Arch: same' packages" aptget build-dep forbidden-same -s -a armel
+testequal "Reading package lists...
+Building dependency tree...
+E: Build-Depends dependency for forbidden-foreign can't be satisfied because doxygen:any is not allowed on 'Multi-Arch: foreign' packages" aptget build-dep forbidden-foreign -s -a armel
+
testequal 'Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
--
cgit v1.2.3-70-g09d2
From 249a02f55a2b311fc130efe3b3a99995b6a71360 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Mon, 11 Jun 2012 02:17:17 +0200
Subject: add a few tests to check that arch-specific qualifiers work
---
.../test-bug-632221-cross-dependency-satisfaction | 43 ++++++++++++++++++++++
1 file changed, 43 insertions(+)
(limited to 'test')
diff --git a/test/integration/test-bug-632221-cross-dependency-satisfaction b/test/integration/test-bug-632221-cross-dependency-satisfaction
index 93cc153e6..208c613a2 100755
--- a/test/integration/test-bug-632221-cross-dependency-satisfaction
+++ b/test/integration/test-bug-632221-cross-dependency-satisfaction
@@ -27,6 +27,12 @@ insertsource 'unstable' 'forbidden-none' 'any' '1' 'Build-Depends: amdboot:any'
insertsource 'unstable' 'forbidden-same' 'any' '1' 'Build-Depends: libc6:any'
insertsource 'unstable' 'forbidden-foreign' 'any' '1' 'Build-Depends: doxygen:any'
+insertpackage 'unstable' 'specific' 'amd64' '1.0' 'Depends: libc6:amd64'
+insertpackage 'unstable' 'specific' 'armel' '1.0' 'Depends: libc6:armel'
+
+insertsource 'unstable' 'source-specific-amd64' 'amd64' '1' 'Build-Depends: specific:amd64'
+insertsource 'unstable' 'source-specific-armel' 'armel' '1' 'Build-Depends: specific:armel'
+
setupaptarchive
testequal "Reading package lists...
@@ -39,6 +45,43 @@ testequal "Reading package lists...
Building dependency tree...
E: Build-Depends dependency for forbidden-foreign can't be satisfied because doxygen:any is not allowed on 'Multi-Arch: foreign' packages" aptget build-dep forbidden-foreign -s -a armel
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ libc6 specific
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst libc6 (1.0 unstable [amd64])
+Inst specific (1.0 unstable [amd64])
+Conf libc6 (1.0 unstable [amd64])
+Conf specific (1.0 unstable [amd64])' aptget build-dep source-specific-amd64 -s
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ libc6 specific
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst libc6 (1.0 unstable [amd64])
+Inst specific (1.0 unstable [amd64])
+Conf libc6 (1.0 unstable [amd64])
+Conf specific (1.0 unstable [amd64])' aptget build-dep source-specific-amd64 -s -a armel
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ libc6:armel specific:armel
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst libc6:armel (1.0 unstable [armel])
+Inst specific:armel (1.0 unstable [armel])
+Conf libc6:armel (1.0 unstable [armel])
+Conf specific:armel (1.0 unstable [armel])' aptget build-dep source-specific-armel -s
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ libc6:armel specific:armel
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst libc6:armel (1.0 unstable [armel])
+Inst specific:armel (1.0 unstable [armel])
+Conf libc6:armel (1.0 unstable [armel])
+Conf specific:armel (1.0 unstable [armel])' aptget build-dep source-specific-armel -s -a armel
+
testequal 'Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
--
cgit v1.2.3-70-g09d2
From 82c6f7528d583431722ef180b6064b86b644ad85 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Tue, 12 Jun 2012 15:40:56 +0200
Subject: add a testcase for #675449, which i forgot to commit
---
.../test-673536-pre-depends-breaks-loop | 23 ------
.../test-bug-673536-pre-depends-breaks-loop | 23 ++++++
.../test-bug-675449-essential-are-protected | 88 ++++++++++++++++++++++
3 files changed, 111 insertions(+), 23 deletions(-)
delete mode 100755 test/integration/test-673536-pre-depends-breaks-loop
create mode 100755 test/integration/test-bug-673536-pre-depends-breaks-loop
create mode 100755 test/integration/test-bug-675449-essential-are-protected
(limited to 'test')
diff --git a/test/integration/test-673536-pre-depends-breaks-loop b/test/integration/test-673536-pre-depends-breaks-loop
deleted file mode 100755
index e9d3c4de6..000000000
--- a/test/integration/test-673536-pre-depends-breaks-loop
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-set -e
-
-TESTDIR=$(readlink -f $(dirname $0))
-. $TESTDIR/framework
-setupenvironment
-configarchitecture 'native'
-
-buildsimplenativepackage 'basic' 'native' '1' 'stable'
-buildsimplenativepackage 'basic' 'native' '2' 'unstable' 'Pre-Depends: common'
-buildsimplenativepackage 'common' 'native' '2' 'unstable' 'Breaks: basic (<= 1)'
-
-setupaptarchive
-
-# we check with 'real' packages here as the simulation reports a 'Conf broken'
-# which is technical correct for the simulation, but testing errormsg is ugly
-
-aptget install basic=1 -qq > /dev/null
-testdpkginstalled basic
-testdpkgnotinstalled common
-
-aptget dist-upgrade -qq > /dev/null
-testdpkginstalled basic common
diff --git a/test/integration/test-bug-673536-pre-depends-breaks-loop b/test/integration/test-bug-673536-pre-depends-breaks-loop
new file mode 100755
index 000000000..e9d3c4de6
--- /dev/null
+++ b/test/integration/test-bug-673536-pre-depends-breaks-loop
@@ -0,0 +1,23 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'native'
+
+buildsimplenativepackage 'basic' 'native' '1' 'stable'
+buildsimplenativepackage 'basic' 'native' '2' 'unstable' 'Pre-Depends: common'
+buildsimplenativepackage 'common' 'native' '2' 'unstable' 'Breaks: basic (<= 1)'
+
+setupaptarchive
+
+# we check with 'real' packages here as the simulation reports a 'Conf broken'
+# which is technical correct for the simulation, but testing errormsg is ugly
+
+aptget install basic=1 -qq > /dev/null
+testdpkginstalled basic
+testdpkgnotinstalled common
+
+aptget dist-upgrade -qq > /dev/null
+testdpkginstalled basic common
diff --git a/test/integration/test-bug-675449-essential-are-protected b/test/integration/test-bug-675449-essential-are-protected
new file mode 100755
index 000000000..7d8cc3484
--- /dev/null
+++ b/test/integration/test-bug-675449-essential-are-protected
@@ -0,0 +1,88 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'i386'
+
+insertinstalledpackage 'pkg-native' 'amd64' '1' 'Multi-Arch: foreign
+Essential: yes'
+insertinstalledpackage 'pkg-foreign' 'i386' '1' 'Multi-Arch: foreign
+Essential: yes'
+insertinstalledpackage 'pkg-none-native' 'amd64' '1' 'Essential: yes'
+insertinstalledpackage 'pkg-none-foreign' 'i386' '1' 'Essential: yes'
+
+insertpackage 'unstable' 'pkg-native' 'amd64,i386' '2' 'Multi-Arch: foreign
+Essential: yes'
+insertpackage 'unstable' 'pkg-foreign' 'amd64,i386' '2' 'Multi-Arch: foreign
+Depends: pkg-depends-new
+Essential: yes'
+insertpackage 'unstable' 'pkg-none-native' 'amd64,i386' '2' 'Essential: yes'
+insertpackage 'unstable' 'pkg-none-foreign' 'amd64,i386' '2' 'Essential: yes
+Depends: pkg-depends-new'
+
+insertpackage 'unstable' 'pkg-none-new' 'amd64,i386' '2' 'Essential: yes'
+insertpackage 'unstable' 'pkg-depends-new' 'amd64,i386' '2' 'Essential: yes'
+
+setupaptarchive
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be REMOVED:
+ pkg-native*
+WARNING: The following essential packages will be removed.
+This should NOT be done unless you know exactly what you are doing!
+ pkg-native
+0 upgraded, 0 newly installed, 1 to remove and 3 not upgraded.
+Purg pkg-native [1]' aptget purge pkg-native -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be REMOVED:
+ pkg-foreign:i386*
+WARNING: The following essential packages will be removed.
+This should NOT be done unless you know exactly what you are doing!
+ pkg-foreign:i386
+0 upgraded, 0 newly installed, 1 to remove and 3 not upgraded.
+Purg pkg-foreign:i386 [1]' aptget purge pkg-foreign:i386 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be REMOVED:
+ pkg-none-native*
+WARNING: The following essential packages will be removed.
+This should NOT be done unless you know exactly what you are doing!
+ pkg-none-native
+0 upgraded, 0 newly installed, 1 to remove and 3 not upgraded.
+Purg pkg-none-native [1]' aptget purge pkg-none-native -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be REMOVED:
+ pkg-none-foreign:i386*
+WARNING: The following essential packages will be removed.
+This should NOT be done unless you know exactly what you are doing!
+ pkg-none-foreign:i386
+0 upgraded, 0 newly installed, 1 to remove and 3 not upgraded.
+Purg pkg-none-foreign:i386 [1]' aptget purge pkg-none-foreign:i386 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ pkg-depends-new:i386 pkg-none-new
+The following packages will be upgraded:
+ pkg-foreign:i386 pkg-native pkg-none-foreign:i386 pkg-none-native
+4 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst pkg-depends-new:i386 (2 unstable [i386])
+Conf pkg-depends-new:i386 (2 unstable [i386])
+Inst pkg-foreign:i386 [1] (2 unstable [i386])
+Conf pkg-foreign:i386 (2 unstable [i386])
+Inst pkg-native [1] (2 unstable [amd64])
+Conf pkg-native (2 unstable [amd64])
+Inst pkg-none-foreign:i386 [1] (2 unstable [i386])
+Conf pkg-none-foreign:i386 (2 unstable [i386])
+Inst pkg-none-native [1] (2 unstable [amd64])
+Conf pkg-none-native (2 unstable [amd64])
+Inst pkg-none-new (2 unstable [amd64])
+Conf pkg-none-new (2 unstable [amd64])' aptget dist-upgrade -s
--
cgit v1.2.3-70-g09d2
From 01f520ce27c7f466dc6191c45507ace79d685725 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Thu, 14 Jun 2012 19:07:15 +0200
Subject: add two tests for architecture specifications
---
test/integration/framework | 13 ++-
.../test-architecture-specification-parsing | 96 ++++++++++++++++++++++
.../test-cachecontainer-architecture-specification | 87 ++++++++++++++++++++
test/libapt/parsedepends_test.cc | 10 +--
4 files changed, 197 insertions(+), 9 deletions(-)
create mode 100755 test/integration/test-architecture-specification-parsing
create mode 100755 test/integration/test-cachecontainer-architecture-specification
(limited to 'test')
diff --git a/test/integration/framework b/test/integration/framework
index dba8c0162..2d6ada117 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -304,23 +304,28 @@ echo '$NAME says \"Hello!\"'" > ${BUILDDIR}/${NAME}
Section: $SECTION
Priority: $PRIORITY
Maintainer: Joe Sixpack
-Standards-Version: 3.9.1
+Standards-Version: 3.9.3" > ${BUILDDIR}/debian/control
+ local BUILDDEPS="$(echo "$DEPENDENCIES" | grep '^Build-')"
+ test -z "$BUILDDEPS" || echo "$BUILDDEPS" >> ${BUILDDIR}/debian/control
+ echo "
+Package: $NAME" >> ${BUILDDIR}/debian/control
-Package: $NAME" > ${BUILDDIR}/debian/control
if [ "$ARCH" = 'all' ]; then
echo "Architecture: all" >> ${BUILDDIR}/debian/control
else
echo "Architecture: any" >> ${BUILDDIR}/debian/control
fi
- test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> ${BUILDDIR}/debian/control
+ local DEPS="$(echo "$DEPENDENCIES" | grep -v '^Build-')"
+ test -z "$DEPS" || echo "$DEPS" >> ${BUILDDIR}/debian/control
if [ -z "$DESCRIPTION" ]; then
echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
If you find such a package installed on your system,
YOU did something horribly wrong! They are autogenerated
und used only by testcases for APT and surf no other propose…" >> ${BUILDDIR}/debian/control
else
- echo "Description: $DESCRIPTION" >> ${BUILDIR}/debian/control
+ echo "Description: $DESCRIPTION" >> ${BUILDDIR}/debian/control
fi
+
echo '3.0 (native)' > ${BUILDDIR}/debian/source/format
local SRCS="$( (cd ${BUILDDIR}/..; dpkg-source -b ${NAME}-${VERSION} 2>&1) | grep '^dpkg-source: info: building' | grep -o '[a-z0-9._+~-]*$')"
for SRC in $SRCS; do
diff --git a/test/integration/test-architecture-specification-parsing b/test/integration/test-architecture-specification-parsing
new file mode 100755
index 000000000..8f365dd55
--- /dev/null
+++ b/test/integration/test-architecture-specification-parsing
@@ -0,0 +1,96 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64'
+
+buildsimplenativepackage 'pkg-arch-foo' 'amd64' '1.0' 'stable' 'Build-Depends: foo [amd64 !amd64]
+Depends: foo [amd64 !amd64]'
+buildsimplenativepackage 'pkg-arch-no-foo' 'amd64' '1.0' 'stable' 'Build-Depends: foo [!amd64 amd64]
+Depends: foo [!amd64 amd64]'
+buildsimplenativepackage 'pkg-arch-foo-unrelated-no' 'amd64' '1.0' 'stable' 'Build-Depends: foo [!kfreebsd-any amd64]
+Depends: foo [!kfreebsd-any amd64]'
+buildsimplenativepackage 'pkg-arch-foo-unrelated-no2' 'amd64' '1.0' 'stable' 'Build-Depends: foo [amd64 !kfreebsd-any]
+Depends: foo [amd64 !kfreebsd-any]'
+
+buildsimplenativepackage 'foo' 'amd64' '1.0' 'stable'
+
+insertinstalledpackage 'build-essential' 'all' '11.5' 'Multi-Arch: foreign'
+
+setupaptarchive
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+ foo
+The following NEW packages will be installed:
+ foo pkg-arch-foo
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst foo (1.0 stable [amd64])
+Inst pkg-arch-foo (1.0 stable [amd64])
+Conf foo (1.0 stable [amd64])
+Conf pkg-arch-foo (1.0 stable [amd64])' aptget install pkg-arch-foo -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ pkg-arch-no-foo
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst pkg-arch-no-foo (1.0 stable [amd64])
+Conf pkg-arch-no-foo (1.0 stable [amd64])' aptget install pkg-arch-no-foo -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+ foo
+The following NEW packages will be installed:
+ foo pkg-arch-foo-unrelated-no
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst foo (1.0 stable [amd64])
+Inst pkg-arch-foo-unrelated-no (1.0 stable [amd64])
+Conf foo (1.0 stable [amd64])
+Conf pkg-arch-foo-unrelated-no (1.0 stable [amd64])' aptget install pkg-arch-foo-unrelated-no -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+ foo
+The following NEW packages will be installed:
+ foo pkg-arch-foo-unrelated-no2
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst foo (1.0 stable [amd64])
+Inst pkg-arch-foo-unrelated-no2 (1.0 stable [amd64])
+Conf foo (1.0 stable [amd64])
+Conf pkg-arch-foo-unrelated-no2 (1.0 stable [amd64])' aptget install pkg-arch-foo-unrelated-no2 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ foo
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst foo (1.0 stable [amd64])
+Conf foo (1.0 stable [amd64])' aptget build-dep pkg-arch-foo -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' aptget build-dep pkg-arch-no-foo -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ foo
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst foo (1.0 stable [amd64])
+Conf foo (1.0 stable [amd64])' aptget build-dep pkg-arch-foo-unrelated-no -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ foo
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst foo (1.0 stable [amd64])
+Conf foo (1.0 stable [amd64])' aptget build-dep pkg-arch-foo-unrelated-no2 -s
+
+
diff --git a/test/integration/test-cachecontainer-architecture-specification b/test/integration/test-cachecontainer-architecture-specification
new file mode 100755
index 000000000..174efb087
--- /dev/null
+++ b/test/integration/test-cachecontainer-architecture-specification
@@ -0,0 +1,87 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'armel'
+
+#insertinstalledpackage 'xserver-xorg-core' 'amd64' '2:1.7.6-2ubuntu7.10'
+insertpackage 'unstable' 'libsame' 'armel,amd64' '1' 'Multi-Arch: same'
+
+setupaptarchive
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ libsame
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst libsame (1 unstable [amd64])
+Conf libsame (1 unstable [amd64])' aptget -s install libsame
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ libsame:armel
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst libsame:armel (1 unstable [armel])
+Conf libsame:armel (1 unstable [armel])' aptget -s install libsame:armel
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ libsame
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst libsame (1 unstable [amd64])
+Conf libsame (1 unstable [amd64])' aptget -s install libsame:amd64
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ libsame libsame:armel
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst libsame (1 unstable [amd64])
+Inst libsame:armel (1 unstable [armel])
+Conf libsame (1 unstable [amd64])
+Conf libsame:armel (1 unstable [armel])' aptget -s install libsame:armel libsame:amd64
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ libsame libsame:armel
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst libsame (1 unstable [amd64])
+Inst libsame:armel (1 unstable [armel])
+Conf libsame (1 unstable [amd64])
+Conf libsame:armel (1 unstable [armel])' aptget -s install libsame:*
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ libsame
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst libsame (1 unstable [amd64])
+Conf libsame (1 unstable [amd64])' aptget -s install libsame:any
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ libsame libsame:armel
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst libsame (1 unstable [amd64])
+Inst libsame:armel (1 unstable [armel])
+Conf libsame (1 unstable [amd64])
+Conf libsame:armel (1 unstable [armel])' aptget -s install libsame:a*
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ libsame
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst libsame (1 unstable [amd64])
+Conf libsame (1 unstable [amd64])' aptget -s install libsame:linux-any
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ libsame libsame:armel
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst libsame (1 unstable [amd64])
+Inst libsame:armel (1 unstable [armel])
+Conf libsame (1 unstable [amd64])
+Conf libsame:armel (1 unstable [armel])' aptget -s install libsame:linux-*
+testequal 'Reading package lists...
+Building dependency tree...
+E: Unable to locate package libsame' aptget -s install libsame:windows-any
diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc
index b5d92d9d2..677b1c892 100644
--- a/test/libapt/parsedepends_test.cc
+++ b/test/libapt/parsedepends_test.cc
@@ -10,7 +10,7 @@ int main(int argc,char *argv[]) {
unsigned int Null = 0;
bool StripMultiArch = true;
bool ParseArchFlags = false;
- _config->Set("APT::Architecture","dsk");
+ _config->Set("APT::Architecture","amd64");
const char* Depends =
"debhelper:any (>= 5.0), "
@@ -19,13 +19,13 @@ int main(int argc,char *argv[]) {
"libcurl4-gnutls-dev:native | libcurl3-gnutls-dev (>> 7.15.5), "
"debiandoc-sgml, "
"apt (>= 0.7.25), "
- "not-for-me [ !dsk ], "
- "only-for-me [ dsk ], "
+ "not-for-me [ !amd64 ], "
+ "only-for-me [ amd64 ], "
"any-for-me [ any ], "
"not-for-darwin [ !darwin-any ], "
- "cpu-for-me [ any-dsk ], "
+ "cpu-for-me [ any-amd64 ], "
"os-for-me [ linux-any ], "
- "cpu-not-for-me [ any-amd64 ], "
+ "cpu-not-for-me [ any-armel ], "
"os-not-for-me [ kfreebsd-any ], "
"overlord-dev:any (= 7.15.3~) | overlord-dev:native (>> 7.15.5), "
;
--
cgit v1.2.3-70-g09d2
From 567785b979d9b71ceb92edda82e4f15bb40a2e61 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Mon, 18 Jun 2012 13:19:47 +0200
Subject: * cmdline/apt-get.cc: - print a friendly message in 'download' if a
package can't be downloaded (Closes: #677887)
---
cmdline/apt-get.cc | 16 ++++++++++++++--
debian/changelog | 3 +++
test/integration/test-apt-get-download | 4 ++++
3 files changed, 21 insertions(+), 2 deletions(-)
(limited to 'test')
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 870c77280..d4c7f4200 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -2362,6 +2362,8 @@ bool DoDownload(CommandLine &CmdL)
pkgRecords Recs(Cache);
pkgSourceList *SrcList = Cache.GetSourceList();
+ bool gotAll = true;
+
for (APT::VersionList::const_iterator Ver = verset.begin();
Ver != verset.end();
++Ver)
@@ -2372,11 +2374,19 @@ bool DoDownload(CommandLine &CmdL)
pkgRecords::Parser &rec=Recs.Lookup(Ver.FileList());
pkgCache::VerFileIterator Vf = Ver.FileList();
if (Vf.end() == true)
- return _error->Error("Can not find VerFile");
+ {
+ _error->Error("Can not find VerFile for %s in version %s", Pkg.FullName().c_str(), Ver.VerStr());
+ gotAll = false;
+ continue;
+ }
pkgCache::PkgFileIterator F = Vf.File();
pkgIndexFile *index;
if(SrcList->FindIndex(F, index) == false)
- return _error->Error("FindIndex failed");
+ {
+ _error->Error(_("Can't find a source to download version '%s' of '%s'"), Ver.VerStr(), Pkg.FullName().c_str());
+ gotAll = false;
+ continue;
+ }
string uri = index->ArchiveURI(rec.FileName());
strprintf(descr, _("Downloading %s %s"), Pkg.Name(), Ver.VerStr());
// get the most appropriate hash
@@ -2392,6 +2402,8 @@ bool DoDownload(CommandLine &CmdL)
// get the file
new pkgAcqFile(&Fetcher, uri, hash.toStr(), (*Ver)->Size, descr, Pkg.Name(), ".");
}
+ if (gotAll == false)
+ return false;
// Just print out the uris and exit if the --print-uris flag was used
if (_config->FindB("APT::Get::Print-URIs") == true)
diff --git a/debian/changelog b/debian/changelog
index ad5a4a1a3..281915837 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -20,6 +20,9 @@ apt (0.9.6.1) UNRELEASED; urgency=low
* buildlib/configure.mak:
- print a message detailing how to get config.guess and config.sub
in case they are not in /usr/share/misc (Closes: #677312)
+ * cmdline/apt-get.cc:
+ - print a friendly message in 'download' if a package can't be
+ downloaded (Closes: #677887)
-- David Kalnischkies Thu, 14 Jun 2012 15:45:13 +0200
diff --git a/test/integration/test-apt-get-download b/test/integration/test-apt-get-download
index 4edb7c173..b164f7dba 100755
--- a/test/integration/test-apt-get-download
+++ b/test/integration/test-apt-get-download
@@ -9,6 +9,7 @@ configarchitecture "i386"
buildsimplenativepackage 'apt' 'all' '1.0' 'stable'
buildsimplenativepackage 'apt' 'all' '2.0' 'unstable'
+insertinstalledpackage 'vrms' 'all' '1.0'
setupaptarchive
@@ -26,3 +27,6 @@ testdownload apt_2.0_all.deb apt
DEBFILE="$(readlink -f aptarchive)/pool/apt_2.0_all.deb"
testequal "'file://${DEBFILE}' apt_2.0_all.deb $(stat -c%s $DEBFILE) sha256:$(sha256sum $DEBFILE | cut -d' ' -f 1)" aptget download apt --print-uris
+
+# deb:677887
+testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms
--
cgit v1.2.3-70-g09d2
From 1098ae37273547d0b4c7d05c8c6b36db56c25443 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Fri, 29 Jun 2012 13:52:52 +0200
Subject: * debian/control: - demote debiandoc-sgml to Build-Depends-Indep *
doc/makefile: - separate translation building of debiandoc from manpages
so that we don't need to build debiandoc for binary packages
---
Makefile | 4 +--
buildlib/debiandoc.mak | 6 +++--
buildlib/defaults.mak | 2 +-
buildlib/po4a_manpage.mak | 4 ++-
debian/changelog | 6 ++++-
debian/control | 4 +--
debian/rules | 10 +++----
doc/makefile | 66 ++++++++++++++++++++++++++++-------------------
test/Makefile | 2 +-
9 files changed, 63 insertions(+), 41 deletions(-)
(limited to 'test')
diff --git a/Makefile b/Makefile
index 24f5b3e2b..98b6d337a 100644
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,7 @@ endif
default: startup all
.PHONY: headers library clean veryclean all binary program doc test update-po
-all headers library clean veryclean binary program doc manpages test update-po startup dirs:
+all headers library clean veryclean binary program doc manpages debiandoc test update-po startup dirs:
$(MAKE) -C apt-pkg $@
$(MAKE) -C apt-inst $@
$(MAKE) -C methods $@
@@ -21,7 +21,7 @@ all headers library clean veryclean binary program doc manpages test update-po s
$(MAKE) -C po $@
$(MAKE) -C test $@
-all headers library clean veryclean binary program doc manpages test update-po: startup dirs
+all headers library clean veryclean binary program doc manpages debiandoc test update-po: startup dirs
dirs: startup
diff --git a/buildlib/debiandoc.mak b/buildlib/debiandoc.mak
index a97af0caf..7e22467cf 100644
--- a/buildlib/debiandoc.mak
+++ b/buildlib/debiandoc.mak
@@ -14,13 +14,15 @@ LOCAL := debiandoc-$(firstword $(SOURCE))
$(LOCAL)-HTML := $(addsuffix .html,$(addprefix $(DOC)/,$(basename $(SOURCE))))
$(LOCAL)-TEXT := $(addsuffix .text,$(addprefix $(DOC)/,$(basename $(SOURCE))))
+debiandoc:
+
#---------
# Rules to build HTML documentations
ifdef DEBIANDOC_HTML
# Install generation hooks
-doc: $($(LOCAL)-HTML)
+debiandoc: $($(LOCAL)-HTML)
veryclean: veryclean/html/$(LOCAL)
vpath %.sgml $(SUBDIRS)
@@ -42,7 +44,7 @@ endif
ifdef DEBIANDOC_TEXT
# Install generation hooks
-doc: $($(LOCAL)-TEXT)
+debiandoc: $($(LOCAL)-TEXT)
veryclean: veryclean/text/$(LOCAL)
vpath %.sgml $(SUBDIRS)
diff --git a/buildlib/defaults.mak b/buildlib/defaults.mak
index 7b084f4b9..5b970876a 100644
--- a/buildlib/defaults.mak
+++ b/buildlib/defaults.mak
@@ -121,7 +121,7 @@ MKDIRS := $(BIN)
all: dirs binary doc
binary: library program
maintainer-clean dist-clean distclean pristine sanity: veryclean
-startup headers library clean veryclean program test update-po manpages:
+startup headers library clean veryclean program test update-po manpages debiandoc:
veryclean:
echo Very Clean done for $(SUBDIR)
diff --git a/buildlib/po4a_manpage.mak b/buildlib/po4a_manpage.mak
index 1dedd0dcd..09eca0ec2 100644
--- a/buildlib/po4a_manpage.mak
+++ b/buildlib/po4a_manpage.mak
@@ -13,6 +13,8 @@
SOURCE = $(patsubst %.xml,%,$(wildcard *.$(LC).?.xml))
INCLUDES = apt.ent apt-verbatim.ent
+manpages:
+
# Do not use XMLTO, build the manpages directly with XSLTPROC
ifdef XSLTPROC
@@ -22,7 +24,7 @@ LOCAL := po4a-manpage-$(firstword $(SOURCE))
$(LOCAL)-LIST := $(SOURCE)
# Install generation hooks
-doc: $($(LOCAL)-LIST)
+manpages: $($(LOCAL)-LIST)
veryclean: veryclean/$(LOCAL)
apt-verbatim.ent: ../apt-verbatim.ent
diff --git a/debian/changelog b/debian/changelog
index 1e63657bc..c8b48cc4f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -14,8 +14,12 @@ apt (0.9.7.1) UNRELEASED; urgency=low
* debian/control:
- libapt-{pkg,inst} packages should be in section 'libs' instead
of 'admin' as by ftp-master override request in #677596
+ - demote debiandoc-sgml to Build-Depends-Indep
+ * doc/makefile:
+ - separate translation building of debiandoc from manpages
+ so that we don't need to build debiandoc for binary packages
- -- David Kalnischkies Mon, 25 Jun 2012 18:07:13 +0200
+ -- David Kalnischkies Fri, 29 Jun 2012 13:52:30 +0200
apt (0.9.7) unstable; urgency=low
diff --git a/debian/control b/debian/control
index 0020056a8..ec0d817fb 100644
--- a/debian/control
+++ b/debian/control
@@ -9,8 +9,8 @@ Standards-Version: 3.9.3
Build-Depends: dpkg-dev (>= 1.15.8), debhelper (>= 8.1.3~), libdb-dev,
gettext (>= 0.12), libcurl4-gnutls-dev (>= 7.19.0),
zlib1g-dev, libbz2-dev, xsltproc, docbook-xsl, docbook-xml,
- po4a (>= 0.34-2), autotools-dev, autoconf, automake, debiandoc-sgml
-Build-Depends-Indep: doxygen
+ po4a (>= 0.34-2), autotools-dev, autoconf, automake
+Build-Depends-Indep: doxygen, debiandoc-sgml
Build-Conflicts: autoconf2.13, automake1.4
Vcs-Bzr: http://bzr.debian.org/apt/debian-sid/
Vcs-Browser: http://bzr.debian.org/loggerhead/apt/debian-sid/
diff --git a/debian/rules b/debian/rules
index ee001fe12..83e23881c 100755
--- a/debian/rules
+++ b/debian/rules
@@ -67,7 +67,7 @@ LIBAPT_INST=libapt-inst$(LIBAPTINST_MAJOR)
export DPKG_GENSYMBOLS_CHECK_LEVEL=0
build: build/build-stamp
-build-doc: build-manpages build/build-doc-stamp
+build-debiandoc: build/build-debiandoc-stamp
build-manpages: build/build-manpages-stamp
# Note that this is unconditionally done first as part of loading environment.mak
@@ -98,9 +98,9 @@ else
endif
touch $@
-build/build-doc-stamp: build/build-manpages-stamp build/configure-stamp
+build/build-debiandoc-stamp: build/configure-stamp
# Add here commands to compile the package.
- $(MAKE) doc
+ $(MAKE) debiandoc
touch $@
build/build-manpages-stamp: build/configure-stamp
@@ -121,7 +121,7 @@ debian/%.install: debian/%.install.in
binary-indep: apt-doc libapt-pkg-doc
# Build architecture-independent files here.
-libapt-pkg-doc: build-doc
+libapt-pkg-doc: build-debiandoc
dh_testdir -p$@
dh_testroot -p$@
dh_prep -p$@
@@ -147,7 +147,7 @@ libapt-pkg-doc: build-doc
dh_md5sums -p$@
dh_builddeb -p$@
-apt-doc: build-doc
+apt-doc: build-debiandoc
dh_testdir -p$@
dh_testroot -p$@
dh_prep -p$@
diff --git a/doc/makefile b/doc/makefile
index 220a6160d..8021bce3f 100644
--- a/doc/makefile
+++ b/doc/makefile
@@ -11,10 +11,7 @@ SOURCE = $(wildcard *.sgml)
DEBIANDOC_HTML_OPTIONS=-l en.UTF-8
include $(DEBIANDOC_H)
-MANPAGEPO = $(patsubst %.po,%,$(notdir $(wildcard po/*.po)))
-MANPAGEPOLIST = $(patsubst %,manpages-translation-%,$(MANPAGEPO))
-
-doc: manpages
+doc: manpages debiandoc
# Do not use XMLTO, build the manpages directly with XSLTPROC
ifdef XSLTPROC
@@ -27,29 +24,17 @@ LOCAL := manpage-$(firstword $(SOURCE))
$(LOCAL)-LIST := $(SOURCE)
# Install generation hooks
-manpages: $(MANPAGEPOLIST) $($(LOCAL)-LIST)
+manpages: $($(LOCAL)-LIST)
$($(LOCAL)-LIST) :: % : %.xml $(STYLESHEET) $(INCLUDES)
echo Creating man page $@
$(XSLTPROC) -o $@ $(STYLESHEET) $<
-$(MANPAGEPOLIST) :: manpages-translation-% : %/makefile po4a
- $(MAKE) -C $(dir $<) doc
-
-.PHONY: manpages dirs-manpage-subdirs $(MANPAGEPOLIST)
-dirs: dirs-manpage-subdirs
-dirs-manpage-subdirs:
- for i in $(MANPAGEPO); do \
- test -d $$i || mkdir $$i; \
- test -f $$i/makefile || sed "s#@@LANG@@#$$i#" lang.makefile > $$i/makefile; \
- done
-
# Clean rule
.PHONY: veryclean/$(LOCAL)
veryclean: veryclean/$(LOCAL)
veryclean/$(LOCAL):
-rm -rf $($(@F)-LIST)
-
endif
# Chain to the manpage rule
@@ -65,7 +50,7 @@ TO = $(DOC)
TARGET = binary
include $(COPY_H)
-.PHONY: clean clean-subdirs veryclean veryclean-subdirs all binary doc
+.PHONY: clean clean-subdirs veryclean veryclean-subdirs all binary doc stats
clean: clean-subdirs
veryclean: veryclean-subdirs
@@ -80,24 +65,53 @@ veryclean-subdirs:
rm -rf $$dir; \
done
-.PHONY: update-po po4a stats
+stats:
+ for i in po/*.po; do echo -n "$$i: "; msgfmt --output-file=/dev/null --statistics $$i; done
ifdef PO4A
-doc: po4a
+DOCUMENTATIONPO = $(patsubst %.po,%,$(notdir $(wildcard po/*.po)))
+MANPAGEPOLIST = $(addprefix manpages-translation-,$(DOCUMENTATIONPO))
+DEBIANDOCPOLIST = $(addprefix debiandoc-translation-,$(DOCUMENTATIONPO))
+
+MANPAGEDIRLIST = $(addsuffix /makefile,$(DOCUMENTATIONPO))
+
+.PHONY: update-po po4a $(MANPAGEPOLIST) $(MANPAGEDIRLIST)
+
+manpages: $(MANPAGEPOLIST)
+debiandoc: $(DEBIANDOCPOLIST)
+po4a: $(MANPAGEPOLIST) $(DEBIANDOCPOLIST)
update-po:
po4a --previous --no-backups --force --no-translations \
--package-name='$(PACKAGE)-doc' --package-version='$(PACKAGE_VERSION)' \
--msgid-bugs-address='$(PACKAGE_MAIL)' po4a.conf
-po4a:
- po4a --previous --no-backups \
+$(MANPAGEPOLIST) :: manpages-translation-% : %/makefile po4a.conf
+ po4a --previous --no-backups --translate-only $(dir $<)apt.ent \
+ $(patsubst %,--translate-only $(dir $<)%,$(patsubst %.1.xml,%.$(subst /,,$(dir $<)).1.xml,$(wildcard *.1.xml))) \
+ $(patsubst %,--translate-only $(dir $<)%,$(patsubst %.2.xml,%.$(subst /,,$(dir $<)).2.xml,$(wildcard *.2.xml))) \
+ $(patsubst %,--translate-only $(dir $<)%,$(patsubst %.3.xml,%.$(subst /,,$(dir $<)).3.xml,$(wildcard *.3.xml))) \
+ $(patsubst %,--translate-only $(dir $<)%,$(patsubst %.4.xml,%.$(subst /,,$(dir $<)).4.xml,$(wildcard *.4.xml))) \
+ $(patsubst %,--translate-only $(dir $<)%,$(patsubst %.5.xml,%.$(subst /,,$(dir $<)).5.xml,$(wildcard *.5.xml))) \
+ $(patsubst %,--translate-only $(dir $<)%,$(patsubst %.6.xml,%.$(subst /,,$(dir $<)).6.xml,$(wildcard *.6.xml))) \
+ $(patsubst %,--translate-only $(dir $<)%,$(patsubst %.7.xml,%.$(subst /,,$(dir $<)).7.xml,$(wildcard *.7.xml))) \
+ $(patsubst %,--translate-only $(dir $<)%,$(patsubst %.8.xml,%.$(subst /,,$(dir $<)).8.xml,$(wildcard *.8.xml))) \
--package-name='$(PACKAGE)-doc' --package-version='$(PACKAGE_VERSION)' \
--msgid-bugs-address='$(PACKAGE_MAIL)' po4a.conf
-endif
+ $(MAKE) -C $(dir $<) manpages
-stats:
- for i in po/*.po; do echo -n "$$i: "; msgfmt --output-file=/dev/null --statistics $$i; done
+$(DEBIANDOCPOLIST) :: debiandoc-translation-% : %/makefile po4a.conf
+ po4a --previous --no-backups --translate-only $(dir $<)apt.ent \
+ $(patsubst %,--translate-only $(dir $<)%,$(patsubst %.sgml,%.$(subst /,,$(dir $<)).sgml,$(wildcard *.sgml))) \
+ --package-name='$(PACKAGE)-doc' --package-version='$(PACKAGE_VERSION)' \
+ --msgid-bugs-address='$(PACKAGE_MAIL)' po4a.conf
+ $(MAKE) -C $(dir $<) debiandoc
+
+dirs: $(MANPAGEDIRLIST)
+$(MANPAGEDIRLIST) :: %/makefile : lang.makefile
+ test -d $(dir $@) || mkdir $(dir $@)
+ sed "s#@@LANG@@#$(subst /,,$(dir $@))#" $< > $@
+endif
ifdef DOXYGEN
DOXYGEN_SOURCES = $(shell find $(BASE)/apt-pkg -not -name .\\\#* -and \( -name \*.cc -or -name \*.h \) )
@@ -114,5 +128,5 @@ $(BUILD)/doc/doxygen-stamp: $(DOXYGEN_SOURCES) $(BUILD)/doc/Doxyfile
$(DOXYGEN) $(BUILD)/doc/Doxyfile
touch $(BUILD)/doc/doxygen-stamp
-doc: $(BUILD)/doc/doxygen-stamp
+debiandoc: $(BUILD)/doc/doxygen-stamp
endif
diff --git a/test/Makefile b/test/Makefile
index 8207ebdab..74bffccb7 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -7,7 +7,7 @@ ifndef NOISY
endif
.PHONY: startup headers library clean veryclean all binary program doc test update-po
-startup all clean veryclean binary program dirs test update-po manpages:
+startup all clean veryclean binary program dirs test update-po manpages debiandoc:
$(MAKE) -C libapt $@
$(MAKE) -C interactive-helper $@
--
cgit v1.2.3-70-g09d2
From e6cd40dc17722bbe6c9d734c3a58b39a18c34174 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Mon, 9 Jul 2012 17:38:40 +0200
Subject: start implementing an extremely simple webserver for testing APT
---
test/integration/framework | 7 +-
test/integration/skip-aptwebserver | 25 ++++
test/interactive-helper/aptwebserver.cc | 216 ++++++++++++++++++++++++++++++++
test/interactive-helper/makefile | 7 ++
4 files changed, 254 insertions(+), 1 deletion(-)
create mode 100755 test/integration/skip-aptwebserver
create mode 100644 test/interactive-helper/aptwebserver.cc
(limited to 'test')
diff --git a/test/integration/framework b/test/integration/framework
index 2d6ada117..a514bef20 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -688,7 +688,12 @@ signreleasefiles() {
}
changetowebserver() {
- if which weborf > /dev/null; then
+ if test -x ${BUILDDIRECTORY}/aptwebserver; then
+ cd aptarchive
+ LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/aptwebserver 2> /dev/null > /dev/null &
+ addtrap "kill $!;"
+ cd - > /dev/null
+ elif which weborf > /dev/null; then
weborf -xb aptarchive/ 2>&1 > /dev/null &
addtrap "kill $!;"
elif which gatling > /dev/null; then
diff --git a/test/integration/skip-aptwebserver b/test/integration/skip-aptwebserver
new file mode 100755
index 000000000..0622941ce
--- /dev/null
+++ b/test/integration/skip-aptwebserver
@@ -0,0 +1,25 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture 'amd64'
+
+buildsimplenativepackage 'apt' 'all' '1.0' 'stable'
+
+setupaptarchive
+changetowebserver
+
+rm -rf rootdir/var/lib/apt/lists
+aptget update -qq
+testequal 'Hit http://localhost stable InRelease
+Hit http://localhost stable/main Sources
+Hit http://localhost stable/main amd64 Packages
+Hit http://localhost stable/main Translation-en
+Reading package lists...' aptget update
+
+mv rootdir/var/lib/apt/lists/localhost* rootdir/var/lib/apt/lists/partial
+aptget update
+
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
new file mode 100644
index 000000000..7a3624b6e
--- /dev/null
+++ b/test/interactive-helper/aptwebserver.cc
@@ -0,0 +1,216 @@
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+char const * const httpcodeToStr(int httpcode) { /*{{{*/
+ switch (httpcode) {
+ // Informational 1xx
+ case 100: return "100 Continue";
+ case 101: return "101 Switching Protocols";
+ // Successful 2xx
+ case 200: return "200 OK";
+ case 201: return "201 Created";
+ case 202: return "202 Accepted";
+ case 203: return "203 Non-Authoritative Information";
+ case 204: return "204 No Content";
+ case 205: return "205 Reset Content";
+ case 206: return "206 Partial Conent";
+ // Redirections 3xx
+ case 300: return "300 Multiple Choices";
+ case 301: return "301 Moved Permanently";
+ case 302: return "302 Found";
+ case 303: return "303 See Other";
+ case 304: return "304 Not Modified";
+ case 305: return "304 Use Proxy";
+ case 307: return "307 Temporary Redirect";
+ // Client errors 4xx
+ case 400: return "400 Bad Request";
+ case 401: return "401 Unauthorized";
+ case 402: return "402 Payment Required";
+ case 403: return "403 Forbidden";
+ case 404: return "404 Not Found";
+ case 405: return "405 Method Not Allowed";
+ case 406: return "406 Not Acceptable";
+ case 407: return "Proxy Authentication Required";
+ case 408: return "Request Time-out";
+ case 409: return "Conflict";
+ case 410: return "Gone";
+ case 411: return "Length Required";
+ case 412: return "Precondition Failed";
+ case 413: return "Request Entity Too Large";
+ case 414: return "Request-URI Too Large";
+ case 415: return "Unsupported Media Type";
+ case 416: return "Requested range not satisfiable";
+ case 417: return "Expectation Failed";
+ // Server error 5xx
+ case 500: return "Internal Server Error";
+ case 501: return "Not Implemented";
+ case 502: return "Bad Gateway";
+ case 503: return "Service Unavailable";
+ case 504: return "Gateway Time-out";
+ case 505: return "HTTP Version not supported";
+ }
+ return NULL;
+} /*}}}*/
+void addFileHeaders(std::list &headers, FileFd &data) { /*{{{*/
+ std::ostringstream contentlength;
+ contentlength << "Content-Length: " << data.FileSize();
+ headers.push_back(contentlength.str());
+
+ std::string lastmodified("Last-Modified: ");
+ lastmodified.append(TimeRFC1123(data.ModificationTime()));
+ headers.push_back(lastmodified);
+} /*}}}*/
+bool sendHead(int client, int httpcode, std::list &headers) { /*{{{*/
+ string response("HTTP/1.1 ");
+ response.append(httpcodeToStr(httpcode));
+ headers.push_front(response);
+
+ headers.push_back("Server: APT webserver");
+
+ std::string date("Date: ");
+ date.append(TimeRFC1123(time(NULL)));
+ headers.push_back(date);
+
+ std::clog << ">>> RESPONSE >>>" << std::endl;
+ bool Success = true;
+ for (std::list::const_iterator h = headers.begin();
+ Success == true && h != headers.end(); ++h) {
+ Success &= FileFd::Write(client, h->c_str(), h->size());
+ Success &= FileFd::Write(client, "\r\n", 2);
+ std::clog << *h << std::endl;
+ }
+ Success &= FileFd::Write(client, "\r\n", 2);
+ std::clog << "<<<<<<<<<<<<<<<<" << std::endl;
+ return Success;
+} /*}}}*/
+bool sendFile(int client, FileFd &data) { /*{{{*/
+ bool Success = true;
+ char buffer[500];
+ unsigned long long actual = 0;
+ while ((Success &= data.Read(buffer, sizeof(buffer), &actual)) == true) {
+ if (actual == 0)
+ break;
+ Success &= FileFd::Write(client, buffer, actual);
+ }
+ Success &= FileFd::Write(client, "\r\n", 2);
+ return Success;
+} /*}}}*/
+bool sendData(int client, std::string &data) { /*{{{*/
+ bool Success = true;
+ Success &= FileFd::Write(client, data.c_str(), data.size());
+ Success &= FileFd::Write(client, "\r\n", 2);
+ return Success;
+} /*}}}*/
+void sendError(int client, int httpcode, string request, bool content) { /*{{{*/
+ std::list headers;
+ sendHead(client, httpcode, headers);
+ if (content == false)
+ return;
+ string response("");
+ response.append(httpcodeToStr(httpcode)).append("");
+ response.append("").append(httpcodeToStr(httpcode)).append("
");
+ response.append(request).append("");
+ sendData(client, response);
+} /*}}}*/
+
+int main(int argc, const char *argv[])
+{
+ // create socket, bind and listen to it {{{
+ int sock = socket(AF_INET6, SOCK_STREAM, 0);
+ if(sock < 0 ) {
+ _error->Errno("aptwerbserver", "Couldn't create socket");
+ _error->DumpErrors(std::cerr);
+ return 1;
+ }
+
+ // ensure that we accept all connections: v4 or v6
+ int const iponly = 0;
+ setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &iponly, sizeof(iponly));
+ // to not linger to an address
+ int const enable = 1;
+ setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable));
+
+ struct sockaddr_in6 locAddr;
+ memset(&locAddr, 0, sizeof(locAddr));
+ locAddr.sin6_family = AF_INET6;
+ locAddr.sin6_port = htons(8080);
+ locAddr.sin6_addr = in6addr_any;
+
+ if (bind(sock, (struct sockaddr*) &locAddr, sizeof(locAddr)) < 0) {
+ _error->Errno("aptwerbserver", "Couldn't bind");
+ _error->DumpErrors(std::cerr);
+ return 2;
+ }
+
+ listen(sock, 1);
+ /*}}}*/
+
+ std::vector messages;
+ int client;
+ while ((client = accept(sock, NULL, NULL)) != -1) {
+ std::clog << "ACCEPT client " << client << " on socket " << sock << std::endl;
+
+ while (ReadMessages(client, messages)) {
+ for (std::vector::const_iterator m = messages.begin();
+ m != messages.end(); ++m) {
+ std::clog << ">>> REQUEST >>>>" << std::endl << *m << std::endl << "<<<<<<<<<<<<<<<<" << std::endl;
+ std::list headers;
+ bool sendContent = true;
+ if (strncmp(m->c_str(), "HEAD ", 5) == 0)
+ sendContent = false;
+ if (strncmp(m->c_str(), "GET ", 4) != 0)
+ sendError(client, 501, *m, true);
+
+ std::string host = LookupTag(*m, "Host", "");
+ if (host.empty() == true) {
+ // RFC 2616 §14.23 Host
+ sendError(client, 400, *m, sendContent);
+ continue;
+ }
+
+ size_t const filestart = m->find(' ', 5);
+ string filename = m->substr(5, filestart - 5);
+
+ if (RealFileExists(filename) == false)
+ sendError(client, 404, *m, sendContent);
+ else {
+ FileFd data(filename, FileFd::ReadOnly);
+ std::string condition = LookupTag(*m, "If-Modified-Since", "");
+ if (condition.empty() == false) {
+ time_t cache;
+ if (RFC1123StrToTime(condition.c_str(), cache) == true && cache >= data.ModificationTime()) {
+ sendError(client, 304, *m, false);
+ continue;
+ }
+ }
+ addFileHeaders(headers, data);
+ sendHead(client, 200, headers);
+ if (sendContent == true)
+ sendFile(client, data);
+ }
+ }
+ _error->DumpErrors(std::cerr);
+ messages.clear();
+ }
+
+ std::clog << "CLOSE client " << client << " on socket " << sock << std::endl;
+ close(client);
+ }
+ return 0;
+}
diff --git a/test/interactive-helper/makefile b/test/interactive-helper/makefile
index 10d1e44ec..fee94cd77 100644
--- a/test/interactive-helper/makefile
+++ b/test/interactive-helper/makefile
@@ -37,3 +37,10 @@ include $(PROGRAM_H)
#SLIBS = -lapt-pkg -lrpm
#SOURCE = rpmver.cc
#include $(PROGRAM_H)
+
+# very simple webserver for APT testing
+PROGRAM=aptwebserver
+SLIBS = -lapt-pkg
+LIB_MAKES = apt-pkg/makefile
+SOURCE = aptwebserver.cc
+include $(PROGRAM_H)
--
cgit v1.2.3-70-g09d2
From 90d1d54ef2a68bd443815f26e9e2b578a1d7c419 Mon Sep 17 00:00:00 2001
From: Michael Vogt
Date: Tue, 10 Jul 2012 11:35:56 +0200
Subject: add commandline, add configurable port, add --simulate-paywall to
simulate a broken webserver that intercepts connections and returns nonsese
---
test/interactive-helper/aptwebserver.cc | 52 ++++++++++++++++++++++++++++-----
1 file changed, 45 insertions(+), 7 deletions(-)
(limited to 'test')
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index 7a3624b6e..3c476ad05 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -2,6 +2,8 @@
#include
#include
#include
+#include
+#include
#include
#include
@@ -66,6 +68,7 @@ char const * const httpcodeToStr(int httpcode) { /*{{{*/
}
return NULL;
} /*}}}*/
+
void addFileHeaders(std::list &headers, FileFd &data) { /*{{{*/
std::ostringstream contentlength;
contentlength << "Content-Length: " << data.FileSize();
@@ -98,6 +101,7 @@ bool sendHead(int client, int httpcode, std::list &headers) { /*{{{
std::clog << "<<<<<<<<<<<<<<<<" << std::endl;
return Success;
} /*}}}*/
+
bool sendFile(int client, FileFd &data) { /*{{{*/
bool Success = true;
char buffer[500];
@@ -110,12 +114,14 @@ bool sendFile(int client, FileFd &data) { /*{{{*/
Success &= FileFd::Write(client, "\r\n", 2);
return Success;
} /*}}}*/
+
bool sendData(int client, std::string &data) { /*{{{*/
bool Success = true;
Success &= FileFd::Write(client, data.c_str(), data.size());
Success &= FileFd::Write(client, "\r\n", 2);
return Success;
} /*}}}*/
+
void sendError(int client, int httpcode, string request, bool content) { /*{{{*/
std::list headers;
sendHead(client, httpcode, headers);
@@ -131,6 +137,19 @@ void sendError(int client, int httpcode, string request, bool content) { /*{{{*/
int main(int argc, const char *argv[])
{
+ CommandLine::Args Args[] = {
+ {0, "simulate-paywall", "aptwebserver::Simulate-Paywall",
+ CommandLine::Boolean},
+ {0, "port", "aptwebserver::port", CommandLine::HasArg},
+ {0,0,0,0}
+ };
+
+ CommandLine CmdL(Args, _config);
+ if(pkgInitConfig(*_config) == false || CmdL.Parse(argc,argv) == false) {
+ _error->DumpErrors();
+ exit(1);
+ }
+
// create socket, bind and listen to it {{{
int sock = socket(AF_INET6, SOCK_STREAM, 0);
if(sock < 0 ) {
@@ -139,6 +158,10 @@ int main(int argc, const char *argv[])
return 1;
}
+ // get the port
+ int const port = _config->FindI("aptwebserver::port", 8080);
+ bool const simulate_broken_server = _config->FindB("aptwebserver::Simulate-Paywall", false);
+
// ensure that we accept all connections: v4 or v6
int const iponly = 0;
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &iponly, sizeof(iponly));
@@ -149,7 +172,7 @@ int main(int argc, const char *argv[])
struct sockaddr_in6 locAddr;
memset(&locAddr, 0, sizeof(locAddr));
locAddr.sin6_family = AF_INET6;
- locAddr.sin6_port = htons(8080);
+ locAddr.sin6_port = htons(port);
locAddr.sin6_addr = in6addr_any;
if (bind(sock, (struct sockaddr*) &locAddr, sizeof(locAddr)) < 0) {
@@ -158,18 +181,26 @@ int main(int argc, const char *argv[])
return 2;
}
+ if (simulate_broken_server) {
+ std::clog << "Simulating a broken web server that return nonsense "
+ "for all querries" << std::endl;
+ } else {
+ std::clog << "Serving ANY file on port: " << port << std::endl;
+ }
+
listen(sock, 1);
- /*}}}*/
std::vector messages;
int client;
while ((client = accept(sock, NULL, NULL)) != -1) {
- std::clog << "ACCEPT client " << client << " on socket " << sock << std::endl;
+ std::clog << "ACCEPT client " << client
+ << " on socket " << sock << std::endl;
while (ReadMessages(client, messages)) {
for (std::vector::const_iterator m = messages.begin();
m != messages.end(); ++m) {
- std::clog << ">>> REQUEST >>>>" << std::endl << *m << std::endl << "<<<<<<<<<<<<<<<<" << std::endl;
+ std::clog << ">>> REQUEST >>>>" << std::endl << *m
+ << std::endl << "<<<<<<<<<<<<<<<<" << std::endl;
std::list headers;
bool sendContent = true;
if (strncmp(m->c_str(), "HEAD ", 5) == 0)
@@ -187,14 +218,20 @@ int main(int argc, const char *argv[])
size_t const filestart = m->find(' ', 5);
string filename = m->substr(5, filestart - 5);
- if (RealFileExists(filename) == false)
+ if (simulate_broken_server == true) {
+ sendHead(client, 200, headers);
+ string data("ni ni ni");
+ sendData(client, data);
+ }
+ else if (RealFileExists(filename) == false)
sendError(client, 404, *m, sendContent);
else {
FileFd data(filename, FileFd::ReadOnly);
std::string condition = LookupTag(*m, "If-Modified-Since", "");
if (condition.empty() == false) {
time_t cache;
- if (RFC1123StrToTime(condition.c_str(), cache) == true && cache >= data.ModificationTime()) {
+ if (RFC1123StrToTime(condition.c_str(), cache) == true &&
+ cache >= data.ModificationTime()) {
sendError(client, 304, *m, false);
continue;
}
@@ -209,7 +246,8 @@ int main(int argc, const char *argv[])
messages.clear();
}
- std::clog << "CLOSE client " << client << " on socket " << sock << std::endl;
+ std::clog << "CLOSE client " << client
+ << " on socket " << sock << std::endl;
close(client);
}
return 0;
--
cgit v1.2.3-70-g09d2
From da3ebfe79d570c3aeb5f0a407cfec7996f44420c Mon Sep 17 00:00:00 2001
From: Michael Vogt
Date: Tue, 10 Jul 2012 12:01:46 +0200
Subject: add failing regression test for bug #346386
---
test/integration/framework | 9 ++++++++-
test/integration/test-ubuntu-bug346386 | 19 +++++++++++++++++++
test/interactive-helper/aptwebserver.cc | 8 ++++----
3 files changed, 31 insertions(+), 5 deletions(-)
create mode 100755 test/integration/test-ubuntu-bug346386
(limited to 'test')
diff --git a/test/integration/framework b/test/integration/framework
index a514bef20..bf46ae0c5 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -687,10 +687,17 @@ signreleasefiles() {
msgdone "info"
}
+simulatebrokenwebserver() {
+ if ! test -x ${BUILDDIRECTORY}/aptwebserver; then
+ msgdie 'Need the aptwebserver to simulate broken connections'
+ fi
+ changetowebserver '--simulate-paywall'
+}
+
changetowebserver() {
if test -x ${BUILDDIRECTORY}/aptwebserver; then
cd aptarchive
- LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/aptwebserver 2> /dev/null > /dev/null &
+ LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/aptwebserver $@ 2> /dev/null > /dev/null &
addtrap "kill $!;"
cd - > /dev/null
elif which weborf > /dev/null; then
diff --git a/test/integration/test-ubuntu-bug346386 b/test/integration/test-ubuntu-bug346386
new file mode 100755
index 000000000..57004f343
--- /dev/null
+++ b/test/integration/test-ubuntu-bug346386
@@ -0,0 +1,19 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture 'amd64'
+
+buildsimplenativepackage 'apt' 'all' '1.0' 'stable'
+
+setupaptarchive
+simulatebrokenwebserver
+
+rm -rf rootdir/var/lib/apt/lists
+aptget update
+testequal 'partial' "$(ls rootdir/var/lib/apt/lists/)"
+
+
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index 3c476ad05..c7b815925 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -244,11 +244,11 @@ int main(int argc, const char *argv[])
}
_error->DumpErrors(std::cerr);
messages.clear();
- }
- std::clog << "CLOSE client " << client
- << " on socket " << sock << std::endl;
- close(client);
+ std::clog << "CLOSE client " << client
+ << " on socket " << sock << std::endl;
+ close(client);
+ }
}
return 0;
}
--
cgit v1.2.3-70-g09d2
From a38a00b981de3031a51e76c8a2e220b59557c469 Mon Sep 17 00:00:00 2001
From: Michael Vogt
Date: Tue, 10 Jul 2012 12:26:15 +0200
Subject: always send content-length via the new addDataHeaders() to ensure
w3m/curl are happy too for 404 pages and to comply with the http 1.1 spec
---
test/interactive-helper/aptwebserver.cc | 34 +++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
(limited to 'test')
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index c7b815925..ebe04d2a3 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -78,6 +78,13 @@ void addFileHeaders(std::list &headers, FileFd &data) { /*{{{*/
lastmodified.append(TimeRFC1123(data.ModificationTime()));
headers.push_back(lastmodified);
} /*}}}*/
+
+void addDataHeaders(std::list &headers, std::string &data) {/*{{{*/
+ std::ostringstream contentlength;
+ contentlength << "Content-Length: " << data.size();
+ headers.push_back(contentlength.str());
+} /*}}}*/
+
bool sendHead(int client, int httpcode, std::list &headers) { /*{{{*/
string response("HTTP/1.1 ");
response.append(httpcodeToStr(httpcode));
@@ -124,14 +131,16 @@ bool sendData(int client, std::string &data) { /*{{{*/
void sendError(int client, int httpcode, string request, bool content) { /*{{{*/
std::list headers;
+ string response;
+ if (content == true) {
+ response.append("");
+ response.append(httpcodeToStr(httpcode)).append("");
+ response.append("").append(httpcodeToStr(httpcode)).append("
");
+ response.append(request).append("");
+ addDataHeaders(headers, response);
+ }
sendHead(client, httpcode, headers);
- if (content == false)
- return;
- string response("");
- response.append(httpcodeToStr(httpcode)).append("");
- response.append("").append(httpcodeToStr(httpcode)).append("
");
- response.append(request).append("");
sendData(client, response);
} /*}}}*/
@@ -219,8 +228,9 @@ int main(int argc, const char *argv[])
string filename = m->substr(5, filestart - 5);
if (simulate_broken_server == true) {
+ string data("ni ni ni\n");
+ addDataHeaders(headers, data);
sendHead(client, 200, headers);
- string data("ni ni ni");
sendData(client, data);
}
else if (RealFileExists(filename) == false)
@@ -244,11 +254,11 @@ int main(int argc, const char *argv[])
}
_error->DumpErrors(std::cerr);
messages.clear();
-
- std::clog << "CLOSE client " << client
- << " on socket " << sock << std::endl;
- close(client);
}
+
+ std::clog << "CLOSE client " << client
+ << " on socket " << sock << std::endl;
+ close(client);
}
return 0;
}
--
cgit v1.2.3-70-g09d2
From 3ce22d4f714414d6deb8b044c5b08a8fe7a78967 Mon Sep 17 00:00:00 2001
From: Michael Vogt
Date: Tue, 10 Jul 2012 13:19:54 +0200
Subject: cleanup, thanks to donkult for his feedback
---
test/integration/framework | 9 +++------
test/integration/test-ubuntu-bug346386 | 2 +-
test/interactive-helper/aptwebserver.cc | 2 +-
3 files changed, 5 insertions(+), 8 deletions(-)
(limited to 'test')
diff --git a/test/integration/framework b/test/integration/framework
index bf46ae0c5..8f37d4a03 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -687,14 +687,11 @@ signreleasefiles() {
msgdone "info"
}
-simulatebrokenwebserver() {
- if ! test -x ${BUILDDIRECTORY}/aptwebserver; then
- msgdie 'Need the aptwebserver to simulate broken connections'
+changetowebserver() {
+ if [ -n "$1" ] && ! test -x ${BUILDDIRECTORY}/aptwebserver; then
+ msgdie 'Need the aptwebserver when passing arguments'
fi
- changetowebserver '--simulate-paywall'
-}
-changetowebserver() {
if test -x ${BUILDDIRECTORY}/aptwebserver; then
cd aptarchive
LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/aptwebserver $@ 2> /dev/null > /dev/null &
diff --git a/test/integration/test-ubuntu-bug346386 b/test/integration/test-ubuntu-bug346386
index 57004f343..a5f502853 100755
--- a/test/integration/test-ubuntu-bug346386
+++ b/test/integration/test-ubuntu-bug346386
@@ -10,7 +10,7 @@ configarchitecture 'amd64'
buildsimplenativepackage 'apt' 'all' '1.0' 'stable'
setupaptarchive
-simulatebrokenwebserver
+changetowebserver --simulate-paywall
rm -rf rootdir/var/lib/apt/lists
aptget update
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index ebe04d2a3..8fbb9eab9 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -154,7 +154,7 @@ int main(int argc, const char *argv[])
};
CommandLine CmdL(Args, _config);
- if(pkgInitConfig(*_config) == false || CmdL.Parse(argc,argv) == false) {
+ if(CmdL.Parse(argc,argv) == false) {
_error->DumpErrors();
exit(1);
}
--
cgit v1.2.3-70-g09d2
From 549b49394848d051dc116600571df55d7160eeaa Mon Sep 17 00:00:00 2001
From: Michael Vogt
Date: Tue, 10 Jul 2012 14:10:19 +0200
Subject: improve test some more
---
test/integration/framework | 1 +
test/integration/test-ubuntu-bug346386 | 32 ++++++++++++++++++++++++++++++--
2 files changed, 31 insertions(+), 2 deletions(-)
(limited to 'test')
diff --git a/test/integration/framework b/test/integration/framework
index 8f37d4a03..d15fd0e01 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -688,6 +688,7 @@ signreleasefiles() {
}
changetowebserver() {
+
if [ -n "$1" ] && ! test -x ${BUILDDIRECTORY}/aptwebserver; then
msgdie 'Need the aptwebserver when passing arguments'
fi
diff --git a/test/integration/test-ubuntu-bug346386 b/test/integration/test-ubuntu-bug346386
index a5f502853..1fbfb5ca4 100755
--- a/test/integration/test-ubuntu-bug346386
+++ b/test/integration/test-ubuntu-bug346386
@@ -1,6 +1,24 @@
#!/bin/sh
set -e
+ensure_n_canary_strings_in_dir() {
+ DIR=$1
+ CANARY_STRING=$2
+ EXPECTED_N=$3
+
+ msgtest "Testing for $EXPECTED_N canary strings '$CANARY_STRING' in in $DIR"
+
+
+ N=$(grep "$CANARY_STRING" $DIR/* 2>/dev/null |wc -l )
+ if [ "$N" = "$EXPECTED_N" ]; then
+ msgpass
+ return 0
+ else
+ msgfail "Expected $EXPECTED_N canaries, got $N"
+ return 1
+ fi
+}
+
TESTDIR=$(readlink -f $(dirname $0))
. $TESTDIR/framework
@@ -13,7 +31,17 @@ setupaptarchive
changetowebserver --simulate-paywall
rm -rf rootdir/var/lib/apt/lists
-aptget update
-testequal 'partial' "$(ls rootdir/var/lib/apt/lists/)"
+if aptget update -qq 2>/dev/null; then
+ msgfail "excpected apt-get update failure"
+fi
+ensure_n_canary_strings_in_dir rootdir/var/lib/apt/lists/ "ni ni ni" 0
+testequal 'partial' ls rootdir/var/lib/apt/lists/
+# again, this time with pre-existing files valid data
+for f in Release Release.gpg main_binary-amd64_Packages stable_main_source_Sources; do
+ echo "canary" > rootdir/var/lib/apt/lists/localhost:8080_dists_stable_${f}
+done
+# this will fail, the important part is that the canaries remain
+aptget update -qq 2>/dev/null || true
+ensure_n_canary_strings_in_dir rootdir/var/lib/apt/lists/ "canary" 4
--
cgit v1.2.3-70-g09d2
From 721b05b8501b3ffffcaef4d90b4f24e2a72b0fef Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Tue, 10 Jul 2012 15:28:28 +0200
Subject: rename the paywall testcase and reformat it a bit
---
.../test-ubuntu-bug-346386-apt-get-update-paywall | 47 ++++++++++++++++++++++
test/integration/test-ubuntu-bug346386 | 47 ----------------------
2 files changed, 47 insertions(+), 47 deletions(-)
create mode 100755 test/integration/test-ubuntu-bug-346386-apt-get-update-paywall
delete mode 100755 test/integration/test-ubuntu-bug346386
(limited to 'test')
diff --git a/test/integration/test-ubuntu-bug-346386-apt-get-update-paywall b/test/integration/test-ubuntu-bug-346386-apt-get-update-paywall
new file mode 100755
index 000000000..25cccf067
--- /dev/null
+++ b/test/integration/test-ubuntu-bug-346386-apt-get-update-paywall
@@ -0,0 +1,47 @@
+#!/bin/sh
+set -e
+
+ensure_n_canary_strings_in_dir() {
+ DIR=$1
+ CANARY_STRING=$2
+ EXPECTED_N=$3
+
+ msgtest "Testing for $EXPECTED_N canary strings '$CANARY_STRING' in in" "$DIR"
+
+ N=$(grep "$CANARY_STRING" $DIR/* 2>/dev/null |wc -l )
+ if [ "$N" = "$EXPECTED_N" ]; then
+ msgpass
+ return 0
+ else
+ msgfail "Expected $EXPECTED_N canaries, got $N"
+ return 1
+ fi
+}
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture 'native'
+
+insertpackage 'unstable' 'unrelated' 'all' '1.0' 'stable'
+
+setupaptarchive
+changetowebserver --simulate-paywall
+
+rm -rf rootdir/var/lib/apt/lists
+msgtest 'excpected failure of' 'apt-get update'
+aptget update -qq 2>/dev/null && msgfail || msgpass
+
+ensure_n_canary_strings_in_dir rootdir/var/lib/apt/lists/ 'ni ni ni' 0
+testequal 'partial' ls rootdir/var/lib/apt/lists/
+
+# again, this time with pre-existing files valid data
+for f in Release Release.gpg main_binary-amd64_Packages stable_main_source_Sources; do
+ echo "canary" > rootdir/var/lib/apt/lists/localhost:8080_dists_stable_${f}
+done
+
+# this will fail, the important part is that the canaries remain
+msgtest 'excpected failure of' 'apt-get update'
+aptget update -qq 2>/dev/null && msgfail || msgpass
+ensure_n_canary_strings_in_dir rootdir/var/lib/apt/lists/ 'canary' 4
diff --git a/test/integration/test-ubuntu-bug346386 b/test/integration/test-ubuntu-bug346386
deleted file mode 100755
index 1fbfb5ca4..000000000
--- a/test/integration/test-ubuntu-bug346386
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-set -e
-
-ensure_n_canary_strings_in_dir() {
- DIR=$1
- CANARY_STRING=$2
- EXPECTED_N=$3
-
- msgtest "Testing for $EXPECTED_N canary strings '$CANARY_STRING' in in $DIR"
-
-
- N=$(grep "$CANARY_STRING" $DIR/* 2>/dev/null |wc -l )
- if [ "$N" = "$EXPECTED_N" ]; then
- msgpass
- return 0
- else
- msgfail "Expected $EXPECTED_N canaries, got $N"
- return 1
- fi
-}
-
-TESTDIR=$(readlink -f $(dirname $0))
-. $TESTDIR/framework
-
-setupenvironment
-configarchitecture 'amd64'
-
-buildsimplenativepackage 'apt' 'all' '1.0' 'stable'
-
-setupaptarchive
-changetowebserver --simulate-paywall
-
-rm -rf rootdir/var/lib/apt/lists
-if aptget update -qq 2>/dev/null; then
- msgfail "excpected apt-get update failure"
-fi
-ensure_n_canary_strings_in_dir rootdir/var/lib/apt/lists/ "ni ni ni" 0
-testequal 'partial' ls rootdir/var/lib/apt/lists/
-
-# again, this time with pre-existing files valid data
-for f in Release Release.gpg main_binary-amd64_Packages stable_main_source_Sources; do
- echo "canary" > rootdir/var/lib/apt/lists/localhost:8080_dists_stable_${f}
-done
-# this will fail, the important part is that the canaries remain
-aptget update -qq 2>/dev/null || true
-ensure_n_canary_strings_in_dir rootdir/var/lib/apt/lists/ "canary" 4
-
--
cgit v1.2.3-70-g09d2
From dc57a59b1e7a904ad7263245fa2b1d6a5a55655e Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Tue, 10 Jul 2012 18:00:11 +0200
Subject: reformat the aptwebserver code to look more like the rest of APT
---
test/interactive-helper/aptwebserver.cc | 89 ++++++++++++++++-----------------
1 file changed, 44 insertions(+), 45 deletions(-)
(limited to 'test')
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index 8fbb9eab9..97a298c70 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -18,7 +18,7 @@
#include
#include
-char const * const httpcodeToStr(int httpcode) { /*{{{*/
+char const * const httpcodeToStr(int const httpcode) { /*{{{*/
switch (httpcode) {
// Informational 1xx
case 100: return "100 Continue";
@@ -67,9 +67,9 @@ char const * const httpcodeToStr(int httpcode) { /*{{{*/
case 505: return "HTTP Version not supported";
}
return NULL;
-} /*}}}*/
-
-void addFileHeaders(std::list &headers, FileFd &data) { /*{{{*/
+}
+ /*}}}*/
+void addFileHeaders(std::list &headers, FileFd &data) { /*{{{*/
std::ostringstream contentlength;
contentlength << "Content-Length: " << data.FileSize();
headers.push_back(contentlength.str());
@@ -77,15 +77,15 @@ void addFileHeaders(std::list &headers, FileFd &data) { /*{{{*/
std::string lastmodified("Last-Modified: ");
lastmodified.append(TimeRFC1123(data.ModificationTime()));
headers.push_back(lastmodified);
-} /*}}}*/
-
+}
+ /*}}}*/
void addDataHeaders(std::list &headers, std::string &data) {/*{{{*/
std::ostringstream contentlength;
contentlength << "Content-Length: " << data.size();
headers.push_back(contentlength.str());
-} /*}}}*/
-
-bool sendHead(int client, int httpcode, std::list &headers) { /*{{{*/
+}
+ /*}}}*/
+bool sendHead(int const client, int const httpcode, std::list &headers) { /*{{{*/
string response("HTTP/1.1 ");
response.append(httpcodeToStr(httpcode));
headers.push_front(response);
@@ -107,9 +107,9 @@ bool sendHead(int client, int httpcode, std::list &headers) { /*{{{
Success &= FileFd::Write(client, "\r\n", 2);
std::clog << "<<<<<<<<<<<<<<<<" << std::endl;
return Success;
-} /*}}}*/
-
-bool sendFile(int client, FileFd &data) { /*{{{*/
+}
+ /*}}}*/
+bool sendFile(int const client, FileFd &data) { /*{{{*/
bool Success = true;
char buffer[500];
unsigned long long actual = 0;
@@ -120,34 +120,32 @@ bool sendFile(int client, FileFd &data) { /*{{{*/
}
Success &= FileFd::Write(client, "\r\n", 2);
return Success;
-} /*}}}*/
-
-bool sendData(int client, std::string &data) { /*{{{*/
+}
+ /*}}}*/
+bool sendData(int const client, std::string const &data) { /*{{{*/
bool Success = true;
Success &= FileFd::Write(client, data.c_str(), data.size());
Success &= FileFd::Write(client, "\r\n", 2);
return Success;
-} /*}}}*/
-
-void sendError(int client, int httpcode, string request, bool content) { /*{{{*/
+}
+ /*}}}*/
+void sendError(int const client, int const httpcode, string const &request, bool content) { /*{{{*/
std::list headers;
- string response;
- if (content == true) {
- response.append("");
- response.append(httpcodeToStr(httpcode)).append("");
- response.append("").append(httpcodeToStr(httpcode)).append("
");
- response.append(request).append("");
- addDataHeaders(headers, response);
- }
+ string response("");
+ response.append(httpcodeToStr(httpcode)).append("");
+ response.append("").append(httpcodeToStr(httpcode)).append("
");
+ response.append(request).append("");
+ addDataHeaders(headers, response);
sendHead(client, httpcode, headers);
- sendData(client, response);
-} /*}}}*/
-
-int main(int argc, const char *argv[])
+ if (content == true)
+ sendData(client, response);
+}
+ /*}}}*/
+int main(int const argc, const char * argv[])
{
CommandLine::Args Args[] = {
- {0, "simulate-paywall", "aptwebserver::Simulate-Paywall",
+ {0, "simulate-paywall", "aptwebserver::Simulate-Paywall",
CommandLine::Boolean},
{0, "port", "aptwebserver::port", CommandLine::HasArg},
{0,0,0,0}
@@ -198,18 +196,19 @@ int main(int argc, const char *argv[])
}
listen(sock, 1);
+ /*}}}*/
std::vector messages;
int client;
while ((client = accept(sock, NULL, NULL)) != -1) {
std::clog << "ACCEPT client " << client
- << " on socket " << sock << std::endl;
+ << " on socket " << sock << std::endl;
while (ReadMessages(client, messages)) {
for (std::vector::const_iterator m = messages.begin();
m != messages.end(); ++m) {
- std::clog << ">>> REQUEST >>>>" << std::endl << *m
- << std::endl << "<<<<<<<<<<<<<<<<" << std::endl;
+ std::clog << ">>> REQUEST >>>>" << std::endl << *m
+ << std::endl << "<<<<<<<<<<<<<<<<" << std::endl;
std::list headers;
bool sendContent = true;
if (strncmp(m->c_str(), "HEAD ", 5) == 0)
@@ -227,12 +226,12 @@ int main(int argc, const char *argv[])
size_t const filestart = m->find(' ', 5);
string filename = m->substr(5, filestart - 5);
- if (simulate_broken_server == true) {
- string data("ni ni ni\n");
- addDataHeaders(headers, data);
- sendHead(client, 200, headers);
- sendData(client, data);
- }
+ if (simulate_broken_server == true) {
+ string data("ni ni ni\n");
+ addDataHeaders(headers, data);
+ sendHead(client, 200, headers);
+ sendData(client, data);
+ }
else if (RealFileExists(filename) == false)
sendError(client, 404, *m, sendContent);
else {
@@ -240,8 +239,8 @@ int main(int argc, const char *argv[])
std::string condition = LookupTag(*m, "If-Modified-Since", "");
if (condition.empty() == false) {
time_t cache;
- if (RFC1123StrToTime(condition.c_str(), cache) == true &&
- cache >= data.ModificationTime()) {
+ if (RFC1123StrToTime(condition.c_str(), cache) == true &&
+ cache >= data.ModificationTime()) {
sendError(client, 304, *m, false);
continue;
}
@@ -256,8 +255,8 @@ int main(int argc, const char *argv[])
messages.clear();
}
- std::clog << "CLOSE client " << client
- << " on socket " << sock << std::endl;
+ std::clog << "CLOSE client " << client
+ << " on socket " << sock << std::endl;
close(client);
}
return 0;
--
cgit v1.2.3-70-g09d2
From d64053295c5544c62d7743c13bd415e42cf8f84d Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Tue, 10 Jul 2012 20:03:00 +0200
Subject: implement directory listing in your webserver
---
test/interactive-helper/aptwebserver.cc | 95 +++++++++++++++++++++++++++++++--
1 file changed, 91 insertions(+), 4 deletions(-)
(limited to 'test')
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index 97a298c70..0b2720dad 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -12,11 +12,13 @@
#include
#include
+#include
#include
#include
#include
#include
#include
+#include
char const * const httpcodeToStr(int const httpcode) { /*{{{*/
switch (httpcode) {
@@ -142,6 +144,86 @@ void sendError(int const client, int const httpcode, string const &request, bool
sendData(client, response);
}
/*}}}*/
+// sendDirectoryLisiting /*{{{*/
+int filter_hidden_files(const struct dirent *a) {
+ if (a->d_name[0] == '.')
+ return 0;
+#ifdef _DIRENT_HAVE_D_TYPE
+ // if we have the d_type check that only files and dirs will be included
+ if (a->d_type != DT_UNKNOWN &&
+ a->d_type != DT_REG &&
+ a->d_type != DT_LNK && // this includes links to regular files
+ a->d_type != DT_DIR)
+ return 0;
+#endif
+ return 1;
+}
+int grouped_alpha_case_sort(const struct dirent **a, const struct dirent **b) {
+#ifdef _DIRENT_HAVE_D_TYPE
+ if ((*a)->d_type == DT_DIR && (*b)->d_type == DT_DIR);
+ else if ((*a)->d_type == DT_DIR && (*b)->d_type == DT_REG)
+ return -1;
+ else if ((*b)->d_type == DT_DIR && (*a)->d_type == DT_REG)
+ return 1;
+ else
+#endif
+ {
+ struct stat f_prop; //File's property
+ stat((*a)->d_name, &f_prop);
+ int const amode = f_prop.st_mode;
+ stat((*b)->d_name, &f_prop);
+ int const bmode = f_prop.st_mode;
+ if (S_ISDIR(amode) && S_ISDIR(bmode));
+ else if (S_ISDIR(amode))
+ return -1;
+ else if (S_ISDIR(bmode))
+ return 1;
+ }
+ return strcasecmp((*a)->d_name, (*b)->d_name);
+}
+void sendDirectoryListing(int const client, string const &dir, string const &request, bool content) {
+ std::list headers;
+ std::ostringstream listing;
+
+ struct dirent **namelist;
+ int const counter = scandir(dir.c_str(), &namelist, filter_hidden_files, grouped_alpha_case_sort);
+ if (counter == -1) {
+ sendError(client, 500, request, content);
+ return;
+ }
+
+ listing << "Index of " << dir << ""
+ << ""
+ << "" << std::endl
+ << "Index of " << dir << "
" << std::endl
+ << "| # | Name | Size | Last-Modified |
" << std::endl;
+ if (dir != ".")
+ listing << "| d | Parent Directory | - | - |
";
+ for (int i = 0; i < counter; ++i) {
+ struct stat fs;
+ std::string filename(dir);
+ filename.append("/").append(namelist[i]->d_name);
+ stat(filename.c_str(), &fs);
+ listing << "| " << ((S_ISDIR(fs.st_mode)) ? 'd' : 'f') << " | "
+ << "d_name << "\">" << namelist[i]->d_name << " | ";
+ if (S_ISDIR(fs.st_mode))
+ listing << "- | ";
+ else
+ listing << "" << SizeToStr(fs.st_size) << "B | ";
+ listing << "" << TimeRFC1123(fs.st_mtime) << " |
" << std::endl;
+ }
+ listing << "
" << std::endl;
+
+ std::string response(listing.str());
+ addDataHeaders(headers, response);
+ sendHead(client, 200, headers);
+ if (content == true)
+ sendData(client, response);
+}
+ /*}}}*/
int main(int const argc, const char * argv[])
{
CommandLine::Args Args[] = {
@@ -225,6 +307,8 @@ int main(int const argc, const char * argv[])
size_t const filestart = m->find(' ', 5);
string filename = m->substr(5, filestart - 5);
+ if (filename.empty() == true)
+ filename = ".";
if (simulate_broken_server == true) {
string data("ni ni ni\n");
@@ -232,16 +316,14 @@ int main(int const argc, const char * argv[])
sendHead(client, 200, headers);
sendData(client, data);
}
- else if (RealFileExists(filename) == false)
- sendError(client, 404, *m, sendContent);
- else {
+ else if (RealFileExists(filename) == true) {
FileFd data(filename, FileFd::ReadOnly);
std::string condition = LookupTag(*m, "If-Modified-Since", "");
if (condition.empty() == false) {
time_t cache;
if (RFC1123StrToTime(condition.c_str(), cache) == true &&
cache >= data.ModificationTime()) {
- sendError(client, 304, *m, false);
+ sendHead(client, 304, headers);
continue;
}
}
@@ -250,6 +332,11 @@ int main(int const argc, const char * argv[])
if (sendContent == true)
sendFile(client, data);
}
+ else if (DirectoryExists(filename) == true) {
+ sendDirectoryListing(client, filename, *m, sendContent);
+ }
+ else
+ sendError(client, 404, *m, false);
}
_error->DumpErrors(std::cerr);
messages.clear();
--
cgit v1.2.3-70-g09d2
From 4958ba98e66af264e1f03f5dbacc713e51cd437d Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Tue, 10 Jul 2012 20:05:05 +0200
Subject: include our usual config.h in the webserver
---
test/interactive-helper/aptwebserver.cc | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
(limited to 'test')
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index 0b2720dad..0780288a4 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -1,3 +1,5 @@
+#include
+
#include
#include
#include
@@ -88,7 +90,7 @@ void addDataHeaders(std::list &headers, std::string &data) {/*{{{*/
}
/*}}}*/
bool sendHead(int const client, int const httpcode, std::list &headers) { /*{{{*/
- string response("HTTP/1.1 ");
+ std::string response("HTTP/1.1 ");
response.append(httpcodeToStr(httpcode));
headers.push_front(response);
@@ -131,9 +133,9 @@ bool sendData(int const client, std::string const &data) { /*{{{*/
return Success;
}
/*}}}*/
-void sendError(int const client, int const httpcode, string const &request, bool content) { /*{{{*/
+void sendError(int const client, int const httpcode, std::string const &request, bool content) { /*{{{*/
std::list headers;
- string response("");
+ std::string response("");
response.append(httpcodeToStr(httpcode)).append("");
response.append("").append(httpcodeToStr(httpcode)).append("
");
@@ -181,7 +183,7 @@ int grouped_alpha_case_sort(const struct dirent **a, const struct dirent **b) {
}
return strcasecmp((*a)->d_name, (*b)->d_name);
}
-void sendDirectoryListing(int const client, string const &dir, string const &request, bool content) {
+void sendDirectoryListing(int const client, std::string const &dir, std::string const &request, bool content) {
std::list headers;
std::ostringstream listing;
@@ -306,12 +308,12 @@ int main(int const argc, const char * argv[])
}
size_t const filestart = m->find(' ', 5);
- string filename = m->substr(5, filestart - 5);
+ std::string filename = m->substr(5, filestart - 5);
if (filename.empty() == true)
filename = ".";
if (simulate_broken_server == true) {
- string data("ni ni ni\n");
+ std::string data("ni ni ni\n");
addDataHeaders(headers, data);
sendHead(client, 200, headers);
sendData(client, data);
--
cgit v1.2.3-70-g09d2
From 59fe94ea0135b1f8bc3d66e97460bd481054b061 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Tue, 10 Jul 2012 20:08:58 +0200
Subject: http get requests need to be dequoted
---
test/interactive-helper/aptwebserver.cc | 2 ++
1 file changed, 2 insertions(+)
(limited to 'test')
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index 0780288a4..920ab3bcc 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -311,6 +311,8 @@ int main(int const argc, const char * argv[])
std::string filename = m->substr(5, filestart - 5);
if (filename.empty() == true)
filename = ".";
+ else
+ filename = DeQuoteString(filename);
if (simulate_broken_server == true) {
std::string data("ni ni ni\n");
--
cgit v1.2.3-70-g09d2
From 64a28515923aa67a1d109a82aba1892cd227bb15 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Wed, 11 Jul 2012 00:46:27 +0200
Subject: ensure that directories are accessed with a slash at the end of the
url
---
test/interactive-helper/aptwebserver.cc | 40 +++++++++++++++++++++++++++------
1 file changed, 33 insertions(+), 7 deletions(-)
(limited to 'test')
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index 920ab3bcc..2052fe6d8 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -146,6 +146,26 @@ void sendError(int const client, int const httpcode, std::string const &request,
sendData(client, response);
}
/*}}}*/
+void sendRedirect(int const client, int const httpcode, std::string const &uri, std::string const &request, bool content) { /*{{{*/
+ std::list headers;
+ std::string response("");
+ response.append(httpcodeToStr(httpcode)).append("");
+ response.append("").append(httpcodeToStr(httpcode)).append("
You should be redirected to ").append(uri).append("
");
+ response.append("This page is a result of the request: ");
+ response.append(request).append("");
+ addDataHeaders(headers, response);
+ std::string location("Location: ");
+ if (strncmp(uri.c_str(), "http://", 7) != 0)
+ location.append("http://").append(LookupTag(request, "Host")).append("/").append(uri);
+ else
+ location.append(uri);
+ headers.push_back(location);
+ sendHead(client, httpcode, headers);
+ if (content == true)
+ sendData(client, response);
+}
+ /*}}}*/
// sendDirectoryLisiting /*{{{*/
int filter_hidden_files(const struct dirent *a) {
if (a->d_name[0] == '.')
@@ -209,12 +229,15 @@ void sendDirectoryListing(int const client, std::string const &dir, std::string
std::string filename(dir);
filename.append("/").append(namelist[i]->d_name);
stat(filename.c_str(), &fs);
- listing << "| " << ((S_ISDIR(fs.st_mode)) ? 'd' : 'f') << " | "
- << "d_name << "\">" << namelist[i]->d_name << " | ";
- if (S_ISDIR(fs.st_mode))
- listing << "- | ";
- else
- listing << "" << SizeToStr(fs.st_size) << "B | ";
+ if (S_ISDIR(fs.st_mode)) {
+ listing << "
| d | "
+ << "d_name << "/\">" << namelist[i]->d_name << " | "
+ << "- | ";
+ } else {
+ listing << "
| f | "
+ << "d_name << "\">" << namelist[i]->d_name << " | "
+ << "" << SizeToStr(fs.st_size) << "B | ";
+ }
listing << "" << TimeRFC1123(fs.st_mtime) << " |
" << std::endl;
}
listing << "" << std::endl;
@@ -337,7 +360,10 @@ int main(int const argc, const char * argv[])
sendFile(client, data);
}
else if (DirectoryExists(filename) == true) {
- sendDirectoryListing(client, filename, *m, sendContent);
+ if (filename == "." || filename[filename.length()-1] == '/')
+ sendDirectoryListing(client, filename, *m, sendContent);
+ else
+ sendRedirect(client, 301, filename.append("/"), *m, sendContent);
}
else
sendError(client, 404, *m, false);
--
cgit v1.2.3-70-g09d2
From 3522b1a8f16f45cf9c0c45b8b86cc886f1368df4 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Wed, 11 Jul 2012 10:39:51 +0200
Subject: do not hardcode /dev/null in changetowebserver so it can be changed
for debugging easily
---
test/integration/framework | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
(limited to 'test')
diff --git a/test/integration/framework b/test/integration/framework
index d15fd0e01..965f984ca 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -688,30 +688,30 @@ signreleasefiles() {
}
changetowebserver() {
+ if [ -n "$1" ] && ! test -x ${BUILDDIRECTORY}/aptwebserver; then
+ msgdie 'Need the aptwebserver when passing arguments'
+ fi
- if [ -n "$1" ] && ! test -x ${BUILDDIRECTORY}/aptwebserver; then
- msgdie 'Need the aptwebserver when passing arguments'
- fi
-
+ local LOG='/dev/null'
if test -x ${BUILDDIRECTORY}/aptwebserver; then
cd aptarchive
- LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/aptwebserver $@ 2> /dev/null > /dev/null &
+ LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/aptwebserver $@ 2> $LOG > $LOG &
addtrap "kill $!;"
cd - > /dev/null
elif which weborf > /dev/null; then
- weborf -xb aptarchive/ 2>&1 > /dev/null &
+ weborf -xb aptarchive/ 2> $LOG > $LOG &
addtrap "kill $!;"
elif which gatling > /dev/null; then
cd aptarchive
- gatling -p 8080 -F -S 2>&1 > /dev/null &
+ gatling -p 8080 -F -S 2> $LOG > $LOG &
addtrap "kill $!;"
cd - > /dev/null
elif which lighttpd > /dev/null; then
echo "server.document-root = \"$(readlink -f ./aptarchive)\"
server.port = 8080
server.stat-cache-engine = \"disable\"" > lighttpd.conf
- lighttpd -t -f lighttpd.conf >/dev/null || msgdie 'Can not change to webserver: our lighttpd config is invalid'
- lighttpd -D -f lighttpd.conf 2>/dev/null >/dev/null &
+ lighttpd -t -f lighttpd.conf 2> $LOG > $LOG || msgdie 'Can not change to webserver: our lighttpd config is invalid'
+ lighttpd -D -f lighttpd.conf 2> $LOG > $LOG &
addtrap "kill $!;"
else
msgdie 'You have to install weborf or lighttpd first'
--
cgit v1.2.3-70-g09d2
From d37911acee3eb34368e6d9e6a0046c9150d2bce6 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Wed, 11 Jul 2012 11:07:54 +0200
Subject: add simple url rewriting to the webserver
---
test/integration/skip-bug-602412-dequote-redirect | 38 -----------------------
test/integration/test-bug-602412-dequote-redirect | 29 +++++++++++++++++
test/interactive-helper/aptwebserver.cc | 19 ++++++++++--
3 files changed, 46 insertions(+), 40 deletions(-)
delete mode 100755 test/integration/skip-bug-602412-dequote-redirect
create mode 100755 test/integration/test-bug-602412-dequote-redirect
(limited to 'test')
diff --git a/test/integration/skip-bug-602412-dequote-redirect b/test/integration/skip-bug-602412-dequote-redirect
deleted file mode 100755
index 689b671ce..000000000
--- a/test/integration/skip-bug-602412-dequote-redirect
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-set -e
-
-TESTDIR=$(readlink -f $(dirname $0))
-. $TESTDIR/framework
-setupenvironment
-configarchitecture 'i386'
-
-if ! which lighttpd > /dev/null; then
- msgdie 'You need lighttpd for this testcase, sorry…'
- exit 1
-fi
-
-buildsimplenativepackage 'unrelated' 'all' '0.5~squeeze1' 'unstable'
-
-setupaptarchive
-
-echo "server.modules = ( \"mod_redirect\" )
-server.document-root = \"$(readlink -f ./aptarchive)\"
-server.port = 8080
-server.stat-cache-engine = \"disable\"
-url.redirect = ( \"^/pool/(.*)$\" => \"/newpool/\$1\",
- \"^/dists/(.*)$\" => \"/newdists/\$1\" )" > lighttpd.conf
-
-mv aptarchive/pool aptarchive/newpool
-mv aptarchive/dists aptarchive/newdists
-
-lighttpd -t -f lighttpd.conf >/dev/null || msgdie 'Can not change to webserver: our lighttpd config is invalid'
-lighttpd -D -f lighttpd.conf 2>/dev/null >/dev/null &
-addtrap "kill $!;"
-
-APTARCHIVE="file://$(readlink -f ./aptarchive)"
-for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
- sed -i $LIST -e "s#$APTARCHIVE#http://localhost:8080/#"
-done
-
-aptget update || msgdie 'apt-get update failed'
-aptget install unrelated --download-only || msgdie 'downloading package failed'
diff --git a/test/integration/test-bug-602412-dequote-redirect b/test/integration/test-bug-602412-dequote-redirect
new file mode 100755
index 000000000..f1e67c6d8
--- /dev/null
+++ b/test/integration/test-bug-602412-dequote-redirect
@@ -0,0 +1,29 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64'
+
+buildsimplenativepackage 'unrelated' 'all' '0.5~squeeze1' 'unstable'
+
+setupaptarchive
+changetowebserver -o aptwebserver::redirect::replace::/pool/=/newpool/ \
+ -o aptwebserver::redirect::replace::/dists/=/newdists/
+
+mv aptarchive/pool aptarchive/newpool
+mv aptarchive/dists aptarchive/newdists
+
+msgtest 'Test redirection works in' 'apt-get update'
+aptget update -qq && msgpass || msgfail
+
+# check that I-M-S header is kept in redirections
+testequal 'Hit http://localhost unstable InRelease
+Hit http://localhost unstable/main Sources
+Hit http://localhost unstable/main amd64 Packages
+Hit http://localhost unstable/main Translation-en
+Reading package lists...' aptget update
+
+msgtest 'Test redirection works in' 'package download'
+aptget install unrelated --download-only -qq && msgpass || msgfail
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index 2052fe6d8..7fa322ea9 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -137,7 +137,7 @@ void sendError(int const client, int const httpcode, std::string const &request,
std::list headers;
std::string response("");
response.append(httpcodeToStr(httpcode)).append("");
- response.append("").append(httpcodeToStr(httpcode)).append("
").append(httpcodeToStr(httpcode)).append("
");
response.append("This error is a result of the request: ");
response.append(request).append("");
addDataHeaders(headers, response);
@@ -255,6 +255,8 @@ int main(int const argc, const char * argv[])
{0, "simulate-paywall", "aptwebserver::Simulate-Paywall",
CommandLine::Boolean},
{0, "port", "aptwebserver::port", CommandLine::HasArg},
+ {'c',"config-file",0,CommandLine::ConfigFile},
+ {'o',"option",0,CommandLine::ArbItem},
{0,0,0,0}
};
@@ -366,7 +368,20 @@ int main(int const argc, const char * argv[])
sendRedirect(client, 301, filename.append("/"), *m, sendContent);
}
else
- sendError(client, 404, *m, false);
+ {
+ ::Configuration::Item const *Replaces = _config->Tree("aptwebserver::redirect::replace");
+ if (Replaces != NULL) {
+ std::string redirect = "/" + filename;
+ for (::Configuration::Item *I = Replaces->Child; I != NULL; I = I->Next)
+ redirect = SubstVar(redirect, I->Tag, I->Value);
+ redirect.erase(0,1);
+ if (redirect != filename) {
+ sendRedirect(client, 301, redirect, *m, sendContent);
+ continue;
+ }
+ }
+ sendError(client, 404, *m, sendContent);
+ }
}
_error->DumpErrors(std::cerr);
messages.clear();
--
cgit v1.2.3-70-g09d2
From 7a1bed9d453379fcd22489bdb9f81f377abcaae2 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Wed, 11 Jul 2012 17:11:26 +0200
Subject: rework parsing of the first request-line to be more robust
---
test/interactive-helper/aptwebserver.cc | 106 ++++++++++++++++++++++----------
1 file changed, 75 insertions(+), 31 deletions(-)
(limited to 'test')
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index 7fa322ea9..4746aed96 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -51,24 +51,24 @@ char const * const httpcodeToStr(int const httpcode) { /*{{{*/
case 404: return "404 Not Found";
case 405: return "405 Method Not Allowed";
case 406: return "406 Not Acceptable";
- case 407: return "Proxy Authentication Required";
- case 408: return "Request Time-out";
- case 409: return "Conflict";
- case 410: return "Gone";
- case 411: return "Length Required";
- case 412: return "Precondition Failed";
- case 413: return "Request Entity Too Large";
- case 414: return "Request-URI Too Large";
- case 415: return "Unsupported Media Type";
- case 416: return "Requested range not satisfiable";
- case 417: return "Expectation Failed";
+ case 407: return "407 Proxy Authentication Required";
+ case 408: return "408 Request Time-out";
+ case 409: return "409 Conflict";
+ case 410: return "410 Gone";
+ case 411: return "411 Length Required";
+ case 412: return "412 Precondition Failed";
+ case 413: return "413 Request Entity Too Large";
+ case 414: return "414 Request-URI Too Large";
+ case 415: return "415 Unsupported Media Type";
+ case 416: return "416 Requested range not satisfiable";
+ case 417: return "417 Expectation Failed";
// Server error 5xx
- case 500: return "Internal Server Error";
- case 501: return "Not Implemented";
- case 502: return "Bad Gateway";
- case 503: return "Service Unavailable";
- case 504: return "Gateway Time-out";
- case 505: return "HTTP Version not supported";
+ case 500: return "500 Internal Server Error";
+ case 501: return "501 Not Implemented";
+ case 502: return "502 Bad Gateway";
+ case 503: return "503 Service Unavailable";
+ case 504: return "504 Gateway Time-out";
+ case 505: return "505 HTTP Version not supported";
}
return NULL;
}
@@ -133,11 +133,13 @@ bool sendData(int const client, std::string const &data) { /*{{{*/
return Success;
}
/*}}}*/
-void sendError(int const client, int const httpcode, std::string const &request, bool content) { /*{{{*/
+void sendError(int const client, int const httpcode, std::string const &request, bool content, std::string const &error = "") { /*{{{*/
std::list headers;
std::string response("");
response.append(httpcodeToStr(httpcode)).append("");
response.append("").append(httpcodeToStr(httpcode)).append("
");
+ if (error.empty() == false)
+ response.append("Error: ").append(error).append("
");
response.append("This error is a result of the request: ");
response.append(request).append("");
addDataHeaders(headers, response);
@@ -249,6 +251,55 @@ void sendDirectoryListing(int const client, std::string const &dir, std::string
sendData(client, response);
}
/*}}}*/
+bool parseFirstLine(int const client, std::string const &request, std::string &filename, bool &sendContent) { /*{{{*/
+ if (strncmp(request.c_str(), "HEAD ", 5) == 0)
+ sendContent = false;
+ if (strncmp(request.c_str(), "GET ", 4) != 0)
+ {
+ sendError(client, 501, request, true);
+ return false;
+ }
+
+ size_t const lineend = request.find('\n');
+ size_t filestart = request.find(' ');
+ for (; request[filestart] == ' '; ++filestart);
+ size_t fileend = request.rfind(' ', lineend);
+ if (lineend == std::string::npos || filestart == std::string::npos ||
+ fileend == std::string::npos || filestart == fileend) {
+ sendError(client, 500, request, sendContent, "Filename can't be extracted");
+ return false;
+ }
+
+ size_t httpstart = fileend;
+ for (; request[httpstart] == ' '; ++httpstart);
+ if (strncmp(request.c_str() + httpstart, "HTTP/1.1\r", 9) != 0) {
+ sendError(client, 500, request, sendContent, "Not an HTTP/1.1 request");
+ return false;
+ }
+
+ filename = request.substr(filestart, fileend - filestart);
+ if (filename.find(' ') != std::string::npos) {
+ sendError(client, 500, request, sendContent, "Filename contains an unencoded space");
+ return false;
+ }
+ filename = DeQuoteString(filename);
+
+ // this is not a secure server, but at least prevent the obvious …
+ if (filename.empty() == true || filename[0] != '/' ||
+ strncmp(filename.c_str(), "//", 2) == 0 ||
+ filename.find_first_of("\r\n\t\f\v") != std::string::npos ||
+ filename.find("/../") != std::string::npos) {
+ sendError(client, 400, request, sendContent, "Filename contains illegal character (sequence)");
+ return false;
+ }
+
+ // nuke the first character which is a / as we assured above
+ filename.erase(0, 1);
+ if (filename.empty() == true)
+ filename = ".";
+ return true;
+}
+ /*}}}*/
int main(int const argc, const char * argv[])
{
CommandLine::Args Args[] = {
@@ -318,27 +369,20 @@ int main(int const argc, const char * argv[])
m != messages.end(); ++m) {
std::clog << ">>> REQUEST >>>>" << std::endl << *m
<< std::endl << "<<<<<<<<<<<<<<<<" << std::endl;
+
std::list headers;
+ std::string filename;
bool sendContent = true;
- if (strncmp(m->c_str(), "HEAD ", 5) == 0)
- sendContent = false;
- if (strncmp(m->c_str(), "GET ", 4) != 0)
- sendError(client, 501, *m, true);
+ if (parseFirstLine(client, *m, filename, sendContent) == false)
+ continue;
std::string host = LookupTag(*m, "Host", "");
if (host.empty() == true) {
- // RFC 2616 §14.23 Host
- sendError(client, 400, *m, sendContent);
+ // RFC 2616 §14.23 requires Host
+ sendError(client, 400, *m, sendContent, "Host header is required");
continue;
}
- size_t const filestart = m->find(' ', 5);
- std::string filename = m->substr(5, filestart - 5);
- if (filename.empty() == true)
- filename = ".";
- else
- filename = DeQuoteString(filename);
-
if (simulate_broken_server == true) {
std::string data("ni ni ni\n");
addDataHeaders(headers, data);
--
cgit v1.2.3-70-g09d2
From 57d13de2fb64a97d1a43d493c253ad2132ffd566 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Wed, 11 Jul 2012 18:43:53 +0200
Subject: make the server a little more robust against write errors (e.g.
broken pipe)
---
test/interactive-helper/aptwebserver.cc | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
(limited to 'test')
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index 4746aed96..dbc4a19e0 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -21,6 +21,7 @@
#include
#include
#include
+#include
char const * const httpcodeToStr(int const httpcode) { /*{{{*/
switch (httpcode) {
@@ -105,10 +106,12 @@ bool sendHead(int const client, int const httpcode, std::list &head
for (std::list::const_iterator h = headers.begin();
Success == true && h != headers.end(); ++h) {
Success &= FileFd::Write(client, h->c_str(), h->size());
- Success &= FileFd::Write(client, "\r\n", 2);
+ if (Success == true)
+ Success &= FileFd::Write(client, "\r\n", 2);
std::clog << *h << std::endl;
}
- Success &= FileFd::Write(client, "\r\n", 2);
+ if (Success == true)
+ Success &= FileFd::Write(client, "\r\n", 2);
std::clog << "<<<<<<<<<<<<<<<<" << std::endl;
return Success;
}
@@ -122,14 +125,16 @@ bool sendFile(int const client, FileFd &data) { /*{{{*/
break;
Success &= FileFd::Write(client, buffer, actual);
}
- Success &= FileFd::Write(client, "\r\n", 2);
+ if (Success == true)
+ Success &= FileFd::Write(client, "\r\n", 2);
return Success;
}
/*}}}*/
bool sendData(int const client, std::string const &data) { /*{{{*/
bool Success = true;
Success &= FileFd::Write(client, data.c_str(), data.size());
- Success &= FileFd::Write(client, "\r\n", 2);
+ if (Success == true)
+ Success &= FileFd::Write(client, "\r\n", 2);
return Success;
}
/*}}}*/
@@ -318,6 +323,8 @@ int main(int const argc, const char * argv[])
}
// create socket, bind and listen to it {{{
+ // ignore SIGPIPE, this can happen on write() if the socket closes connection
+ signal(SIGPIPE, SIG_IGN);
int sock = socket(AF_INET6, SOCK_STREAM, 0);
if(sock < 0 ) {
_error->Errno("aptwerbserver", "Couldn't create socket");
--
cgit v1.2.3-70-g09d2
From 06b3095f81d9a730e8cb95274c8208cb0604cdfe Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Wed, 11 Jul 2012 19:11:24 +0200
Subject: add option to send Content-Type based on file extension
---
test/interactive-helper/aptwebserver.cc | 12 ++++++++++++
1 file changed, 12 insertions(+)
(limited to 'test')
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index dbc4a19e0..4ef9631b8 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -82,6 +82,18 @@ void addFileHeaders(std::list &headers, FileFd &data) { /*{{{*/
std::string lastmodified("Last-Modified: ");
lastmodified.append(TimeRFC1123(data.ModificationTime()));
headers.push_back(lastmodified);
+
+ std::string const fileext = flExtension(data.Name());
+ if (fileext.empty() == false && fileext != data.Name()) {
+ std::string confcontenttype("aptwebserver::ContentType::");
+ confcontenttype.append(fileext);
+ std::string const contenttype = _config->Find(confcontenttype);
+ if (contenttype.empty() == false) {
+ std::string header("Content-Type: ");
+ header.append(contenttype);
+ headers.push_back(header);
+ }
+ }
}
/*}}}*/
void addDataHeaders(std::list &headers, std::string &data) {/*{{{*/
--
cgit v1.2.3-70-g09d2
From 056c36565706cad136df288db777c01555f4ecd9 Mon Sep 17 00:00:00 2001
From: David Kalnischkies
Date: Thu, 12 Jul 2012 12:04:36 +0200
Subject: add (partial) partial request support for the webserver
---
test/interactive-helper/aptwebserver.cc | 71 +++++++++++++++++++++++++++++----
1 file changed, 63 insertions(+), 8 deletions(-)
(limited to 'test')
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index 4ef9631b8..ff60d64a3 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -35,7 +35,7 @@ char const * const httpcodeToStr(int const httpcode) { /*{{{*/
case 203: return "203 Non-Authoritative Information";
case 204: return "204 No Content";
case 205: return "205 Reset Content";
- case 206: return "206 Partial Conent";
+ case 206: return "206 Partial Content";
// Redirections 3xx
case 300: return "300 Multiple Choices";
case 301: return "301 Moved Permanently";
@@ -113,6 +113,8 @@ bool sendHead(int const client, int const httpcode, std::list &head
date.append(TimeRFC1123(time(NULL)));
headers.push_back(date);
+ headers.push_back("Accept-Ranges: bytes");
+
std::clog << ">>> RESPONSE >>>" << std::endl;
bool Success = true;
for (std::list::const_iterator h = headers.begin();
@@ -135,7 +137,8 @@ bool sendFile(int const client, FileFd &data) { /*{{{*/
while ((Success &= data.Read(buffer, sizeof(buffer), &actual)) == true) {
if (actual == 0)
break;
- Success &= FileFd::Write(client, buffer, actual);
+ if (Success == true)
+ Success &= FileFd::Write(client, buffer, actual);
}
if (Success == true)
Success &= FileFd::Write(client, "\r\n", 2);
@@ -268,7 +271,7 @@ void sendDirectoryListing(int const client, std::string const &dir, std::string
sendData(client, response);
}
/*}}}*/
-bool parseFirstLine(int const client, std::string const &request, std::string &filename, bool &sendContent) { /*{{{*/
+bool parseFirstLine(int const client, std::string const &request, std::string &filename, bool &sendContent, bool &closeConnection) { /*{{{*/
if (strncmp(request.c_str(), "HEAD ", 5) == 0)
sendContent = false;
if (strncmp(request.c_str(), "GET ", 4) != 0)
@@ -289,8 +292,12 @@ bool parseFirstLine(int const client, std::string const &request, std::string &f
size_t httpstart = fileend;
for (; request[httpstart] == ' '; ++httpstart);
- if (strncmp(request.c_str() + httpstart, "HTTP/1.1\r", 9) != 0) {
- sendError(client, 500, request, sendContent, "Not an HTTP/1.1 request");
+ if (strncmp(request.c_str() + httpstart, "HTTP/1.1\r", 9) == 0)
+ closeConnection = strcasecmp(LookupTag(request, "Connection", "Keep-Alive").c_str(), "Keep-Alive") != 0;
+ else if (strncmp(request.c_str() + httpstart, "HTTP/1.0\r", 9) == 0)
+ closeConnection = strcasecmp(LookupTag(request, "Connection", "Keep-Alive").c_str(), "close") == 0;
+ else {
+ sendError(client, 500, request, sendContent, "Not an HTTP/1.{0,1} request");
return false;
}
@@ -384,15 +391,15 @@ int main(int const argc, const char * argv[])
<< " on socket " << sock << std::endl;
while (ReadMessages(client, messages)) {
+ bool closeConnection = false;
for (std::vector::const_iterator m = messages.begin();
- m != messages.end(); ++m) {
+ m != messages.end() && closeConnection == false; ++m) {
std::clog << ">>> REQUEST >>>>" << std::endl << *m
<< std::endl << "<<<<<<<<<<<<<<<<" << std::endl;
-
std::list headers;
std::string filename;
bool sendContent = true;
- if (parseFirstLine(client, *m, filename, sendContent) == false)
+ if (parseFirstLine(client, *m, filename, sendContent, closeConnection) == false)
continue;
std::string host = LookupTag(*m, "Host", "");
@@ -419,6 +426,52 @@ int main(int const argc, const char * argv[])
continue;
}
}
+ condition = LookupTag(*m, "If-Range", "");
+ bool ignoreRange = false;
+ if (condition.empty() == false) {
+ time_t cache;
+ if (RFC1123StrToTime(condition.c_str(), cache) == false ||
+ cache < data.ModificationTime())
+ ignoreRange = true;
+ }
+ condition = LookupTag(*m, "Range", "");
+ if (ignoreRange == false && condition.empty() == false &&
+ strncmp(condition.c_str(), "bytes=", 6) == 0) {
+ size_t end = condition.find(',');
+ // FIXME: support multiple byte-ranges
+ if (end == std::string::npos) {
+ size_t start = 6;
+ unsigned long long filestart = strtoull(condition.c_str() + start, NULL, 10);
+ // FIXME: no fileend support
+ size_t dash = condition.find('-') + 1;
+ unsigned long long fileend = strtoull(condition.c_str() + dash, NULL, 10);
+ unsigned long long filesize = data.FileSize();
+ if (fileend == 0 || fileend == filesize) {
+ if (filesize > filestart) {
+ data.Skip(filestart);
+ std::ostringstream contentlength;
+ contentlength << "Content-Length: " << (filesize - filestart);
+ headers.push_back(contentlength.str());
+ std::ostringstream contentrange;
+ contentrange << "Content-Range: bytes " << filestart << "-"
+ << filesize - 1 << "/" << filesize;
+ headers.push_back(contentrange.str());
+ sendHead(client, 206, headers);
+ if (sendContent == true)
+ sendFile(client, data);
+ continue;
+ } else {
+ headers.push_back("Content-Length: 0");
+ std::ostringstream contentrange;
+ contentrange << "Content-Range: bytes 0-0/" << filesize;
+ headers.push_back(contentrange.str());
+ sendHead(client, 416, headers);
+ continue;
+ }
+ }
+ }
+ }
+
addFileHeaders(headers, data);
sendHead(client, 200, headers);
if (sendContent == true)
@@ -448,6 +501,8 @@ int main(int const argc, const char * argv[])
}
_error->DumpErrors(std::cerr);
messages.clear();
+ if (closeConnection == true)
+ break;
}
std::clog << "CLOSE client " << client
--
cgit v1.2.3-70-g09d2