]> git.saurik.com Git - apt.git/commitdiff
avoid deb specific code in private-install
authorMichael Vogt <mvo@ubuntu.com>
Mon, 28 Apr 2014 12:50:11 +0000 (14:50 +0200)
committerMichael Vogt <mvo@ubuntu.com>
Mon, 28 Apr 2014 12:50:11 +0000 (14:50 +0200)
apt-pkg/deb/debmetaindex.cc
apt-private/private-install.cc

index 67da592d68cd4224eef66e85366a0ea71aa24000..56eecdca11c201fa14efdac74557fdeead141619 100644 (file)
@@ -516,5 +516,25 @@ class debSLTypeDebSrc : public debSLTypeDebian
    }   
 };
 
    }   
 };
 
+class debSLTypeDebFile : public pkgSourceList::Type
+{
+   public:
+
+   bool CreateItem(vector<metaIndex *> &List, string const &URI,
+                  string const &Dist, string const &Section,
+                  std::map<string, string> const &Options) const
+   {
+      metaIndex *mi = new debDebFileMetaIndex(URI);
+      List.push_back(mi);
+      return true;
+   }
+   
+   debSLTypeDebFile()
+   {
+      Name = "deb-file";
+      Label = "Debian Deb File";
+   }   
+};
 debSLTypeDeb _apt_DebType;
 debSLTypeDebSrc _apt_DebSrcType;
 debSLTypeDeb _apt_DebType;
 debSLTypeDebSrc _apt_DebSrcType;
+debSLTypeDebFile _apt_DebFileType;
index 40165af31161f1f6df529c8dcf50441fe4bf00ff..4a68bb9d167940e764bd21647659968432e3309b 100644 (file)
@@ -21,9 +21,6 @@
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/sourcelist.h>
 
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/sourcelist.h>
 
-// FIXME: include of deb specific header
-#include <apt-pkg/debmetaindex.h>
-
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
@@ -33,6 +30,7 @@
 #include <iostream>
 #include <set>
 #include <vector>
 #include <iostream>
 #include <set>
 #include <vector>
+#include <map>
 
 #include <apt-private/acqprogress.h>
 #include <apt-private/private-install.h>
 
 #include <apt-private/acqprogress.h>
 #include <apt-private/private-install.h>
@@ -678,10 +676,19 @@ bool DoInstall(CommandLine &CmdL)
    {
       if(FileExists(*I))
       {
    {
       if(FileExists(*I))
       {
-         // FIMXE: direct usage of .deb specific stuff
-         metaIndex *mi = new debDebFileMetaIndex(*I);
-         pkgSourceList *sources = Cache.GetSourceList();
-         sources->Add(mi);
+         // FIXME: make this more elegant
+         std::string TypeStr = flExtension(*I) + "-file";
+         pkgSourceList::Type *Type = pkgSourceList::Type::GetType(TypeStr.c_str());
+         if(Type != 0)
+         {
+            std::vector<metaIndex *> List;
+            std::map<std::string, std::string> Options;
+            if(Type->CreateItem(List, *I, "", "", Options))
+            {
+               pkgSourceList *sources = Cache.GetSourceList();
+               sources->Add(List[0]);
+            }
+         }
       }
    }
 
       }
    }