]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/edsp/edspsystem.cc
prepare-release: ignore newer version symbols
[apt.git] / apt-pkg / edsp / edspsystem.cc
index ac0bb8beb877d5462b47b8567113597fcc838c21..0d967863ef86cc6b198a2a685ef5ced99f2df988 100644 (file)
@@ -9,34 +9,72 @@
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
-#include <apt-pkg/edspsystem.h>
+#include <config.h>
+
+#include <apt-pkg/configuration.h>
 #include <apt-pkg/debversion.h>
 #include <apt-pkg/edspindexfile.h>
 #include <apt-pkg/debversion.h>
 #include <apt-pkg/edspindexfile.h>
-#include <apt-pkg/configuration.h>
-#include <apt-pkg/error.h>
+#include <apt-pkg/edspsystem.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
-#include <apti18n.h>
-#include <sys/types.h>
+
+#include <stddef.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <unistd.h>
-#include <dirent.h>
-#include <errno.h>
+
+#include <string>
+#include <vector>
+
                                                                        /*}}}*/
 
                                                                        /*}}}*/
 
-edspSystem edspSys;
+class edspSystemPrivate {
+   std::string tempDir;
+   std::string tempStatesFile;
+   std::string tempPrefsFile;
 
 
-// System::debSystem - Constructor                                     /*{{{*/
-edspSystem::edspSystem()
-{
-   StatusFile = 0;
+public:
+   edspSystemPrivate() {}
 
 
-   Label = "Debian APT solver interface";
-   VS = &debVS;
+   void Initialize(Configuration &Cnf)
+   {
+      DeInitialize();
+      Cnf.Set("Dir::State::extended_states", "/dev/null");
+      Cnf.Set("Dir::Etc::preferences", "/dev/null");
+      std::string const tmp = GetTempDir();
+      char tmpname[100];
+      snprintf(tmpname, sizeof(tmpname), "%s/apt-edsp-solver-XXXXXX", tmp.c_str());
+      if (NULL == mkdtemp(tmpname))
+        return;
+      tempDir = tmpname;
+      tempStatesFile = flCombine(tempDir, "extended_states");
+      Cnf.Set("Dir::State::extended_states", tempStatesFile);
+      tempPrefsFile = flCombine(tempDir, "apt_preferences");
+      Cnf.Set("Dir::Etc::preferences", tempPrefsFile);
+   }
+
+   void DeInitialize()
+   {
+      if (tempDir.empty())
+        return;
+
+      RemoveFile("DeInitialize", tempStatesFile);
+      RemoveFile("DeInitialize", tempPrefsFile);
+      rmdir(tempDir.c_str());
+   }
+
+   ~edspSystemPrivate() { DeInitialize(); }
+};
+// System::edspSystem - Constructor                                    /*{{{*/
+edspSystem::edspSystem() : pkgSystem("Debian APT solver interface", &debVS), d(new edspSystemPrivate()), StatusFile(NULL)
+{
 }
                                                                        /*}}}*/
 // System::~debSystem - Destructor                                     /*{{{*/
 edspSystem::~edspSystem()
 {
    delete StatusFile;
 }
                                                                        /*}}}*/
 // System::~debSystem - Destructor                                     /*{{{*/
 edspSystem::~edspSystem()
 {
    delete StatusFile;
+   delete d;
 }
                                                                        /*}}}*/
 // System::Lock - Get the lock                                         /*{{{*/
 }
                                                                        /*}}}*/
 // System::Lock - Get the lock                                         /*{{{*/
@@ -46,7 +84,7 @@ bool edspSystem::Lock()
 }
                                                                        /*}}}*/
 // System::UnLock - Drop a lock                                                /*{{{*/
 }
                                                                        /*}}}*/
 // System::UnLock - Drop a lock                                                /*{{{*/
-bool edspSystem::UnLock(bool NoErrors)
+bool edspSystem::UnLock(bool /*NoErrors*/)
 {
    return true;
 }
 {
    return true;
 }
@@ -55,7 +93,7 @@ bool edspSystem::UnLock(bool NoErrors)
 // ---------------------------------------------------------------------
 /* we can't use edsp input as input for real installations - just a
    simulation can work, but everything else will fail bigtime */
 // ---------------------------------------------------------------------
 /* we can't use edsp input as input for real installations - just a
    simulation can work, but everything else will fail bigtime */
-pkgPackageManager *edspSystem::CreatePM(pkgDepCache *Cache) const
+pkgPackageManager *edspSystem::CreatePM(pkgDepCache * /*Cache*/) const
 {
    return NULL;
 }
 {
    return NULL;
 }
@@ -63,7 +101,8 @@ pkgPackageManager *edspSystem::CreatePM(pkgDepCache *Cache) const
 // System::Initialize - Setup the configuration space..                        /*{{{*/
 bool edspSystem::Initialize(Configuration &Cnf)
 {
 // System::Initialize - Setup the configuration space..                        /*{{{*/
 bool edspSystem::Initialize(Configuration &Cnf)
 {
-   Cnf.Set("Dir::State::extended_states", "/dev/null");
+   d->Initialize(Cnf);
+   Cnf.Set("Dir::Etc::preferencesparts", "/dev/null");
    Cnf.Set("Dir::State::status","/dev/null");
    Cnf.Set("Dir::State::lists","/dev/null");
 
    Cnf.Set("Dir::State::status","/dev/null");
    Cnf.Set("Dir::State::lists","/dev/null");
 
@@ -78,28 +117,23 @@ bool edspSystem::Initialize(Configuration &Cnf)
 }
                                                                        /*}}}*/
 // System::ArchiveSupported - Is a file format supported               /*{{{*/
 }
                                                                        /*}}}*/
 // System::ArchiveSupported - Is a file format supported               /*{{{*/
-bool edspSystem::ArchiveSupported(const char *Type)
+bool edspSystem::ArchiveSupported(const char * /*Type*/)
 {
    return false;
 }
                                                                        /*}}}*/
 {
    return false;
 }
                                                                        /*}}}*/
-// System::Score - Determine if we should use the edsp system          /*{{{*/
-signed edspSystem::Score(Configuration const &Cnf)
+// System::Score - Never use the EDSP system automatically             /*{{{*/
+signed edspSystem::Score(Configuration const &)
 {
 {
-   if (Cnf.Find("edsp::scenario", "") == "stdin")
-      return 1000;
-   if (FileExists(Cnf.FindFile("edsp::scenario","")) == true)
-      return 1000;
    return -1000;
 }
                                                                        /*}}}*/
    return -1000;
 }
                                                                        /*}}}*/
-// System::AddStatusFiles - Register the status files                  /*{{{*/
-bool edspSystem::AddStatusFiles(vector<pkgIndexFile *> &List)
+bool edspSystem::AddStatusFiles(std::vector<pkgIndexFile *> &List)     /*{{{*/
 {
    if (StatusFile == 0)
    {
 {
    if (StatusFile == 0)
    {
-      if (_config->Find("edsp::scenario", "") == "stdin")
-        StatusFile = new edspIndex("stdin");
+      if (_config->Find("edsp::scenario", "") == "/nonexistent/stdin")
+        StatusFile = new edspIndex("/nonexistent/stdin");
       else
         StatusFile = new edspIndex(_config->FindFile("edsp::scenario"));
    }
       else
         StatusFile = new edspIndex(_config->FindFile("edsp::scenario"));
    }
@@ -122,3 +156,5 @@ bool edspSystem::FindIndex(pkgCache::PkgFileIterator File,
    return false;
 }
                                                                        /*}}}*/
    return false;
 }
                                                                        /*}}}*/
+
+APT_HIDDEN edspSystem edspSys;