Просмотр исходного кода

Switch FileFd to not transparently gunzip, since that breaks code which expects the compressed contents to stay (such as the copy backend, or when using file:// repositories. Instead, introduce a new ReadOnlyGzip mode and use that where needed

martin@piware.de лет назад: 16
Родитель
Сommit
c4fc2fd7fa

+ 2 - 2
apt-pkg/acquire-item.cc

@@ -228,7 +228,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile)		/*{{{*/
       ss >> ServerSha1 >> size;
       ss >> ServerSha1 >> size;
       unsigned long const ServerSize = atol(size.c_str());
       unsigned long const ServerSize = atol(size.c_str());
 
 
-      FileFd fd(CurrentPackagesFile, FileFd::ReadOnly);
+      FileFd fd(CurrentPackagesFile, FileFd::ReadOnlyGzip);
       SHA1Summation SHA1;
       SHA1Summation SHA1;
       SHA1.AddFD(fd.Fd(), fd.Size());
       SHA1.AddFD(fd.Fd(), fd.Size());
       string const local_sha1 = SHA1.Result();
       string const local_sha1 = SHA1.Result();
@@ -459,7 +459,7 @@ bool pkgAcqIndexDiffs::QueueNextDiff()					/*{{{*/
    string FinalFile = _config->FindDir("Dir::State::lists");
    string FinalFile = _config->FindDir("Dir::State::lists");
    FinalFile += URItoFileName(RealURI);
    FinalFile += URItoFileName(RealURI);
 
 
-   FileFd fd(FinalFile, FileFd::ReadOnly);
+   FileFd fd(FinalFile, FileFd::ReadOnlyGzip);
    SHA1Summation SHA1;
    SHA1Summation SHA1;
    SHA1.AddFD(fd.Fd(), fd.Size());
    SHA1.AddFD(fd.Fd(), fd.Size());
    string local_sha1 = string(SHA1.Result());
    string local_sha1 = string(SHA1.Result());

+ 9 - 5
apt-pkg/contrib/fileutl.cc

@@ -604,12 +604,16 @@ bool FileFd::Open(string FileName,OpenMode Mode, unsigned long Perms)
    {
    {
       case ReadOnly:
       case ReadOnly:
       iFd = open(FileName.c_str(),O_RDONLY);
       iFd = open(FileName.c_str(),O_RDONLY);
+      break;
+
+      case ReadOnlyGzip:
+      iFd = open(FileName.c_str(),O_RDONLY);
       if (iFd > 0 && FileName.compare(FileName.size()-3, 3, ".gz") == 0) {
       if (iFd > 0 && FileName.compare(FileName.size()-3, 3, ".gz") == 0) {
-	  gz = gzdopen (iFd, "r");
-	  if (gz == NULL) {
-	      close (iFd);
-	      iFd = -1;
-	  }
+	 gz = gzdopen (iFd, "r");
+	 if (gz == NULL) {
+	     close (iFd);
+	     iFd = -1;
+	 }
       }
       }
       break;
       break;
       
       

+ 1 - 1
apt-pkg/contrib/fileutl.h

@@ -41,7 +41,7 @@ class FileFd
    gzFile gz;
    gzFile gz;
    
    
    public:
    public:
-   enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp};
+   enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp,ReadOnlyGzip};
    
    
    inline bool Read(void *To,unsigned long Size,bool AllowEof)
    inline bool Read(void *To,unsigned long Size,bool AllowEof)
    {
    {

+ 3 - 3
apt-pkg/deb/debindexfile.cc

@@ -273,7 +273,7 @@ unsigned long debPackagesIndex::Size() const
 bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
 bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
 {
 {
    string PackageFile = IndexFile("Packages");
    string PackageFile = IndexFile("Packages");
-   FileFd Pkg(PackageFile,FileFd::ReadOnly);
+   FileFd Pkg(PackageFile,FileFd::ReadOnlyGzip);
    debListParser Parser(&Pkg);
    debListParser Parser(&Pkg);
    if (_error->PendingError() == true)
    if (_error->PendingError() == true)
       return _error->Error("Problem opening %s",PackageFile.c_str());
       return _error->Error("Problem opening %s",PackageFile.c_str());
@@ -464,7 +464,7 @@ bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
    string TranslationFile = IndexFile(Language);
    string TranslationFile = IndexFile(Language);
    if (TranslationsAvailable() && FileExists(TranslationFile))
    if (TranslationsAvailable() && FileExists(TranslationFile))
    {
    {
-     FileFd Trans(TranslationFile,FileFd::ReadOnly);
+     FileFd Trans(TranslationFile,FileFd::ReadOnlyGzip);
      debListParser TransParser(&Trans);
      debListParser TransParser(&Trans);
      if (_error->PendingError() == true)
      if (_error->PendingError() == true)
        return false;
        return false;
@@ -544,7 +544,7 @@ unsigned long debStatusIndex::Size() const
 /* */
 /* */
 bool debStatusIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
 bool debStatusIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
 {
 {
-   FileFd Pkg(File,FileFd::ReadOnly);
+   FileFd Pkg(File,FileFd::ReadOnlyGzip);
    if (_error->PendingError() == true)
    if (_error->PendingError() == true)
       return false;
       return false;
    debListParser Parser(&Pkg);
    debListParser Parser(&Pkg);

+ 1 - 1
apt-pkg/deb/debrecords.cc

@@ -19,7 +19,7 @@
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
 debRecordParser::debRecordParser(string FileName,pkgCache &Cache) : 
 debRecordParser::debRecordParser(string FileName,pkgCache &Cache) : 
-                  File(FileName,FileFd::ReadOnly), 
+                  File(FileName,FileFd::ReadOnlyGzip), 
                   Tags(&File, std::max(Cache.Head().MaxVerFileSize, 
                   Tags(&File, std::max(Cache.Head().MaxVerFileSize, 
 				       Cache.Head().MaxDescFileSize) + 200)
 				       Cache.Head().MaxDescFileSize) + 200)
 {
 {

+ 1 - 1
apt-pkg/deb/debsrcrecords.h

@@ -48,7 +48,7 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
    virtual bool Files(vector<pkgSrcRecords::File> &F);
    virtual bool Files(vector<pkgSrcRecords::File> &F);
 
 
    debSrcRecordParser(string const &File,pkgIndexFile const *Index) 
    debSrcRecordParser(string const &File,pkgIndexFile const *Index) 
-      : Parser(Index), Fd(File,FileFd::ReadOnly), Tags(&Fd,102400), 
+      : Parser(Index), Fd(File,FileFd::ReadOnlyGzip), Tags(&Fd,102400), 
         Buffer(0), BufSize(0) {}
         Buffer(0), BufSize(0) {}
    ~debSrcRecordParser();
    ~debSrcRecordParser();
 };
 };

+ 1 - 1
cmdline/apt-cache.cc

@@ -1220,7 +1220,7 @@ bool DisplayRecord(pkgCache::VerIterator V)
    if (I.IsOk() == false)
    if (I.IsOk() == false)
       return _error->Error(_("Package file %s is out of sync."),I.FileName());
       return _error->Error(_("Package file %s is out of sync."),I.FileName());
    
    
-   FileFd PkgF(I.FileName(),FileFd::ReadOnly);
+   FileFd PkgF(I.FileName(),FileFd::ReadOnlyGzip);
    if (_error->PendingError() == true)
    if (_error->PendingError() == true)
       return false;
       return false;
    
    

+ 7 - 3
debian/changelog

@@ -9,13 +9,17 @@ apt (0.7.26~exp5) UNRELEASED; urgency=low
     - Make DEB_BUILD_OPTIONS=noopt actually work by passing the right
     - Make DEB_BUILD_OPTIONS=noopt actually work by passing the right
       CXXFLAGS.
       CXXFLAGS.
   * apt-pkg/contrib/fileutl.{h,cc}:
   * apt-pkg/contrib/fileutl.{h,cc}:
-    - Add support for transparent reading of gzipped files.
+    - Add support for reading of gzipped files with the new "ReadOnlyGzip"
+      OpenMode.
     - Link against zlib (in apt-pkg/makefile) and add zlib build dependency.
     - Link against zlib (in apt-pkg/makefile) and add zlib build dependency.
     - [ABI BREAK] This adds a new private member to FileFd, but its
     - [ABI BREAK] This adds a new private member to FileFd, but its
-      initialization is in the public header file. This also changes the
-      behaviour of FileFd for reading gzipped files.
+      initialization is in the public header file.
   * configure.in:
   * configure.in:
     - Check for zlib library and headers.
     - Check for zlib library and headers.
+  * apt-pkg/acquire-item.cc, apt-pkg/deb/debindexfile.cc,
+    apt-pkg/deb/debrecords.cc, apt-pkg/deb/debsrcrecords.h,
+    cmdline/apt-cache.cc:
+    - Open Packages, Sources, and Translations indexes in "ReadOnlyGzip" mode.
   * apt-pkg/deb/debindexfile.cc:
   * apt-pkg/deb/debindexfile.cc:
     - If we do not find uncompressed package/source/translation indexes, look
     - If we do not find uncompressed package/source/translation indexes, look
       for gzip compressed ones.
       for gzip compressed ones.