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 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 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