summaryrefslogtreecommitdiff
path: root/cmdline/apt-get.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2006-09-19 16:05:44 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2006-09-19 16:05:44 +0200
commit36afd8495a5646ccdec0153c93945a5a27606fce (patch)
tree35410bfee6ead769fb56c08c21bb066619432e2e /cmdline/apt-get.cc
parent455f831c3cbd7f555d3a0b0c949a42432efc63d3 (diff)
parentc158ff49dacb8f6fdca98f9b43329eac44f1a827 (diff)
* merged apt--tasks, this brings in the latest changes from apt--mvo as well
Diffstat (limited to 'cmdline/apt-get.cc')
-rw-r--r--cmdline/apt-get.cc56
1 files changed, 56 insertions, 0 deletions
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 089b64701..cd43e17c7 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -1496,6 +1496,61 @@ bool DoUpgrade(CommandLine &CmdL)
return InstallPackages(Cache,true);
}
/*}}}*/
+// DoInstallTask - Install task from the command line /*{{{*/
+// ---------------------------------------------------------------------
+/* Install named task */
+bool DoInstallTask(CommandLine &CmdL)
+{
+ const char *start, *end;
+ pkgCache::PkgIterator Pkg;
+
+ CacheFile Cache;
+ if (Cache.OpenForInstall() == false ||
+ Cache.CheckDeps(CmdL.FileSize() != 1) == false)
+ return false;
+
+ // create the records parser
+ pkgRecords Recs(Cache);
+
+ unsigned int ExpectedInst = 0;
+ unsigned int Packages = 0;
+ pkgProblemResolver Fix(Cache);
+ char buf[64*1024];
+
+ for (const char **I = CmdL.FileList + 1; *I != 0; I++)
+ {
+ regex_t Pattern;
+ int Res;
+
+ // build regexp for the task
+ char S[300];
+ snprintf(S, sizeof(S), "^Task:.*%s.*\n", *I);
+ regcomp(&Pattern,S, REG_EXTENDED | REG_NOSUB | REG_NEWLINE);
+
+ 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;
+ TryToInstall(Pkg,Cache,Fix,false,false,ExpectedInst);
+ }
+ }
+
+ // Call the scored problem resolver
+ Fix.InstallProtect();
+ if (Fix.Resolve(true) == false)
+ _error->Discard();
+
+ // prompt for install
+ return InstallPackages(Cache,false,true);
+}
+
// DoInstall - Install packages from the command line /*{{{*/
// ---------------------------------------------------------------------
/* Install named packages */
@@ -2653,6 +2708,7 @@ int main(int argc,const char *argv[])
CommandLine::Dispatch Cmds[] = {{"update",&DoUpdate},
{"upgrade",&DoUpgrade},
{"install",&DoInstall},
+ {"installtask",&DoInstallTask},
{"remove",&DoInstall},
{"autoremove",&DoInstall},
{"dist-upgrade",&DoDistUpgrade},