From 54668e4e591651be2d83b95ff4a9d96668db1e36 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 26 Jul 2006 10:58:26 +0200 Subject: * cmdline/apt-get.cc: - add a scope with a ActionGroup in DoInstall() to speed up the install of long package lists (e.g. pbuilder) --- cmdline/apt-get.cc | 261 +++++++++++++++++++++++++++-------------------------- 1 file changed, 132 insertions(+), 129 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 8b3c68573..ad4da133f 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1476,159 +1476,162 @@ bool DoInstall(CommandLine &CmdL) if (strcasecmp(CmdL.FileList[0],"remove") == 0) DefRemove = true; else if (strcasecmp(CmdL.FileList[0], "autoremove") == 0) - { - _config->Set("APT::Get::AutomaticRemove", "true"); - DefRemove = true; - } + { + _config->Set("APT::Get::AutomaticRemove", "true"); + DefRemove = true; + } - for (const char **I = CmdL.FileList + 1; *I != 0; I++) + // new scope for the ActionGroup { - // Duplicate the string - unsigned int Length = strlen(*I); - char S[300]; - if (Length >= sizeof(S)) - continue; - strcpy(S,*I); - - // See if we are removing and special indicators.. - bool Remove = DefRemove; - char *VerTag = 0; - bool VerIsRel = false; - while (Cache->FindPkg(S).end() == true) + pkgDepCache::ActionGroup group(Cache); + for (const char **I = CmdL.FileList + 1; *I != 0; I++) { - // Handle an optional end tag indicating what to do - if (Length >= 1 && S[Length - 1] == '-') - { - Remove = true; - S[--Length] = 0; + // Duplicate the string + unsigned int Length = strlen(*I); + char S[300]; + if (Length >= sizeof(S)) continue; - } - - if (Length >= 1 && S[Length - 1] == '+') + strcpy(S,*I); + + // See if we are removing and special indicators.. + bool Remove = DefRemove; + char *VerTag = 0; + bool VerIsRel = false; + while (Cache->FindPkg(S).end() == true) { - Remove = false; - S[--Length] = 0; - continue; - } + // Handle an optional end tag indicating what to do + if (Length >= 1 && S[Length - 1] == '-') + { + Remove = true; + S[--Length] = 0; + continue; + } - char *Slash = strchr(S,'='); - if (Slash != 0) - { - VerIsRel = false; - *Slash = 0; - VerTag = Slash + 1; - } + if (Length >= 1 && S[Length - 1] == '+') + { + Remove = false; + S[--Length] = 0; + continue; + } - Slash = strchr(S,'/'); - if (Slash != 0) - { - VerIsRel = true; - *Slash = 0; - VerTag = Slash + 1; - } + char *Slash = strchr(S,'='); + if (Slash != 0) + { + VerIsRel = false; + *Slash = 0; + VerTag = Slash + 1; + } - break; - } - - // Locate the package - pkgCache::PkgIterator Pkg = Cache->FindPkg(S); - Packages++; - if (Pkg.end() == true) - { - // Check if the name is a regex - const char *I; - for (I = S; *I != 0; I++) - if (*I == '?' || *I == '*' || *I == '|' || - *I == '[' || *I == '^' || *I == '$') - break; - if (*I == 0) - return _error->Error(_("Couldn't find package %s"),S); - - // Regexs must always be confirmed - ExpectedInst += 1000; + Slash = strchr(S,'/'); + if (Slash != 0) + { + VerIsRel = true; + *Slash = 0; + VerTag = Slash + 1; + } - // Compile the regex pattern - regex_t Pattern; - int Res; - if ((Res = regcomp(&Pattern,S,REG_EXTENDED | REG_ICASE | - REG_NOSUB)) != 0) - { - char Error[300]; - regerror(Res,&Pattern,Error,sizeof(Error)); - return _error->Error(_("Regex compilation error - %s"),Error); + break; } - - // Run over the matches - bool Hit = false; - for (Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + + // Locate the package + pkgCache::PkgIterator Pkg = Cache->FindPkg(S); + Packages++; + if (Pkg.end() == true) { - if (regexec(&Pattern,Pkg.Name(),0,0,0) != 0) - continue; + // Check if the name is a regex + const char *I; + for (I = S; *I != 0; I++) + if (*I == '?' || *I == '*' || *I == '|' || + *I == '[' || *I == '^' || *I == '$') + break; + if (*I == 0) + return _error->Error(_("Couldn't find package %s"),S); + + // Regexs must always be confirmed + ExpectedInst += 1000; + + // Compile the regex pattern + regex_t Pattern; + int Res; + if ((Res = regcomp(&Pattern,S,REG_EXTENDED | REG_ICASE | + REG_NOSUB)) != 0) + { + char Error[300]; + regerror(Res,&Pattern,Error,sizeof(Error)); + return _error->Error(_("Regex compilation error - %s"),Error); + } + + // Run over the matches + bool Hit = false; + for (Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + { + if (regexec(&Pattern,Pkg.Name(),0,0,0) != 0) + continue; + + ioprintf(c1out,_("Note, selecting %s for regex '%s'\n"), + Pkg.Name(),S); - ioprintf(c1out,_("Note, selecting %s for regex '%s'\n"), - Pkg.Name(),S); + if (VerTag != 0) + if (TryToChangeVer(Pkg,Cache,VerTag,VerIsRel) == false) + return false; + Hit |= TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix, + ExpectedInst,false); + } + regfree(&Pattern); + + if (Hit == false) + return _error->Error(_("Couldn't find package %s"),S); + } + else + { if (VerTag != 0) if (TryToChangeVer(Pkg,Cache,VerTag,VerIsRel) == false) return false; - - Hit |= TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix, - ExpectedInst,false); - } - regfree(&Pattern); - - if (Hit == false) - return _error->Error(_("Couldn't find package %s"),S); - } - else - { - if (VerTag != 0) - if (TryToChangeVer(Pkg,Cache,VerTag,VerIsRel) == false) + if (TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix,ExpectedInst) == false) return false; - if (TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix,ExpectedInst) == false) - return false; - } - } + } + } - /* If we are in the Broken fixing mode we do not attempt to fix the - problems. This is if the user invoked install without -f and gave - packages */ - if (BrokenFix == true && Cache->BrokenCount() != 0) - { - c1out << _("You might want to run `apt-get -f install' to correct these:") << endl; - ShowBroken(c1out,Cache,false); + /* If we are in the Broken fixing mode we do not attempt to fix the + problems. This is if the user invoked install without -f and gave + packages */ + if (BrokenFix == true && Cache->BrokenCount() != 0) + { + c1out << _("You might want to run `apt-get -f install' to correct these:") << endl; + ShowBroken(c1out,Cache,false); - return _error->Error(_("Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).")); - } + return _error->Error(_("Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).")); + } - // Call the scored problem resolver - Fix.InstallProtect(); - if (Fix.Resolve(true) == false) - _error->Discard(); + // Call the scored problem resolver + Fix.InstallProtect(); + if (Fix.Resolve(true) == false) + _error->Discard(); - // Now we check the state of the packages, - if (Cache->BrokenCount() != 0) - { - c1out << - _("Some packages could not be installed. This may mean that you have\n" - "requested an impossible situation or if you are using the unstable\n" - "distribution that some required packages have not yet been created\n" - "or been moved out of Incoming.") << endl; - if (Packages == 1) + // Now we check the state of the packages, + if (Cache->BrokenCount() != 0) { - c1out << endl; c1out << - _("Since you only requested a single operation it is extremely likely that\n" - "the package is simply not installable and a bug report against\n" - "that package should be filed.") << endl; - } + _("Some packages could not be installed. This may mean that you have\n" + "requested an impossible situation or if you are using the unstable\n" + "distribution that some required packages have not yet been created\n" + "or been moved out of Incoming.") << endl; + if (Packages == 1) + { + c1out << endl; + c1out << + _("Since you only requested a single operation it is extremely likely that\n" + "the package is simply not installable and a bug report against\n" + "that package should be filed.") << endl; + } - c1out << _("The following information may help to resolve the situation:") << endl; - c1out << endl; - ShowBroken(c1out,Cache,false); - return _error->Error(_("Broken packages")); - } - + c1out << _("The following information may help to resolve the situation:") << endl; + c1out << endl; + ShowBroken(c1out,Cache,false); + return _error->Error(_("Broken packages")); + } + } if (_config->FindB("APT::Get::AutomaticRemove")) { if (!DoAutomaticRemove(Cache)) return false; -- cgit v1.2.3 From 9d2938d4e6e86c6afdb9606f76f4ae9ce0ac4ee5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 6 Sep 2006 19:12:34 +0200 Subject: * cmdline/apt-get.cc: - always show the autoremove information and give advice how to use it * debian/rules: - install apt.conf.autoremove with blacklist for linux-image and linux-restriceted-modules --- cmdline/apt-get.cc | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 9e7071988..5e1ccb0c0 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1392,31 +1392,42 @@ bool DoUpdate(CommandLine &CmdL) /* Remove unused automatic packages */ bool DoAutomaticRemove(CacheFile &Cache) { - if(_config->FindI("Debug::pkgAutoRemove",false)) + bool Debug = _config->FindI("Debug::pkgAutoRemove",false); + pkgDepCache::ActionGroup group(*Cache); + + if(Debug) std::cout << "DoAutomaticRemove()" << std::endl; if (_config->FindB("APT::Get::Remove",true) == false) return _error->Error(_("We are not supposed to delete stuff, can't " "start AutoRemover")); + string autoremovelist, autoremoveversions; + // look over the cache to see what can be removed + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) { - pkgDepCache::ActionGroup group(*Cache); - - // look over the cache to see what can be removed - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) - { - if (Cache[Pkg].Garbage) - { - if(Pkg.CurrentVer() != 0 || Cache[Pkg].Install()) - fprintf(stdout,"We could delete %s\n", Pkg.Name()); - - if(Pkg.CurrentVer() != 0 && Pkg->CurrentState != pkgCache::State::ConfigFiles) + if (Cache[Pkg].Garbage) + { + 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) + " "; + if (_config->FindB("APT::Get::AutomaticRemove")) + { + if(Pkg.CurrentVer() != 0 && + Pkg->CurrentState != pkgCache::State::ConfigFiles) Cache->MarkDelete(Pkg, _config->FindB("APT::Get::Purge", false)); - else + else Cache->MarkKeep(Pkg, false, false); - } - } + } + } } + ShowList(c1out, _("The following packages where automatically installed and are no longer required:"), autoremovelist, autoremoveversions); + if (!_config->FindB("APT::Get::AutomaticRemove") && + autoremovelist.size() > 0) + c1out << _("Use 'apt-get autoremove' to remove them.") << std::endl; // Now see if we destroyed anything if (Cache->BrokenCount() != 0) @@ -1632,10 +1643,8 @@ bool DoInstall(CommandLine &CmdL) return _error->Error(_("Broken packages")); } } - if (_config->FindB("APT::Get::AutomaticRemove")) { - if (!DoAutomaticRemove(Cache)) + if (!DoAutomaticRemove(Cache)) return false; - } /* Print out a list of packages that are going to be installed extra to what the user asked */ -- cgit v1.2.3 From c15f569038c9d08cfb5186945d9c5095f7776768 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 8 Sep 2006 19:36:31 +0200 Subject: * apt-pkg/algorithms.cc: - bugfix in the InstallProcted() code (preserver the auto-install information) * cmdline/makefile: - install apt-mark as well --- cmdline/makefile | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cmdline') diff --git a/cmdline/makefile b/cmdline/makefile index 882a0e1b5..49035be44 100644 --- a/cmdline/makefile +++ b/cmdline/makefile @@ -52,3 +52,9 @@ SOURCE=apt-key TO=$(BIN) TARGET=program include $(COPY_H) + +# The apt-mark program +SOURCE=apt-mark +TO=$(BIN) +TARGET=program +include $(COPY_H) -- cgit v1.2.3 From c97fd4ec4a34eb15eb8985890a47e768f4b94f0d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 13 Sep 2006 11:32:32 +0200 Subject: * cmdline/apt-get.cc: - only error out if both "APT::Get::Autoremove" is set to true and "APT::Get::Remove" to false, in this case the the save options wins and apt will abort --- cmdline/apt-get.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 5e1ccb0c0..411b16e90 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1398,7 +1398,8 @@ bool DoAutomaticRemove(CacheFile &Cache) if(Debug) std::cout << "DoAutomaticRemove()" << std::endl; - if (_config->FindB("APT::Get::Remove",true) == false) + if (_config->FindB("APT::Get::AutomaticRemove") && + _config->FindB("APT::Get::Remove",true) == false) return _error->Error(_("We are not supposed to delete stuff, can't " "start AutoRemover")); -- cgit v1.2.3 From 3d0de656b6263d51c288d82ef2b352e53023382c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 13 Sep 2006 11:52:19 +0200 Subject: * cmdline/apt-get.cc: - changed the behaviour of --no-remove and --auto-remove, if --no-remove is given, then that will turn off --auto-remove implicitely --- cmdline/apt-get.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 411b16e90..4af23641b 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1393,15 +1393,20 @@ bool DoUpdate(CommandLine &CmdL) bool DoAutomaticRemove(CacheFile &Cache) { bool Debug = _config->FindI("Debug::pkgAutoRemove",false); + bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove"); pkgDepCache::ActionGroup group(*Cache); + if(Debug) std::cout << "DoAutomaticRemove()" << std::endl; - if (_config->FindB("APT::Get::AutomaticRemove") && - _config->FindB("APT::Get::Remove",true) == false) - return _error->Error(_("We are not supposed to delete stuff, can't " - "start AutoRemover")); + if (_config->FindB("APT::Get::Remove",true) == false && + doAutoRemove == true) + { + c1out << _("We are not supposed to delete stuff, can't start " + "AutoRemover") << std::endl; + doAutoRemove = false; + } string autoremovelist, autoremoveversions; // look over the cache to see what can be removed @@ -1415,7 +1420,7 @@ bool DoAutomaticRemove(CacheFile &Cache) autoremovelist += string(Pkg.Name()) + " "; autoremoveversions += string(Cache[Pkg].CandVersion) + " "; - if (_config->FindB("APT::Get::AutomaticRemove")) + if (doAutoRemove) { if(Pkg.CurrentVer() != 0 && Pkg->CurrentState != pkgCache::State::ConfigFiles) @@ -1426,8 +1431,7 @@ bool DoAutomaticRemove(CacheFile &Cache) } } ShowList(c1out, _("The following packages where automatically installed and are no longer required:"), autoremovelist, autoremoveversions); - if (!_config->FindB("APT::Get::AutomaticRemove") && - autoremovelist.size() > 0) + if (!doAutoRemove && autoremovelist.size() > 0) c1out << _("Use 'apt-get autoremove' to remove them.") << std::endl; // Now see if we destroyed anything -- cgit v1.2.3 From ae24ac67f6bbab1474a5386b946fc7bd97ad86c8 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 13 Sep 2006 11:53:26 +0200 Subject: * cmdline/apt-get.cc: - typo --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 4af23641b..570e1016c 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1430,7 +1430,7 @@ bool DoAutomaticRemove(CacheFile &Cache) } } } - ShowList(c1out, _("The following packages where automatically installed and are no longer required:"), autoremovelist, autoremoveversions); + ShowList(c1out, _("The following packages were automatically installed and are no longer required:"), autoremovelist, autoremoveversions); if (!doAutoRemove && autoremovelist.size() > 0) c1out << _("Use 'apt-get autoremove' to remove them.") << std::endl; -- cgit v1.2.3