diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2010-10-13 22:27:56 +0200 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2010-10-13 22:27:56 +0200 |
commit | 2faaf8bea85149fb131735a6bd7437fec3771ee0 (patch) | |
tree | 6c6ccb53abac45fdf9cb1f6fb3991ac4bcecb5c1 /apt-pkg | |
parent | 3b9c5cc2bdf1584525792aafe4e8f15d09951583 (diff) | |
parent | be61b563c20267c521494cca92bd7ac158366c89 (diff) |
merge with debian-sid
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 28 | ||||
-rw-r--r-- | apt-pkg/deb/debindexfile.cc | 22 | ||||
-rw-r--r-- | apt-pkg/deb/debsystem.cc | 4 |
3 files changed, 41 insertions, 13 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index eabaadf90..cbf1d64a9 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -915,11 +915,35 @@ unsigned long FileFd::Tell() /* */ unsigned long FileFd::Size() { - //TODO: For gz, do we need the actual file size here or the uncompressed length? struct stat Buf; + unsigned long size; + off_t orig_pos; + if (fstat(iFd,&Buf) != 0) return _error->Errno("fstat","Unable to determine the file size"); - return Buf.st_size; + size = Buf.st_size; + + // only check gzsize if we are actually a gzip file, just checking for + // "gz" is not sufficient as uncompressed files will be opened with + // gzopen in "direct" mode as well + if (gz && !gzdirect(gz) && size > 0) + { + /* unfortunately zlib.h doesn't provide a gzsize(), so we have to do + * this ourselves; the original (uncompressed) file size is the last 32 + * bits of the file */ + orig_pos = lseek(iFd, 0, SEEK_CUR); + if (lseek(iFd, -4, SEEK_END) < 0) + return _error->Errno("lseek","Unable to seek to end of gzipped file"); + if (read(iFd, &size, 4) != 4) + return _error->Errno("read","Unable to read original size of gzipped file"); + size &= 0xFFFFFFFF; + + if (lseek(iFd, orig_pos, SEEK_SET) < 0) + return _error->Errno("lseek","Unable to seek in gzipped file"); + return size; + } + + return size; } /*}}}*/ // FileFd::Close - Close the file if the close flag is set /*{{{*/ diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index ba5b3f266..a89a2574f 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -149,10 +149,11 @@ bool debSourcesIndex::Exists() const /* */ unsigned long debSourcesIndex::Size() const { - struct stat S; - if (stat(IndexFile("Sources").c_str(),&S) != 0) + FileFd f = FileFd (IndexFile("Sources"), FileFd::ReadOnlyGzip); + + if (f.Failed()) return 0; - return S.st_size; + return f.Size(); } /*}}}*/ @@ -268,10 +269,11 @@ bool debPackagesIndex::Exists() const /* This is really only used for progress reporting. */ unsigned long debPackagesIndex::Size() const { - struct stat S; - if (stat(IndexFile("Packages").c_str(),&S) != 0) + FileFd f = FileFd (IndexFile("Packages"), FileFd::ReadOnlyGzip); + + if (f.Failed()) return 0; - return S.st_size; + return f.Size(); } /*}}}*/ // PackagesIndex::Merge - Load the index file into a cache /*{{{*/ @@ -458,10 +460,12 @@ bool debTranslationsIndex::Exists() const /* This is really only used for progress reporting. */ unsigned long debTranslationsIndex::Size() const { - struct stat S; - if (stat(IndexFile(Language).c_str(),&S) != 0) + FileFd f = FileFd (IndexFile(Language), FileFd::ReadOnlyGzip); + + if (f.Failed()) return 0; - return S.st_size; + + return f.Size(); } /*}}}*/ // TranslationsIndex::Merge - Load the index file into a cache /*{{{*/ diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index ab08a8f4d..8619822df 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -164,8 +164,8 @@ bool debSystem::Initialize(Configuration &Cnf) /* These really should be jammed into a generic 'Local Database' engine which is yet to be determined. The functions in pkgcachegen should be the only users of these */ - Cnf.CndSet("Dir::State::extended_states", Cnf.FindDir("Dir::State").append("extended_states")); - Cnf.CndSet("Dir::State::status", Cnf.FindDir("Dir", "/").append("var/lib/dpkg/status")); + Cnf.CndSet("Dir::State::extended_states", "extended_states"); + Cnf.CndSet("Dir::State::status","/var/lib/dpkg/status"); Cnf.CndSet("Dir::Bin::dpkg","/usr/bin/dpkg"); if (StatusFile) { |