summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-08-10 16:08:21 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-08-10 17:27:59 +0200
commit5f4495e342e94a75b17ceed2fa05d689f050df7b (patch)
tree6375bf439aba960a649f7cc119cd0b15352f9a91
parent7c2cc4a7bc999c8e07fba607354bfaa3b09118f9 (diff)
move manual-bit from 'oldlibs' pkg to its dependencies
oldlibs used to be in APT::Never-MarkAuto-Sections so that old transition packages can be removed without causing the then (autoinstalled) renamed package to be autoremoved. It isn't ideal through as ideally you want the oldlibs package to be removed after nothing depends on it anymore regardless of if you have once installed it by hand or not – and if you had the package talking over (the dependencies) should carry the manual bit now as they are the real deal now. As an added bonus if the package has no dependencies because it is an oldlibs without a direct replacement you should move away from (like lib1 and lib2 are currently in the archive, but there will hopefully only be lib2 in the release) you get a lib1 marked as auto. If the user still needs the oldlibs package for some reason all he has to do is mark it as manual once as this move is only performed if a installed package changes its section from a not-Move-Autobit-Sections to a Move-Autobit-Sections.
-rw-r--r--apt-pkg/depcache.cc28
-rw-r--r--debian/apt.conf.autoremove4
-rwxr-xr-xtest/integration/test-apt-move-and-forget-manual-sections31
3 files changed, 63 insertions, 0 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 99e694a06..02f61bf13 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -1128,9 +1128,26 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
if (DebugMarker == true)
std::clog << OutputInDepth(Depth) << "MarkInstall " << Pkg << " FU=" << FromUser << std::endl;
+ bool MoveAutoBitToDependencies = false;
VerIterator const PV = P.InstVerIter(*this);
if (unlikely(PV.end() == true))
return false;
+ else if (PV->Section != 0 && (P.Flags & Flag::Auto) != Flag::Auto)
+ {
+ VerIterator const CurVer = Pkg.CurrentVer();
+ if (CurVer.end() == false && CurVer->Section != 0 && strcmp(CurVer.Section(), PV.Section()) != 0)
+ {
+ bool const CurVerInMoveSection = ConfigValueInSubTree("APT::Move-Autobit-Sections", CurVer.Section());
+ bool const InstVerInMoveSection = ConfigValueInSubTree("APT::Move-Autobit-Sections", PV.Section());
+ MoveAutoBitToDependencies = (CurVerInMoveSection == false && InstVerInMoveSection == true);
+ if (MoveAutoBitToDependencies == true)
+ {
+ if(DebugAutoInstall == true)
+ std::clog << OutputInDepth(Depth) << "Setting " << Pkg.FullName(false) << " as auto-installed, moving manual to its dependencies" << std::endl;
+ MarkAuto(Pkg, true);
+ }
+ }
+ }
DepIterator Dep = PV.DependsList();
for (; Dep.end() != true;)
@@ -1244,6 +1261,17 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
verlist.erase(InstVer);
continue;
}
+
+ // now check if we should consider it a automatic dependency or not
+ if(InstPkg->CurrentVer == 0 && MoveAutoBitToDependencies)
+ {
+ if(DebugAutoInstall == true)
+ std::clog << OutputInDepth(Depth) << "Setting " << InstPkg.FullName(false) << " NOT as auto-installed (direct "
+ << Start.DepType() << " of " << Pkg.FullName(false) << " which is manual and in APT::Move-Autobit-Sections)" << std::endl;
+ MarkAuto(InstPkg, false);
+ }
+
+
break;
} while(true);
continue;
diff --git a/debian/apt.conf.autoremove b/debian/apt.conf.autoremove
index fc02350ae..3c4843e3d 100644
--- a/debian/apt.conf.autoremove
+++ b/debian/apt.conf.autoremove
@@ -32,6 +32,10 @@ APT
"restricted/metapackages";
"universe/metapackages";
"multiverse/metapackages";
+ };
+
+ Move-Autobit-Sections
+ {
"oldlibs";
"restricted/oldlibs";
"universe/oldlibs";
diff --git a/test/integration/test-apt-move-and-forget-manual-sections b/test/integration/test-apt-move-and-forget-manual-sections
new file mode 100755
index 000000000..845444f53
--- /dev/null
+++ b/test/integration/test-apt-move-and-forget-manual-sections
@@ -0,0 +1,31 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64'
+
+aptconfig dump --no-empty --format '%v%n' APT::Move-Autobit-Sections > move-autobit.sections
+testsuccess grep '^oldlibs$' move-autobit.sections
+
+buildsimplenativepackage 'libabc' 'amd64' '1' 'stable' '' '' 'libs'
+buildsimplenativepackage 'libabc' 'amd64' '2' 'unstable' 'Depends: libdef' '' 'oldlibs'
+buildsimplenativepackage 'libdef' 'amd64' '1' 'unstable' '' '' 'libs'
+setupaptarchive
+
+testmarkedauto
+testmarkedmanual
+
+testsuccess aptget install libabc/stable -y
+testdpkginstalled 'libabc'
+testdpkgnotinstalled 'libdef'
+
+testmarkedmanual 'libabc'
+testmarkedauto
+
+testsuccess aptget dist-upgrade -y
+testdpkginstalled 'libabc' 'libdef'
+
+testmarkedauto 'libabc'
+testmarkedmanual 'libdef'