summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2022-07-08 13:34:22 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2022-07-24 15:27:18 +0200
commit119a8d0ed19a4e946591b9aef7d662e14ca7ece5 (patch)
tree4f3173b9ed68105697c1c7c01e28ccfb653b6796
parentb141ce0d355e667885536790ea5caa2d4d86d333 (diff)
Upgrade all binaries in a source package
Schedule all other binaries in the source package for upgrade if the candidate version belongs to the same source version as the package we are upgrading. This will significantly reduce the risk of partial upgrades and should make life a lot easier.
-rw-r--r--apt-pkg/depcache.cc27
-rwxr-xr-xtest/integration/test-ubuntu-bug-61499316
2 files changed, 36 insertions, 7 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 82b2fda99..f1ad7729e 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -1494,6 +1494,31 @@ 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) /*{{{*/
+{
+ 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';
+ 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 +1730,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/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