From 648e3cb48955f82ce2e34c67eb9eefb76138a3b3 Mon Sep 17 00:00:00 2001 From: Arch Librarian Date: Mon, 20 Sep 2004 16:54:57 +0000 Subject: Regex, --all-versions and more OR stuff Author: jgg Date: 1999-10-22 04:05:47 GMT Regex, --all-versions and more OR stuff --- apt-pkg/algorithms.cc | 152 +++++++++++++++++++++++++++++++++----------------- cmdline/apt-cache.cc | 25 +++++++-- cmdline/apt-get.cc | 85 +++++++++++++++++----------- debian/changelog | 1 + doc/apt-cache.8.yo | 4 ++ doc/apt-get.8.yo | 3 +- doc/examples/apt.conf | 13 +++-- 7 files changed, 186 insertions(+), 97 deletions(-) diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 51573df54..596473a65 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: algorithms.cc,v 1.25 1999/10/02 04:14:53 jgg Exp $ +// $Id: algorithms.cc,v 1.26 1999/10/22 04:05:47 jgg Exp $ /* ###################################################################### Algorithms - A set of misc algorithms @@ -549,34 +549,38 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg) if ((Flags[P->ID] & Protected) == Protected) { if (Debug == true) - clog << " Reinet Failed because of protected " << P.Name() << endl; + clog << " Reinst Failed because of protected " << P.Name() << endl; Fail = true; - break; } - - // Upgrade the package if the candidate version will fix the problem. - if ((Cache[Start] & pkgDepCache::DepCVer) == pkgDepCache::DepCVer) + else { - if (DoUpgrade(P) == false) + // Upgrade the package if the candidate version will fix the problem. + if ((Cache[Start] & pkgDepCache::DepCVer) == pkgDepCache::DepCVer) + { + if (DoUpgrade(P) == false) + { + if (Debug == true) + clog << " Reinst Failed because of " << P.Name() << endl; + Fail = true; + } + else + { + Fail = false; + break; + } + } + else { + /* We let the algorithm deal with conflicts on its next iteration, + it is much smarter than us */ + if (Start->Type == pkgCache::Dep::Conflicts) + continue; + if (Debug == true) - clog << " Reinst Failed because of " << P.Name() << endl; + clog << " Reinst Failed early because of " << Start.TargetPkg().Name() << endl; Fail = true; - break; - } + } } - else - { - /* We let the algorithm deal with conflicts on its next iteration, - it is much smarter than us */ - if (Start->Type == pkgCache::Dep::Conflicts) - continue; - - if (Debug == true) - clog << " Reinst Failed early because of " << Start.TargetPkg().Name() << endl; - Fail = true; - break; - } if (Start == End) break; @@ -721,12 +725,29 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) bool InOr = false; pkgCache::DepIterator Start; pkgCache::DepIterator End; + PackageKill *OldEnd; + + enum {OrRemove,OrKeep} OrOp = OrRemove; for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false || InOr == true;) { // Compute a single dependency element (glob or) - if (InOr == false) + if (Start == End) + { + // Decide what to do + if (InOr == true) + { + if (OldEnd == LEnd && OrOp == OrRemove) + Cache.MarkDelete(I); + if (OldEnd == LEnd && OrOp == OrKeep) + Cache.MarkKeep(I); + } + + OrOp = OrRemove; D.GlobOr(Start,End); + InOr = Start != End; + OldEnd = LEnd; + } else Start++; @@ -737,9 +758,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) // Dep is ok if ((Cache[End] & pkgDepCache::DepGInstall) == pkgDepCache::DepGInstall) continue; - - InOr = Start != End; - + if (Debug == true) clog << "Package " << I.Name() << " has broken dep on " << Start.TargetPkg().Name() << endl; @@ -748,11 +767,18 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) if a package has a dep on another package that cant be found */ pkgCache::Version **VList = Start.AllTargets(); if (*VList == 0 && (Flags[I->ID] & Protected) != Protected && - Start->Type != pkgCache::Dep::Conflicts && + Start->Type != pkgCache::Dep::Conflicts && Cache[I].NowBroken() == false) - { + { + if (InOr == true) + { + /* No keep choice because the keep being OK could be the + result of another element in the OR group! */ + continue; + } + Change = true; - Cache.MarkKeep(I); + Cache.MarkKeep(I); break; } @@ -778,10 +804,19 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) } /* See if a keep will do, unless the package is protected, - then installing it will be necessary */ + then installing it will be necessary */ + bool Installed = Cache[I].Install(); Cache.MarkKeep(I); if (Cache[I].InstBroken() == false) { + // Unwind operation will be keep now + if (OrOp == OrRemove) + OrOp = OrKeep; + + // Restore + if (InOr == true && Installed == true) + Cache.MarkInstall(I,false); + if (Debug == true) clog << " Holding Back " << I.Name() << " rather than change " << Start.TargetPkg().Name() << endl; } @@ -807,7 +842,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) } else { - // Skip this if it is protected + // Skip adding to the kill list if it is protected if ((Flags[Pkg->ID] & Protected) != 0) continue; @@ -822,11 +857,20 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) // Hm, nothing can possibly satisify this dep. Nuke it. if (VList[0] == 0 && Start->Type != pkgCache::Dep::Conflicts && - (Flags[I->ID] & Protected) != Protected && InOr == false) + (Flags[I->ID] & Protected) != Protected) { + bool Installed = Cache[I].Install(); Cache.MarkKeep(I); if (Cache[I].InstBroken() == false) { + // Unwind operation will be keep now + if (OrOp == OrRemove) + OrOp = OrKeep; + + // Restore + if (InOr == true && Installed == true) + Cache.MarkInstall(I,false); + if (Debug == true) clog << " Holding Back " << I.Name() << " because I can't find " << Start.TargetPkg().Name() << endl; } @@ -834,47 +878,51 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) { if (Debug == true) clog << " Removing " << I.Name() << " because I can't find " << Start.TargetPkg().Name() << endl; - Cache.MarkDelete(I); + if (InOr == false) + Cache.MarkDelete(I); } Change = true; Done = true; } + delete [] VList; + // Try some more if (InOr == true) continue; - delete [] VList; if (Done == true) break; } // Apply the kill list now if (Cache[I].InstallVer != 0) + { for (PackageKill *J = KillList; J != LEnd; J++) - { - Change = true; - if ((Cache[J->Dep] & pkgDepCache::DepGNow) == 0) { - if (J->Dep->Type == pkgCache::Dep::Conflicts) + Change = true; + if ((Cache[J->Dep] & pkgDepCache::DepGNow) == 0) + { + if (J->Dep->Type == pkgCache::Dep::Conflicts) + { + if (Debug == true) + clog << " Fixing " << I.Name() << " via remove of " << J->Pkg.Name() << endl; + Cache.MarkDelete(J->Pkg); + } + } + else { if (Debug == true) - clog << " Fixing " << I.Name() << " via remove of " << J->Pkg.Name() << endl; - Cache.MarkDelete(J->Pkg); + clog << " Fixing " << I.Name() << " via keep of " << J->Pkg.Name() << endl; + Cache.MarkKeep(J->Pkg); } - } - else - { - if (Debug == true) - clog << " Fixing " << I.Name() << " via keep of " << J->Pkg.Name() << endl; - Cache.MarkKeep(J->Pkg); - } - - if (Counter > 1) - Scores[J->Pkg->ID] = Scores[I->ID]; - } - } + + if (Counter > 1) + Scores[J->Pkg->ID] = Scores[I->ID]; + } + } + } } if (Debug == true) diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 8dc56a72b..80c15a749 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: apt-cache.cc,v 1.40 1999/10/18 04:15:25 jgg Exp $ +// $Id: apt-cache.cc,v 1.41 1999/10/22 04:05:47 jgg Exp $ /* ###################################################################### apt-cache - Manages the cache files @@ -589,11 +589,23 @@ bool ShowPackage(CommandLine &CmdL) } // Find the proper version to use. We should probably use the DepCache. - pkgCache::VerIterator V = Cache.GetCandidateVer(Pkg); - if (V.end() == true || V.FileList().end() == true) - continue; - if (DisplayRecord(V) == false) - return false; + if (_config->FindB("APT::Cache::AllVersions","true") == true) + { + pkgCache::VerIterator V; + for (V = Pkg.VersionList(); V.end() == false; V++) + { + if (DisplayRecord(V) == false) + return false; + } + } + else + { + pkgCache::VerIterator V = Cache.GetCandidateVer(Pkg); + if (V.end() == true || V.FileList().end() == true) + continue; + if (DisplayRecord(V) == false) + return false; + } } return true; } @@ -698,6 +710,7 @@ int main(int argc,const char *argv[]) {'i',"important","APT::Cache::Important",0}, {'f',"full","APT::Cache::ShowFull",0}, {'g',"no-generate","APT::Cache::NoGenerate",0}, + {'a',"all-versions","APT::Cache::AllVersions",0}, {0,"names-only","APT::Cache::NamesOnly",0}, {'c',"config-file",0,CommandLine::ConfigFile}, {'o',"option",0,CommandLine::ArbItem}, diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index e134acf7a..51ebe5f41 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: apt-get.cc,v 1.81 1999/10/21 06:35:00 jgg Exp $ +// $Id: apt-get.cc,v 1.82 1999/10/22 04:05:47 jgg Exp $ /* ###################################################################### apt-get - Cover for dpkg @@ -167,7 +167,7 @@ void ShowBroken(ostream &out,CacheFile &Cache,bool Now) // Print out each package and the failed dependencies out <<" " << I.Name() << ":"; - int Indent = strlen(I.Name()) + 3; + unsigned Indent = strlen(I.Name()) + 3; bool First = true; if (Cache[I].InstVerIter(Cache).end() == true) { @@ -185,43 +185,62 @@ void ShowBroken(ostream &out,CacheFile &Cache,bool Now) if (Cache->IsImportantDep(End) == false || (Cache[End] & pkgDepCache::DepGInstall) == pkgDepCache::DepGInstall) continue; - - if (First == false) - for (int J = 0; J != Indent; J++) - out << ' '; - First = false; - out << ' ' << End.DepType() << ": " << End.TargetPkg().Name(); - - // Show a quick summary of the version requirements - if (End.TargetVer() != 0) - out << " (" << End.CompType() << " " << End.TargetVer() << - ")"; - - /* Show a summary of the target package if possible. In the case - of virtual packages we show nothing */ - pkgCache::PkgIterator Targ = End.TargetPkg(); - if (Targ->ProvidesList == 0) + bool FirstOr = true; + while (1) { - out << " but "; - pkgCache::VerIterator Ver = Cache[Targ].InstVerIter(Cache); - if (Ver.end() == false) - out << Ver.VerStr() << (Now?" is installed":" is to be installed"); + if (First == false) + for (unsigned J = 0; J != Indent; J++) + out << ' '; + First = false; + + if (FirstOr == false) + { + for (unsigned J = 0; J != strlen(End.DepType()) + 3; J++) + out << ' '; + } else + out << ' ' << End.DepType() << ": "; + FirstOr = false; + + out << Start.TargetPkg().Name(); + + // Show a quick summary of the version requirements + if (Start.TargetVer() != 0) + out << " (" << Start.CompType() << " " << Start.TargetVer() << + ")"; + + /* Show a summary of the target package if possible. In the case + of virtual packages we show nothing */ + pkgCache::PkgIterator Targ = Start.TargetPkg(); + if (Targ->ProvidesList == 0) { - if (Cache[Targ].CandidateVerIter(Cache).end() == true) + out << " but "; + pkgCache::VerIterator Ver = Cache[Targ].InstVerIter(Cache); + if (Ver.end() == false) + out << Ver.VerStr() << (Now?" is installed":" is to be installed"); + else { - if (Targ->ProvidesList == 0) - out << "it is not installable"; + if (Cache[Targ].CandidateVerIter(Cache).end() == true) + { + if (Targ->ProvidesList == 0) + out << "it is not installable"; + else + out << "it is a virtual package"; + } else - out << "it is a virtual package"; - } - else - out << (Now?"it is not installed":"it is not going to be installed"); - } - } - - out << endl; + out << (Now?"it is not installed":"it is not going to be installed"); + } + } + + if (Start != End) + cout << " or"; + out << endl; + + if (Start == End) + break; + Start++; + } } } } diff --git a/debian/changelog b/debian/changelog index 283650652..7ab220e46 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,6 +22,7 @@ apt (0.3.13.1) unstable; urgency=low * apt-cache showsrc Closes: #45799 * De-Refs Single Pure virtual packages. Closes: #42437 * Regexs for install. Closes: #35304 + * Dependency reports now show OR group relations -- Jason Gunthorpe Fri, 3 Sep 1999 09:04:28 -0700 diff --git a/doc/apt-cache.8.yo b/doc/apt-cache.8.yo index e03e4cbf4..c75af9313 100644 --- a/doc/apt-cache.8.yo +++ b/doc/apt-cache.8.yo @@ -199,6 +199,10 @@ See bf(APT::Cache::Important). dit(bf(-f --full)) Print full package records when searching. See bf(APT::Cache::ShowFull). +dit(bf(-a --all-versions)) +Print full records for all available versions, this is only applicable to the +show command. See bf(APT::Cache::AllVersions) + dit(bf(-g --no-generate)) Do not perform automatic package cache regeneration, use the cache as it is. See bf(APT::Cache::NoGenerate). diff --git a/doc/apt-get.8.yo b/doc/apt-get.8.yo index 393f9ec6f..ac2cbab9a 100644 --- a/doc/apt-get.8.yo +++ b/doc/apt-get.8.yo @@ -81,7 +81,8 @@ may be used to override decisions made by apt-get's conflict resolution system. If no package matches the given expression and the expression contains one of '.', '?' or '*' then it is assumed to be a POSIX regex and it is applied to all package names in the database. Any matches are then installed (or -removed). +removed). Note that matching is done by substring so 'lo*' matches 'how-lo' +and 'lowest'. If this is undesired prefix with a '^' character. dit(bf(remove)) bf(remove) is identical to bf(install) except that packages are removed diff --git a/doc/examples/apt.conf b/doc/examples/apt.conf index 452e9c629..2249cadba 100644 --- a/doc/examples/apt.conf +++ b/doc/examples/apt.conf @@ -1,7 +1,9 @@ -// $Id: apt.conf,v 1.38 1999/10/03 21:09:27 jgg Exp $ +// $Id: apt.conf,v 1.39 1999/10/22 04:05:48 jgg Exp $ /* This file is an index of all APT configuration directives. It should NOT actually be used as a real config file, though it is a completely - valid file. + valid file. Most of the options have sane default values, unless + you have specific needs you should NOT include arbitary items in a custom + configuration. In some instances involving filenames it is possible to set the default directory when the path is evaluated. This means you can use relative @@ -41,6 +43,7 @@ APT Cache { Important "false"; + AllVersions "false"; }; CDROM @@ -164,8 +167,8 @@ DSelect DPkg { - // Probably don't want to set this one.. - Options {"--force-downgrade";} + // Probably don't want to use force-downgrade.. + Options {"--force-overwrite";"--force-downgrade";} // Auto re-mounting of a readonly /usr Pre-Invoke {"mount -o remount,rw /usr";}; @@ -199,4 +202,4 @@ Debug /* Whatever you do, do not use this configuration file!! Take out ONLY the portions you need */ -ThisIsNotAValidConfigFile +This Is Not A Valid Config File -- cgit v1.2.3