summaryrefslogtreecommitdiff
path: root/cmdline/apt-get.cc
diff options
context:
space:
mode:
authorMichael Vogt <egon@bottom>2006-10-02 01:03:40 +0200
committerMichael Vogt <egon@bottom>2006-10-02 01:03:40 +0200
commitdd09a217ac0d331f4a0324cf42559da5d35edc9a (patch)
treef525d71757612671df3d5538b306cbf5eea14677 /cmdline/apt-get.cc
parente6549dfd43ccf76b6adbe0149b1aa42ea61cb962 (diff)
parent39cc1bbdd0faa13dcb150b573f56cd2dd64fa460 (diff)
* merged the "apt--install-task" branch
Diffstat (limited to 'cmdline/apt-get.cc')
-rw-r--r--cmdline/apt-get.cc59
1 files changed, 58 insertions, 1 deletions
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 4dfb3325c..cb0690bdf 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -1469,6 +1469,51 @@ 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)
+{
+ 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:.*[^a-z]%s[^a-z].*\n", taskname);
+ regcomp(&Pattern,S, REG_EXTENDED | REG_NOSUB | REG_NEWLINE);
+
+ bool found = false;
+ bool res = 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,false,BrokenFix,ExpectedInst);
+ found = 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 */
@@ -1510,6 +1555,18 @@ bool DoInstall(CommandLine &CmdL)
bool Remove = DefRemove;
char *VerTag = 0;
bool VerIsRel = false;
+
+ // 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);
+ continue;
+ }
+
while (Cache->FindPkg(S).end() == true)
{
// Handle an optional end tag indicating what to do
@@ -1526,7 +1583,7 @@ bool DoInstall(CommandLine &CmdL)
S[--Length] = 0;
continue;
}
-
+
char *Slash = strchr(S,'=');
if (Slash != 0)
{