summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2024-04-26 18:50:49 +0000
committerDavid Kalnischkies <david@kalnischkies.de>2024-04-26 20:10:30 +0000
commitc98bcdf00e5366fec101dd17094d36be21872a02 (patch)
treeb1c8f2777d9c4a1e746f229442c93878db973b32
parent05a1ee0cf4d5948ec2a084629bb9712af7d9c475 (diff)
Allow parsing an empty Provides linemain
If dpkg-gencontrol was involved in the creation of a package we will not usually encounter empty or otherwise useless fields, but apparently not everyone is using it. It isn't recommended to have these empty lines, but it isn't too hard to ignore for Provides as we did for dependencies already and apt-ftparchive can be convinced to produce empty files (if you feed it such a package) as well, so lets be nice and provide users with a more accepting parser. Closes: #1069874
-rw-r--r--apt-pkg/deb/deblistparser.cc2
-rw-r--r--test/integration/framework8
-rwxr-xr-xtest/integration/test-bug-1069874-working-with-not-normalized-packages57
3 files changed, 64 insertions, 3 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 071189b04..9177d54f4 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -887,7 +887,7 @@ bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
bool const barbarianArch = not APT::Configuration::checkArchitecture(Arch);
const char *Start;
const char *Stop;
- if (Section.Find(pkgTagSection::Key::Provides,Start,Stop) == true)
+ if (Section.Find(pkgTagSection::Key::Provides,Start,Stop) && Start != Stop)
{
StringView Package;
StringView Version;
diff --git a/test/integration/framework b/test/integration/framework
index de280cb8d..98fd7710a 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -882,8 +882,12 @@ buildsimplenativepackage() {
cp -ar "$FILE_TREE" "${BUILDDIR}/debian/tmp"
fi
- (cd "${BUILDDIR}"; dpkg-gencontrol -DArchitecture=$arch)
- (cd "${BUILDDIR}/debian/tmp"; md5sum $(find usr/ -type f) > DEBIAN/md5sums)
+ if [ ! -e "${BUILDDIR}/debian/tmp/DEBIAN/control" ]; then
+ (cd "${BUILDDIR}"; dpkg-gencontrol -DArchitecture=$arch)
+ fi
+ if [ ! -e "${BUILDDIR}/debian/tmp/DEBIAN/md5sums" ]; then
+ (cd "${BUILDDIR}/debian/tmp"; md5sum $(find usr/ -type f) > DEBIAN/md5sums)
+ fi
local LOG="${BUILDDIR}/../${NAME}_${VERSION}_${arch}.dpkg-deb.log"
# ensure the right permissions as dpkg-deb insists
chmod 755 "${BUILDDIR}/debian/tmp/DEBIAN"
diff --git a/test/integration/test-bug-1069874-working-with-not-normalized-packages b/test/integration/test-bug-1069874-working-with-not-normalized-packages
new file mode 100755
index 000000000..d45acee67
--- /dev/null
+++ b/test/integration/test-bug-1069874-working-with-not-normalized-packages
@@ -0,0 +1,57 @@
+#!/bin/sh
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+setupenvironment
+configarchitecture 'amd64'
+
+WORKDIR="${TMPWORKINGDIRECTORY}/badcontrol"
+mkdir -p "${WORKDIR}/DEBIAN"
+cat > "${WORKDIR}/DEBIAN/control" << EOF
+Package: perccli
+Version: 007.2616.0000.0000
+Section: perccli
+Priority: optional
+Architecture: all
+Depends:
+Pre-Depends:
+Recommends:
+Suggests:
+Installed-Size: 7000
+Maintainer: Jane Doe <foo@example.org>
+Conflicts:
+Replaces:
+Provides:
+Description: Not a real package
+EOF
+buildsimplenativepackage 'perccli' 'all' '007.2616.0000.0000' 'stable' '' '' '' '' "${WORKDIR}/DEBIAN"
+cp -a "${WORKDIR}/DEBIAN/control" aptarchive/Packages
+rm -rf "$WORKDIR"
+
+setupaptarchive --no-update
+echo "deb [trusted=yes] file:${TMPWORKINGDIRECTORY}/aptarchive ./" > rootdir/etc/apt/sources.list.d/00badcontrol.list
+testsuccess apt update
+
+# uses the flat Packages file which includes the line ending spaces
+testsuccess aptcache show perccli
+cp -a rootdir/tmp/testsuccess.output perccli.show
+testsuccessequal '4' grep -c '^\(\(Pre-\|\)Depends\|Provides\|Replaces\): \+$' perccli.show
+
+testdpkgnotinstalled perccli
+testsuccess apt install perccli
+testdpkginstalled perccli
+
+testsuccess apt policy perccli
+cp -a rootdir/tmp/testsuccess.output perccli.policy
+testsuccessequal '3' grep -c '7\.2616\.' perccli.policy
+
+# apt-ftparchive outputs empty fields, but not the space ending
+testsuccess rm rootdir/var/lib/apt/lists/*_._Packages
+testsuccess aptcache show perccli/now
+cp -a rootdir/tmp/testsuccess.output perccli.show
+testsuccessequal '4' grep -c '^\(\(Pre-\|\)Depends\|Provides\|Replaces\):$' perccli.show
+
+testsuccess apt policy perccli
+cp -a rootdir/tmp/testsuccess.output perccli.policy
+testsuccessequal '3' grep -c '7\.2616\.' perccli.policy