From 117ab302176a65536d9d55de30c53e94f08057ae Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 11 Apr 2018 12:39:40 +0200 Subject: Start pkg records for deb files with dpkg output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is easier to prepend our fields, but that results in confusion for things working on the so generated records as they don't start with the usual "Package" – that shouldn't be a problem in theory, but in practice e.g. "apt-cache show" shows these records directly to the user who will probably be more confused by it than tools. --- apt-pkg/deb/debindexfile.cc | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index 10ebd1d3e..f7e3c7a5c 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -185,28 +185,22 @@ bool debDebPkgFileIndex::GetContent(std::ostream &content, std::string const &de if(Popen((const char**)&Args[0], PipeFd, Child, FileFd::ReadOnly) == false) return _error->Error("Popen failed"); - content << "Filename: " << debfile << "\n"; - content << "Size: " << std::to_string(Buf.st_size) << "\n"; + std::string line; bool first_line_seen = false; - char buffer[1024]; - do { - unsigned long long actual = 0; - if (PipeFd.Read(buffer, sizeof(buffer)-1, &actual) == false) - return _error->Errno("read", "Failed to read dpkg pipe"); - if (actual == 0) - break; - buffer[actual] = '\0'; - char const * b = buffer; + while (PipeFd.ReadLine(line)) + { if (first_line_seen == false) { - for (; *b != '\0' && (*b == '\n' || *b == '\r'); ++b) - /* skip over leading newlines */; - if (*b == '\0') + if (line.empty()) continue; first_line_seen = true; } - content << b; - } while(true); + else if (line.empty()) + break; + content << line << "\n"; + } + content << "Filename: " << debfile << "\n"; + content << "Size: " << std::to_string(Buf.st_size) << "\n"; ExecWait(Child, "Popen"); return true; -- cgit v1.2.3 From c5e2fa2b772524c03b0c7f777ffea6f2485fe6ca Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 11 Apr 2018 12:45:38 +0200 Subject: Deprectate buggy/incorrect Rls/PkgFile::IsOk methods With the advent of compressed files and especially with in-memory post-processed files the simple assumptions made in IsOk are no longer true. Worse, they are at best duplicates of checks performed by the cache generation (and validation) earlier and isn't used in too many places. It is hence best to simply get right of these calls instead of trying to fix them. --- apt-pkg/cacheiterators.h | 2 ++ apt-pkg/pkgcache.cc | 14 -------------- 2 files changed, 2 insertions(+), 14 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 52915aae4..20853061e 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -422,6 +422,7 @@ class pkgCache::RlsFileIterator : public Iterator inline const char *Site() const {return S->Site == 0?0:Owner->StrP + S->Site;} inline bool Flagged(pkgCache::Flag::ReleaseFileFlags const flag) const {return (S->Flags & flag) == flag; } + APT_DEPRECATED_MSG("Can be remove without replacement; it is a no-op") bool IsOk(); std::string RelStr(); @@ -457,6 +458,7 @@ class pkgCache::PkgFileIterator : public Iterator inline const char *Architecture() const {return S->Architecture == 0?0:Owner->StrP + S->Architecture;} inline const char *IndexType() const {return S->IndexType == 0?0:Owner->StrP + S->IndexType;} + APT_DEPRECATED_MSG("Can be remove without replacement; it is a no-op") bool IsOk(); std::string RelStr(); diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 6b9c645a4..92f0cb777 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -968,13 +968,6 @@ const char * pkgCache::VerIterator::MultiArchType() const included here. */ bool pkgCache::RlsFileIterator::IsOk() { - struct stat Buf; - if (stat(FileName(),&Buf) != 0) - return false; - - if (Buf.st_size != (signed)S->Size || Buf.st_mtime != S->mtime) - return false; - return true; } /*}}}*/ @@ -1002,13 +995,6 @@ string pkgCache::RlsFileIterator::RelStr() included here. */ bool pkgCache::PkgFileIterator::IsOk() { - struct stat Buf; - if (stat(FileName(),&Buf) != 0) - return false; - - if (Buf.st_size != (signed)S->Size || Buf.st_mtime != S->mtime) - return false; - return true; } /*}}}*/ -- cgit v1.2.3