]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/edsp/edsplistparser.cc
merge sources.list lines based on Release filename
[apt.git] / apt-pkg / edsp / edsplistparser.cc
index 3349e8cce3c7482f5b5f674c82f02bf47a3fcdf0..39a6e8a6e6650843f8e63e14c850d31274c8bb55 100644 (file)
@@ -9,45 +9,55 @@
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
-#include <apt-pkg/edsplistparser.h>
-#include <apt-pkg/error.h>
+#include <config.h>
+
 #include <apt-pkg/configuration.h>
-#include <apt-pkg/strutl.h>
+#include <apt-pkg/edsplistparser.h>
 #include <apt-pkg/md5.h>
-#include <apt-pkg/macros.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 <apt-pkg/pkgsystem.h>
+
                                                                        /*}}}*/
 
 // ListParser::edspListParser - Constructor                            /*{{{*/
-edspListParser::edspListParser(FileFd *File, string const &Arch) : debListParser(File, Arch)
-{}
+edspLikeListParser::edspLikeListParser(FileFd * const File) : debListParser(File)
+{
+}
+edspListParser::edspListParser(FileFd * const File) : edspLikeListParser(File)
+{
+   std::string const states = _config->FindFile("Dir::State::extended_states");
+   RemoveFile("edspListParserPrivate", states);
+   extendedstates.Open(states, FileFd::WriteOnly | FileFd::Create | FileFd::Exclusive, 0600);
+   std::string const prefs = _config->FindFile("Dir::Etc::preferences");
+   RemoveFile("edspListParserPrivate", prefs);
+   preferences.Open(prefs, FileFd::WriteOnly | FileFd::Create | FileFd::Exclusive, 0600);
+}
                                                                        /*}}}*/
 // ListParser::NewVersion - Fill in the version structure              /*{{{*/
-bool edspListParser::NewVersion(pkgCache::VerIterator &Ver)
+bool edspLikeListParser::NewVersion(pkgCache::VerIterator &Ver)
 {
-   Ver->ID = Section.FindI("APT-ID", Ver->ID);
+   _system->SetVersionMapping(Ver->ID, Section.FindI("APT-ID", Ver->ID));
    return debListParser::NewVersion(Ver);
 }
                                                                        /*}}}*/
 // ListParser::Description - Return the description string             /*{{{*/
 // ---------------------------------------------------------------------
 /* Sorry, no description for the resolvers… */
-string edspListParser::Description()
+std::vector<std::string> edspLikeListParser::AvailableDescriptionLanguages()
 {
-   return "";
+   return {};
 }
-string edspListParser::DescriptionLanguage()
-{
-   return "";
-}
-MD5SumValue edspListParser::Description_md5()
+MD5SumValue edspLikeListParser::Description_md5()
 {
    return MD5SumValue("");
 }
                                                                        /*}}}*/
 // ListParser::VersionHash - Compute a unique hash for this version    /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-unsigned short edspListParser::VersionHash()
+unsigned short edspLikeListParser::VersionHash()
 {
    if (Section.Exists("APT-Hash") == true)
       return Section.FindI("APT-Hash");
@@ -56,6 +66,13 @@ unsigned short edspListParser::VersionHash()
    return 0;
 }
                                                                        /*}}}*/
+// ListParser::LoadReleaseInfo - Load the release information          /*{{{*/
+APT_CONST bool edspLikeListParser::LoadReleaseInfo(pkgCache::RlsFileIterator & /*FileI*/,
+                                   FileFd & /*File*/, std::string const &/*component*/)
+{
+   return true;
+}
+                                                                       /*}}}*/
 // ListParser::ParseStatus - Parse the status field                    /*{{{*/
 // ---------------------------------------------------------------------
 /* The Status: line here is not a normal dpkg one but just one which tells
@@ -78,13 +95,35 @@ 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 (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 (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 (preferences.Write(out.c_str(), out.length()) == false)
+        return false;
+   }
+
    return true;
 }
                                                                        /*}}}*/
-// ListParser::LoadReleaseInfo - Load the release information          /*{{{*/
-bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
-                                   FileFd &File, string component)
-{
-   return true;
-}
-                                                                       /*}}}*/
+
+edspLikeListParser::~edspLikeListParser() {}
+edspListParser::~edspListParser() {}