]> git.saurik.com Git - apt.git/commitdiff
Allow passing a full path to apt-get install /foo/bar.deb
authorMichael Vogt <mvo@debian.org>
Thu, 10 Jul 2014 08:47:08 +0000 (10:47 +0200)
committerMichael Vogt <mvo@debian.org>
Thu, 10 Jul 2014 08:47:08 +0000 (10:47 +0200)
CLoses: #752327

apt-pkg/cacheset.cc
apt-pkg/deb/debindexfile.cc

index 5d7f2851525f2e59c988b5de2f9211b78337e698..346bad3aaa3a587f0fc6b0202be534a4e8e76929 100644 (file)
@@ -24,6 +24,7 @@
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/macros.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/macros.h>
 #include <apt-pkg/pkgcache.h>
+#include <apt-pkg/fileutl.h>
 
 #include <stddef.h>
 #include <stdio.h>
 
 #include <stddef.h>
 #include <stdio.h>
@@ -445,6 +446,13 @@ bool VersionContainerInterface::FromString(VersionContainerInterface * const vci
                                           pkgCacheFile &Cache, std::string pkg,
                                           Version const &fallback, CacheSetHelper &helper,
                                           bool const onlyFromName) {
                                           pkgCacheFile &Cache, std::string pkg,
                                           Version const &fallback, CacheSetHelper &helper,
                                           bool const onlyFromName) {
+        PackageSet pkgset;
+        if(FileExists(pkg))
+        {
+                PackageContainerInterface::FromString(&pkgset, Cache, pkg, helper);
+                return VersionContainerInterface::FromPackage(vci, Cache, pkgset.begin(), fallback, helper);
+        }
+
        std::string ver;
        bool verIsRel = false;
        size_t const vertag = pkg.find_last_of("/=");
        std::string ver;
        bool verIsRel = false;
        size_t const vertag = pkg.find_last_of("/=");
@@ -453,7 +461,6 @@ bool VersionContainerInterface::FromString(VersionContainerInterface * const vci
                verIsRel = (pkg[vertag] == '/');
                pkg.erase(vertag);
        }
                verIsRel = (pkg[vertag] == '/');
                pkg.erase(vertag);
        }
-       PackageSet pkgset;
        if (onlyFromName == false)
                PackageContainerInterface::FromString(&pkgset, Cache, pkg, helper);
        else {
        if (onlyFromName == false)
                PackageContainerInterface::FromString(&pkgset, Cache, pkg, helper);
        else {
index c1c2b726a11d900fb25ebe6ac665b4040af96460..feda8d0d838ada32385db42edd6db94f6556dcc5 100644 (file)
@@ -692,15 +692,27 @@ bool debDebPkgFileIndex::Merge(pkgCacheGenerator& Gen, OpProgress* Prog) const
 
    // get the control data out of the deb file vid dpkg -I
    // ... can I haz libdpkg?
 
    // get the control data out of the deb file vid dpkg -I
    // ... can I haz libdpkg?
+   Configuration::Item const *Opts = _config->Tree("DPkg::Options");
    std::string dpkg = _config->Find("Dir::Bin::dpkg","dpkg");
    std::string dpkg = _config->Find("Dir::Bin::dpkg","dpkg");
-   const char *Args[5] = {dpkg.c_str(),
-                          "-I",
-                          DebFile.c_str(),
-                          "control",
-                          NULL};
+   std::vector<const char *> Args;
+   Args.push_back(dpkg.c_str());
+   if (Opts != 0)
+   {
+      Opts = Opts->Child;
+      for (; Opts != 0; Opts = Opts->Next)
+      {
+        if (Opts->Value.empty() == true)
+           continue;
+        Args.push_back(Opts->Value.c_str());
+      }
+   }
+   Args.push_back("-I");
+   Args.push_back(DebFile.c_str());
+   Args.push_back("control");
+   Args.push_back(NULL);
    FileFd PipeFd;
    pid_t Child;
    FileFd PipeFd;
    pid_t Child;
-   if(Popen(Args, PipeFd, Child, FileFd::ReadOnly) == false)
+   if(Popen((const char**)&Args[0], PipeFd, Child, FileFd::ReadOnly) == false)
       return _error->Error("Popen failed");
    // FIXME: static buffer
    char buf[8*1024];
       return _error->Error("Popen failed");
    // FIXME: static buffer
    char buf[8*1024];
@@ -710,7 +722,7 @@ bool debDebPkgFileIndex::Merge(pkgCacheGenerator& Gen, OpProgress* Prog) const
    ExecWait(Child, "Popen");
 
    // now write the control data to a tempfile
    ExecWait(Child, "Popen");
 
    // now write the control data to a tempfile
-   SPtr<FileFd> DebControl = GetTempFile("deb-file-" + DebFile);
+   SPtr<FileFd> DebControl = GetTempFile("deb-file-" + flNotDir(DebFile));
    if(DebControl == NULL)
       return false;
    DebControl->Write(buf, n);
    if(DebControl == NULL)
       return false;
    DebControl->Write(buf, n);
@@ -738,8 +750,6 @@ bool debDebPkgFileIndex::Merge(pkgCacheGenerator& Gen, OpProgress* Prog) const
 }
 pkgCache::PkgFileIterator debDebPkgFileIndex::FindInCache(pkgCache &Cache) const
 {
 }
 pkgCache::PkgFileIterator debDebPkgFileIndex::FindInCache(pkgCache &Cache) const
 {
-   // FIXME: we could simply always return pkgCache::PkgFileIterator(Cache);
-   //        to indicate its never in the cache which will force a Merge()
    pkgCache::PkgFileIterator File = Cache.FileBegin();
    for (; File.end() == false; ++File)
    {
    pkgCache::PkgFileIterator File = Cache.FileBegin();
    for (; File.end() == false; ++File)
    {