From 7434f15cb688f3a394accba2ce10615adcb9c48a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 11 Nov 2016 13:15:27 +0100 Subject: show distribution mismatch for changed codenames We have the last Release file around for other checks, so its trivial to look if the new Release file contains a new codename (e.g. the user has "testing" in the sources and it flipped from stretch to buster). Such a change can be okay and expected, but also be a hint of problems, so a warning if we see it happen seems okay. We can only print it once anyhow and frontends and co are likely to ignore/hide it. --- apt-pkg/acquire-item.cc | 8 ++++++++ .../test-bug-841874-warning-for-mismatching-distribution | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 54cb9db71..154b9a16e 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1608,6 +1608,14 @@ bool pkgAcqMetaBase::VerifyVendor(string const &) /*{{{*/ if (TransactionManager->MetaIndexParser->CheckDist(ExpectedDist) == false) _error->Warning(_("Conflicting distribution: %s (expected %s but got %s)"), Desc.Description.c_str(), ExpectedDist.c_str(), NowCodename.c_str()); + // might be okay, might be not + if (TransactionManager->LastMetaIndexParser != nullptr) + { + auto const LastCodename = TransactionManager->LastMetaIndexParser->GetCodename(); + if (LastCodename.empty() == false && NowCodename.empty() == false && LastCodename != NowCodename) + _error->Warning(_("Conflicting distribution: %s (expected %s but got %s)"), + Desc.Description.c_str(), LastCodename.c_str(), NowCodename.c_str()); + } return true; } /*}}}*/ diff --git a/test/integration/test-bug-841874-warning-for-mismatching-distribution b/test/integration/test-bug-841874-warning-for-mismatching-distribution index 7502eefc3..6cc8e3173 100755 --- a/test/integration/test-bug-841874-warning-for-mismatching-distribution +++ b/test/integration/test-bug-841874-warning-for-mismatching-distribution @@ -47,3 +47,15 @@ testfailure apt show foo ln -s "${APTARCHIVE}/dists/testing" "${APTARCHIVE}/dists/buster" testsuccess apt update testsuccess apt show foo + +# changing codenames gets a warning, too +rm -rf rootdir/var/lib/apt/lists +sed -i -e 's#buster#testing#g' rootdir/etc/apt/sources.list.d/* +testsuccess apt update +testsuccess apt show foo +sed -i -e 's#^Codename: buster#Codename: zurg#g' $(find ./aptarchive -name 'Release') +signreleasefiles +testwarningmsg "W: Conflicting distribution: file:$APTARCHIVE testing/updates InRelease (expected buster/updates but got zurg/updates)" apt update +testsuccess apt show foo +testsuccess apt update +testsuccess apt show foo -- cgit v1.2.3