summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/depcache.cc37
-rw-r--r--debian/NEWS8
-rw-r--r--doc/examples/configure-index1
-rwxr-xr-xtest/integration/test-apt-get-upgrade-by-source53
-rwxr-xr-xtest/integration/test-ubuntu-bug-61499316
5 files changed, 108 insertions, 7 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 82b2fda99..bc5843153 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -1494,6 +1494,41 @@ static bool MarkInstall_UpgradeOrRemoveConflicts(pkgDepCache &Cache, bool const
return not failedToRemoveSomething;
}
/*}}}*/
+static bool MarkInstall_UpgradeOtherBinaries(pkgDepCache &Cache, bool const DebugAutoInstall, unsigned long Depth, bool const ForceImportantDeps, pkgCache::PkgIterator Pkg, pkgCache::VerIterator Ver) /*{{{*/
+{
+ APT::PackageSet toUpgrade;
+
+ if (not _config->FindB("APT::Get::Upgrade-By-Source-Package", true))
+ return true;
+
+ auto SrcGrp = Cache.FindGrp(Ver.SourcePkgName());
+ for (auto OtherBinary = SrcGrp.VersionsInSource(); not OtherBinary.end(); OtherBinary = OtherBinary.NextInSource())
+ {
+ auto OtherPkg = OtherBinary.ParentPkg();
+ auto OtherState = Cache[OtherPkg];
+ if (OtherPkg == Pkg)
+ continue;
+ // Package is not installed or at right version, don't need to upgrade
+ if (OtherPkg->CurrentVer == 0 || OtherPkg.CurrentVer() == OtherBinary)
+ continue;
+ // Package is to be installed at right version, don't need to upgrade
+ if (OtherState.Install() && OtherState.InstallVer == OtherBinary)
+ continue;
+ // Package has a different source version than us, so it's not relevant
+ if (strcmp(OtherBinary.SourceVerStr(), Ver.SourceVerStr()) != 0 || OtherState.CandidateVer != OtherBinary)
+ continue;
+ if (DebugAutoInstall)
+ std::clog << OutputInDepth(Depth) << "Upgrading " << APT::PrettyPkg(&Cache, OtherPkg) << " due to " << Pkg.FullName() << '\n';
+
+ toUpgrade.insert(OtherPkg);
+ }
+ for (auto &OtherPkg : toUpgrade)
+ Cache.MarkInstall(OtherPkg, false, Depth + 1, false, ForceImportantDeps);
+ for (auto &OtherPkg : toUpgrade)
+ Cache.MarkInstall(OtherPkg, true, Depth + 1, false, ForceImportantDeps);
+ return true;
+}
+ /*}}}*/
static bool MarkInstall_InstallDependencies(pkgDepCache &Cache, bool const DebugAutoInstall, bool const DebugMarker, pkgCache::PkgIterator const &Pkg, unsigned long Depth, bool const ForceImportantDeps, std::vector<pkgCache::DepIterator> &toInstall, APT::PackageVector *const toMoveAuto, bool const propagateProtected, bool const FromUser) /*{{{*/
{
auto const IsSatisfiedByInstalled = [&](auto &D) { return (Cache[pkgCache::DepIterator{Cache, &D}] & pkgDepCache::DepInstall) == pkgDepCache::DepInstall; };
@@ -1705,6 +1740,8 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg, bool AutoInst,
operator bool() noexcept { return already; }
} propagateProtected{PkgState[Pkg->ID]};
+ if (not MarkInstall_UpgradeOtherBinaries(*this, DebugAutoInstall, Depth, ForceImportantDeps, Pkg, P.CandidateVerIter(*this)))
+ return false;
if (not MarkInstall_UpgradeOrRemoveConflicts(*this, DebugAutoInstall, Depth, ForceImportantDeps, toUpgrade, propagateProtected, FromUser))
{
if (failEarly)
diff --git a/debian/NEWS b/debian/NEWS
index 382a6df9c..a5607e94d 100644
--- a/debian/NEWS
+++ b/debian/NEWS
@@ -1,3 +1,11 @@
+apt (2.5.2) UNRELEASED; urgency=medium
+
+ Installing or upgrading a binary package now upgrades other binaries from
+ the same source package if they have the same candidate version. You can
+ disable this by setting `APT::Get::Upgrade-By-Source-Package` to `false`.
+
+ -- Julian Andres Klode <juliank@ubuntu.com> Sun, 24 Jul 2022 15:45:15 +0200
+
apt (2.4.0) unstable; urgency=medium
GPG verification now first tries only the trusted.gpg.d keys, before
diff --git a/doc/examples/configure-index b/doc/examples/configure-index
index 07feea4dc..b3deccaaf 100644
--- a/doc/examples/configure-index
+++ b/doc/examples/configure-index
@@ -103,6 +103,7 @@ APT
Upgrade "<BOOL>";
Only-Upgrade "<BOOL>";
Upgrade-Allow-New "<BOOL>";
+ Upgrade-By-Source-Package "<BOOL>";
Always-Include-Phased-Updates "<BOOL>";
Never-Include-Phased-Updates "<BOOL>";
Phase-Policy "<BOOL>"; // internal
diff --git a/test/integration/test-apt-get-upgrade-by-source b/test/integration/test-apt-get-upgrade-by-source
new file mode 100755
index 000000000..0f87005d3
--- /dev/null
+++ b/test/integration/test-apt-get-upgrade-by-source
@@ -0,0 +1,53 @@
+#!/bin/sh
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+
+setupenvironment
+
+insertinstalledpackage 'pkg' 'all' '1' 'Source: pkg'
+insertinstalledpackage 'pkg-foo' 'all' '1' 'Source: pkg'
+insertinstalledpackage 'pkg-bar' 'all' '1' 'Source: pkg'
+insertpackage 'unstable' 'pkg' 'all' '2' 'Source: pkg'
+insertpackage 'unstable' 'pkg-foo' 'all' '2' 'Source: pkg'
+insertpackage 'unstable' 'pkg-bar' 'all' '2' 'Source: pkg'
+
+configarchitecture 'arm64'
+setupaptarchive
+
+noprogress() {
+ "$@" | sed /^Progress/d
+}
+
+testsuccessequal "Reading package lists...
+Building dependency tree...
+ MarkInstall pkg:arm64 < 1 -> 2 @ii puU > FU=1
+ Upgrading pkg-bar:arm64 < 1 | 2 @ii uH > due to pkg:arm64
+ Upgrading pkg-foo:arm64 < 1 | 2 @ii uH > due to pkg:arm64
+Starting pkgProblemResolver with broken count: 0
+Starting 2 pkgProblemResolver with broken count: 0
+Done
+The following additional packages will be installed:
+ pkg-bar pkg-foo
+The following packages will be upgraded:
+ pkg pkg-bar pkg-foo
+3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+Inst pkg [1] (2 unstable [all])
+Inst pkg-bar [1] (2 unstable [all])
+Inst pkg-foo [1] (2 unstable [all])
+Conf pkg (2 unstable [all])
+Conf pkg-bar (2 unstable [all])
+Conf pkg-foo (2 unstable [all])" aptget install pkg -o debug::pkgdepcache::marker=1 -o Debug::pkgProblemResolver=1 -o Debug::pkgDepCache::AutoInstall=1 -s
+
+testsuccessequal "Reading package lists...
+Building dependency tree...
+ MarkInstall pkg:arm64 < 1 -> 2 @ii puU > FU=1
+Starting pkgProblemResolver with broken count: 0
+Starting 2 pkgProblemResolver with broken count: 0
+Done
+The following packages will be upgraded:
+ pkg
+1 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
+Inst pkg [1] (2 unstable [all])
+Conf pkg (2 unstable [all])" aptget install pkg -o debug::pkgdepcache::marker=1 -o Debug::pkgProblemResolver=1 -o Debug::pkgDepCache::AutoInstall=1 -o APT::Get::Upgrade-By-Source-Package=0 -s
diff --git a/test/integration/test-ubuntu-bug-614993 b/test/integration/test-ubuntu-bug-614993
index e7357bc67..542e55105 100755
--- a/test/integration/test-ubuntu-bug-614993
+++ b/test/integration/test-ubuntu-bug-614993
@@ -11,8 +11,9 @@ setupaptarchive
UPGRADE="Reading package lists...
Building dependency tree...
The following additional packages will be installed:
- libdrm-intel1 libdrm-nouveau1 libmtdev1 libutouch-grail1 libx11-xcb1
- libxcb-aux0 libxcb-dri2-0 libxfont1 xserver-common xserver-xorg-core
+ libdrm-intel1 libdrm-nouveau1 libdrm-radeon1 libdrm2 libmtdev1
+ libutouch-grail1 libx11-xcb1 libxcb-aux0 libxcb-dri2-0 libxfont1
+ xserver-common xserver-xorg-core xserver-xorg-input-all
xserver-xorg-input-evdev xserver-xorg-input-mouse
xserver-xorg-input-synaptics xserver-xorg-input-vmmouse
xserver-xorg-input-wacom xserver-xorg-video-all xserver-xorg-video-apm
@@ -36,8 +37,9 @@ The following packages will be REMOVED:
The following NEW packages will be installed:
libmtdev1 libutouch-grail1 libx11-xcb1 libxcb-aux0 libxcb-dri2-0
The following packages will be upgraded:
- libdrm-intel1 libdrm-nouveau1 libxfont1 xserver-common xserver-xorg
- xserver-xorg-core xserver-xorg-input-evdev xserver-xorg-input-mouse
+ libdrm-intel1 libdrm-nouveau1 libdrm-radeon1 libdrm2 libxfont1
+ xserver-common xserver-xorg xserver-xorg-core xserver-xorg-input-all
+ xserver-xorg-input-evdev xserver-xorg-input-mouse
xserver-xorg-input-synaptics xserver-xorg-input-vmmouse
xserver-xorg-input-wacom xserver-xorg-video-all xserver-xorg-video-apm
xserver-xorg-video-ark xserver-xorg-video-ati xserver-xorg-video-chips
@@ -51,9 +53,9 @@ The following packages will be upgraded:
xserver-xorg-video-sisusb xserver-xorg-video-tdfx xserver-xorg-video-trident
xserver-xorg-video-tseng xserver-xorg-video-vesa xserver-xorg-video-vmware
xserver-xorg-video-voodoo
-41 upgraded, 5 newly installed, 1 to remove and 3 not upgraded.
-Need to get 0 B/5505 kB of archives.
-After this operation, 2294 kB disk space will be freed.
+44 upgraded, 5 newly installed, 1 to remove and 0 not upgraded.
+Need to get 0 B/5561 kB of archives.
+After this operation, 3027 kB disk space will be freed.
E: Trivial Only specified but this is not a trivial operation."
testfailureequal "$UPGRADE" aptget install xserver-xorg --trivial-only