summaryrefslogtreecommitdiff
path: root/cmdline/apt-get.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2006-09-19 14:02:53 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2006-09-19 14:02:53 +0200
commitc158ff49dacb8f6fdca98f9b43329eac44f1a827 (patch)
treed5b9e8a8db9481d907d681b4f0a9677c348c922f /cmdline/apt-get.cc
parent3772dc74d3e7767980a011e01302dd688b3764fc (diff)
* tasksupport (apt-get installtask lala) added
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 64882e3e8..9705f84dc 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -1406,6 +1406,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 */
@@ -2546,6 +2601,7 @@ int main(int argc,const char *argv[])
CommandLine::Dispatch Cmds[] = {{"update",&DoUpdate},
{"upgrade",&DoUpgrade},
{"install",&DoInstall},
+ {"installtask",&DoInstallTask},
{"remove",&DoInstall},
{"dist-upgrade",&DoDistUpgrade},
{"dselect-upgrade",&DoDSelectUpgrade},