summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <egon@bottom>2007-05-02 13:58:21 +0200
committerMichael Vogt <egon@bottom>2007-05-02 13:58:21 +0200
commitb51ff02a550881118ce4c677a6f2ce1d0aff9cd8 (patch)
treeeb13239922de5805476416e86096e5b0b4f4cbdd
parent8171c75b9939a13aa22a3f45d436a6305af561ff (diff)
parent54eda6ae969cd66d06fe82f7175f753a74d2b7dc (diff)
* updated from http://people.ubuntu.com/~mvo/bzr/apt/auto-mark/
-rw-r--r--apt-pkg/depcache.cc21
-rw-r--r--apt-pkg/packagemanager.cc3
-rw-r--r--cmdline/apt-get.cc39
-rwxr-xr-xcmdline/apt-mark1
-rw-r--r--doc/examples/configure-index4
-rw-r--r--po/apt-all.pot2
6 files changed, 57 insertions, 13 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 390d93dc8..ac667d51d 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -948,11 +948,22 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
std::clog << "Installing " << InstPkg.Name()
<< " as dep of " << Pkg.Name()
<< std::endl;
- MarkInstall(InstPkg,true,Depth + 1, false, ForceImportantDeps);
-
- // Set the autoflag, after MarkInstall because MarkInstall unsets it
- if (P->CurrentVer == 0)
- PkgState[InstPkg->ID].Flags |= Flag::Auto;
+ // now check if we should consider it a automatic dependency or not
+ string sec = _config->Find("APT::Never-MarkAuto-Section","");
+ if(Pkg.Section() && (string(Pkg.Section()) == sec))
+ {
+ if(_config->FindB("Debug::pkgDepCache::AutoInstall",false) == true)
+ std::clog << "Setting NOT as auto-installed because its a direct dep of a package in section " << sec << std::endl;
+ MarkInstall(InstPkg,true,Depth + 1, true);
+ }
+ else
+ {
+ // mark automatic dependency
+ MarkInstall(InstPkg,true,Depth + 1, false, ForceImportantDeps);
+ // Set the autoflag, after MarkInstall because MarkInstall unsets it
+ if (P->CurrentVer == 0)
+ PkgState[InstPkg->ID].Flags |= Flag::Auto;
+ }
}
continue;
}
diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index b0dd43629..1e57d6455 100644
--- a/apt-pkg/packagemanager.cc
+++ b/apt-pkg/packagemanager.cc
@@ -95,9 +95,10 @@ bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
be downloaded. */
bool pkgPackageManager::FixMissing()
{
+ pkgDepCache::ActionGroup group(Cache);
pkgProblemResolver Resolve(&Cache);
List->SetFileList(FileNames);
-
+
bool Bad = false;
for (PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
{
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index b47c2ec09..aa6a70ffe 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -1421,8 +1421,8 @@ bool DoAutomaticRemove(CacheFile &Cache)
{
bool Debug = _config->FindI("Debug::pkgAutoRemove",false);
bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove", false);
+ bool hideAutoRemove = _config->FindB("APT::Get::HideAutoRemove");
pkgDepCache::ActionGroup group(*Cache);
-
if(Debug)
std::cout << "DoAutomaticRemove()" << std::endl;
@@ -1444,9 +1444,13 @@ bool DoAutomaticRemove(CacheFile &Cache)
if(Pkg.CurrentVer() != 0 || Cache[Pkg].Install())
if(Debug)
std::cout << "We could delete %s" << Pkg.Name() << std::endl;
-
- autoremovelist += string(Pkg.Name()) + " ";
- autoremoveversions += string(Cache[Pkg].CandVersion) + " ";
+
+ // only show stuff in the list that is not yet marked for removal
+ if(Cache[Pkg].Delete() == false)
+ {
+ autoremovelist += string(Pkg.Name()) + " ";
+ autoremoveversions += string(Cache[Pkg].CandVersion) + "\n";
+ }
if (doAutoRemove)
{
if(Pkg.CurrentVer() != 0 &&
@@ -1457,8 +1461,9 @@ bool DoAutomaticRemove(CacheFile &Cache)
}
}
}
- ShowList(c1out, _("The following packages were automatically installed and are no longer required:"), autoremovelist, autoremoveversions);
- if (!doAutoRemove && autoremovelist.size() > 0)
+ if (!hideAutoRemove)
+ ShowList(c1out, _("The following packages were automatically installed and are no longer required:"), autoremovelist, autoremoveversions);
+ if (!doAutoRemove && !hideAutoRemove && autoremovelist.size() > 0)
c1out << _("Use 'apt-get autoremove' to remove them.") << std::endl;
// Now see if we destroyed anything
@@ -1556,6 +1561,7 @@ bool DoInstall(CommandLine &CmdL)
if (Cache->BrokenCount() != 0)
BrokenFix = true;
+ unsigned int AutoMarkChanged = 0;
unsigned int ExpectedInst = 0;
unsigned int Packages = 0;
pkgProblemResolver Fix(Cache);
@@ -1678,6 +1684,19 @@ bool DoInstall(CommandLine &CmdL)
return false;
if (TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix,ExpectedInst) == false)
return false;
+
+ // see if we need to fix the auto-mark flag
+ // e.g. apt-get install foo
+ // where foo is marked automatic
+ if(!Remove &&
+ Cache[Pkg].Install() == false &&
+ (Cache[Pkg].Flags & pkgCache::Flag::Auto))
+ {
+ ioprintf(c1out,_("%s set to manual installed.\n"),
+ Pkg.Name());
+ Cache->MarkAuto(Pkg,false);
+ AutoMarkChanged++;
+ }
}
}
@@ -1842,6 +1861,14 @@ bool DoInstall(CommandLine &CmdL)
}
+ // if nothing changed in the cache, but only the automark information
+ // we write the StateFile here, otherwise it will be written in
+ // cache.commit()
+ if (AutoMarkChanged > 0 &&
+ Cache->DelCount() == 0 && Cache->InstCount() == 0 &&
+ Cache->BadCount() == 0)
+ Cache->writeStateFile(NULL);
+
// See if we need to prompt
if (Cache->InstCount() == ExpectedInst && Cache->DelCount() == 0)
return InstallPackages(Cache,false,false);
diff --git a/cmdline/apt-mark b/cmdline/apt-mark
index 533ed8715..dadc01366 100755
--- a/cmdline/apt-mark
+++ b/cmdline/apt-mark
@@ -60,4 +60,5 @@ if __name__ == "__main__":
else:
outfile.write(str(tagfile.Section)+"\n")
# all done, rename the tmpfile
+ os.chmod(outfile.name, 0644)
os.rename(outfile.name, STATE_FILE)
diff --git a/doc/examples/configure-index b/doc/examples/configure-index
index 56389b749..d0aad1e3d 100644
--- a/doc/examples/configure-index
+++ b/doc/examples/configure-index
@@ -33,6 +33,7 @@ APT
{
Arch-Only "false";
AutomaticRemove "false";
+ HideAutoRemove "false";
Download-Only "false";
Simulate "false";
Assume-Yes "false";
@@ -99,6 +100,9 @@ APT
APT::Install-Recommends "false";
APT::Install-Suggests "false";
+ // consider dependencies of packages in this section manual
+ Never-MarkAuto-Section "metapackages";
+
// Write progress messages on this fd (for stuff like base-config)
Status-Fd "-1";
// Keep the list of FDs open (normally apt closes all fds when it
diff --git a/po/apt-all.pot b/po/apt-all.pot
index 81d742437..bd066ab06 100644
--- a/po/apt-all.pot
+++ b/po/apt-all.pot
@@ -2218,7 +2218,7 @@ msgstr ""
msgid "Malformed line %u in source list %s (vendor id)"
msgstr ""
-#: apt-pkg/packagemanager.cc:402
+#: apt-pkg/packagemanager.cc:402 apt-pkg/packagemanager.cc:403
#, c-format
msgid ""
"This installation run will require temporarily removing the essential "