summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2013-07-16 23:15:55 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2013-07-16 23:15:55 +0200
commit86fdeec2a76f6b134ee8400eb1e53d06fe0974fe (patch)
treeb1d2b05cf27d1ee0b632398c8603201207ea1646
parentc7a629dd114c41a1244744e2f5085df2f505dc90 (diff)
fix if-clause to generate hook-info for 'rc' packages
The code incorrectly skips printing of current version information, if the package has no current version (for APT, but for dpkg as it is the case for packages which are removed but not purged) by using an unintended "else if" rather than an "if". Closes: 717006
-rw-r--r--apt-pkg/deb/dpkgpm.cc2
-rwxr-xr-xtest/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch25
2 files changed, 26 insertions, 1 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index fb0473535..d8fc8ef68 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -294,7 +294,7 @@ bool pkgDPkgPM::SendPkgsInfo(FILE * const F, unsigned int const &Version)
if (CurVer.end() == true && (I->Op == Item::Remove || I->Op == Item::Purge))
CurVer = FindNowVersion(I->Pkg);
- else if (CurVer.end() == true)
+ if (CurVer.end() == true)
{
if (Version <= 2)
fprintf(F, "- ");
diff --git a/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch b/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch
index aee44f76b..a89cb7191 100755
--- a/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch
+++ b/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch
@@ -13,6 +13,13 @@ buildsimplenativepackage 'libsame' 'i386,amd64' '2' 'unstable' 'Multi-Arch: same
buildsimplenativepackage 'stuff' 'i386,amd64' '1' 'stable' 'Depends: libsame (= 1), toolkit (= 1)'
buildsimplenativepackage 'stuff' 'i386,amd64' '2' 'unstable' 'Depends: libsame (= 2), toolkit (= 2)'
+setupsimplenativepackage 'confpkg' 'amd64' '1' 'unstable'
+BUILDDIR='incoming/confpkg-1'
+echo 'foo "bar";' > ${BUILDDIR}/pkg.conf
+echo 'pkg.conf /etc/pkg.conf' >> ${BUILDDIR}/debian/install
+buildpackage "$BUILDDIR" 'unstable' 'main' 'amd64'
+rm -rf "$BUILDDIR"
+
setupaptarchive
hook='pre-install-pkgs'
@@ -93,3 +100,21 @@ testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**
stuff 2 i386 none > - - none **REMOVE**
libsame 2 i386 same > - - none **REMOVE**
toolkit 2 amd64 foreign > - - none **REMOVE**'
+
+observehook install confpkg
+testfileequal "${hook}-v2.list" 'confpkg - < 1 **CONFIGURE**'
+testfileequal "${hook}-v3.list" 'confpkg - - none < 1 amd64 none **CONFIGURE**'
+
+observehook remove confpkg
+testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**'
+testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**'
+
+msgtest 'Conffiles of package remained after remove' 'confpkg'
+dpkg -l confpkg | grep -q '^rc' && msgpass || msgfail
+
+observehook purge confpkg
+testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**'
+testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**'
+
+msgtest 'Conffiles are gone after purge' 'confpkg'
+dpkg -l confpkg 2>/dev/null | grep -q '^rc' && msgfail || msgpass