From 3238423f4d0bebf02c02fa6e5ca5b6db4fca56c5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 18 Jun 2007 14:06:21 +0200 Subject: * implement warning when Vcs-*: header is found in source record --- cmdline/apt-get.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 554677f39..51bcfde12 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2114,6 +2114,28 @@ bool DoSource(CommandLine &CmdL) if (Last == 0) return _error->Error(_("Unable to find a source package for %s"),Src.c_str()); + string srec = Last->AsStr(); + string::size_type pos = srec.find("\nVcs-"); + if (pos != string::npos ) + { + pos += strlen("\nVcs-"); + string vcs = srec.substr(pos,srec.find(":",pos)-pos); + pos += vcs.length()+2; + string::size_type epos = srec.find("\n", pos); + string uri = srec.substr(pos,epos-pos).c_str(); + ioprintf(c1out, _("WARNING: '%s' is maintained in " + "the '%s' version control system at:\n" + "'%s'\n"), + Src.c_str(), vcs.c_str(), uri.c_str()); + if(vcs == "Bzr") + ioprintf(c1out,_("Please use: 'bzr get %s'\n" + "to modify the package.\n"), + uri.c_str()); + ioprintf(c1out, "Are you sure you want to continue [yN]? "); + if(!YnPrompt(false)) + return _error->Error(_("Abort.")); + } + // Back track vector Lst; if (Last->Files(Lst) == false) -- cgit v1.2.3 From 541c83b92a4919ba0aed6150f71e227d07f93a02 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 27 Jun 2007 13:34:34 +0200 Subject: * cmdline/apt-get.cc: - fix InstallTask code when a pkgRecord ends with a single '\n' (thanks to Soren Hansen for reporting) --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 51bcfde12..974427f51 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1519,7 +1519,7 @@ bool TryInstallTask(pkgDepCache &Cache, pkgProblemResolver &Fix, // build regexp for the task char S[300]; - snprintf(S, sizeof(S), "^Task:.*[^a-z]%s[^a-z].*\n", taskname); + snprintf(S, sizeof(S), "^Task:.*[^a-z]%s[^a-z].*$", taskname); regcomp(&Pattern,S, REG_EXTENDED | REG_NOSUB | REG_NEWLINE); bool found = false; -- cgit v1.2.3 From 927677f0ae5f92bb6935c91b08ee6ffe220d4bfa Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 28 Jun 2007 18:19:58 +0200 Subject: * cmdline/apt-get.cc: - make the ouput more friendly for copy and paste (thanks to Matt Zimmerman) --- cmdline/apt-get.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 51bcfde12..930d88d99 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2128,7 +2128,8 @@ bool DoSource(CommandLine &CmdL) "'%s'\n"), Src.c_str(), vcs.c_str(), uri.c_str()); if(vcs == "Bzr") - ioprintf(c1out,_("Please use: 'bzr get %s'\n" + ioprintf(c1out,_("Please use:\n" + "bzr get %s\n" "to modify the package.\n"), uri.c_str()); ioprintf(c1out, "Are you sure you want to continue [yN]? "); -- cgit v1.2.3 From 8756297c0f5987d2320955c21e5c64395ce311cc Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 28 Jun 2007 18:38:55 +0200 Subject: * cmdline/apt-get.cc: - remove '' around xs-vcs-$repo to make pasting easier --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 930d88d99..fa7ae32eb 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2125,7 +2125,7 @@ bool DoSource(CommandLine &CmdL) string uri = srec.substr(pos,epos-pos).c_str(); ioprintf(c1out, _("WARNING: '%s' is maintained in " "the '%s' version control system at:\n" - "'%s'\n"), + "%s\n"), Src.c_str(), vcs.c_str(), uri.c_str()); if(vcs == "Bzr") ioprintf(c1out,_("Please use:\n" -- cgit v1.2.3 From 774a66876919712d5b8e12174f01f0337d2f3393 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 29 Jun 2007 13:04:17 +0200 Subject: * cmdline/apt-get.cc: - ignore Vcs-Browser flag (#121770) --- cmdline/apt-get.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index fa7ae32eb..08bb1bc34 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2116,10 +2116,15 @@ bool DoSource(CommandLine &CmdL) string srec = Last->AsStr(); string::size_type pos = srec.find("\nVcs-"); - if (pos != string::npos ) + while (pos != string::npos) { pos += strlen("\nVcs-"); string vcs = srec.substr(pos,srec.find(":",pos)-pos); + if(vcs == "Browser") + { + pos = srec.find("\nVcs-", pos); + continue; + } pos += vcs.length()+2; string::size_type epos = srec.find("\n", pos); string uri = srec.substr(pos,epos-pos).c_str(); @@ -2135,6 +2140,8 @@ bool DoSource(CommandLine &CmdL) ioprintf(c1out, "Are you sure you want to continue [yN]? "); if(!YnPrompt(false)) return _error->Error(_("Abort.")); + else + break; } // Back track -- cgit v1.2.3 From b799e134fc730519cc8f0c0ea4387badffac4092 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 8 Aug 2007 12:52:56 +0200 Subject: * cmdline/apt-get.cc: - remove YnPrompt when a XS-Vcs- tag is found, improve the notice (LP: #129575) --- cmdline/apt-get.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index ead053136..e7b7d5204 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2130,20 +2130,17 @@ bool DoSource(CommandLine &CmdL) pos += vcs.length()+2; string::size_type epos = srec.find("\n", pos); string uri = srec.substr(pos,epos-pos).c_str(); - ioprintf(c1out, _("WARNING: '%s' is maintained in " + ioprintf(c1out, _("NOTICE: '%s' packaging is maintained in " "the '%s' version control system at:\n" "%s\n"), Src.c_str(), vcs.c_str(), uri.c_str()); if(vcs == "Bzr") ioprintf(c1out,_("Please use:\n" "bzr get %s\n" - "to modify the package.\n"), + "to retrieve the latest (possible unreleased) " + "updates to the package.\n"), uri.c_str()); - ioprintf(c1out, "Are you sure you want to continue [yN]? "); - if(!YnPrompt(false)) - return _error->Error(_("Abort.")); - else - break; + break; } // Back track -- cgit v1.2.3 From 6f320e7b0fe9e9f1e1ac4452ba7a4c1eca297842 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 11 Mar 2008 09:54:45 +0100 Subject: * cmdline/apt-get.cc: - fix incorrect help output for -f (LP: #57487) --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 8956332a3..c522d4f87 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2662,7 +2662,7 @@ bool ShowHelp(CommandLine &CmdL) " -d Download only - do NOT install or unpack archives\n" " -s No-act. Perform ordering simulation\n" " -y Assume Yes to all queries and do not prompt\n" - " -f Attempt to continue if the integrity check fails\n" + " -f Attempt to correct a system with broken dependencies in place\n" " -m Attempt to continue if archives are unlocatable\n" " -u Show a list of upgraded packages as well\n" " -b Build the source package after fetching it\n" -- cgit v1.2.3 From 95717122196eb888bc81f5c3e8daa74cad8db649 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 11 Mar 2008 17:41:55 +0100 Subject: - run the problemResolver after a task was installed so that it can correct any missing dependencies --- cmdline/apt-get.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index c522d4f87..c8671447e 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1506,10 +1506,13 @@ bool TryInstallTask(pkgDepCache &Cache, pkgProblemResolver &Fix, buf[end-start] = 0x0; if (regexec(&Pattern,buf,0,0,0) != 0) continue; - res &= TryToInstall(Pkg,Cache,Fix,Remove,false,ExpectedInst); + res &= TryToInstall(Pkg,Cache,Fix,Remove,true,ExpectedInst); found = true; } + // now let the problem resolver deal with any issues + Fix.Resolve(true); + if(!found) _error->Error(_("Couldn't find task %s"),taskname); -- cgit v1.2.3 From c22356d86150dfee4903ff146a64cd5ad63be827 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 13 Mar 2008 23:42:43 +0100 Subject: * cmdline/apt-get.cc: - do two passes when installing tasks, first ignoring dependencies, then resolving them and run the problemResolver at the end so that it can correct any missing dependencies. This should fix livecd building for kubuntu (thanks to Jonathan Riddell for reporting the problem) --- cmdline/apt-get.cc | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index c8671447e..cabbde5cb 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1495,19 +1495,24 @@ bool TryInstallTask(pkgDepCache &Cache, pkgProblemResolver &Fix, bool found = false; bool res = true; - for (Pkg = Cache.PkgBegin(); Pkg.end() == false; Pkg++) + + // two runs, first ignore dependencies, second install any missing + for(int IgnoreBroken=1; IgnoreBroken >= 0; IgnoreBroken--) { - pkgCache::VerIterator ver = Cache[Pkg].CandidateVerIter(Cache); - if(ver.end()) - continue; - pkgRecords::Parser &parser = Recs.Lookup(ver.FileList()); - parser.GetRec(start,end); - strncpy(buf, start, end-start); - buf[end-start] = 0x0; - if (regexec(&Pattern,buf,0,0,0) != 0) - continue; - res &= TryToInstall(Pkg,Cache,Fix,Remove,true,ExpectedInst); - found = true; + for (Pkg = Cache.PkgBegin(); Pkg.end() == false; Pkg++) + { + pkgCache::VerIterator ver = Cache[Pkg].CandidateVerIter(Cache); + if(ver.end()) + continue; + pkgRecords::Parser &parser = Recs.Lookup(ver.FileList()); + parser.GetRec(start,end); + strncpy(buf, start, end-start); + buf[end-start] = 0x0; + if (regexec(&Pattern,buf,0,0,0) != 0) + continue; + res &= TryToInstall(Pkg,Cache,Fix,Remove,IgnoreBroken,ExpectedInst); + found = true; + } } // now let the problem resolver deal with any issues -- cgit v1.2.3 From 9772f307fdf1f4cc94690b4ba3705a8f891033fe Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 8 Dec 2008 09:37:09 -0800 Subject: * cmdline/apt-get.cc: - fix "apt-get source pkg=ver" if binary name != source name (LP: #202219) * doc/makefile: - add examples/apt-https-method-example.conf --- cmdline/apt-get.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index bd95e917b..ea7d45952 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1295,9 +1295,9 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, { string Ver = Parse->Version(); - // Skip name mismatches - if (IsMatch == true && Parse->Package() != Src) - continue; + // show name mismatches + if (IsMatch == true && Parse->Package() != Src) + ioprintf(c1out, _("No source package '%s' picking '%s' instead"), Parse->Package(), Src); if (VerTag.empty() == false) { -- cgit v1.2.3 From 71da8af4dabe8680802ef291267c2f53d7942d18 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 16 Dec 2008 07:38:42 +0100 Subject: Clarify the --help for 'purge' (LP: #243948) --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index ea7d45952..d5869da43 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2659,7 +2659,7 @@ bool ShowHelp(CommandLine &CmdL) " install - Install new packages (pkg is libc6 not libc6.deb)\n" " remove - Remove packages\n" " autoremove - Remove automatically all unused packages\n" - " purge - Remove and purge packages\n" + " purge - Remove packages and config files\n" " source - Download source archives\n" " build-dep - Configure build-dependencies for source packages\n" " dist-upgrade - Distribution upgrade, see apt-get(8)\n" -- cgit v1.2.3 From 236527f0fffe30fc8988e17d926778c23ac1f902 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 28 Jan 2009 17:39:37 +0100 Subject: LP: #263089 --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index d5869da43..38775f70d 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1297,7 +1297,7 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, // show name mismatches if (IsMatch == true && Parse->Package() != Src) - ioprintf(c1out, _("No source package '%s' picking '%s' instead"), Parse->Package(), Src); + ioprintf(c1out, _("No source package '%s' picking '%s' instead"), Parse->Package().c_str(), Src.c_str()); if (VerTag.empty() == false) { -- cgit v1.2.3 From 4bfb7a7756eed967c1edad63bc16a37b741cafaa Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 9 Feb 2009 14:34:50 +0100 Subject: * cmdline/apt-get.cc: - default to "false" for the "APT::Get::Build-Dep-Automatic" option (follow debian here) --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 38775f70d..2117a7f2a 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2542,7 +2542,7 @@ bool DoBuildDep(CommandLine &CmdL) { // We successfully installed something; skip remaining alternatives skipAlternatives = hasAlternatives; - if(_config->FindB("APT::Get::Build-Dep-Automatic", true) == true) + if(_config->FindB("APT::Get::Build-Dep-Automatic", false) == true) Cache->MarkAuto(Pkg, true); continue; } -- cgit v1.2.3 From 5ef499349c609f5ef50bd633692faa2665f4f96f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 9 Mar 2009 16:33:39 +0100 Subject: * cmdline/apt-get.cc - fix "apt-get source pkg" if there is a binary package and a source package of the same name but from different packages (LP: #330103) --- cmdline/apt-get.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 2117a7f2a..0339afdf1 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1272,16 +1272,23 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, } } } - - // No source package name.. - if (Src.empty() == true) - Src = TmpSrc; - + // The best hit pkgSrcRecords::Parser *Last = 0; unsigned long Offset = 0; string Version; bool IsMatch = false; + bool MatchSrcOnly = false; + + // No source package name.. + if (Src.empty() == true) + Src = TmpSrc; + else + // if we have a source pkg name, make sure to only search + // for srcpkg names, otherwise apt gets confused if there + // is a binary package "pkg1" and a source package "pkg1" + // with the same name but that comes from different packages + MatchSrcOnly = true; // If we are matching by version then we need exact matches to be happy if (VerTag.empty() == false) @@ -1291,13 +1298,13 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, binary packages in the search */ pkgSrcRecords::Parser *Parse; SrcRecs.Restart(); - while ((Parse = SrcRecs.Find(Src.c_str(),false)) != 0) + while ((Parse = SrcRecs.Find(Src.c_str(), MatchSrcOnly)) != 0) { string Ver = Parse->Version(); // show name mismatches if (IsMatch == true && Parse->Package() != Src) - ioprintf(c1out, _("No source package '%s' picking '%s' instead"), Parse->Package().c_str(), Src.c_str()); + ioprintf(c1out, _("No source package '%s' picking '%s' instead\n"), Parse->Package().c_str(), Src.c_str()); if (VerTag.empty() == false) { -- cgit v1.2.3 From 28b5ff3f76e63f0b4bbed5980b9c13f4a7c3cecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Sun, 10 May 2009 12:12:29 +0200 Subject: Drop duplicate "purge" in command list. --- cmdline/apt-get.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 0339afdf1..988abe216 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2778,7 +2778,6 @@ int main(int argc,const char *argv[]) {"remove",&DoInstall}, {"purge",&DoInstall}, {"autoremove",&DoInstall}, - {"purge",&DoInstall}, {"dist-upgrade",&DoDistUpgrade}, {"dselect-upgrade",&DoDSelectUpgrade}, {"build-dep",&DoBuildDep}, -- cgit v1.2.3 From 3d513bbd0c7cdcfb962403645dd9f05f0a127938 Mon Sep 17 00:00:00 2001 From: Brian Murray Date: Thu, 13 Aug 2009 13:25:21 -0700 Subject: incorporate string-fix patch from Matthew East for LP: #370094 --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 04f3944a9..7385c3dd3 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2127,7 +2127,7 @@ bool DoSource(CommandLine &CmdL) if(vcs == "Bzr") ioprintf(c1out,_("Please use:\n" "bzr get %s\n" - "to retrieve the latest (possible unreleased) " + "to retrieve the latest (possibly unreleased) " "updates to the package.\n"), uri.c_str()); break; -- cgit v1.2.3 From fb1e7ecf359510b263bc4acd23659024b54c17c9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 27 Nov 2009 10:02:27 +0100 Subject: add --debian-only as alias for --diff-only for all source v3 lovers --- cmdline/apt-get.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 49fde7466..7325bbf22 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2799,6 +2799,7 @@ int main(int argc,const char *argv[]) /*{{{*/ {0,"force-yes","APT::Get::force-yes",0}, {0,"print-uris","APT::Get::Print-URIs",0}, {0,"diff-only","APT::Get::Diff-Only",0}, + {0,"debian-only","APT::Get::Diff-Only",0}, {0,"tar-only","APT::Get::Tar-Only",0}, {0,"dsc-only","APT::Get::Dsc-Only",0}, {0,"purge","APT::Get::Purge",0}, -- cgit v1.2.3 From e57a5bff9c131aaa02f5756186927c755289089e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 31 Jan 2010 02:16:17 +0100 Subject: * cmdline/apt-get.cc: - don't mark as manually if in download only (Closes: #468180) --- cmdline/apt-get.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index dede0137e..34ae2fed9 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1776,7 +1776,8 @@ bool DoInstall(CommandLine &CmdL) if(!Remove && Cache[Pkg].Install() == false && (Cache[Pkg].Flags & pkgCache::Flag::Auto) && - _config->FindB("APT::Get::ReInstall",false) == false) + _config->FindB("APT::Get::ReInstall",false) == false && + _config->FindB("APT::Get::Download-Only",false) == false) { ioprintf(c1out,_("%s set to manually installed.\n"), Pkg.Name()); -- cgit v1.2.3 From 6293e04ff36cd1cb4756fc30a4777ad6aaf8ffac Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Feb 2010 15:41:04 +0100 Subject: display the architecture of the package if it is not the default architecture in apt-get, display policy for all available architectures and use GrpIterator in apt-cache pkgnames --- cmdline/apt-get.cc | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 7325bbf22..2597a6acb 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -227,6 +227,17 @@ bool ShowList(ostream &out,string Title,string List,string VersionsList) return false; } /*}}}*/ +// ShowPkg - display a package name /*{{{*/ +// --------------------------------------------------------------------- +/* Displays the package name and maybe also the architecture + if it is not the main architecture */ +string ShowPkg(pkgCache::PkgIterator const Pkg) { + string p = Pkg.Name(); + if (_config->Find("APT::Architecture") != Pkg.Arch()) + p.append(":").append(Pkg.Arch()); + return p; +} + /*}}}*/ // ShowBroken - Debugging aide /*{{{*/ // --------------------------------------------------------------------- /* This prints out the names of all the packages that are broken along @@ -258,8 +269,8 @@ void ShowBroken(ostream &out,CacheFile &Cache,bool Now) } // Print out each package and the failed dependencies - out <<" " << I.Name() << ":"; - unsigned Indent = strlen(I.Name()) + 3; + out << " " << ShowPkg(I) << " :"; + unsigned const Indent = ShowPkg(I).size() + 3; bool First = true; pkgCache::VerIterator Ver; @@ -312,7 +323,7 @@ void ShowBroken(ostream &out,CacheFile &Cache,bool Now) out << ' ' << End.DepType() << ": "; FirstOr = false; - out << Start.TargetPkg().Name(); + out << ShowPkg(Start.TargetPkg()); // Show a quick summary of the version requirements if (Start.TargetVer() != 0) @@ -374,7 +385,7 @@ void ShowNew(ostream &out,CacheFile &Cache) { pkgCache::PkgIterator I(Cache,Cache.List[J]); if (Cache[I].NewInstall() == true) { - List += string(I.Name()) + " "; + List += ShowPkg(I) + " "; VersionsList += string(Cache[I].CandVersion) + "\n"; } } @@ -397,9 +408,9 @@ void ShowDel(ostream &out,CacheFile &Cache) if (Cache[I].Delete() == true) { if ((Cache[I].iFlags & pkgDepCache::Purge) == pkgDepCache::Purge) - List += string(I.Name()) + "* "; + List += ShowPkg(I) + "* "; else - List += string(I.Name()) + " "; + List += ShowPkg(I) + " "; VersionsList += string(Cache[I].CandVersion)+ "\n"; } @@ -424,7 +435,7 @@ void ShowKept(ostream &out,CacheFile &Cache) I->CurrentVer == 0 || Cache[I].Delete() == true) continue; - List += string(I.Name()) + " "; + List += ShowPkg(I) + " "; VersionsList += string(Cache[I].CurVersion) + " => " + Cache[I].CandVersion + "\n"; } ShowList(out,_("The following packages have been kept back:"),List,VersionsList); @@ -445,7 +456,7 @@ void ShowUpgraded(ostream &out,CacheFile &Cache) if (Cache[I].Upgrade() == false || Cache[I].NewInstall() == true) continue; - List += string(I.Name()) + " "; + List += ShowPkg(I) + " "; VersionsList += string(Cache[I].CurVersion) + " => " + Cache[I].CandVersion + "\n"; } ShowList(out,_("The following packages will be upgraded:"),List,VersionsList); @@ -466,7 +477,7 @@ bool ShowDowngraded(ostream &out,CacheFile &Cache) if (Cache[I].Downgrade() == false || Cache[I].NewInstall() == true) continue; - List += string(I.Name()) + " "; + List += ShowPkg(I) + " "; VersionsList += string(Cache[I].CurVersion) + " => " + Cache[I].CandVersion + "\n"; } return ShowList(out,_("The following packages will be DOWNGRADED:"),List,VersionsList); @@ -484,7 +495,7 @@ bool ShowHold(ostream &out,CacheFile &Cache) pkgCache::PkgIterator I(Cache,Cache.List[J]); if (Cache[I].InstallVer != (pkgCache::Version *)I.CurrentVer() && I->SelectedState == pkgCache::State::Hold) { - List += string(I.Name()) + " "; + List += ShowPkg(I) + " "; VersionsList += string(Cache[I].CurVersion) + " => " + Cache[I].CandVersion + "\n"; } } @@ -518,7 +529,7 @@ bool ShowEssential(ostream &out,CacheFile &Cache) if (Added[I->ID] == false) { Added[I->ID] = true; - List += string(I.Name()) + " "; + List += ShowPkg(I) + " "; //VersionsList += string(Cache[I].CurVersion) + "\n"; ??? } } -- cgit v1.2.3 From 803ea2a87f81252b2c0d541b8502ed206ce57c84 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 12 Feb 2010 00:04:31 +0100 Subject: Add yet another pseudo package which isn't as pseudo as the others: Arch all packages are now represented by arch depending packages which all depend on a package with the same name and the special arch "all". This packages has NO dependencies, but beside this the same information. It is the only package which has a size, the arch depending ones all have a zero size. While the arch depending pseudo packages are used for dependency resolution the arch "all" package is used for downloading and ordering of the package. --- cmdline/apt-get.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 2597a6acb..93065004c 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -233,7 +233,7 @@ bool ShowList(ostream &out,string Title,string List,string VersionsList) if it is not the main architecture */ string ShowPkg(pkgCache::PkgIterator const Pkg) { string p = Pkg.Name(); - if (_config->Find("APT::Architecture") != Pkg.Arch()) + if (strcmp(Pkg.Arch(),"all") != 0 && _config->Find("APT::Architecture") != Pkg.Arch()) p.append(":").append(Pkg.Arch()); return p; } @@ -385,6 +385,8 @@ void ShowNew(ostream &out,CacheFile &Cache) { pkgCache::PkgIterator I(Cache,Cache.List[J]); if (Cache[I].NewInstall() == true) { + if (Cache[I].CandidateVerIter(Cache).Pseudo() == true) + continue; List += ShowPkg(I) + " "; VersionsList += string(Cache[I].CandVersion) + "\n"; } @@ -407,6 +409,8 @@ void ShowDel(ostream &out,CacheFile &Cache) pkgCache::PkgIterator I(Cache,Cache.List[J]); if (Cache[I].Delete() == true) { + if (Cache[I].CandidateVerIter(Cache).Pseudo() == true) + continue; if ((Cache[I].iFlags & pkgDepCache::Purge) == pkgDepCache::Purge) List += ShowPkg(I) + "* "; else @@ -455,7 +459,9 @@ void ShowUpgraded(ostream &out,CacheFile &Cache) // Not interesting if (Cache[I].Upgrade() == false || Cache[I].NewInstall() == true) continue; - + if (Cache[I].CandidateVerIter(Cache).Pseudo() == true) + continue; + List += ShowPkg(I) + " "; VersionsList += string(Cache[I].CurVersion) + " => " + Cache[I].CandVersion + "\n"; } @@ -476,7 +482,9 @@ bool ShowDowngraded(ostream &out,CacheFile &Cache) // Not interesting if (Cache[I].Downgrade() == false || Cache[I].NewInstall() == true) continue; - + if (Cache[I].CandidateVerIter(Cache).Pseudo() == true) + continue; + List += ShowPkg(I) + " "; VersionsList += string(Cache[I].CurVersion) + " => " + Cache[I].CandVersion + "\n"; } -- cgit v1.2.3 From 42d71ab5fe58953a680bd300a99d173e23430d7c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 12 Feb 2010 17:17:16 +0100 Subject: In SingleArch environments we don't need the arch "all" pseudo package for handling arch:all packages, so we create only one package and stop calling it a pseudo package. --- cmdline/apt-get.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 93065004c..343226bc3 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -585,6 +585,9 @@ void Stats(ostream &out,pkgDepCache &Dep) unsigned long ReInstall = 0; for (pkgCache::PkgIterator I = Dep.PkgBegin(); I.end() == false; I++) { + if (pkgCache::VerIterator(Dep, Dep[I].CandidateVer).Pseudo() == true) + continue; + if (Dep[I].NewInstall() == true) Install++; else -- cgit v1.2.3 From af3f8112590edf58cab36e72bca6d5f8e161fbc3 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 15 Feb 2010 00:01:36 +0100 Subject: Activate support of :any and stuff in apt-get build-dep as we have now support for MultiArch, so Multi-Arch: allowed packages should already provide package:any --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 5ef5533e2..216383bc6 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2458,7 +2458,7 @@ bool DoBuildDep(CommandLine &CmdL) // Process the build-dependencies vector BuildDeps; - if (Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only",false)) == false) + if (Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only",true)) == false) return _error->Error(_("Unable to get build-dependency information for %s"),Src.c_str()); // Also ensure that build-essential packages are present -- cgit v1.2.3 From d44b437bd2897bf7fbfbde07a4511c6f7b9ef6a2 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 15 Feb 2010 13:02:27 +0100 Subject: * buildlib/apti18n.h.in, po/makefile: - add ngettext support with P_() --- cmdline/apt-get.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 216383bc6..c8c733716 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1526,10 +1526,9 @@ bool DoAutomaticRemove(CacheFile &Cache) // only show stuff in the list that is not yet marked for removal if(Cache[Pkg].Delete() == false) { + ++autoRemoveCount; // we don't need to fill the strings if we don't need them - if (smallList == true) - ++autoRemoveCount; - else + if (smallList == false) { autoremovelist += string(Pkg.Name()) + " "; autoremoveversions += string(Cache[Pkg].CandVersion) + "\n"; @@ -1542,9 +1541,12 @@ bool DoAutomaticRemove(CacheFile &Cache) if (doAutoRemove == false && (autoremovelist.empty() == false || autoRemoveCount != 0)) { if (smallList == false) - ShowList(c1out, _("The following packages were automatically installed and are no longer required:"), autoremovelist, autoremoveversions); + ShowList(c1out, P_("The following package is automatically installed and is no longer required:", + "The following packages were automatically installed and are no longer required:", + autoRemoveCount), autoremovelist, autoremoveversions); else - ioprintf(c1out, _("%lu packages were automatically installed and are no longer required.\n"), autoRemoveCount); + ioprintf(c1out, P_("%lu package was automatically installed and is no longer required.\n", + "%lu packages were automatically installed and are no longer required.\n", autoRemoveCount), autoRemoveCount); c1out << _("Use 'apt-get autoremove' to remove them.") << std::endl; } // Now see if we had destroyed anything (if we had done anything) -- cgit v1.2.3 From f0f2f956957af36389790fd47899a1f65302b21c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 18 Feb 2010 00:31:49 +0100 Subject: * buildlib/apti18n.h.in, po/makefile: - add ngettext support with P_() --- cmdline/apt-get.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 34ae2fed9..5a814e255 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1504,10 +1504,9 @@ bool DoAutomaticRemove(CacheFile &Cache) // only show stuff in the list that is not yet marked for removal if(Cache[Pkg].Delete() == false) { + ++autoRemoveCount; // we don't need to fill the strings if we don't need them - if (smallList == true) - ++autoRemoveCount; - else + if (smallList == false) { autoremovelist += string(Pkg.Name()) + " "; autoremoveversions += string(Cache[Pkg].CandVersion) + "\n"; @@ -1520,9 +1519,12 @@ bool DoAutomaticRemove(CacheFile &Cache) if (doAutoRemove == false && (autoremovelist.empty() == false || autoRemoveCount != 0)) { if (smallList == false) - ShowList(c1out, _("The following packages were automatically installed and are no longer required:"), autoremovelist, autoremoveversions); + ShowList(c1out, P_("The following package is automatically installed and is no longer required:", + "The following packages were automatically installed and are no longer required:", + autoRemoveCount), autoremovelist, autoremoveversions); else - ioprintf(c1out, _("%lu packages were automatically installed and are no longer required.\n"), autoRemoveCount); + ioprintf(c1out, P_("%lu package was automatically installed and is no longer required.\n", + "%lu packages were automatically installed and are no longer required.\n", autoRemoveCount), autoRemoveCount); c1out << _("Use 'apt-get autoremove' to remove them.") << std::endl; } // Now see if we had destroyed anything (if we had done anything) -- cgit v1.2.3 From 75ce206243e409b170d06723430eb85a4a747882 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 26 Feb 2010 20:47:19 +0100 Subject: move ShowPkg() from apt-get to the PkgIterator and rename it to FullName() responseable for displaying a package name and the architecture in a uniform way. Pretty option can be used to not append the architecture if it is the native architecture or all - and use it all over the place in the commandline tools. --- cmdline/apt-get.cc | 80 +++++++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 46 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index c8c733716..4596c3d61 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -227,17 +227,6 @@ bool ShowList(ostream &out,string Title,string List,string VersionsList) return false; } /*}}}*/ -// ShowPkg - display a package name /*{{{*/ -// --------------------------------------------------------------------- -/* Displays the package name and maybe also the architecture - if it is not the main architecture */ -string ShowPkg(pkgCache::PkgIterator const Pkg) { - string p = Pkg.Name(); - if (strcmp(Pkg.Arch(),"all") != 0 && _config->Find("APT::Architecture") != Pkg.Arch()) - p.append(":").append(Pkg.Arch()); - return p; -} - /*}}}*/ // ShowBroken - Debugging aide /*{{{*/ // --------------------------------------------------------------------- /* This prints out the names of all the packages that are broken along @@ -269,8 +258,8 @@ void ShowBroken(ostream &out,CacheFile &Cache,bool Now) } // Print out each package and the failed dependencies - out << " " << ShowPkg(I) << " :"; - unsigned const Indent = ShowPkg(I).size() + 3; + out << " " << I.FullName(true) << " :"; + unsigned const Indent = I.FullName(true).size() + 3; bool First = true; pkgCache::VerIterator Ver; @@ -323,7 +312,7 @@ void ShowBroken(ostream &out,CacheFile &Cache,bool Now) out << ' ' << End.DepType() << ": "; FirstOr = false; - out << ShowPkg(Start.TargetPkg()); + out << Start.TargetPkg().FullName(true); // Show a quick summary of the version requirements if (Start.TargetVer() != 0) @@ -387,7 +376,7 @@ void ShowNew(ostream &out,CacheFile &Cache) if (Cache[I].NewInstall() == true) { if (Cache[I].CandidateVerIter(Cache).Pseudo() == true) continue; - List += ShowPkg(I) + " "; + List += I.FullName(true) + " "; VersionsList += string(Cache[I].CandVersion) + "\n"; } } @@ -412,9 +401,9 @@ void ShowDel(ostream &out,CacheFile &Cache) if (Cache[I].CandidateVerIter(Cache).Pseudo() == true) continue; if ((Cache[I].iFlags & pkgDepCache::Purge) == pkgDepCache::Purge) - List += ShowPkg(I) + "* "; + List += I.FullName(true) + "* "; else - List += ShowPkg(I) + " "; + List += I.FullName(true) + " "; VersionsList += string(Cache[I].CandVersion)+ "\n"; } @@ -439,7 +428,7 @@ void ShowKept(ostream &out,CacheFile &Cache) I->CurrentVer == 0 || Cache[I].Delete() == true) continue; - List += ShowPkg(I) + " "; + List += I.FullName(true) + " "; VersionsList += string(Cache[I].CurVersion) + " => " + Cache[I].CandVersion + "\n"; } ShowList(out,_("The following packages have been kept back:"),List,VersionsList); @@ -462,7 +451,7 @@ void ShowUpgraded(ostream &out,CacheFile &Cache) if (Cache[I].CandidateVerIter(Cache).Pseudo() == true) continue; - List += ShowPkg(I) + " "; + List += I.FullName(true) + " "; VersionsList += string(Cache[I].CurVersion) + " => " + Cache[I].CandVersion + "\n"; } ShowList(out,_("The following packages will be upgraded:"),List,VersionsList); @@ -485,7 +474,7 @@ bool ShowDowngraded(ostream &out,CacheFile &Cache) if (Cache[I].CandidateVerIter(Cache).Pseudo() == true) continue; - List += ShowPkg(I) + " "; + List += I.FullName(true) + " "; VersionsList += string(Cache[I].CurVersion) + " => " + Cache[I].CandVersion + "\n"; } return ShowList(out,_("The following packages will be DOWNGRADED:"),List,VersionsList); @@ -503,7 +492,7 @@ bool ShowHold(ostream &out,CacheFile &Cache) pkgCache::PkgIterator I(Cache,Cache.List[J]); if (Cache[I].InstallVer != (pkgCache::Version *)I.CurrentVer() && I->SelectedState == pkgCache::State::Hold) { - List += ShowPkg(I) + " "; + List += I.FullName(true) + " "; VersionsList += string(Cache[I].CurVersion) + " => " + Cache[I].CandVersion + "\n"; } } @@ -537,7 +526,7 @@ bool ShowEssential(ostream &out,CacheFile &Cache) if (Added[I->ID] == false) { Added[I->ID] = true; - List += ShowPkg(I) + " "; + List += I.FullName(true) + " "; //VersionsList += string(Cache[I].CurVersion) + "\n"; ??? } } @@ -561,7 +550,7 @@ bool ShowEssential(ostream &out,CacheFile &Cache) Added[P->ID] = true; char S[300]; - snprintf(S,sizeof(S),_("%s (due to %s) "),P.Name(),I.Name()); + snprintf(S,sizeof(S),_("%s (due to %s) "),P.FullName(true).c_str(),I.FullName(true).c_str()); List += S; //VersionsList += "\n"; ??? } @@ -1106,7 +1095,7 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, if (found_one == true) { ioprintf(c1out,_("Note, selecting %s instead of %s\n"), - Prov.Name(),Pkg.Name()); + Prov.FullName(true).c_str(),Pkg.FullName(true).c_str()); Pkg = Prov; } } @@ -1117,7 +1106,7 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, { if (AllowFail == true) ioprintf(c1out,_("Skipping %s, it is already installed and upgrade is not set.\n"), - Pkg.Name()); + Pkg.FullName(true).c_str()); return true; } @@ -1134,7 +1123,7 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, if (AllowFail == false) return false; - ioprintf(c1out,_("Package %s is not installed, so not removed\n"),Pkg.Name()); + ioprintf(c1out,_("Package %s is not installed, so not removed\n"),Pkg.FullName(true).c_str()); return true; } @@ -1146,7 +1135,7 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, if (Pkg->ProvidesList != 0) { ioprintf(c1out,_("Package %s is a virtual package provided by:\n"), - Pkg.Name()); + Pkg.FullName(true).c_str()); pkgCache::PrvIterator I = Pkg.ProvidesList(); for (; I.end() == false; I++) @@ -1156,10 +1145,10 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, if (Cache[Pkg].CandidateVerIter(Cache) == I.OwnerVer()) { if (Cache[Pkg].Install() == true && Cache[Pkg].NewInstall() == false) - c1out << " " << Pkg.Name() << " " << I.OwnerVer().VerStr() << + c1out << " " << Pkg.FullName(true) << " " << I.OwnerVer().VerStr() << _(" [Installed]") << endl; else - c1out << " " << Pkg.Name() << " " << I.OwnerVer().VerStr() << endl; + c1out << " " << Pkg.FullName(true) << " " << I.OwnerVer().VerStr() << endl; } } c1out << _("You should explicitly select one to install.") << endl; @@ -1169,7 +1158,7 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, ioprintf(c1out, _("Package %s is not available, but is referred to by another package.\n" "This may mean that the package is missing, has been obsoleted, or\n" - "is only available from another source\n"),Pkg.Name()); + "is only available from another source\n"),Pkg.FullName(true).c_str()); string List; string VersionsList; @@ -1183,13 +1172,13 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, if (Seen[Dep.ParentPkg()->ID] == true) continue; Seen[Dep.ParentPkg()->ID] = true; - List += string(Dep.ParentPkg().Name()) + " "; + List += Dep.ParentPkg().FullName(true) + " "; //VersionsList += string(Dep.ParentPkg().CurVersion) + "\n"; ??? } ShowList(c1out,_("However the following packages replace it:"),List,VersionsList); } - _error->Error(_("Package %s has no installation candidate"),Pkg.Name()); + _error->Error(_("Package %s has no installation candidate"),Pkg.FullName(true).c_str()); return false; } @@ -1210,7 +1199,7 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, { if (Pkg->CurrentVer == 0 || Pkg.CurrentVer().Downloadable() == false) ioprintf(c1out,_("Reinstallation of %s is not possible, it cannot be downloaded.\n"), - Pkg.Name()); + Pkg.FullName(true).c_str()); else Cache.SetReInstall(Pkg,true); } @@ -1218,7 +1207,7 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, { if (AllowFail == true) ioprintf(c1out,_("%s is already the newest version.\n"), - Pkg.Name()); + Pkg.FullName(true).c_str()); } } else @@ -1247,15 +1236,15 @@ bool TryToChangeVer(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, { if (IsRel == true) return _error->Error(_("Release '%s' for '%s' was not found"), - VerTag,Pkg.Name()); + VerTag,Pkg.FullName(true).c_str()); return _error->Error(_("Version '%s' for '%s' was not found"), - VerTag,Pkg.Name()); + VerTag,Pkg.FullName(true).c_str()); } if (strcmp(VerTag,Ver.VerStr()) != 0) { ioprintf(c1out,_("Selected version %s (%s) for %s\n"), - Ver.VerStr(),Ver.RelStr().c_str(),Pkg.Name()); + Ver.VerStr(),Ver.RelStr().c_str(),Pkg.FullName(true).c_str()); } Cache.SetCandidateVersion(Ver); @@ -1511,7 +1500,7 @@ bool DoAutomaticRemove(CacheFile &Cache) { if(Pkg.CurrentVer() != 0 || Cache[Pkg].Install()) if(Debug) - std::cout << "We could delete %s" << Pkg.Name() << std::endl; + std::cout << "We could delete %s" << Pkg.FullName(true).c_str() << std::endl; if (doAutoRemove) { @@ -1530,7 +1519,7 @@ bool DoAutomaticRemove(CacheFile &Cache) // we don't need to fill the strings if we don't need them if (smallList == false) { - autoremovelist += string(Pkg.Name()) + " "; + autoremovelist += Pkg.FullName(true) + " "; autoremoveversions += string(Cache[Pkg].CandVersion) + "\n"; } } @@ -1804,7 +1793,7 @@ bool DoInstall(CommandLine &CmdL) _config->FindB("APT::Get::Download-Only",false) == false) { ioprintf(c1out,_("%s set to manually installed.\n"), - Pkg.Name()); + Pkg.FullName(true).c_str()); Cache->MarkAuto(Pkg,false); AutoMarkChanged++; } @@ -1873,7 +1862,7 @@ bool DoInstall(CommandLine &CmdL) break; if (*J == 0) { - List += string(I.Name()) + " "; + List += I.FullName(true) + " "; VersionsList += string(Cache[I].CandVersion) + "\n"; } } @@ -1909,7 +1898,7 @@ bool DoInstall(CommandLine &CmdL) for(;;) { /* Skip if package is installed already, or is about to be */ - string target = string(Start.TargetPkg().Name()) + " "; + string target = Start.TargetPkg().FullName(true) + " "; if ((*Start.TargetPkg()).SelectedState == pkgCache::State::Install || Cache[Start.TargetPkg()].Install()) @@ -2559,7 +2548,7 @@ bool DoBuildDep(CommandLine &CmdL) for (; Prv.end() != true; Prv++) { if (_config->FindB("Debug::BuildDeps",false) == true) - cout << " Checking provider " << Prv.OwnerPkg().Name() << endl; + cout << " Checking provider " << Prv.OwnerPkg().FullName() << endl; if ((*Cache)[Prv.OwnerPkg()].InstVerIter(*Cache).end() == false) break; @@ -2600,7 +2589,7 @@ bool DoBuildDep(CommandLine &CmdL) if (Prv.end() == false) { if (_config->FindB("Debug::BuildDeps",false) == true) - cout << " Is provided by installed package " << Prv.OwnerPkg().Name() << endl; + cout << " Is provided by installed package " << Prv.OwnerPkg().FullName() << endl; skipAlternatives = hasAlternatives; continue; } @@ -2625,7 +2614,7 @@ bool DoBuildDep(CommandLine &CmdL) return _error->Error(_("Failed to satisfy %s dependency for %s: Installed package %s is too new"), Last->BuildDepType((*D).Type), Src.c_str(), - Pkg.Name()); + Pkg.FullName(true).c_str()); } } @@ -2674,7 +2663,6 @@ bool DoBuildDep(CommandLine &CmdL) return true; } /*}}}*/ - // DoMoo - Never Ask, Never Tell /*{{{*/ // --------------------------------------------------------------------- /* */ -- cgit v1.2.3 From 6cd9fbd763298816e5d010703ceb9ffad0c235c9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 12 Mar 2010 10:59:37 +0100 Subject: * cmdline/apt-get.cc: - add a --only-upgrade flag to install command (Closes: #572259) That is NOT what is requested in e.g. #74067 - this is a very simple flag which behaves orthogonal to --no-upgrade not a full-blown upgrade option for a single package instead of the whole package set. --- cmdline/apt-get.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 5a814e255..b35e16b92 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1098,7 +1098,17 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, Pkg.Name()); return true; } - + + // Ignore request for install if package would be new + if (_config->FindB("APT::Get::Only-Upgrade", false) == true && + Pkg->CurrentVer == 0) + { + if (AllowFail == true) + ioprintf(c1out,_("Skipping %s, it is not installed and only upgrades are requested.\n"), + Pkg.Name()); + return true; + } + // Check if there is something at all to install pkgDepCache::StateCache &State = Cache[Pkg]; if (Remove == true && Pkg->CurrentVer == 0) @@ -1779,6 +1789,7 @@ bool DoInstall(CommandLine &CmdL) Cache[Pkg].Install() == false && (Cache[Pkg].Flags & pkgCache::Flag::Auto) && _config->FindB("APT::Get::ReInstall",false) == false && + _config->FindB("APT::Get::Only-Upgrade",false) == false && _config->FindB("APT::Get::Download-Only",false) == false) { ioprintf(c1out,_("%s set to manually installed.\n"), @@ -2821,6 +2832,7 @@ int main(int argc,const char *argv[]) /*{{{*/ {0,"fix-missing","APT::Get::Fix-Missing",0}, {0,"ignore-hold","APT::Ignore-Hold",0}, {0,"upgrade","APT::Get::upgrade",0}, + {0,"only-upgrade","APT::Get::Only-Upgrade",0}, {0,"force-yes","APT::Get::force-yes",0}, {0,"print-uris","APT::Get::Print-URIs",0}, {0,"diff-only","APT::Get::Diff-Only",0}, -- cgit v1.2.3 From 3a4477a4241bcfbc9db541cf34cc75c1f1111b78 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 12 Mar 2010 11:08:13 +0100 Subject: * cmdline/apt-get.cc - fix memory leaks in error conditions in DoSource() --- cmdline/apt-get.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index b35e16b92..849401b0c 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2299,6 +2299,7 @@ bool DoSource(CommandLine &CmdL) { for (unsigned I = 0; I != J; I++) ioprintf(cout,_("Fetch source %s\n"),Dsc[I].Package.c_str()); + delete[] Dsc; return true; } @@ -2309,6 +2310,7 @@ bool DoSource(CommandLine &CmdL) for (; I != Fetcher.UriEnd(); I++) cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl; + delete[] Dsc; return true; } @@ -2334,6 +2336,7 @@ bool DoSource(CommandLine &CmdL) if (_config->FindB("APT::Get::Download-only",false) == true) { c1out << _("Download complete and in download only mode") << endl; + delete[] Dsc; return true; } @@ -2395,7 +2398,8 @@ bool DoSource(CommandLine &CmdL) _exit(0); } - + delete[] Dsc; + // Wait for the subprocess int Status = 0; while (waitpid(Process,&Status,0) != Process) -- cgit v1.2.3 From 7a511e5d959f59ec6062a84b3a1ae372ff4f8e86 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 26 Mar 2010 17:25:04 +0100 Subject: * cmdline/apt-get.cc, apt-pkg/cdrom.cc: - fix memory leaks in error conditions in DoSource() --- cmdline/apt-get.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index ea236676b..0bc8fc571 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2315,6 +2315,7 @@ bool DoSource(CommandLine &CmdL) { for (unsigned I = 0; I != J; I++) ioprintf(cout,_("Fetch source %s\n"),Dsc[I].Package.c_str()); + delete[] Dsc; return true; } @@ -2325,6 +2326,7 @@ bool DoSource(CommandLine &CmdL) for (; I != Fetcher.UriEnd(); I++) cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl; + delete[] Dsc; return true; } @@ -2350,6 +2352,7 @@ bool DoSource(CommandLine &CmdL) if (_config->FindB("APT::Get::Download-only",false) == true) { c1out << _("Download complete and in download only mode") << endl; + delete[] Dsc; return true; } @@ -2411,7 +2414,8 @@ bool DoSource(CommandLine &CmdL) _exit(0); } - + delete[] Dsc; + // Wait for the subprocess int Status = 0; while (waitpid(Process,&Status,0) != Process) -- cgit v1.2.3 From e84adb76c87f419ed5bad8f7d08a4132de2bc406 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 30 Mar 2010 17:47:19 +0200 Subject: try version match in FindSrc first exact than fuzzy (LP: #551178) --- cmdline/apt-get.cc | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 7875ae20f..5af2dca04 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1291,12 +1291,26 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, { if(VerTag.empty() == false || DefRel.empty() == false) { + bool fuzzy = false; // we have a default release, try to locate the pkg. we do it like // this because GetCandidateVer() will not "downgrade", that means // "apt-get source -t stable apt" won't work on a unstable system - for (pkgCache::VerIterator Ver = Pkg.VersionList(); - Ver.end() == false; Ver++) + for (pkgCache::VerIterator Ver = Pkg.VersionList();; Ver++) { + // try first only exact matches, later fuzzy matches + if (Ver.end() == true) + { + if (fuzzy == true) + break; + fuzzy = true; + Ver = Pkg.VersionList(); + } + // We match against a concrete version (or a part of this version) + if (VerTag.empty() == false && + (fuzzy == true || Cache.VS().CmpVersion(VerTag, Ver.VerStr()) != 0) && // exact match + (fuzzy == false || strncmp(VerTag.c_str(), Ver.VerStr(), VerTag.size()) != 0)) // fuzzy match + continue; + for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false; VF++) { @@ -1309,10 +1323,6 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, pkgCache::Flag::NotSource && Pkg.CurrentVer() != Ver) continue; - // We match against a concrete version (or a part of this version) - if (VerTag.empty() == false && strncmp(VerTag.c_str(), Ver.VerStr(), VerTag.size()) != 0) - continue; - // or we match against a release if(VerTag.empty() == false || (VF.File().Archive() != 0 && VF.File().Archive() == DefRel) || @@ -1323,10 +1333,9 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, // no SourcePkg name, so it is the "binary" name if (Src.empty() == true) Src = TmpSrc; - // no Version, so we try the Version of the SourcePkg - - // and after that the version of the binary package - if (VerTag.empty() == true) - VerTag = Parse.SourceVer(); + // the Version we have is possibly fuzzy or includes binUploads, + // so we use the Version of the SourcePkg (empty if same as package) + VerTag = Parse.SourceVer(); if (VerTag.empty() == true) VerTag = Ver.VerStr(); break; @@ -1390,7 +1399,8 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, const string Ver = Parse->Version(); // Ignore all versions which doesn't fit - if (VerTag.empty() == false && strncmp(VerTag.c_str(), Ver.c_str(), VerTag.size()) != 0) + if (VerTag.empty() == false && + Cache.VS().CmpVersion(VerTag, Ver) != 0) // exact match continue; // Newer version or an exact match? Save the hit -- cgit v1.2.3 From a4787a959bbed2e16f6017c8e3238ae9cf98bc69 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 31 Mar 2010 22:00:36 +0200 Subject: cherry pick -r 1983..1984 lp:~donkult/apt/sid --- cmdline/apt-get.cc | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 0bc8fc571..5de3fb036 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1270,12 +1270,26 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, { if(VerTag.empty() == false || DefRel.empty() == false) { + bool fuzzy = false; // we have a default release, try to locate the pkg. we do it like // this because GetCandidateVer() will not "downgrade", that means // "apt-get source -t stable apt" won't work on a unstable system - for (pkgCache::VerIterator Ver = Pkg.VersionList(); - Ver.end() == false; Ver++) + for (pkgCache::VerIterator Ver = Pkg.VersionList();; Ver++) { + // try first only exact matches, later fuzzy matches + if (Ver.end() == true) + { + if (fuzzy == true) + break; + fuzzy = true; + Ver = Pkg.VersionList(); + } + // We match against a concrete version (or a part of this version) + if (VerTag.empty() == false && + (fuzzy == true || Cache.VS().CmpVersion(VerTag, Ver.VerStr()) != 0) && // exact match + (fuzzy == false || strncmp(VerTag.c_str(), Ver.VerStr(), VerTag.size()) != 0)) // fuzzy match + continue; + for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false; VF++) { @@ -1288,10 +1302,6 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, pkgCache::Flag::NotSource && Pkg.CurrentVer() != Ver) continue; - // We match against a concrete version (or a part of this version) - if (VerTag.empty() == false && strncmp(VerTag.c_str(), Ver.VerStr(), VerTag.size()) != 0) - continue; - // or we match against a release if(VerTag.empty() == false || (VF.File().Archive() != 0 && VF.File().Archive() == DefRel) || @@ -1302,10 +1312,9 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, // no SourcePkg name, so it is the "binary" name if (Src.empty() == true) Src = TmpSrc; - // no Version, so we try the Version of the SourcePkg - - // and after that the version of the binary package - if (VerTag.empty() == true) - VerTag = Parse.SourceVer(); + // the Version we have is possibly fuzzy or includes binUploads, + // so we use the Version of the SourcePkg (empty if same as package) + VerTag = Parse.SourceVer(); if (VerTag.empty() == true) VerTag = Ver.VerStr(); break; @@ -1371,7 +1380,8 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, const string Ver = Parse->Version(); // Ignore all versions which doesn't fit - if (VerTag.empty() == false && strncmp(VerTag.c_str(), Ver.c_str(), VerTag.size()) != 0) + if (VerTag.empty() == false && + Cache.VS().CmpVersion(VerTag, Ver) != 0) // exact match continue; // Newer version or an exact match? Save the hit -- cgit v1.2.3 From 1cd1c398d18b78f4aa9d882a5de5385f4538e0be Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 7 Apr 2010 16:38:18 +0200 Subject: * apt-pkg/contrib/fileutl.cc: - add a parent-guarded "mkdir -p" as CreateDirectory() * apt-pkg/acquire.{cc,h}: - add a delayed constructor with Setup() for success reporting - check for and create directories in Setup if needed instead of error out unfriendly in the Constructor (Closes: #523920, #525783) - optional handle a lock file in Setup() * cmdline/apt-get.cc: - remove the lock file handling and let Acquire take care of it instead --- cmdline/apt-get.cc | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 62f712c39..416d316da 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -811,20 +811,13 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, pkgRecords Recs(Cache); if (_error->PendingError() == true) return false; - - // Lock the archive directory - FileFd Lock; - if (_config->FindB("Debug::NoLocking",false) == false && - _config->FindB("APT::Get::Print-URIs") == false) - { - Lock.Fd(GetLock(_config->FindDir("Dir::Cache::Archives") + "lock")); - if (_error->PendingError() == true) - return _error->Error(_("Unable to lock the download directory")); - } - + // Create the download object + pkgAcquire Fetcher; AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0)); - pkgAcquire Fetcher(&Stat); + if (Fetcher.Setup(&Stat, _config->FindB("APT::Get::Print-URIs", false) + ? "" : _config->FindDir("Dir::Cache::Archives")) == false) + return false; // Read the source list pkgSourceList List; @@ -1442,15 +1435,6 @@ bool DoUpdate(CommandLine &CmdL) if (List.ReadMainList() == false) return false; - // Lock the list directory - FileFd Lock; - if (_config->FindB("Debug::NoLocking",false) == false) - { - Lock.Fd(GetLock(_config->FindDir("Dir::State::Lists") + "lock")); - if (_error->PendingError() == true) - return _error->Error(_("Unable to lock the list directory")); - } - // Create the progress AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0)); @@ -1458,7 +1442,9 @@ bool DoUpdate(CommandLine &CmdL) if (_config->FindB("APT::Get::Print-URIs") == true) { // get a fetcher - pkgAcquire Fetcher(&Stat); + pkgAcquire Fetcher; + if (Fetcher.Setup(&Stat) == false) + return false; // Populate it with the source selection and get all Indexes // (GetAll=true) @@ -2207,7 +2193,9 @@ bool DoSource(CommandLine &CmdL) // Create the download object AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0)); - pkgAcquire Fetcher(&Stat); + pkgAcquire Fetcher; + if (Fetcher.Setup(&Stat) == false) + return false; DscFile *Dsc = new DscFile[CmdL.FileSize()]; @@ -2464,7 +2452,9 @@ bool DoBuildDep(CommandLine &CmdL) // Create the download object AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0)); - pkgAcquire Fetcher(&Stat); + pkgAcquire Fetcher; + if (Fetcher.Setup(&Stat) == false) + return false; unsigned J = 0; for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++) -- cgit v1.2.3 From 259f688a29728604d7930662e9743619982706ab Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 8 Apr 2010 20:57:01 +0200 Subject: * cmdline/apt-get.cc: - fix crash when pkg.VersionList() is empty --- cmdline/apt-get.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 62f712c39..cd450b27a 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1304,6 +1304,10 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, break; fuzzy = true; Ver = Pkg.VersionList(); + // exit right away from the Pkg.VersionList() loop if we + // don't have any versions + if (Ver.end() == true) + break; } // We match against a concrete version (or a part of this version) if (VerTag.empty() == false && -- cgit v1.2.3 From b1fd12d41f9be5d5f33e4768761ed28f87953082 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 8 Apr 2010 21:14:03 +0200 Subject: * cmdline/apt-get.cc: - fix crash when pkg.VersionList() is empty (LP: #556056) --- cmdline/apt-get.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 5de3fb036..b379dc82f 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1283,6 +1283,10 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, break; fuzzy = true; Ver = Pkg.VersionList(); + // exit right away from the Pkg.VersionList() loop if we + // don't have any versions + if (Ver.end() == true) + break; } // We match against a concrete version (or a part of this version) if (VerTag.empty() == false && -- cgit v1.2.3 From a722b2c5c935768efbdd5b23eed7ce32ccd60908 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 9 Apr 2010 15:38:48 +0200 Subject: * apt-pkg/acquire-item.cc: - Acquire::ForceHash to force method for expected hash - display MD5Sum in --print-uris if not forced to use another method instead of displaying the strongest available (Closes: #576420) --- cmdline/apt-get.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 416d316da..7c42e672d 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -815,8 +815,14 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, // Create the download object pkgAcquire Fetcher; AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0)); - if (Fetcher.Setup(&Stat, _config->FindB("APT::Get::Print-URIs", false) - ? "" : _config->FindDir("Dir::Cache::Archives")) == false) + if (_config->FindB("APT::Get::Print-URIs", false) == true) + { + // force a hashsum for compatibility reasons + _config->CndSet("Acquire::ForceHash", "md5sum"); + if (Fetcher.Setup(&Stat, "") == false) + return false; + } + else if (Fetcher.Setup(&Stat, _config->FindDir("Dir::Cache::Archives")) == false) return false; // Read the source list @@ -1441,6 +1447,9 @@ bool DoUpdate(CommandLine &CmdL) // Just print out the uris an exit if the --print-uris flag was used if (_config->FindB("APT::Get::Print-URIs") == true) { + // force a hashsum for compatibility reasons + _config->CndSet("Acquire::ForceHash", "md5sum"); + // get a fetcher pkgAcquire Fetcher; if (Fetcher.Setup(&Stat) == false) -- cgit v1.2.3 From 3d5a34b22a83eb4bf9b1407e13240b8e2a333d5f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 13 Apr 2010 09:28:57 +0200 Subject: regex for package names executed on Grp- not PkgIterator --- cmdline/apt-get.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 7c42e672d..52cbce945 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1772,11 +1772,14 @@ bool DoInstall(CommandLine &CmdL) // Run over the matches bool Hit = false; - for (Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + for (pkgCache::GrpIterator Grp = Cache->GrpBegin(); Grp.end() == false; ++Grp) { - if (regexec(&Pattern,Pkg.Name(),0,0,0) != 0) + if (regexec(&Pattern,Grp.Name(),0,0,0) != 0) continue; - + Pkg = Grp.FindPkg("native"); + if (unlikely(Pkg.end() == true)) + continue; + ioprintf(c1out,_("Note, selecting %s for regex '%s'\n"), Pkg.Name(),S); -- cgit v1.2.3 From b564740226100331f1aba8a1e35a57e5483361f7 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 21 Apr 2010 13:14:40 +0200 Subject: replace backticks with single quote in broken packages message. Thanks to Jari Aalto for spotting & patching! (Closes: #577168) --- cmdline/apt-get.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 52cbce945..9d67a82f8 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -692,7 +692,7 @@ bool CacheFile::CheckDeps(bool AllowBroken) } else { - c1out << _("You might want to run `apt-get -f install' to correct these.") << endl; + c1out << _("You might want to run 'apt-get -f install' to correct these.") << endl; ShowBroken(c1out,*this,true); return _error->Error(_("Unmet dependencies. Try using -f.")); @@ -1826,7 +1826,7 @@ bool DoInstall(CommandLine &CmdL) packages */ if (BrokenFix == true && Cache->BrokenCount() != 0) { - c1out << _("You might want to run `apt-get -f install' to correct these:") << endl; + 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).")); -- cgit v1.2.3 From 3b796dfc90d6ca9d42077bddd38665b0b93a2266 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 24 Apr 2010 10:49:48 +0200 Subject: show non-candidates as fallback for virtual packages (Closes: #578385) --- cmdline/apt-get.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 9d67a82f8..672f64c68 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1147,20 +1147,27 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, Pkg.FullName(true).c_str()); pkgCache::PrvIterator I = Pkg.ProvidesList(); + unsigned short provider = 0; for (; I.end() == false; I++) { pkgCache::PkgIterator Pkg = I.OwnerPkg(); if (Cache[Pkg].CandidateVerIter(Cache) == I.OwnerVer()) { + c1out << " " << Pkg.FullName(true) << " " << I.OwnerVer().VerStr(); if (Cache[Pkg].Install() == true && Cache[Pkg].NewInstall() == false) - c1out << " " << Pkg.FullName(true) << " " << I.OwnerVer().VerStr() << - _(" [Installed]") << endl; - else - c1out << " " << Pkg.FullName(true) << " " << I.OwnerVer().VerStr() << endl; - } + c1out << _(" [Installed]"); + c1out << endl; + ++provider; + } } - c1out << _("You should explicitly select one to install.") << endl; + // if we found no candidate which provide this package, show non-candidates + if (provider == 0) + for (I = Pkg.ProvidesList(); I.end() == false; I++) + c1out << " " << I.OwnerPkg().FullName(true) << " " << I.OwnerVer().VerStr() + << _(" [Not candidate version]") << endl; + else + c1out << _("You should explicitly select one to install.") << endl; } else { -- cgit v1.2.3 From 08bd372d9dd5e4a56176ec08bf6e7870ecd41b32 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 24 Apr 2010 13:15:33 +0200 Subject: set also "all" to this version for pseudo packages in TryToChangeVer --- cmdline/apt-get.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 672f64c68..b43164c2f 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1264,6 +1264,11 @@ bool TryToChangeVer(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, } Cache.SetCandidateVersion(Ver); + + // Set the all package to the same candidate + if (Ver.Pseudo() == true) + Cache.SetCandidateVersion(Match.Find(Pkg.Group().FindPkg("all"))); + return true; } /*}}}*/ -- cgit v1.2.3 From d63a1458427692a6f98274e76020e0f803408d81 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 4 May 2010 17:52:36 +0200 Subject: cmdline/apt-get.cc: Add apt-get markauto, showauto and unmarkauto commands. --- cmdline/apt-get.cc | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 26c731978..8f9faf158 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2013,6 +2013,60 @@ bool DoInstall(CommandLine &CmdL) return InstallPackages(Cache,false); } + +/* show automatically installed packages. */ +bool DoShowAuto(CommandLine &CmdL) +{ + OpProgress progress; + pkgCacheFile Cache; + if (Cache.Open(progress, false) == false) + return false; + + for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; P++) + if (Cache[P].Flags & pkgCache::Flag::Auto) + ioprintf(c1out,_("%s\n"), P.Name()); + return true; +} + +/* mark packages as automatically/manually installed. */ +bool DoMarkAuto(CommandLine &CmdL) +{ + bool Action = true; + int AutoMarkChanged = 0; + OpTextProgress progress; + CacheFile Cache; + if (Cache.Open() == false) + return false; + + if (strcasecmp(CmdL.FileList[0],"markauto") == 0) + Action = true; + else if (strcasecmp(CmdL.FileList[0],"unmarkauto") == 0) + Action = false; + + for (const char **I = CmdL.FileList + 1; *I != 0; I++) + { + const char *S = *I; + // Locate the package + pkgCache::PkgIterator Pkg = Cache->FindPkg(S); + if (Pkg.end() == true) { + return _error->Error(_("Couldn't find package %s"),S); + } + else + { + if (!Action) + ioprintf(c1out,_("%s set to manually installed.\n"), Pkg.Name()); + else + ioprintf(c1out,_("%s set to automatically installed.\n"), + Pkg.Name()); + + Cache->MarkAuto(Pkg,Action); + AutoMarkChanged++; + } + } + if (AutoMarkChanged && ! _config->FindB("APT::Get::Simulate",false)) + return Cache->writeStateFile(NULL); + return false; +} /*}}}*/ // DoDistUpgrade - Automatic smart upgrader /*{{{*/ // --------------------------------------------------------------------- @@ -2798,6 +2852,9 @@ bool ShowHelp(CommandLine &CmdL) " clean - Erase downloaded archive files\n" " autoclean - Erase old downloaded archive files\n" " check - Verify that there are no broken dependencies\n" + " markauto - Mark the given packages as automatically installed\n" + " unmarkauto - Mark the given packages as manually installed\n" + " showauto - Display a list of automatically installed packages\n" "\n" "Options:\n" " -h This help text.\n" @@ -2904,6 +2961,9 @@ int main(int argc,const char *argv[]) /*{{{*/ {"purge",&DoInstall}, {"autoremove",&DoInstall}, {"purge",&DoInstall}, + {"showauto",&DoShowAuto}, + {"markauto",&DoMarkAuto}, + {"unmarkauto",&DoMarkAuto}, {"dist-upgrade",&DoDistUpgrade}, {"dselect-upgrade",&DoDSelectUpgrade}, {"build-dep",&DoBuildDep}, -- cgit v1.2.3 From 827d04d3b2ed62d4e666698e639af6fbb3199581 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 4 May 2010 19:44:37 +0200 Subject: rerun dpkg-source in source if --fix-broken is given (Closes: #576752) --- cmdline/apt-get.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index b43164c2f..6a3c91a59 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2380,6 +2380,7 @@ bool DoSource(CommandLine &CmdL) if (Process == 0) { + bool const fixBroken = _config->FindB("APT::Get::Fix-Broken", false); for (unsigned I = 0; I != J; I++) { string Dir = Dsc[I].Package + '-' + Cache->VS().UpstreamVersion(Dsc[I].Version.c_str()); @@ -2392,7 +2393,7 @@ bool DoSource(CommandLine &CmdL) // See if the package is already unpacked struct stat Stat; - if (stat(Dir.c_str(),&Stat) == 0 && + if (fixBroken == false && stat(Dir.c_str(),&Stat) == 0 && S_ISDIR(Stat.st_mode) != 0) { ioprintf(c0out ,_("Skipping unpack of already unpacked source in %s\n"), -- cgit v1.2.3 From 6007c1d41d5aae7ae22fee89824175f925b9e680 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 4 May 2010 21:28:24 +0200 Subject: Move the showauto command to apt-cache and sort output. * cmdline/apt-cache.cc: - Add a showauto command to apt-cache. - Add apt-get markauto and unmarkauto commands. --- cmdline/apt-get.cc | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 8f9faf158..03239dabe 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2014,20 +2014,6 @@ bool DoInstall(CommandLine &CmdL) return InstallPackages(Cache,false); } -/* show automatically installed packages. */ -bool DoShowAuto(CommandLine &CmdL) -{ - OpProgress progress; - pkgCacheFile Cache; - if (Cache.Open(progress, false) == false) - return false; - - for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; P++) - if (Cache[P].Flags & pkgCache::Flag::Auto) - ioprintf(c1out,_("%s\n"), P.Name()); - return true; -} - /* mark packages as automatically/manually installed. */ bool DoMarkAuto(CommandLine &CmdL) { @@ -2854,7 +2840,6 @@ bool ShowHelp(CommandLine &CmdL) " check - Verify that there are no broken dependencies\n" " markauto - Mark the given packages as automatically installed\n" " unmarkauto - Mark the given packages as manually installed\n" - " showauto - Display a list of automatically installed packages\n" "\n" "Options:\n" " -h This help text.\n" @@ -2961,7 +2946,6 @@ int main(int argc,const char *argv[]) /*{{{*/ {"purge",&DoInstall}, {"autoremove",&DoInstall}, {"purge",&DoInstall}, - {"showauto",&DoShowAuto}, {"markauto",&DoMarkAuto}, {"unmarkauto",&DoMarkAuto}, {"dist-upgrade",&DoDistUpgrade}, -- cgit v1.2.3 From 2d847a5919828ab26dd3f3c5993497b95df9051b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 6 May 2010 12:31:55 +0200 Subject: don't suggest held packages as they are installed (Closes: #578135) --- cmdline/apt-get.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 6a3c91a59..de8c7aeaf 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1932,9 +1932,10 @@ bool DoInstall(CommandLine &CmdL) { /* Skip if package is installed already, or is about to be */ string target = Start.TargetPkg().FullName(true) + " "; - - if ((*Start.TargetPkg()).SelectedState == pkgCache::State::Install - || Cache[Start.TargetPkg()].Install()) + pkgCache::PkgIterator const TarPkg = Start.TargetPkg(); + if (TarPkg->SelectedState == pkgCache::State::Install || + TarPkg->SelectedState == pkgCache::State::Hold || + Cache[Start.TargetPkg()].Install()) { foundInstalledInOrGroup=true; break; -- cgit v1.2.3 From 8545b536e3459a06fa007e2c307a77188e5de4b1 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 14 May 2010 12:12:23 +0200 Subject: handle multiple --{tar,diff,dsc}-only options correctly --- cmdline/apt-get.cc | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 00da0855f..dd5ef1743 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2271,6 +2271,14 @@ bool DoSource(CommandLine &CmdL) // insert all downloaded uris into this set to avoid downloading them // twice set queued; + + // Diff only mode only fetches .diff files + bool const diffOnly = _config->FindB("APT::Get::Diff-Only", false); + // Tar only mode only fetches .tar files + bool const tarOnly = _config->FindB("APT::Get::Tar-Only", false); + // Dsc only mode only fetches .dsc files + bool const dscOnly = _config->FindB("APT::Get::Dsc-Only", false); + // Load the requestd sources into the fetcher unsigned J = 0; for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++) @@ -2297,21 +2305,17 @@ bool DoSource(CommandLine &CmdL) Dsc[J].Version = Last->Version(); Dsc[J].Dsc = flNotDir(I->Path); } - - // Diff only mode only fetches .diff files - if (_config->FindB("APT::Get::Diff-Only",false) == true && - I->Type != "diff") - continue; - - // Tar only mode only fetches .tar files - if (_config->FindB("APT::Get::Tar-Only",false) == true && - I->Type != "tar") - continue; - // Dsc only mode only fetches .dsc files - if (_config->FindB("APT::Get::Dsc-Only",false) == true && - I->Type != "dsc") - continue; + // Handle the only options so that multiple can be used at once + if (diffOnly == true || tarOnly == true || dscOnly == true) + { + if ((diffOnly == true && I->Type == "diff") || + (tarOnly == true && I->Type == "tar") || + (dscOnly == true && I->Type == "dsc")) + ; // Fine, we want this file downloaded + else + continue; + } // don't download the same uri twice (should this be moved to // the fetcher interface itself?) -- cgit v1.2.3 From 642ebc1a04c9c7915474c57f1143a9389ee6636a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 24 May 2010 20:10:11 +0200 Subject: - show at the end of the install process a list of disappeared packages * apt-pkg/packagemanager.h: - export info about disappeared packages with GetDisappearedPackages() --- cmdline/apt-get.cc | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index dd5ef1743..44235e358 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1044,7 +1044,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, if (Res == pkgPackageManager::Failed || _error->PendingError() == true) return false; if (Res == pkgPackageManager::Completed) - return true; + break; // Reload the fetcher object and loop again for media swapping Fetcher.Shutdown(); @@ -1052,7 +1052,24 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, return false; _system->Lock(); - } + } + + std::set const disappearedPkgs = PM->GetDisappearedPackages(); + if (disappearedPkgs.empty() == true) + return true; + + string disappear; + for (std::set::const_iterator d = disappearedPkgs.begin(); + d != disappearedPkgs.end(); ++d) + disappear.append(*d).append(" "); + + ShowList(c1out, P_("The following package disappeared from your system as\n" + "all files have been overwritten by other packages:", + "The following packages disappeared from your system as\n" + "all files have been overwritten by other packages:", disappearedPkgs.size()), disappear, ""); + c0out << _("Note: This is done automatic and on purpose by dpkg.") << std::endl; + + return true; } /*}}}*/ // TryToInstall - Try to install a single package /*{{{*/ -- cgit v1.2.3 From ffee1c2bed4accfe25b2ac9e9f0ab9a0ebae9b5b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 30 May 2010 23:12:41 +0200 Subject: move regex magic from apt-get to new FromRegEx method --- cmdline/apt-get.cc | 42 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 44235e358..1cffd6730 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -40,7 +40,8 @@ #include #include #include - +#include + #include #include @@ -1780,51 +1781,24 @@ bool DoInstall(CommandLine &CmdL) 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) + APT::PackageSet pkgset = APT::PackageSet::FromRegEx(Cache, S, c1out); + if (pkgset.empty() == true) 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 (pkgCache::GrpIterator Grp = Cache->GrpBegin(); Grp.end() == false; ++Grp) + for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg) { - if (regexec(&Pattern,Grp.Name(),0,0,0) != 0) - continue; - Pkg = Grp.FindPkg("native"); - if (unlikely(Pkg.end() == true)) - continue; - - 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); } -- cgit v1.2.3 From 7959c5eda83bd6d69876942566cf47d74fc76530 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 31 May 2010 21:00:09 +0200 Subject: rename packageset into cacheset while it is not too late --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 1cffd6730..9894747f4 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include -- cgit v1.2.3 From 3a882565a943644dcf7287c9673fb07f617fb851 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 3 Jun 2010 10:48:19 +0200 Subject: * cmdline/apt-get.cc: - use unsigned long long instead of double to store values it gets --- cmdline/apt-get.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 44235e358..661ca6147 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -837,9 +837,9 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, return false; // Display statistics - double FetchBytes = Fetcher.FetchNeeded(); - double FetchPBytes = Fetcher.PartialPresent(); - double DebBytes = Fetcher.TotalNeeded(); + unsigned long long FetchBytes = Fetcher.FetchNeeded(); + unsigned long long FetchPBytes = Fetcher.PartialPresent(); + unsigned long long DebBytes = Fetcher.TotalNeeded(); if (DebBytes != Cache->DebSize()) { c0out << DebBytes << ',' << Cache->DebSize() << endl; @@ -2362,9 +2362,9 @@ bool DoSource(CommandLine &CmdL) } // Display statistics - double FetchBytes = Fetcher.FetchNeeded(); - double FetchPBytes = Fetcher.PartialPresent(); - double DebBytes = Fetcher.TotalNeeded(); + unsigned long long FetchBytes = Fetcher.FetchNeeded(); + unsigned long long FetchPBytes = Fetcher.PartialPresent(); + unsigned long long DebBytes = Fetcher.TotalNeeded(); // Check for enough free space struct statvfs Buf; -- cgit v1.2.3 From ea4b220b1b17b270fc1a05e454439c32589548b7 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 4 Jun 2010 14:51:21 +0200 Subject: Switch away from the now deprecated methods for Cache building --- cmdline/apt-get.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 9894747f4..c70dd56ac 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -91,14 +91,14 @@ class CacheFile : public pkgCacheFile bool BuildCaches(bool WithLock = true) { OpTextProgress Prog(*_config); - if (pkgCacheFile::BuildCaches(Prog,WithLock) == false) + if (pkgCacheFile::BuildCaches(&Prog,WithLock) == false) return false; return true; } bool Open(bool WithLock = true) { OpTextProgress Prog(*_config); - if (pkgCacheFile::Open(Prog,WithLock) == false) + if (pkgCacheFile::Open(&Prog,WithLock) == false) return false; Sort(); -- cgit v1.2.3 From 313678129b6f8ad37216db0b4e7679059ab37e56 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 19 Jun 2010 14:16:40 +0200 Subject: * cmdline/apt-get.cc: - use the cachsets in the install commands --- cmdline/apt-get.cc | 249 ++++++++++------------------------------------------- 1 file changed, 47 insertions(+), 202 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 0ada46c73..c081ca130 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -40,12 +40,12 @@ #include #include #include -#include #include #include #include "acqprogress.h" +#include "cacheset.h" #include #include @@ -1252,41 +1252,6 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, if ((State.InstBroken() == true || State.InstPolicyBroken() == true) && BrokenFix == false) Cache.MarkInstall(Pkg,true); - return true; -} - /*}}}*/ -// TryToChangeVer - Try to change a candidate version /*{{{*/ -// --------------------------------------------------------------------- -/* */ -bool TryToChangeVer(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, - const char *VerTag,bool IsRel) -{ - pkgVersionMatch Match(VerTag,(IsRel == true?pkgVersionMatch::Release : - pkgVersionMatch::Version)); - - pkgCache::VerIterator Ver = Match.Find(Pkg); - - if (Ver.end() == true) - { - if (IsRel == true) - return _error->Error(_("Release '%s' for '%s' was not found"), - VerTag,Pkg.FullName(true).c_str()); - return _error->Error(_("Version '%s' for '%s' was not found"), - VerTag,Pkg.FullName(true).c_str()); - } - - if (strcmp(VerTag,Ver.VerStr()) != 0) - { - ioprintf(c1out,_("Selected version %s (%s) for %s\n"), - Ver.VerStr(),Ver.RelStr().c_str(),Pkg.FullName(true).c_str()); - } - - Cache.SetCandidateVersion(Ver); - - // Set the all package to the same candidate - if (Ver.Pseudo() == true) - Cache.SetCandidateVersion(Match.Find(Pkg.Group().FindPkg("all"))); - return true; } /*}}}*/ @@ -1624,61 +1589,6 @@ bool DoUpgrade(CommandLine &CmdL) return InstallPackages(Cache,true); } /*}}}*/ -// DoInstallTask - Install task from the command line /*{{{*/ -// --------------------------------------------------------------------- -/* Install named task */ -bool TryInstallTask(pkgDepCache &Cache, pkgProblemResolver &Fix, - bool BrokenFix, - unsigned int& ExpectedInst, - const char *taskname, - bool Remove) -{ - const char *start, *end; - pkgCache::PkgIterator Pkg; - char buf[64*1024]; - regex_t Pattern; - - // get the records - pkgRecords Recs(Cache); - - // build regexp for the task - char S[300]; - snprintf(S, sizeof(S), "^Task:.*[, ]%s([, ]|$)", taskname); - if(regcomp(&Pattern,S, REG_EXTENDED | REG_NOSUB | REG_NEWLINE) != 0) - return _error->Error("Failed to compile task regexp"); - - bool found = false; - bool res = true; - - // two runs, first ignore dependencies, second install any missing - for(int IgnoreBroken=1; IgnoreBroken >= 0; IgnoreBroken--) - { - for (Pkg = Cache.PkgBegin(); Pkg.end() == false; Pkg++) - { - pkgCache::VerIterator ver = Cache[Pkg].CandidateVerIter(Cache); - if(ver.end()) - continue; - pkgRecords::Parser &parser = Recs.Lookup(ver.FileList()); - parser.GetRec(start,end); - strncpy(buf, start, end-start); - buf[end-start] = 0x0; - if (regexec(&Pattern,buf,0,0,0) != 0) - continue; - res &= TryToInstall(Pkg,Cache,Fix,Remove,IgnoreBroken,ExpectedInst); - found = true; - } - } - - // now let the problem resolver deal with any issues - Fix.Resolve(true); - - if(!found) - _error->Error(_("Couldn't find task %s"),taskname); - - regfree(&Pattern); - return res; -} - /*}}}*/ // DoInstall - Install packages from the command line /*{{{*/ // --------------------------------------------------------------------- /* Install named packages */ @@ -1696,138 +1606,73 @@ bool DoInstall(CommandLine &CmdL) unsigned int AutoMarkChanged = 0; unsigned int ExpectedInst = 0; - unsigned int Packages = 0; pkgProblemResolver Fix(Cache); - - bool DefRemove = false; + + unsigned short fallback = 0; if (strcasecmp(CmdL.FileList[0],"remove") == 0) - DefRemove = true; + fallback = 1; else if (strcasecmp(CmdL.FileList[0], "purge") == 0) { _config->Set("APT::Get::Purge", true); - DefRemove = true; + fallback = 1; } else if (strcasecmp(CmdL.FileList[0], "autoremove") == 0) { _config->Set("APT::Get::AutomaticRemove", "true"); - DefRemove = true; + fallback = 1; } // new scope for the ActionGroup { + // TODO: Howto get an ExpectedInst count ? pkgDepCache::ActionGroup group(Cache); - for (const char **I = CmdL.FileList + 1; *I != 0; I++) - { - // 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; + std::list mods; + mods.push_back(APT::VersionSet::Modifier(0, "+", + APT::VersionSet::Modifier::POSTFIX, APT::VersionSet::CANDINST)); + mods.push_back(APT::VersionSet::Modifier(1, "-", + APT::VersionSet::Modifier::POSTFIX, APT::VersionSet::INSTCAND)); + std::map verset = APT::VersionSet::GroupedFromCommandLine(Cache, + CmdL.FileList + 1, mods, fallback, c0out); - // this is a task! - if (Length >= 1 && S[Length - 1] == '^') - { - S[--Length] = 0; - // tasks must always be confirmed - ExpectedInst += 1000; - // see if we can install it - TryInstallTask(Cache, Fix, BrokenFix, ExpectedInst, S, Remove); - continue; - } + if (_error->PendingError() == true) + return false; - while (Cache->FindPkg(S).end() == true) + for (APT::VersionSet::const_iterator Ver = verset[0].begin(); + Ver != verset[0].end(); ++Ver) + { + pkgCache::PkgIterator Pkg = Ver.ParentPkg(); + Cache->SetCandidateVersion(Ver); + + if (TryToInstall(Pkg, Cache, Fix, false, 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 (Cache[Pkg].Install() == false && + (Cache[Pkg].Flags & pkgCache::Flag::Auto) && + _config->FindB("APT::Get::ReInstall",false) == false && + _config->FindB("APT::Get::Only-Upgrade",false) == false && + _config->FindB("APT::Get::Download-Only",false) == false) { - // Handle an optional end tag indicating what to do - if (Length >= 1 && S[Length - 1] == '-') - { - Remove = true; - S[--Length] = 0; - continue; - } - - if (Length >= 1 && S[Length - 1] == '+') - { - Remove = false; - S[--Length] = 0; - continue; - } - - char *Slash = strchr(S,'='); - if (Slash != 0) - { - VerIsRel = false; - *Slash = 0; - VerTag = Slash + 1; - } - - Slash = strchr(S,'/'); - if (Slash != 0) - { - VerIsRel = true; - *Slash = 0; - VerTag = Slash + 1; - } - - break; + ioprintf(c1out,_("%s set to manually installed.\n"), + Pkg.FullName(true).c_str()); + Cache->MarkAuto(Pkg,false); + AutoMarkChanged++; } - - // Locate the package - pkgCache::PkgIterator Pkg = Cache->FindPkg(S); - Packages++; - if (Pkg.end() == true) - { - APT::PackageSet pkgset = APT::PackageSet::FromRegEx(Cache, S, c1out); - if (pkgset.empty() == true) - return _error->Error(_("Couldn't find package %s"),S); - - // Regexs must always be confirmed - ExpectedInst += 1000; - - bool Hit = false; - for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg) - { - if (VerTag != 0) - if (TryToChangeVer(Pkg,Cache,VerTag,VerIsRel) == false) - return false; + } - Hit |= TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix, - ExpectedInst,false); - } + for (APT::VersionSet::const_iterator Ver = verset[1].begin(); + Ver != verset[1].end(); ++Ver) + { + pkgCache::PkgIterator Pkg = Ver.ParentPkg(); - 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; - 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) && - _config->FindB("APT::Get::ReInstall",false) == false && - _config->FindB("APT::Get::Only-Upgrade",false) == false && - _config->FindB("APT::Get::Download-Only",false) == false) - { - ioprintf(c1out,_("%s set to manually installed.\n"), - Pkg.FullName(true).c_str()); - Cache->MarkAuto(Pkg,false); - AutoMarkChanged++; - } - } + if (TryToInstall(Pkg, Cache, Fix, true, BrokenFix, ExpectedInst) == false) + return false; } + if (_error->PendingError() == true) + 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 */ -- cgit v1.2.3 From 70e706adf75ed319d931a220ce27db2b981093f5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 22 Jun 2010 18:01:11 +0200 Subject: =?UTF-8?q?Use=20an=20abstract=20helper=20for=20error=20handling?= =?UTF-8?q?=20and=20output=20instead=20of=20doing=20this=20directly=20in?= =?UTF-8?q?=20the=20CacheSets.=20With=20this=20method=20an=20application?= =?UTF-8?q?=20like=20apt-get=20can=20change=20the=20behavior=20of=20the=20?= =?UTF-8?q?CacheSets=20to=20his=20liking.=20It=20can=20for=20example=20eas?= =?UTF-8?q?ily=20keep=20track=20of=20how=20packages=20were=20added=20to=20?= =?UTF-8?q?the=20set:=20by=20names=20or=20with=20regex's=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmdline/apt-get.cc | 79 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 23 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index c081ca130..6a7d7a448 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1079,7 +1079,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, name matching it was split out.. */ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, pkgProblemResolver &Fix,bool Remove,bool BrokenFix, - unsigned int &ExpectedInst,bool AllowFail = true) + bool AllowFail = true) { /* This is a pure virtual package and there is a single available candidate providing it. */ @@ -1244,9 +1244,7 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, Pkg.FullName(true).c_str()); } } - else - ExpectedInst++; - + // Install it with autoinstalling enabled (if we not respect the minial // required deps or the policy) if ((State.InstBroken() == true || State.InstPolicyBroken() == true) && BrokenFix == false) @@ -1589,6 +1587,41 @@ bool DoUpgrade(CommandLine &CmdL) return InstallPackages(Cache,true); } /*}}}*/ +// CacheSetHelperAPTGet - responsible for message telling from the CacheSets/*{{{*/ +class CacheSetHelperAPTGet : public APT::CacheSetHelper { + /** \brief stream message should be printed to */ + std::ostream &out; + /** \brief were things like Task or RegEx used to select packages? */ + bool explicitlyNamed; + +public: + CacheSetHelperAPTGet(std::ostream &out) : APT::CacheSetHelper(true), out(out) { + explicitlyNamed = true; + } + + virtual void showTaskSelection(APT::PackageSet const &pkgset, string const &pattern) { + for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg) + ioprintf(out, _("Note, selecting %s for task '%s'\n"), + Pkg.FullName(true).c_str(), pattern.c_str()); + explicitlyNamed = false; + } + virtual void showRegExSelection(APT::PackageSet const &pkgset, string const &pattern) { + for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg) + ioprintf(out, _("Note, selecting %s for regex '%s'\n"), + Pkg.FullName(true).c_str(), pattern.c_str()); + explicitlyNamed = false; + } + virtual void showSelectedVersion(pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const Ver, + string const &ver, bool const &verIsRel) { + if (ver != Ver.VerStr()) + ioprintf(out, _("Selected version '%s' (%s) for '%s'\n"), + Ver.VerStr(), Ver.RelStr().c_str(), Pkg.FullName(true).c_str()); + } + + inline bool allPkgNamedExplicitly() const { return explicitlyNamed; } + +}; + /*}}}*/ // DoInstall - Install packages from the command line /*{{{*/ // --------------------------------------------------------------------- /* Install named packages */ @@ -1605,7 +1638,6 @@ bool DoInstall(CommandLine &CmdL) BrokenFix = true; unsigned int AutoMarkChanged = 0; - unsigned int ExpectedInst = 0; pkgProblemResolver Fix(Cache); unsigned short fallback = 0; @@ -1621,28 +1653,29 @@ bool DoInstall(CommandLine &CmdL) _config->Set("APT::Get::AutomaticRemove", "true"); fallback = 1; } - // new scope for the ActionGroup - { - // TODO: Howto get an ExpectedInst count ? - pkgDepCache::ActionGroup group(Cache); - std::list mods; - mods.push_back(APT::VersionSet::Modifier(0, "+", + + std::list mods; + mods.push_back(APT::VersionSet::Modifier(0, "+", APT::VersionSet::Modifier::POSTFIX, APT::VersionSet::CANDINST)); - mods.push_back(APT::VersionSet::Modifier(1, "-", + mods.push_back(APT::VersionSet::Modifier(1, "-", APT::VersionSet::Modifier::POSTFIX, APT::VersionSet::INSTCAND)); - std::map verset = APT::VersionSet::GroupedFromCommandLine(Cache, - CmdL.FileList + 1, mods, fallback, c0out); + CacheSetHelperAPTGet helper(c0out); + std::map verset = APT::VersionSet::GroupedFromCommandLine(Cache, + CmdL.FileList + 1, mods, fallback, helper); - if (_error->PendingError() == true) - return false; + if (_error->PendingError() == true) + return false; + // new scope for the ActionGroup + { + pkgDepCache::ActionGroup group(Cache); for (APT::VersionSet::const_iterator Ver = verset[0].begin(); Ver != verset[0].end(); ++Ver) { pkgCache::PkgIterator Pkg = Ver.ParentPkg(); Cache->SetCandidateVersion(Ver); - if (TryToInstall(Pkg, Cache, Fix, false, BrokenFix, ExpectedInst) == false) + if (TryToInstall(Pkg, Cache, Fix, false, BrokenFix) == false) return false; // see if we need to fix the auto-mark flag @@ -1666,7 +1699,7 @@ bool DoInstall(CommandLine &CmdL) { pkgCache::PkgIterator Pkg = Ver.ParentPkg(); - if (TryToInstall(Pkg, Cache, Fix, true, BrokenFix, ExpectedInst) == false) + if (TryToInstall(Pkg, Cache, Fix, true, BrokenFix) == false) return false; } @@ -1719,7 +1752,7 @@ bool DoInstall(CommandLine &CmdL) /* Print out a list of packages that are going to be installed extra to what the user asked */ - if (Cache->InstCount() != ExpectedInst) + if (Cache->InstCount() != verset[0].size()) { string List; string VersionsList; @@ -1845,7 +1878,8 @@ bool DoInstall(CommandLine &CmdL) Cache->writeStateFile(NULL); // See if we need to prompt - if (Cache->InstCount() == ExpectedInst && Cache->DelCount() == 0) + // FIXME: check if really the packages in the set are going to be installed + if (Cache->InstCount() == verset[0].size() && Cache->DelCount() == 0) return InstallPackages(Cache,false,false); return InstallPackages(Cache,false); @@ -2429,7 +2463,6 @@ bool DoBuildDep(CommandLine &CmdL) } // Install the requested packages - unsigned int ExpectedInst = 0; vector ::iterator D; pkgProblemResolver Fix(Cache); bool skipAlternatives = false; // skip remaining alternatives in an or group @@ -2460,7 +2493,7 @@ bool DoBuildDep(CommandLine &CmdL) */ if (IV.end() == false && Cache->VS().CheckDep(IV.VerStr(),(*D).Op,(*D).Version.c_str()) == true) - TryToInstall(Pkg,Cache,Fix,true,false,ExpectedInst); + TryToInstall(Pkg,Cache,Fix,true,false); } else // BuildDep || BuildDepIndep { @@ -2576,7 +2609,7 @@ bool DoBuildDep(CommandLine &CmdL) if (_config->FindB("Debug::BuildDeps",false) == true) cout << " Trying to install " << (*D).Package << endl; - if (TryToInstall(Pkg,Cache,Fix,false,false,ExpectedInst) == true) + if (TryToInstall(Pkg,Cache,Fix,false,false) == true) { // We successfully installed something; skip remaining alternatives skipAlternatives = hasAlternatives; -- cgit v1.2.3 From 65beb5720f82845bf175e0cd80f070da21838827 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 25 Jun 2010 20:11:11 +0200 Subject: print all messages if the application is in an interactive run --- cmdline/apt-get.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 6a7d7a448..605eedb0f 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2920,13 +2920,11 @@ int main(int argc,const char *argv[]) /*{{{*/ CmdL.DispatchArg(Cmds); // Print any errors or warnings found during parsing - if (_error->empty() == false) - { - bool Errors = _error->PendingError(); + bool const Errors = _error->PendingError(); + if (_config->FindI("quiet",0) > 0) _error->DumpErrors(); - return Errors == true?100:0; - } - - return 0; + else + _error->DumpErrors(GlobalError::DEBUG); + return Errors == true ? 100 : 0; } /*}}}*/ -- cgit v1.2.3 From c340d1851242e691e7e0baad18a662d6c7a62bc8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 26 Jun 2010 19:04:20 +0200 Subject: do not override the user set quiet setting even if the target is not a tty --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 605eedb0f..e3477b6db 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2899,7 +2899,7 @@ int main(int argc,const char *argv[]) /*{{{*/ } // Deal with stdout not being a tty - if (!isatty(STDOUT_FILENO) && _config->FindI("quiet",0) < 1) + if (!isatty(STDOUT_FILENO) && _config->FindI("quiet", -1) == -1) _config->Set("quiet","1"); // Setup the output streams -- cgit v1.2.3 From e67c08344dbb9ecd827658d74121fa9b66b28961 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 29 Jun 2010 17:14:45 +0200 Subject: for install, do all installs first and then the removes and vice versa --- cmdline/apt-get.cc | 92 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 38 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index e3477b6db..7ba0e8e5c 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1640,24 +1640,27 @@ bool DoInstall(CommandLine &CmdL) unsigned int AutoMarkChanged = 0; pkgProblemResolver Fix(Cache); - unsigned short fallback = 0; + static const unsigned short MOD_REMOVE = 1; + static const unsigned short MOD_INSTALL = 2; + + unsigned short fallback = MOD_INSTALL; if (strcasecmp(CmdL.FileList[0],"remove") == 0) - fallback = 1; + fallback = MOD_REMOVE; else if (strcasecmp(CmdL.FileList[0], "purge") == 0) { _config->Set("APT::Get::Purge", true); - fallback = 1; + fallback = MOD_REMOVE; } else if (strcasecmp(CmdL.FileList[0], "autoremove") == 0) { _config->Set("APT::Get::AutomaticRemove", "true"); - fallback = 1; + fallback = MOD_REMOVE; } std::list mods; - mods.push_back(APT::VersionSet::Modifier(0, "+", + mods.push_back(APT::VersionSet::Modifier(MOD_INSTALL, "+", APT::VersionSet::Modifier::POSTFIX, APT::VersionSet::CANDINST)); - mods.push_back(APT::VersionSet::Modifier(1, "-", + mods.push_back(APT::VersionSet::Modifier(MOD_REMOVE, "-", APT::VersionSet::Modifier::POSTFIX, APT::VersionSet::INSTCAND)); CacheSetHelperAPTGet helper(c0out); std::map verset = APT::VersionSet::GroupedFromCommandLine(Cache, @@ -1666,41 +1669,54 @@ bool DoInstall(CommandLine &CmdL) if (_error->PendingError() == true) return false; + unsigned short order[] = { 0, 0, 0 }; + if (fallback == MOD_INSTALL) { + order[0] = MOD_INSTALL; + order[1] = MOD_REMOVE; + } else { + order[0] = MOD_REMOVE; + order[1] = MOD_INSTALL; + } + // new scope for the ActionGroup { pkgDepCache::ActionGroup group(Cache); - for (APT::VersionSet::const_iterator Ver = verset[0].begin(); - Ver != verset[0].end(); ++Ver) - { - pkgCache::PkgIterator Pkg = Ver.ParentPkg(); - Cache->SetCandidateVersion(Ver); - - if (TryToInstall(Pkg, Cache, Fix, false, BrokenFix) == 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 (Cache[Pkg].Install() == false && - (Cache[Pkg].Flags & pkgCache::Flag::Auto) && - _config->FindB("APT::Get::ReInstall",false) == false && - _config->FindB("APT::Get::Only-Upgrade",false) == false && - _config->FindB("APT::Get::Download-Only",false) == false) - { - ioprintf(c1out,_("%s set to manually installed.\n"), - Pkg.FullName(true).c_str()); - Cache->MarkAuto(Pkg,false); - AutoMarkChanged++; - } - } - - for (APT::VersionSet::const_iterator Ver = verset[1].begin(); - Ver != verset[1].end(); ++Ver) + for (unsigned short i = 0; order[i] != 0; ++i) { - pkgCache::PkgIterator Pkg = Ver.ParentPkg(); + if (order[i] == MOD_INSTALL) + for (APT::VersionSet::const_iterator Ver = verset[MOD_INSTALL].begin(); + Ver != verset[MOD_INSTALL].end(); ++Ver) + { + pkgCache::PkgIterator Pkg = Ver.ParentPkg(); + Cache->SetCandidateVersion(Ver); + + if (TryToInstall(Pkg, Cache, Fix, false, BrokenFix) == 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 (Cache[Pkg].Install() == false && + (Cache[Pkg].Flags & pkgCache::Flag::Auto) && + _config->FindB("APT::Get::ReInstall",false) == false && + _config->FindB("APT::Get::Only-Upgrade",false) == false && + _config->FindB("APT::Get::Download-Only",false) == false) + { + ioprintf(c1out,_("%s set to manually installed.\n"), + Pkg.FullName(true).c_str()); + Cache->MarkAuto(Pkg,false); + AutoMarkChanged++; + } + } + else if (order[i] == MOD_REMOVE) + for (APT::VersionSet::const_iterator Ver = verset[MOD_REMOVE].begin(); + Ver != verset[MOD_REMOVE].end(); ++Ver) + { + pkgCache::PkgIterator Pkg = Ver.ParentPkg(); - if (TryToInstall(Pkg, Cache, Fix, true, BrokenFix) == false) - return false; + if (TryToInstall(Pkg, Cache, Fix, true, BrokenFix) == false) + return false; + } } if (_error->PendingError() == true) @@ -1752,7 +1768,7 @@ bool DoInstall(CommandLine &CmdL) /* Print out a list of packages that are going to be installed extra to what the user asked */ - if (Cache->InstCount() != verset[0].size()) + if (Cache->InstCount() != verset[MOD_INSTALL].size()) { string List; string VersionsList; @@ -1879,7 +1895,7 @@ bool DoInstall(CommandLine &CmdL) // See if we need to prompt // FIXME: check if really the packages in the set are going to be installed - if (Cache->InstCount() == verset[0].size() && Cache->DelCount() == 0) + if (Cache->InstCount() == verset[MOD_INSTALL].size() && Cache->DelCount() == 0) return InstallPackages(Cache,false,false); return InstallPackages(Cache,false); -- cgit v1.2.3 From cf28bcadb301d00f6534fea97ccf1fde63041e7b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 29 Jun 2010 19:21:35 +0200 Subject: if the package has no installed & candidate but is virtual see if only one package provides it - if it is only one use this package instead --- cmdline/apt-get.cc | 86 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 37 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 7ba0e8e5c..d3ddcbfe8 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1081,41 +1081,6 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, pkgProblemResolver &Fix,bool Remove,bool BrokenFix, bool AllowFail = true) { - /* This is a pure virtual package and there is a single available - candidate providing it. */ - if (Cache[Pkg].CandidateVer == 0 && Pkg->ProvidesList != 0) - { - pkgCache::PkgIterator Prov; - bool found_one = false; - - for (pkgCache::PrvIterator P = Pkg.ProvidesList(); P; P++) - { - pkgCache::VerIterator const PVer = P.OwnerVer(); - pkgCache::PkgIterator const PPkg = PVer.ParentPkg(); - - /* Ignore versions that are not a candidate. */ - if (Cache[PPkg].CandidateVer != PVer) - continue; - - if (found_one == false) - { - Prov = PPkg; - found_one = true; - } - else if (PPkg != Prov) - { - found_one = false; // we found at least two - break; - } - } - - if (found_one == true) - { - ioprintf(c1out,_("Note, selecting %s instead of %s\n"), - Prov.FullName(true).c_str(),Pkg.FullName(true).c_str()); - Pkg = Prov; - } - } // Handle the no-upgrade case if (_config->FindB("APT::Get::upgrade",true) == false && @@ -1601,13 +1566,13 @@ public: virtual void showTaskSelection(APT::PackageSet const &pkgset, string const &pattern) { for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg) - ioprintf(out, _("Note, selecting %s for task '%s'\n"), + ioprintf(out, _("Note, selecting '%s' for task '%s'\n"), Pkg.FullName(true).c_str(), pattern.c_str()); explicitlyNamed = false; } virtual void showRegExSelection(APT::PackageSet const &pkgset, string const &pattern) { for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg) - ioprintf(out, _("Note, selecting %s for regex '%s'\n"), + ioprintf(out, _("Note, selecting '%s' for regex '%s'\n"), Pkg.FullName(true).c_str(), pattern.c_str()); explicitlyNamed = false; } @@ -1618,6 +1583,53 @@ public: Ver.VerStr(), Ver.RelStr().c_str(), Pkg.FullName(true).c_str()); } + virtual APT::VersionSet canNotFindCandInstVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) { + return tryVirtualPackage(Cache, Pkg, APT::VersionSet::CANDINST); + } + + virtual APT::VersionSet canNotFindInstCandVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) { + return tryVirtualPackage(Cache, Pkg, APT::VersionSet::INSTCAND); + } + + APT::VersionSet tryVirtualPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg, + APT::VersionSet::Version const &select) { + /* This is a pure virtual package and there is a single available + candidate providing it. */ + if (unlikely(Cache[Pkg].CandidateVer != 0) || Pkg->ProvidesList == 0) { + if (select == APT::VersionSet::CANDINST) + return APT::CacheSetHelper::canNotFindCandInstVer(Cache, Pkg); + return APT::CacheSetHelper::canNotFindInstCandVer(Cache, Pkg); + } + + pkgCache::PkgIterator Prov; + bool found_one = false; + for (pkgCache::PrvIterator P = Pkg.ProvidesList(); P; ++P) { + pkgCache::VerIterator const PVer = P.OwnerVer(); + pkgCache::PkgIterator const PPkg = PVer.ParentPkg(); + + /* Ignore versions that are not a candidate. */ + if (Cache[PPkg].CandidateVer != PVer) + continue; + + if (found_one == false) { + Prov = PPkg; + found_one = true; + } else if (PPkg != Prov) { + found_one = false; // we found at least two + break; + } + } + + if (found_one == true) { + ioprintf(out, _("Note, selecting '%s' instead of '%s'\n"), + Prov.FullName(true).c_str(), Pkg.FullName(true).c_str()); + return APT::VersionSet::FromPackage(Cache, Prov, select, *this); + } + if (select == APT::VersionSet::CANDINST) + return APT::CacheSetHelper::canNotFindCandInstVer(Cache, Pkg); + return APT::CacheSetHelper::canNotFindInstCandVer(Cache, Pkg); + } + inline bool allPkgNamedExplicitly() const { return explicitlyNamed; } }; -- cgit v1.2.3 From b8ad551295c70a882b629ee94668e8ea527d1a7d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 3 Jul 2010 20:09:17 +0200 Subject: Refactor TryToInstall to look a bit saner by splitting the Remove and the Virtual packages part out of the loop. The function still exists unchanged as TryToInstallBuildDep through for the BuildDep installation method --- cmdline/apt-get.cc | 229 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 177 insertions(+), 52 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index d3ddcbfe8..d17300943 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1073,11 +1073,11 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, return true; } /*}}}*/ -// TryToInstall - Try to install a single package /*{{{*/ +// TryToInstallBuildDep - Try to install a single package /*{{{*/ // --------------------------------------------------------------------- /* This used to be inlined in DoInstall, but with the advent of regex package name matching it was split out.. */ -bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, +bool TryToInstallBuildDep(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, pkgProblemResolver &Fix,bool Remove,bool BrokenFix, bool AllowFail = true) { @@ -1552,6 +1552,93 @@ bool DoUpgrade(CommandLine &CmdL) return InstallPackages(Cache,true); } /*}}}*/ +// TryToInstall - Mark a package for installation /*{{{*/ +struct TryToInstall { + pkgCacheFile* Cache; + pkgProblemResolver* Fix; + bool FixBroken; + unsigned long AutoMarkChanged; + + TryToInstall(pkgCacheFile &Cache, pkgProblemResolver &PM, bool const &FixBroken) : Cache(&Cache), Fix(&PM), + FixBroken(FixBroken), AutoMarkChanged(0) {}; + + void operator() (pkgCache::VerIterator const &Ver) { + pkgCache::PkgIterator Pkg = Ver.ParentPkg(); + Cache->GetDepCache()->SetCandidateVersion(Ver); + pkgDepCache::StateCache &State = (*Cache)[Pkg]; + + // Handle the no-upgrade case + if (_config->FindB("APT::Get::upgrade",true) == false && Pkg->CurrentVer != 0) + ioprintf(c1out,_("Skipping %s, it is already installed and upgrade is not set.\n"), + Pkg.FullName(true).c_str()); + // Ignore request for install if package would be new + else if (_config->FindB("APT::Get::Only-Upgrade", false) == true && Pkg->CurrentVer == 0) + ioprintf(c1out,_("Skipping %s, it is not installed and only upgrades are requested.\n"), + Pkg.FullName(true).c_str()); + else { + Fix->Clear(Pkg); + Fix->Protect(Pkg); + Cache->GetDepCache()->MarkInstall(Pkg,false); + + if (State.Install() == false) { + if (_config->FindB("APT::Get::ReInstall",false) == true) { + if (Pkg->CurrentVer == 0 || Pkg.CurrentVer().Downloadable() == false) + ioprintf(c1out,_("Reinstallation of %s is not possible, it cannot be downloaded.\n"), + Pkg.FullName(true).c_str()); + else + Cache->GetDepCache()->SetReInstall(Pkg, true); + } else + ioprintf(c1out,_("%s is already the newest version.\n"), + Pkg.FullName(true).c_str()); + } + + // Install it with autoinstalling enabled (if we not respect the minial + // required deps or the policy) + if ((State.InstBroken() == true || State.InstPolicyBroken() == true) && FixBroken == false) + Cache->GetDepCache()->MarkInstall(Pkg,true); + } + + // see if we need to fix the auto-mark flag + // e.g. apt-get install foo + // where foo is marked automatic + if (State.Install() == false && + (State.Flags & pkgCache::Flag::Auto) && + _config->FindB("APT::Get::ReInstall",false) == false && + _config->FindB("APT::Get::Only-Upgrade",false) == false && + _config->FindB("APT::Get::Download-Only",false) == false) + { + ioprintf(c1out,_("%s set to manually installed.\n"), + Pkg.FullName(true).c_str()); + Cache->GetDepCache()->MarkAuto(Pkg,false); + AutoMarkChanged++; + } + } +}; + /*}}}*/ +// TryToRemove - Mark a package for removal /*{{{*/ +struct TryToRemove { + pkgCacheFile* Cache; + pkgProblemResolver* Fix; + bool FixBroken; + unsigned long AutoMarkChanged; + + TryToRemove(pkgCacheFile &Cache, pkgProblemResolver &PM) : Cache(&Cache), Fix(&PM) {}; + + void operator() (pkgCache::VerIterator const &Ver) + { + pkgCache::PkgIterator Pkg = Ver.ParentPkg(); + + Fix->Clear(Pkg); + Fix->Protect(Pkg); + Fix->Remove(Pkg); + + if (Pkg->CurrentVer == 0) + ioprintf(c1out,_("Package %s is not installed, so not removed\n"),Pkg.FullName(true).c_str()); + else + Cache->GetDepCache()->MarkDelete(Pkg,_config->FindB("APT::Get::Purge",false)); + } +}; + /*}}}*/ // CacheSetHelperAPTGet - responsible for message telling from the CacheSets/*{{{*/ class CacheSetHelperAPTGet : public APT::CacheSetHelper { /** \brief stream message should be printed to */ @@ -1559,6 +1646,8 @@ class CacheSetHelperAPTGet : public APT::CacheSetHelper { /** \brief were things like Task or RegEx used to select packages? */ bool explicitlyNamed; + APT::PackageSet virtualPkgs; + public: CacheSetHelperAPTGet(std::ostream &out) : APT::CacheSetHelper(true), out(out) { explicitlyNamed = true; @@ -1583,23 +1672,85 @@ public: Ver.VerStr(), Ver.RelStr().c_str(), Pkg.FullName(true).c_str()); } - virtual APT::VersionSet canNotFindCandInstVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) { - return tryVirtualPackage(Cache, Pkg, APT::VersionSet::CANDINST); + void showVirtualPackageErrors(pkgCacheFile &Cache) { + for (APT::PackageSet::const_iterator Pkg = virtualPkgs.begin(); + Pkg != virtualPkgs.end(); ++Pkg) { + if (Pkg->ProvidesList != 0) { + ioprintf(c1out,_("Package %s is a virtual package provided by:\n"), + Pkg.FullName(true).c_str()); + + pkgCache::PrvIterator I = Pkg.ProvidesList(); + unsigned short provider = 0; + for (; I.end() == false; ++I) { + pkgCache::PkgIterator Pkg = I.OwnerPkg(); + + if (Cache[Pkg].CandidateVerIter(Cache) == I.OwnerVer()) { + out << " " << Pkg.FullName(true) << " " << I.OwnerVer().VerStr(); + if (Cache[Pkg].Install() == true && Cache[Pkg].NewInstall() == false) + out << _(" [Installed]"); + out << endl; + ++provider; + } + } + // if we found no candidate which provide this package, show non-candidates + if (provider == 0) + for (I = Pkg.ProvidesList(); I.end() == false; I++) + out << " " << I.OwnerPkg().FullName(true) << " " << I.OwnerVer().VerStr() + << _(" [Not candidate version]") << endl; + else + out << _("You should explicitly select one to install.") << endl; + } else { + ioprintf(out, + _("Package %s is not available, but is referred to by another package.\n" + "This may mean that the package is missing, has been obsoleted, or\n" + "is only available from another source\n"),Pkg.FullName(true).c_str()); + + string List; + string VersionsList; + SPtrArray Seen = new bool[Cache.GetPkgCache()->Head().PackageCount]; + memset(Seen,0,Cache.GetPkgCache()->Head().PackageCount*sizeof(*Seen)); + for (pkgCache::DepIterator Dep = Pkg.RevDependsList(); + Dep.end() == false; Dep++) { + if (Dep->Type != pkgCache::Dep::Replaces) + continue; + if (Seen[Dep.ParentPkg()->ID] == true) + continue; + Seen[Dep.ParentPkg()->ID] = true; + List += Dep.ParentPkg().FullName(true) + " "; + //VersionsList += string(Dep.ParentPkg().CurVersion) + "\n"; ??? + } + ShowList(out,_("However the following packages replace it:"),List,VersionsList); + } + out << std::endl; + } } - virtual APT::VersionSet canNotFindInstCandVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) { - return tryVirtualPackage(Cache, Pkg, APT::VersionSet::INSTCAND); + virtual pkgCache::VerIterator canNotFindCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) { + APT::VersionSet const verset = tryVirtualPackage(Cache, Pkg, APT::VersionSet::CANDIDATE); + if (verset.empty() == false) + return *(verset.begin()); + if (ShowError == true) { + _error->Error(_("Package '%s' has no installation candidate"),Pkg.FullName(true).c_str()); + virtualPkgs.insert(Pkg); + } + return pkgCache::VerIterator(Cache, 0); + } + + virtual pkgCache::VerIterator canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) { + APT::VersionSet const verset = tryVirtualPackage(Cache, Pkg, APT::VersionSet::NEWEST); + if (verset.empty() == false) + return *(verset.begin()); + if (ShowError == true) + ioprintf(out, _("Virtual packages like '%s' can't be removed\n"), Pkg.FullName(true).c_str()); + return pkgCache::VerIterator(Cache, 0); } APT::VersionSet tryVirtualPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg, APT::VersionSet::Version const &select) { /* This is a pure virtual package and there is a single available candidate providing it. */ - if (unlikely(Cache[Pkg].CandidateVer != 0) || Pkg->ProvidesList == 0) { - if (select == APT::VersionSet::CANDINST) - return APT::CacheSetHelper::canNotFindCandInstVer(Cache, Pkg); - return APT::CacheSetHelper::canNotFindInstCandVer(Cache, Pkg); - } + if (unlikely(Cache[Pkg].CandidateVer != 0) || Pkg->ProvidesList == 0) + return APT::VersionSet(); pkgCache::PkgIterator Prov; bool found_one = false; @@ -1625,9 +1776,7 @@ public: Prov.FullName(true).c_str(), Pkg.FullName(true).c_str()); return APT::VersionSet::FromPackage(Cache, Prov, select, *this); } - if (select == APT::VersionSet::CANDINST) - return APT::CacheSetHelper::canNotFindCandInstVer(Cache, Pkg); - return APT::CacheSetHelper::canNotFindInstCandVer(Cache, Pkg); + return APT::VersionSet(); } inline bool allPkgNamedExplicitly() const { return explicitlyNamed; } @@ -1649,7 +1798,6 @@ bool DoInstall(CommandLine &CmdL) if (Cache->BrokenCount() != 0) BrokenFix = true; - unsigned int AutoMarkChanged = 0; pkgProblemResolver Fix(Cache); static const unsigned short MOD_REMOVE = 1; @@ -1671,15 +1819,18 @@ bool DoInstall(CommandLine &CmdL) std::list mods; mods.push_back(APT::VersionSet::Modifier(MOD_INSTALL, "+", - APT::VersionSet::Modifier::POSTFIX, APT::VersionSet::CANDINST)); + APT::VersionSet::Modifier::POSTFIX, APT::VersionSet::CANDIDATE)); mods.push_back(APT::VersionSet::Modifier(MOD_REMOVE, "-", - APT::VersionSet::Modifier::POSTFIX, APT::VersionSet::INSTCAND)); + APT::VersionSet::Modifier::POSTFIX, APT::VersionSet::NEWEST)); CacheSetHelperAPTGet helper(c0out); std::map verset = APT::VersionSet::GroupedFromCommandLine(Cache, CmdL.FileList + 1, mods, fallback, helper); if (_error->PendingError() == true) + { + helper.showVirtualPackageErrors(Cache); return false; + } unsigned short order[] = { 0, 0, 0 }; if (fallback == MOD_INSTALL) { @@ -1690,45 +1841,19 @@ bool DoInstall(CommandLine &CmdL) order[1] = MOD_INSTALL; } + TryToInstall InstallAction(Cache, Fix, BrokenFix); + TryToRemove RemoveAction(Cache, Fix); + // new scope for the ActionGroup { pkgDepCache::ActionGroup group(Cache); + for (unsigned short i = 0; order[i] != 0; ++i) { if (order[i] == MOD_INSTALL) - for (APT::VersionSet::const_iterator Ver = verset[MOD_INSTALL].begin(); - Ver != verset[MOD_INSTALL].end(); ++Ver) - { - pkgCache::PkgIterator Pkg = Ver.ParentPkg(); - Cache->SetCandidateVersion(Ver); - - if (TryToInstall(Pkg, Cache, Fix, false, BrokenFix) == 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 (Cache[Pkg].Install() == false && - (Cache[Pkg].Flags & pkgCache::Flag::Auto) && - _config->FindB("APT::Get::ReInstall",false) == false && - _config->FindB("APT::Get::Only-Upgrade",false) == false && - _config->FindB("APT::Get::Download-Only",false) == false) - { - ioprintf(c1out,_("%s set to manually installed.\n"), - Pkg.FullName(true).c_str()); - Cache->MarkAuto(Pkg,false); - AutoMarkChanged++; - } - } + InstallAction = std::for_each(verset[MOD_INSTALL].begin(), verset[MOD_INSTALL].end(), InstallAction); else if (order[i] == MOD_REMOVE) - for (APT::VersionSet::const_iterator Ver = verset[MOD_REMOVE].begin(); - Ver != verset[MOD_REMOVE].end(); ++Ver) - { - pkgCache::PkgIterator Pkg = Ver.ParentPkg(); - - if (TryToInstall(Pkg, Cache, Fix, true, BrokenFix) == false) - return false; - } + RemoveAction = std::for_each(verset[MOD_REMOVE].begin(), verset[MOD_REMOVE].end(), RemoveAction); } if (_error->PendingError() == true) @@ -1899,7 +2024,7 @@ 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 && + if (InstallAction.AutoMarkChanged > 0 && Cache->DelCount() == 0 && Cache->InstCount() == 0 && Cache->BadCount() == 0 && _config->FindB("APT::Get::Simulate",false) == false) @@ -2521,7 +2646,7 @@ bool DoBuildDep(CommandLine &CmdL) */ if (IV.end() == false && Cache->VS().CheckDep(IV.VerStr(),(*D).Op,(*D).Version.c_str()) == true) - TryToInstall(Pkg,Cache,Fix,true,false); + TryToInstallBuildDep(Pkg,Cache,Fix,true,false); } else // BuildDep || BuildDepIndep { @@ -2637,7 +2762,7 @@ bool DoBuildDep(CommandLine &CmdL) if (_config->FindB("Debug::BuildDeps",false) == true) cout << " Trying to install " << (*D).Package << endl; - if (TryToInstall(Pkg,Cache,Fix,false,false) == true) + if (TryToInstallBuildDep(Pkg,Cache,Fix,false,false) == true) { // We successfully installed something; skip remaining alternatives skipAlternatives = hasAlternatives; -- cgit v1.2.3 From 21d4c9f192b5af9c8edb39356712aac853881348 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 3 Jul 2010 23:55:12 +0200 Subject: reorder classes a bit and make TryToInstallBuildDep use them --- cmdline/apt-get.cc | 610 ++++++++++++++++++++++------------------------------- 1 file changed, 250 insertions(+), 360 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index d17300943..38b93e7e5 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -609,6 +609,240 @@ void Stats(ostream &out,pkgDepCache &Dep) Dep.BadCount()); } /*}}}*/ +// CacheSetHelperAPTGet - responsible for message telling from the CacheSets/*{{{*/ +class CacheSetHelperAPTGet : public APT::CacheSetHelper { + /** \brief stream message should be printed to */ + std::ostream &out; + /** \brief were things like Task or RegEx used to select packages? */ + bool explicitlyNamed; + + APT::PackageSet virtualPkgs; + +public: + CacheSetHelperAPTGet(std::ostream &out) : APT::CacheSetHelper(true), out(out) { + explicitlyNamed = true; + } + + virtual void showTaskSelection(APT::PackageSet const &pkgset, string const &pattern) { + for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg) + ioprintf(out, _("Note, selecting '%s' for task '%s'\n"), + Pkg.FullName(true).c_str(), pattern.c_str()); + explicitlyNamed = false; + } + virtual void showRegExSelection(APT::PackageSet const &pkgset, string const &pattern) { + for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg) + ioprintf(out, _("Note, selecting '%s' for regex '%s'\n"), + Pkg.FullName(true).c_str(), pattern.c_str()); + explicitlyNamed = false; + } + virtual void showSelectedVersion(pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const Ver, + string const &ver, bool const &verIsRel) { + if (ver != Ver.VerStr()) + ioprintf(out, _("Selected version '%s' (%s) for '%s'\n"), + Ver.VerStr(), Ver.RelStr().c_str(), Pkg.FullName(true).c_str()); + } + + bool showVirtualPackageErrors(pkgCacheFile &Cache) { + if (virtualPkgs.empty() == true) + return true; + for (APT::PackageSet::const_iterator Pkg = virtualPkgs.begin(); + Pkg != virtualPkgs.end(); ++Pkg) { + if (Pkg->ProvidesList != 0) { + ioprintf(c1out,_("Package %s is a virtual package provided by:\n"), + Pkg.FullName(true).c_str()); + + pkgCache::PrvIterator I = Pkg.ProvidesList(); + unsigned short provider = 0; + for (; I.end() == false; ++I) { + pkgCache::PkgIterator Pkg = I.OwnerPkg(); + + if (Cache[Pkg].CandidateVerIter(Cache) == I.OwnerVer()) { + out << " " << Pkg.FullName(true) << " " << I.OwnerVer().VerStr(); + if (Cache[Pkg].Install() == true && Cache[Pkg].NewInstall() == false) + out << _(" [Installed]"); + out << endl; + ++provider; + } + } + // if we found no candidate which provide this package, show non-candidates + if (provider == 0) + for (I = Pkg.ProvidesList(); I.end() == false; I++) + out << " " << I.OwnerPkg().FullName(true) << " " << I.OwnerVer().VerStr() + << _(" [Not candidate version]") << endl; + else + out << _("You should explicitly select one to install.") << endl; + } else { + ioprintf(out, + _("Package %s is not available, but is referred to by another package.\n" + "This may mean that the package is missing, has been obsoleted, or\n" + "is only available from another source\n"),Pkg.FullName(true).c_str()); + + string List; + string VersionsList; + SPtrArray Seen = new bool[Cache.GetPkgCache()->Head().PackageCount]; + memset(Seen,0,Cache.GetPkgCache()->Head().PackageCount*sizeof(*Seen)); + for (pkgCache::DepIterator Dep = Pkg.RevDependsList(); + Dep.end() == false; Dep++) { + if (Dep->Type != pkgCache::Dep::Replaces) + continue; + if (Seen[Dep.ParentPkg()->ID] == true) + continue; + Seen[Dep.ParentPkg()->ID] = true; + List += Dep.ParentPkg().FullName(true) + " "; + //VersionsList += string(Dep.ParentPkg().CurVersion) + "\n"; ??? + } + ShowList(out,_("However the following packages replace it:"),List,VersionsList); + } + out << std::endl; + } + return false; + } + + virtual pkgCache::VerIterator canNotFindCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) { + APT::VersionSet const verset = tryVirtualPackage(Cache, Pkg, APT::VersionSet::CANDIDATE); + if (verset.empty() == false) + return *(verset.begin()); + if (ShowError == true) { + _error->Error(_("Package '%s' has no installation candidate"),Pkg.FullName(true).c_str()); + virtualPkgs.insert(Pkg); + } + return pkgCache::VerIterator(Cache, 0); + } + + virtual pkgCache::VerIterator canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) { + APT::VersionSet const verset = tryVirtualPackage(Cache, Pkg, APT::VersionSet::NEWEST); + if (verset.empty() == false) + return *(verset.begin()); + if (ShowError == true) + ioprintf(out, _("Virtual packages like '%s' can't be removed\n"), Pkg.FullName(true).c_str()); + return pkgCache::VerIterator(Cache, 0); + } + + APT::VersionSet tryVirtualPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg, + APT::VersionSet::Version const &select) { + /* This is a pure virtual package and there is a single available + candidate providing it. */ + if (unlikely(Cache[Pkg].CandidateVer != 0) || Pkg->ProvidesList == 0) + return APT::VersionSet(); + + pkgCache::PkgIterator Prov; + bool found_one = false; + for (pkgCache::PrvIterator P = Pkg.ProvidesList(); P; ++P) { + pkgCache::VerIterator const PVer = P.OwnerVer(); + pkgCache::PkgIterator const PPkg = PVer.ParentPkg(); + + /* Ignore versions that are not a candidate. */ + if (Cache[PPkg].CandidateVer != PVer) + continue; + + if (found_one == false) { + Prov = PPkg; + found_one = true; + } else if (PPkg != Prov) { + found_one = false; // we found at least two + break; + } + } + + if (found_one == true) { + ioprintf(out, _("Note, selecting '%s' instead of '%s'\n"), + Prov.FullName(true).c_str(), Pkg.FullName(true).c_str()); + return APT::VersionSet::FromPackage(Cache, Prov, select, *this); + } + return APT::VersionSet(); + } + + inline bool allPkgNamedExplicitly() const { return explicitlyNamed; } + +}; + /*}}}*/ +// TryToInstall - Mark a package for installation /*{{{*/ +struct TryToInstall { + pkgCacheFile* Cache; + pkgProblemResolver* Fix; + bool FixBroken; + unsigned long AutoMarkChanged; + + TryToInstall(pkgCacheFile &Cache, pkgProblemResolver &PM, bool const &FixBroken) : Cache(&Cache), Fix(&PM), + FixBroken(FixBroken), AutoMarkChanged(0) {}; + + void operator() (pkgCache::VerIterator const &Ver) { + pkgCache::PkgIterator Pkg = Ver.ParentPkg(); + Cache->GetDepCache()->SetCandidateVersion(Ver); + pkgDepCache::StateCache &State = (*Cache)[Pkg]; + + // Handle the no-upgrade case + if (_config->FindB("APT::Get::upgrade",true) == false && Pkg->CurrentVer != 0) + ioprintf(c1out,_("Skipping %s, it is already installed and upgrade is not set.\n"), + Pkg.FullName(true).c_str()); + // Ignore request for install if package would be new + else if (_config->FindB("APT::Get::Only-Upgrade", false) == true && Pkg->CurrentVer == 0) + ioprintf(c1out,_("Skipping %s, it is not installed and only upgrades are requested.\n"), + Pkg.FullName(true).c_str()); + else { + Fix->Clear(Pkg); + Fix->Protect(Pkg); + Cache->GetDepCache()->MarkInstall(Pkg,false); + + if (State.Install() == false) { + if (_config->FindB("APT::Get::ReInstall",false) == true) { + if (Pkg->CurrentVer == 0 || Pkg.CurrentVer().Downloadable() == false) + ioprintf(c1out,_("Reinstallation of %s is not possible, it cannot be downloaded.\n"), + Pkg.FullName(true).c_str()); + else + Cache->GetDepCache()->SetReInstall(Pkg, true); + } else + ioprintf(c1out,_("%s is already the newest version.\n"), + Pkg.FullName(true).c_str()); + } + + // Install it with autoinstalling enabled (if we not respect the minial + // required deps or the policy) + if ((State.InstBroken() == true || State.InstPolicyBroken() == true) && FixBroken == false) + Cache->GetDepCache()->MarkInstall(Pkg,true); + } + + // see if we need to fix the auto-mark flag + // e.g. apt-get install foo + // where foo is marked automatic + if (State.Install() == false && + (State.Flags & pkgCache::Flag::Auto) && + _config->FindB("APT::Get::ReInstall",false) == false && + _config->FindB("APT::Get::Only-Upgrade",false) == false && + _config->FindB("APT::Get::Download-Only",false) == false) + { + ioprintf(c1out,_("%s set to manually installed.\n"), + Pkg.FullName(true).c_str()); + Cache->GetDepCache()->MarkAuto(Pkg,false); + AutoMarkChanged++; + } + } +}; + /*}}}*/ +// TryToRemove - Mark a package for removal /*{{{*/ +struct TryToRemove { + pkgCacheFile* Cache; + pkgProblemResolver* Fix; + bool FixBroken; + unsigned long AutoMarkChanged; + + TryToRemove(pkgCacheFile &Cache, pkgProblemResolver &PM) : Cache(&Cache), Fix(&PM) {}; + + void operator() (pkgCache::VerIterator const &Ver) + { + pkgCache::PkgIterator Pkg = Ver.ParentPkg(); + + Fix->Clear(Pkg); + Fix->Protect(Pkg); + Fix->Remove(Pkg); + + if (Pkg->CurrentVer == 0) + ioprintf(c1out,_("Package %s is not installed, so not removed\n"),Pkg.FullName(true).c_str()); + else + Cache->GetDepCache()->MarkDelete(Pkg,_config->FindB("APT::Get::Purge",false)); + } +}; + /*}}}*/ // CacheFile::NameComp - QSort compare by name /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -1077,143 +1311,30 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, // --------------------------------------------------------------------- /* This used to be inlined in DoInstall, but with the advent of regex package name matching it was split out.. */ -bool TryToInstallBuildDep(pkgCache::PkgIterator Pkg,pkgDepCache &Cache, +bool TryToInstallBuildDep(pkgCache::PkgIterator Pkg,pkgCacheFile &Cache, pkgProblemResolver &Fix,bool Remove,bool BrokenFix, bool AllowFail = true) { - - // Handle the no-upgrade case - if (_config->FindB("APT::Get::upgrade",true) == false && - Pkg->CurrentVer != 0) - { - if (AllowFail == true) - ioprintf(c1out,_("Skipping %s, it is already installed and upgrade is not set.\n"), - Pkg.FullName(true).c_str()); - return true; - } - - // Ignore request for install if package would be new - if (_config->FindB("APT::Get::Only-Upgrade", false) == true && - Pkg->CurrentVer == 0) - { - if (AllowFail == true) - ioprintf(c1out,_("Skipping %s, it is not installed and only upgrades are requested.\n"), - Pkg.Name()); - return true; - } - - // Check if there is something at all to install - pkgDepCache::StateCache &State = Cache[Pkg]; - if (Remove == true && Pkg->CurrentVer == 0) - { - Fix.Clear(Pkg); - Fix.Protect(Pkg); - Fix.Remove(Pkg); - - /* We want to continue searching for regex hits, so we return false here - otherwise this is not really an error. */ - if (AllowFail == false) - return false; - - ioprintf(c1out,_("Package %s is not installed, so not removed\n"),Pkg.FullName(true).c_str()); - return true; - } - - if (State.CandidateVer == 0 && Remove == false) + if (Cache[Pkg].CandidateVer == 0 && Pkg->ProvidesList != 0) { - if (AllowFail == false) - return false; - - if (Pkg->ProvidesList != 0) - { - ioprintf(c1out,_("Package %s is a virtual package provided by:\n"), - Pkg.FullName(true).c_str()); - - pkgCache::PrvIterator I = Pkg.ProvidesList(); - unsigned short provider = 0; - for (; I.end() == false; I++) - { - pkgCache::PkgIterator Pkg = I.OwnerPkg(); - - if (Cache[Pkg].CandidateVerIter(Cache) == I.OwnerVer()) - { - c1out << " " << Pkg.FullName(true) << " " << I.OwnerVer().VerStr(); - if (Cache[Pkg].Install() == true && Cache[Pkg].NewInstall() == false) - c1out << _(" [Installed]"); - c1out << endl; - ++provider; - } - } - // if we found no candidate which provide this package, show non-candidates - if (provider == 0) - for (I = Pkg.ProvidesList(); I.end() == false; I++) - c1out << " " << I.OwnerPkg().FullName(true) << " " << I.OwnerVer().VerStr() - << _(" [Not candidate version]") << endl; - else - c1out << _("You should explicitly select one to install.") << endl; - } - else - { - ioprintf(c1out, - _("Package %s is not available, but is referred to by another package.\n" - "This may mean that the package is missing, has been obsoleted, or\n" - "is only available from another source\n"),Pkg.FullName(true).c_str()); - - string List; - string VersionsList; - SPtrArray Seen = new bool[Cache.Head().PackageCount]; - memset(Seen,0,Cache.Head().PackageCount*sizeof(*Seen)); - pkgCache::DepIterator Dep = Pkg.RevDependsList(); - for (; Dep.end() == false; Dep++) - { - if (Dep->Type != pkgCache::Dep::Replaces) - continue; - if (Seen[Dep.ParentPkg()->ID] == true) - continue; - Seen[Dep.ParentPkg()->ID] = true; - List += Dep.ParentPkg().FullName(true) + " "; - //VersionsList += string(Dep.ParentPkg().CurVersion) + "\n"; ??? - } - ShowList(c1out,_("However the following packages replace it:"),List,VersionsList); - } - - _error->Error(_("Package %s has no installation candidate"),Pkg.FullName(true).c_str()); - return false; + CacheSetHelperAPTGet helper(c1out); + helper.showErrors(AllowFail == false); + pkgCache::VerIterator Ver = helper.canNotFindNewestVer(Cache, Pkg); + if (Ver.end() == false) + Pkg = Ver.ParentPkg(); + else if (helper.showVirtualPackageErrors(Cache) == false) + return AllowFail; } - Fix.Clear(Pkg); - Fix.Protect(Pkg); if (Remove == true) { - Fix.Remove(Pkg); - Cache.MarkDelete(Pkg,_config->FindB("APT::Get::Purge",false)); - return true; - } - - // Install it - Cache.MarkInstall(Pkg,false); - if (State.Install() == false) - { - if (_config->FindB("APT::Get::ReInstall",false) == true) - { - if (Pkg->CurrentVer == 0 || Pkg.CurrentVer().Downloadable() == false) - ioprintf(c1out,_("Reinstallation of %s is not possible, it cannot be downloaded.\n"), - Pkg.FullName(true).c_str()); - else - Cache.SetReInstall(Pkg,true); - } - else - { - if (AllowFail == true) - ioprintf(c1out,_("%s is already the newest version.\n"), - Pkg.FullName(true).c_str()); - } - } - - // Install it with autoinstalling enabled (if we not respect the minial - // required deps or the policy) - if ((State.InstBroken() == true || State.InstPolicyBroken() == true) && BrokenFix == false) - Cache.MarkInstall(Pkg,true); + TryToRemove RemoveAction(Cache, Fix); + RemoveAction(Pkg.VersionList()); + } else if (Cache[Pkg].CandidateVer != 0) { + TryToInstall InstallAction(Cache, Fix, BrokenFix); + InstallAction(Cache[Pkg].CandidateVerIter(Cache)); + } else + return AllowFail; return true; } @@ -1552,237 +1673,6 @@ bool DoUpgrade(CommandLine &CmdL) return InstallPackages(Cache,true); } /*}}}*/ -// TryToInstall - Mark a package for installation /*{{{*/ -struct TryToInstall { - pkgCacheFile* Cache; - pkgProblemResolver* Fix; - bool FixBroken; - unsigned long AutoMarkChanged; - - TryToInstall(pkgCacheFile &Cache, pkgProblemResolver &PM, bool const &FixBroken) : Cache(&Cache), Fix(&PM), - FixBroken(FixBroken), AutoMarkChanged(0) {}; - - void operator() (pkgCache::VerIterator const &Ver) { - pkgCache::PkgIterator Pkg = Ver.ParentPkg(); - Cache->GetDepCache()->SetCandidateVersion(Ver); - pkgDepCache::StateCache &State = (*Cache)[Pkg]; - - // Handle the no-upgrade case - if (_config->FindB("APT::Get::upgrade",true) == false && Pkg->CurrentVer != 0) - ioprintf(c1out,_("Skipping %s, it is already installed and upgrade is not set.\n"), - Pkg.FullName(true).c_str()); - // Ignore request for install if package would be new - else if (_config->FindB("APT::Get::Only-Upgrade", false) == true && Pkg->CurrentVer == 0) - ioprintf(c1out,_("Skipping %s, it is not installed and only upgrades are requested.\n"), - Pkg.FullName(true).c_str()); - else { - Fix->Clear(Pkg); - Fix->Protect(Pkg); - Cache->GetDepCache()->MarkInstall(Pkg,false); - - if (State.Install() == false) { - if (_config->FindB("APT::Get::ReInstall",false) == true) { - if (Pkg->CurrentVer == 0 || Pkg.CurrentVer().Downloadable() == false) - ioprintf(c1out,_("Reinstallation of %s is not possible, it cannot be downloaded.\n"), - Pkg.FullName(true).c_str()); - else - Cache->GetDepCache()->SetReInstall(Pkg, true); - } else - ioprintf(c1out,_("%s is already the newest version.\n"), - Pkg.FullName(true).c_str()); - } - - // Install it with autoinstalling enabled (if we not respect the minial - // required deps or the policy) - if ((State.InstBroken() == true || State.InstPolicyBroken() == true) && FixBroken == false) - Cache->GetDepCache()->MarkInstall(Pkg,true); - } - - // see if we need to fix the auto-mark flag - // e.g. apt-get install foo - // where foo is marked automatic - if (State.Install() == false && - (State.Flags & pkgCache::Flag::Auto) && - _config->FindB("APT::Get::ReInstall",false) == false && - _config->FindB("APT::Get::Only-Upgrade",false) == false && - _config->FindB("APT::Get::Download-Only",false) == false) - { - ioprintf(c1out,_("%s set to manually installed.\n"), - Pkg.FullName(true).c_str()); - Cache->GetDepCache()->MarkAuto(Pkg,false); - AutoMarkChanged++; - } - } -}; - /*}}}*/ -// TryToRemove - Mark a package for removal /*{{{*/ -struct TryToRemove { - pkgCacheFile* Cache; - pkgProblemResolver* Fix; - bool FixBroken; - unsigned long AutoMarkChanged; - - TryToRemove(pkgCacheFile &Cache, pkgProblemResolver &PM) : Cache(&Cache), Fix(&PM) {}; - - void operator() (pkgCache::VerIterator const &Ver) - { - pkgCache::PkgIterator Pkg = Ver.ParentPkg(); - - Fix->Clear(Pkg); - Fix->Protect(Pkg); - Fix->Remove(Pkg); - - if (Pkg->CurrentVer == 0) - ioprintf(c1out,_("Package %s is not installed, so not removed\n"),Pkg.FullName(true).c_str()); - else - Cache->GetDepCache()->MarkDelete(Pkg,_config->FindB("APT::Get::Purge",false)); - } -}; - /*}}}*/ -// CacheSetHelperAPTGet - responsible for message telling from the CacheSets/*{{{*/ -class CacheSetHelperAPTGet : public APT::CacheSetHelper { - /** \brief stream message should be printed to */ - std::ostream &out; - /** \brief were things like Task or RegEx used to select packages? */ - bool explicitlyNamed; - - APT::PackageSet virtualPkgs; - -public: - CacheSetHelperAPTGet(std::ostream &out) : APT::CacheSetHelper(true), out(out) { - explicitlyNamed = true; - } - - virtual void showTaskSelection(APT::PackageSet const &pkgset, string const &pattern) { - for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg) - ioprintf(out, _("Note, selecting '%s' for task '%s'\n"), - Pkg.FullName(true).c_str(), pattern.c_str()); - explicitlyNamed = false; - } - virtual void showRegExSelection(APT::PackageSet const &pkgset, string const &pattern) { - for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg) - ioprintf(out, _("Note, selecting '%s' for regex '%s'\n"), - Pkg.FullName(true).c_str(), pattern.c_str()); - explicitlyNamed = false; - } - virtual void showSelectedVersion(pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const Ver, - string const &ver, bool const &verIsRel) { - if (ver != Ver.VerStr()) - ioprintf(out, _("Selected version '%s' (%s) for '%s'\n"), - Ver.VerStr(), Ver.RelStr().c_str(), Pkg.FullName(true).c_str()); - } - - void showVirtualPackageErrors(pkgCacheFile &Cache) { - for (APT::PackageSet::const_iterator Pkg = virtualPkgs.begin(); - Pkg != virtualPkgs.end(); ++Pkg) { - if (Pkg->ProvidesList != 0) { - ioprintf(c1out,_("Package %s is a virtual package provided by:\n"), - Pkg.FullName(true).c_str()); - - pkgCache::PrvIterator I = Pkg.ProvidesList(); - unsigned short provider = 0; - for (; I.end() == false; ++I) { - pkgCache::PkgIterator Pkg = I.OwnerPkg(); - - if (Cache[Pkg].CandidateVerIter(Cache) == I.OwnerVer()) { - out << " " << Pkg.FullName(true) << " " << I.OwnerVer().VerStr(); - if (Cache[Pkg].Install() == true && Cache[Pkg].NewInstall() == false) - out << _(" [Installed]"); - out << endl; - ++provider; - } - } - // if we found no candidate which provide this package, show non-candidates - if (provider == 0) - for (I = Pkg.ProvidesList(); I.end() == false; I++) - out << " " << I.OwnerPkg().FullName(true) << " " << I.OwnerVer().VerStr() - << _(" [Not candidate version]") << endl; - else - out << _("You should explicitly select one to install.") << endl; - } else { - ioprintf(out, - _("Package %s is not available, but is referred to by another package.\n" - "This may mean that the package is missing, has been obsoleted, or\n" - "is only available from another source\n"),Pkg.FullName(true).c_str()); - - string List; - string VersionsList; - SPtrArray Seen = new bool[Cache.GetPkgCache()->Head().PackageCount]; - memset(Seen,0,Cache.GetPkgCache()->Head().PackageCount*sizeof(*Seen)); - for (pkgCache::DepIterator Dep = Pkg.RevDependsList(); - Dep.end() == false; Dep++) { - if (Dep->Type != pkgCache::Dep::Replaces) - continue; - if (Seen[Dep.ParentPkg()->ID] == true) - continue; - Seen[Dep.ParentPkg()->ID] = true; - List += Dep.ParentPkg().FullName(true) + " "; - //VersionsList += string(Dep.ParentPkg().CurVersion) + "\n"; ??? - } - ShowList(out,_("However the following packages replace it:"),List,VersionsList); - } - out << std::endl; - } - } - - virtual pkgCache::VerIterator canNotFindCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) { - APT::VersionSet const verset = tryVirtualPackage(Cache, Pkg, APT::VersionSet::CANDIDATE); - if (verset.empty() == false) - return *(verset.begin()); - if (ShowError == true) { - _error->Error(_("Package '%s' has no installation candidate"),Pkg.FullName(true).c_str()); - virtualPkgs.insert(Pkg); - } - return pkgCache::VerIterator(Cache, 0); - } - - virtual pkgCache::VerIterator canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) { - APT::VersionSet const verset = tryVirtualPackage(Cache, Pkg, APT::VersionSet::NEWEST); - if (verset.empty() == false) - return *(verset.begin()); - if (ShowError == true) - ioprintf(out, _("Virtual packages like '%s' can't be removed\n"), Pkg.FullName(true).c_str()); - return pkgCache::VerIterator(Cache, 0); - } - - APT::VersionSet tryVirtualPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg, - APT::VersionSet::Version const &select) { - /* This is a pure virtual package and there is a single available - candidate providing it. */ - if (unlikely(Cache[Pkg].CandidateVer != 0) || Pkg->ProvidesList == 0) - return APT::VersionSet(); - - pkgCache::PkgIterator Prov; - bool found_one = false; - for (pkgCache::PrvIterator P = Pkg.ProvidesList(); P; ++P) { - pkgCache::VerIterator const PVer = P.OwnerVer(); - pkgCache::PkgIterator const PPkg = PVer.ParentPkg(); - - /* Ignore versions that are not a candidate. */ - if (Cache[PPkg].CandidateVer != PVer) - continue; - - if (found_one == false) { - Prov = PPkg; - found_one = true; - } else if (PPkg != Prov) { - found_one = false; // we found at least two - break; - } - } - - if (found_one == true) { - ioprintf(out, _("Note, selecting '%s' instead of '%s'\n"), - Prov.FullName(true).c_str(), Pkg.FullName(true).c_str()); - return APT::VersionSet::FromPackage(Cache, Prov, select, *this); - } - return APT::VersionSet(); - } - - inline bool allPkgNamedExplicitly() const { return explicitlyNamed; } - -}; - /*}}}*/ // DoInstall - Install packages from the command line /*{{{*/ // --------------------------------------------------------------------- /* Install named packages */ -- cgit v1.2.3 From 2fbfb111312257fa5fc29b0c2ed386fb712f960e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 4 Jul 2010 00:32:52 +0200 Subject: prefer the Policy if it is built instead of the DepCache and if DepCache is not available as fallback built the Policy --- cmdline/apt-get.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 38b93e7e5..9a6c12ee0 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -768,6 +768,9 @@ struct TryToInstall { void operator() (pkgCache::VerIterator const &Ver) { pkgCache::PkgIterator Pkg = Ver.ParentPkg(); + +std::clog << "INSTALL " << Pkg << " VER " << Ver.VerStr() << std::endl; + Cache->GetDepCache()->SetCandidateVersion(Ver); pkgDepCache::StateCache &State = (*Cache)[Pkg]; -- cgit v1.2.3 From 6806db8ac030ab7401b7b8b8324c62bb7b4a0275 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 5 Jul 2010 11:34:35 +0200 Subject: make the specify order of packages irrelevant (half-close #196021) --- cmdline/apt-get.cc | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 9a6c12ee0..7cf760c27 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -762,6 +762,7 @@ struct TryToInstall { pkgProblemResolver* Fix; bool FixBroken; unsigned long AutoMarkChanged; + APT::PackageSet doAutoInstallLater; TryToInstall(pkgCacheFile &Cache, pkgProblemResolver &PM, bool const &FixBroken) : Cache(&Cache), Fix(&PM), FixBroken(FixBroken), AutoMarkChanged(0) {}; @@ -769,8 +770,6 @@ struct TryToInstall { void operator() (pkgCache::VerIterator const &Ver) { pkgCache::PkgIterator Pkg = Ver.ParentPkg(); -std::clog << "INSTALL " << Pkg << " VER " << Ver.VerStr() << std::endl; - Cache->GetDepCache()->SetCandidateVersion(Ver); pkgDepCache::StateCache &State = (*Cache)[Pkg]; @@ -801,8 +800,8 @@ std::clog << "INSTALL " << Pkg << " VER " << Ver.VerStr() << std::endl; // Install it with autoinstalling enabled (if we not respect the minial // required deps or the policy) - if ((State.InstBroken() == true || State.InstPolicyBroken() == true) && FixBroken == false) - Cache->GetDepCache()->MarkInstall(Pkg,true); + if (FixBroken == false) + doAutoInstallLater.insert(Pkg); } // see if we need to fix the auto-mark flag @@ -820,6 +819,17 @@ std::clog << "INSTALL " << Pkg << " VER " << Ver.VerStr() << std::endl; AutoMarkChanged++; } } + + void doAutoInstall() { + for (APT::PackageSet::const_iterator P = doAutoInstallLater.begin(); + P != doAutoInstallLater.end(); ++P) { + pkgDepCache::StateCache &State = (*Cache)[P]; + if (State.InstBroken() == false && State.InstPolicyBroken() == false) + continue; + Cache->GetDepCache()->MarkInstall(P, true); + } + doAutoInstallLater.clear(); + } }; /*}}}*/ // TryToRemove - Mark a package for removal /*{{{*/ @@ -1336,6 +1346,7 @@ bool TryToInstallBuildDep(pkgCache::PkgIterator Pkg,pkgCacheFile &Cache, } else if (Cache[Pkg].CandidateVer != 0) { TryToInstall InstallAction(Cache, Fix, BrokenFix); InstallAction(Cache[Pkg].CandidateVerIter(Cache)); + InstallAction.doAutoInstall(); } else return AllowFail; @@ -1743,8 +1754,10 @@ bool DoInstall(CommandLine &CmdL) for (unsigned short i = 0; order[i] != 0; ++i) { - if (order[i] == MOD_INSTALL) + if (order[i] == MOD_INSTALL) { InstallAction = std::for_each(verset[MOD_INSTALL].begin(), verset[MOD_INSTALL].end(), InstallAction); + InstallAction.doAutoInstall(); + } else if (order[i] == MOD_REMOVE) RemoveAction = std::for_each(verset[MOD_REMOVE].begin(), verset[MOD_REMOVE].end(), RemoveAction); } -- cgit v1.2.3 From 8fde723961709118837153cdf94f150c680e10e9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 17 Jul 2010 20:04:44 +0200 Subject: * apt-pkg/cacheset.cc: - move them back to the library as they look stable now --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 7cf760c27..eaa982856 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -45,7 +46,6 @@ #include #include "acqprogress.h" -#include "cacheset.h" #include #include -- cgit v1.2.3 From 4b12ea903c5166e6215764e6507f6271782df6ff Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 27 Jul 2010 13:27:26 +0200 Subject: * cmdline/apt-get.cc: - Support large filesystems by using statvfs64() instead of statvfs() and statfs64() instead of statfs() (Closes: #590513). --- cmdline/apt-get.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 7cf760c27..a6dfd82ed 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -25,6 +25,9 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#define _LARGEFILE_SOURCE +#define _LARGEFILE64_SOURCE + #include #include #include @@ -63,6 +66,9 @@ #include #include #include + +#define statfs statfs64 +#define statvfs statvfs64 /*}}}*/ #define RAMFS_MAGIC 0x858458f6 -- cgit v1.2.3 From 086bb6d7b5ba933e0a8a6de13d731fcfb8eeda74 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 11 Aug 2010 19:39:44 +0200 Subject: * cmdline/apt-get.cc: - let APT::Get::Arch-Only in build-dep default to false again (Closes: #592628) Thanks Mohamed Amine IL Idrissi for report! --- cmdline/apt-get.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index c0e74b37b..dac0d42a8 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -28,6 +28,7 @@ #define _LARGEFILE_SOURCE #define _LARGEFILE64_SOURCE +#include #include #include #include @@ -2493,6 +2494,7 @@ bool DoBuildDep(CommandLine &CmdL) return false; unsigned J = 0; + bool const StripMultiArch = APT::Configuration::getArchitectures().size() <= 1; for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++) { string Src; @@ -2502,7 +2504,7 @@ bool DoBuildDep(CommandLine &CmdL) // Process the build-dependencies vector BuildDeps; - if (Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only",true)) == false) + if (Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only", false), StripMultiArch) == false) return _error->Error(_("Unable to get build-dependency information for %s"),Src.c_str()); // Also ensure that build-essential packages are present -- cgit v1.2.3 From 6cb1583a73d7f009f05f8a2b20a177fa31249241 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 12 Aug 2010 16:45:41 +0200 Subject: purge packages in 'rc' state, thanks Rogier! (Closes: #150831) --- cmdline/apt-get.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index dac0d42a8..6ca9e1402 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -844,9 +844,11 @@ struct TryToRemove { pkgCacheFile* Cache; pkgProblemResolver* Fix; bool FixBroken; + bool PurgePkgs; unsigned long AutoMarkChanged; - TryToRemove(pkgCacheFile &Cache, pkgProblemResolver &PM) : Cache(&Cache), Fix(&PM) {}; + TryToRemove(pkgCacheFile &Cache, pkgProblemResolver &PM) : Cache(&Cache), Fix(&PM), + PurgePkgs(_config->FindB("APT::Get::Purge", false)) {}; void operator() (pkgCache::VerIterator const &Ver) { @@ -856,10 +858,11 @@ struct TryToRemove { Fix->Protect(Pkg); Fix->Remove(Pkg); - if (Pkg->CurrentVer == 0) + if ((Pkg->CurrentVer == 0 && PurgePkgs == false) || + (PurgePkgs == true && Pkg->CurrentState == pkgCache::State::NotInstalled)) ioprintf(c1out,_("Package %s is not installed, so not removed\n"),Pkg.FullName(true).c_str()); else - Cache->GetDepCache()->MarkDelete(Pkg,_config->FindB("APT::Get::Purge",false)); + Cache->GetDepCache()->MarkDelete(Pkg, PurgePkgs); } }; /*}}}*/ -- cgit v1.2.3 From d204fc7a26dad1d0a62d4a72e15627528ba22d3d Mon Sep 17 00:00:00 2001 From: "bubulle@debian.org" <> Date: Tue, 24 Aug 2010 19:51:50 +0200 Subject: Fix spelling error in cmdline/apt-get.cc. Thanks to Osamu Aoki Closes: #594211 --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 6ca9e1402..9b69e9589 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1654,7 +1654,7 @@ bool DoAutomaticRemove(CacheFile &Cache) if (doAutoRemove == false && (autoremovelist.empty() == false || autoRemoveCount != 0)) { if (smallList == false) - ShowList(c1out, P_("The following package is automatically installed and is no longer required:", + ShowList(c1out, P_("The following package was automatically installed and is no longer required:", "The following packages were automatically installed and are no longer required:", autoRemoveCount), autoremovelist, autoremoveversions); else -- cgit v1.2.3 From 1bb8cd67acb83921ec27a989bcb3c6dd6e0d5786 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 26 Aug 2010 22:41:40 +0200 Subject: * cmdline/apt-get.cc: - remove direct calls of ReadMainList and use the wrapper instead to protect us from useless re-reads and two-times notice display --- cmdline/apt-get.cc | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 9b69e9589..733788353 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1084,13 +1084,13 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, return false; // Read the source list - pkgSourceList List; - if (List.ReadMainList() == false) - return _error->Error(_("The list of sources could not be read.")); + if (Cache.BuildSourceList() == false) + return false; + pkgSourceList *List = Cache.GetSourceList(); // Create the package manager and prepare to download SPtr PM= _system->CreatePM(Cache); - if (PM->GetArchives(&Fetcher,&List,&Recs) == false || + if (PM->GetArchives(&Fetcher,List,&Recs) == false || _error->PendingError() == true) return false; @@ -1306,7 +1306,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, // Reload the fetcher object and loop again for media swapping Fetcher.Shutdown(); - if (PM->GetArchives(&Fetcher,&List,&Recs) == false) + if (PM->GetArchives(&Fetcher,List,&Recs) == false) return false; _system->Lock(); @@ -1542,11 +1542,13 @@ bool DoUpdate(CommandLine &CmdL) { if (CmdL.FileSize() != 1) return _error->Error(_("The update command takes no arguments")); - + + CacheFile Cache; + // Get the source list - pkgSourceList List; - if (List.ReadMainList() == false) + if (Cache.BuildSourceList() == false) return false; + pkgSourceList *List = Cache.GetSourceList(); // Create the progress AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0)); @@ -1564,7 +1566,7 @@ bool DoUpdate(CommandLine &CmdL) // Populate it with the source selection and get all Indexes // (GetAll=true) - if (List.GetIndexes(&Fetcher,true) == false) + if (List->GetIndexes(&Fetcher,true) == false) return false; pkgAcquire::UriIterator I = Fetcher.UriBegin(); @@ -1575,9 +1577,8 @@ bool DoUpdate(CommandLine &CmdL) } // do the work - CacheFile Cache; if (_config->FindB("APT::Get::Download",true) == true) - ListUpdate(Stat, List); + ListUpdate(Stat, *List); // Rebuild the cache. if (Cache.BuildCaches() == false) @@ -2189,13 +2190,13 @@ bool DoSource(CommandLine &CmdL) return _error->Error(_("Must specify at least one package to fetch source for")); // Read the source list - pkgSourceList List; - if (List.ReadMainList() == false) - return _error->Error(_("The list of sources could not be read.")); + if (Cache.BuildSourceList() == false) + return false; + pkgSourceList *List = Cache.GetSourceList(); // Create the text record parsers pkgRecords Recs(Cache); - pkgSrcRecords SrcRecs(List); + pkgSrcRecords SrcRecs(*List); if (_error->PendingError() == true) return false; @@ -2480,13 +2481,13 @@ bool DoBuildDep(CommandLine &CmdL) return _error->Error(_("Must specify at least one package to check builddeps for")); // Read the source list - pkgSourceList List; - if (List.ReadMainList() == false) - return _error->Error(_("The list of sources could not be read.")); + if (Cache.BuildSourceList() == false) + return false; + pkgSourceList *List = Cache.GetSourceList(); // Create the text record parsers pkgRecords Recs(Cache); - pkgSrcRecords SrcRecs(List); + pkgSrcRecords SrcRecs(*List); if (_error->PendingError() == true) return false; -- cgit v1.2.3 From d6ff64f7068b506d82bbcfde0d9aad527f5951d0 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 28 Aug 2010 17:52:55 +0200 Subject: remove death code by removing unused GetInitialize --- cmdline/apt-get.cc | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 733788353..d1c010e49 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2834,22 +2834,6 @@ bool ShowHelp(CommandLine &CmdL) return true; } /*}}}*/ -// GetInitialize - Initialize things for apt-get /*{{{*/ -// --------------------------------------------------------------------- -/* */ -void GetInitialize() -{ - _config->Set("quiet",0); - _config->Set("help",false); - _config->Set("APT::Get::Download-Only",false); - _config->Set("APT::Get::Simulate",false); - _config->Set("APT::Get::Assume-Yes",false); - _config->Set("APT::Get::Fix-Broken",false); - _config->Set("APT::Get::Force-Yes",false); - _config->Set("APT::Get::List-Cleanup",true); - _config->Set("APT::Get::AutomaticRemove",false); -} - /*}}}*/ // SigWinch - Window size change signal handler /*{{{*/ // --------------------------------------------------------------------- /* */ -- cgit v1.2.3