]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/edsp/edsplistparser.cc
reenable gcc warnings for deprecated functions
[apt.git] / apt-pkg / edsp / edsplistparser.cc
index 212dc78406b08a82bb3e56100be83b12c801f755..77a0edc22c8ef13d8e4112b68a2e90b969ef7f42 100644 (file)
 // Include Files                                                       /*{{{*/
 #include <config.h>
 
+#include <apt-pkg/configuration.h>
 #include <apt-pkg/edsplistparser.h>
 #include <apt-pkg/md5.h>
 #include <apt-pkg/deblistparser.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/cacheiterators.h>
 #include <apt-pkg/tagfile.h>
+#include <apt-pkg/fileutl.h>
 
-#include <string>
                                                                        /*}}}*/
 
+class edspListParserPrivate                                            /*{{{*/
+{
+public:
+   FileFd extendedstates;
+   FileFd preferences;
+
+   edspListParserPrivate()
+   {
+      std::string const states = _config->FindFile("Dir::State::extended_states");
+      if (states != "/dev/null")
+        unlink(states.c_str());
+      extendedstates.Open(states, FileFd::WriteOnly | FileFd::Create | FileFd::Exclusive, 0600);
+      std::string const prefs = _config->FindFile("Dir::Etc::preferences");
+      if (prefs != "/dev/null")
+        unlink(prefs.c_str());
+      preferences.Open(prefs, FileFd::WriteOnly | FileFd::Create | FileFd::Exclusive, 0600);
+   }
+};
+                                                                       /*}}}*/
 // ListParser::edspListParser - Constructor                            /*{{{*/
-edspListParser::edspListParser(FileFd *File, std::string const &Arch) : debListParser(File, Arch)
-{}
+edspListParser::edspListParser(FileFd *File) : debListParser(File), d(new edspListParserPrivate())
+{
+}
                                                                        /*}}}*/
 // ListParser::NewVersion - Fill in the version structure              /*{{{*/
 bool edspListParser::NewVersion(pkgCache::VerIterator &Ver)
@@ -82,13 +103,44 @@ bool edspListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
       Pkg->CurrentVer = Ver.Index();
    }
 
+   if (Section.FindB("APT-Automatic", false))
+   {
+      std::string out;
+      strprintf(out, "Package: %s\nArchitecture: %s\nAuto-Installed: 1\n\n", Pkg.Name(), Pkg.Arch());
+      if (d->extendedstates.Write(out.c_str(), out.length()) == false)
+        return false;
+   }
+
+   // FIXME: Using an overriding pin is wrong.
+   if (Section.FindB("APT-Candidate", false))
+   {
+      std::string out;
+      strprintf(out, "Package: %s\nPin: version %s\nPin-Priority: 9999\n\n", Pkg.FullName().c_str(), Ver.VerStr());
+      if (d->preferences.Write(out.c_str(), out.length()) == false)
+        return false;
+   }
+
+   signed short const pinvalue = Section.FindI("APT-Pin", 500);
+   if (pinvalue != 500)
+   {
+      std::string out;
+      strprintf(out, "Package: %s\nPin: version %s\nPin-Priority: %d\n\n", Pkg.FullName().c_str(), Ver.VerStr(), pinvalue);
+      if (d->preferences.Write(out.c_str(), out.length()) == false)
+        return false;
+   }
+
    return true;
 }
                                                                        /*}}}*/
 // ListParser::LoadReleaseInfo - Load the release information          /*{{{*/
-APT_CONST bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator & /*FileI*/,
-                                   FileFd & /*File*/, std::string /*component*/)
+APT_CONST bool edspListParser::LoadReleaseInfo(pkgCache::RlsFileIterator & /*FileI*/,
+                                   FileFd & /*File*/, std::string const &/*component*/)
 {
    return true;
 }
                                                                        /*}}}*/
+edspListParser::~edspListParser()                                      /*{{{*/
+{
+   delete d;
+}
+                                                                       /*}}}*/