]> git.saurik.com Git - apt.git/blobdiff - methods/gzip.cc
tell the release script that we use git now
[apt.git] / methods / gzip.cc
index a51497948646d1d0ac98e2bb70017f1cbbcaaf7b..48c8e98926e05881e616eb345f75252edc5c67fd 100644 (file)
@@ -25,6 +25,8 @@
 #include <apti18n.h>
                                                                        /*}}}*/
 
+const char *Prog;
+
 class GzipMethod : public pkgAcqMethod
 {
    virtual bool Fetch(FetchItem *Itm);
@@ -46,9 +48,18 @@ bool GzipMethod::Fetch(FetchItem *Itm)
    FetchResult Res;
    Res.Filename = Itm->DestFile;
    URIStart(Res);
-   
+
+   std::vector<APT::Configuration::Compressor> const compressors = APT::Configuration::getCompressors();
+   std::vector<APT::Configuration::Compressor>::const_iterator compressor = compressors.begin();
+   for (; compressor != compressors.end(); ++compressor)
+      if (compressor->Name == Prog)
+        break;
+   if (compressor == compressors.end())
+      return _error->Error("Extraction of file %s requires unknown compressor %s", Path.c_str(), Prog);
+
    // Open the source and destination files
-   FileFd From(Path,FileFd::ReadOnlyGzip);
+   FileFd From;
+   From.Open(Path, FileFd::ReadOnly, *compressor);
 
    if(From.FileSize() == 0)
       return _error->Error(_("Empty files can't be valid archives"));
@@ -117,6 +128,9 @@ int main(int argc, char *argv[])
 {
    setlocale(LC_ALL, "");
 
+   Prog = strrchr(argv[0],'/');
+   ++Prog;
+
    GzipMethod Mth;
    return Mth.Run();
 }