+// DPkgPM::SendV2Pkgs - Send version 2 package info /*{{{*/
+// ---------------------------------------------------------------------
+/* This is part of the helper script communication interface, it sends
+ very complete information down to the other end of the pipe.*/
+bool pkgDPkgPM::SendV2Pkgs(FILE *F)
+{
+ fprintf(F,"VERSION 2\n");
+
+ /* Write out all of the configuration directives by walking the
+ configuration tree */
+ const Configuration::Item *Top = _config->Tree(0);
+ for (; Top != 0;)
+ {
+ if (Top->Value.empty() == false)
+ {
+ fprintf(F,"%s=%s\n",
+ QuoteString(Top->FullTag(),"=\"\n").c_str(),
+ QuoteString(Top->Value,"\n").c_str());
+ }
+
+ if (Top->Child != 0)
+ {
+ Top = Top->Child;
+ continue;
+ }
+
+ while (Top != 0 && Top->Next == 0)
+ Top = Top->Parent;
+ if (Top != 0)
+ Top = Top->Next;
+ }
+ fprintf(F,"\n");
+
+ // Write out the package actions in order.
+ for (vector<Item>::iterator I = List.begin(); I != List.end(); I++)
+ {
+ pkgDepCache::StateCache &S = Cache[I->Pkg];
+
+ fprintf(F,"%s ",I->Pkg.Name());
+ // Current version
+ if (I->Pkg->CurrentVer == 0)
+ fprintf(F,"- ");
+ else
+ fprintf(F,"%s ",I->Pkg.CurrentVer().VerStr());
+
+ // Show the compare operator
+ // Target version
+ if (S.InstallVer != 0)
+ {
+ int Comp = 2;
+ if (I->Pkg->CurrentVer != 0)
+ Comp = S.InstVerIter(Cache).CompareVer(I->Pkg.CurrentVer());
+ if (Comp < 0)
+ fprintf(F,"> ");
+ if (Comp == 0)
+ fprintf(F,"= ");
+ if (Comp > 0)
+ fprintf(F,"< ");
+ fprintf(F,"%s ",S.InstVerIter(Cache).VerStr());
+ }
+ else
+ fprintf(F,"> - ");
+
+ // Show the filename/operation
+ if (I->Op == Item::Install)
+ {
+ // No errors here..
+ if (I->File[0] != '/')
+ fprintf(F,"**ERROR**\n");
+ else
+ fprintf(F,"%s\n",I->File.c_str());
+ }
+ if (I->Op == Item::Configure)
+ fprintf(F,"**CONFIGURE**\n");
+ if (I->Op == Item::Remove ||
+ I->Op == Item::Purge)
+ fprintf(F,"**REMOVE**\n");
+
+ if (ferror(F) != 0)
+ return false;
+ }
+ return true;
+}
+ /*}}}*/