diff options
Diffstat (limited to 'apt-pkg')
74 files changed, 1244 insertions, 1533 deletions
diff --git a/apt-pkg/CMakeLists.txt b/apt-pkg/CMakeLists.txt index ce73c6a34..efa680f6b 100644 --- a/apt-pkg/CMakeLists.txt +++ b/apt-pkg/CMakeLists.txt @@ -4,7 +4,7 @@ include_directories(${PROJECT_BINARY_DIR}/include/apt-pkg) add_definitions("-DAPT_PKG_EXPOSE_STRING_VIEW") file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/apt-pkg/) -execute_process(COMMAND ${PERL_EXECUTABLE} ${PROJECT_SOURCE_DIR}/triehash/triehash.pl +execute_process(COMMAND ${TRIEHASH_EXECUTABLE} --ignore-case --header ${PROJECT_BINARY_DIR}/include/apt-pkg/tagfile-keys.h --code ${CMAKE_CURRENT_BINARY_DIR}/tagfile-keys.cc @@ -29,6 +29,8 @@ execute_process(COMMAND grep "^#define APT_PKG_RELEASE" message(STATUS "Building libapt-pkg ${MAJOR} (release ${MINOR})") set(APT_PKG_MAJOR ${MAJOR} PARENT_SCOPE) # exporting for methods/CMakeLists.txt +configure_file(apt-pkg.pc.in ${CMAKE_CURRENT_BINARY_DIR}/apt-pkg.pc @ONLY) + # Definition of the C++ files used to build the library - note that this # is expanded at CMake time, so you have to rerun cmake if you add or remove # a file (you can just run cmake . in the build directory) @@ -69,6 +71,7 @@ add_version_script(apt-pkg) # Install the library and the header files install(TARGETS apt-pkg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/apt-pkg) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/apt-pkg.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) flatify(${PROJECT_BINARY_DIR}/include/apt-pkg/ "${headers}") if(CMAKE_BUILD_TYPE STREQUAL "Coverage") diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index bb3bc1b56..cbfc91007 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -770,15 +770,13 @@ class APT_HIDDEN CleanupItem : public pkgAcqTransactionItem /*{{{*/ /*}}}*/ // Acquire::Item::Item - Constructor /*{{{*/ -APT_IGNORE_DEPRECATED_PUSH pkgAcquire::Item::Item(pkgAcquire * const owner) : - FileSize(0), PartialSize(0), Mode(0), ID(0), Complete(false), Local(false), + FileSize(0), PartialSize(0), ID(0), Complete(false), Local(false), QueueCounter(0), ExpectedAdditionalItems(0), Owner(owner), d(new Private()) { Owner->Add(this); Status = StatIdle; } -APT_IGNORE_DEPRECATED_POP /*}}}*/ // Acquire::Item::~Item - Destructor /*{{{*/ pkgAcquire::Item::~Item() @@ -1120,15 +1118,6 @@ bool pkgAcquire::Item::RenameOnError(pkgAcquire::Item::RenameOnErrorState const void pkgAcquire::Item::SetActiveSubprocess(const std::string &subprocess)/*{{{*/ { ActiveSubprocess = subprocess; - APT_IGNORE_DEPRECATED_PUSH - Mode = ActiveSubprocess.c_str(); - APT_IGNORE_DEPRECATED_POP -} - /*}}}*/ -// Acquire::Item::ReportMirrorFailure /*{{{*/ -void pkgAcquire::Item::ReportMirrorFailure(std::string const &FailCode) -{ - ReportMirrorFailureToCentral(*this, FailCode, FailCode); } /*}}}*/ std::string pkgAcquire::Item::HashSum() const /*{{{*/ @@ -3346,11 +3335,10 @@ pkgAcqIndex::~pkgAcqIndex() {} // --------------------------------------------------------------------- /* This just sets up the initial fetch environment and queues the first possibilitiy */ -APT_IGNORE_DEPRECATED_PUSH pkgAcqArchive::pkgAcqArchive(pkgAcquire *const Owner, pkgSourceList *const Sources, pkgRecords *const Recs, pkgCache::VerIterator const &Version, string &StoreFilename) : Item(Owner), d(NULL), LocalSource(false), Version(Version), Sources(Sources), Recs(Recs), - StoreFilename(StoreFilename), Vf(), + StoreFilename(StoreFilename), Trusted(false) { if (Version.Arch() == 0) @@ -3539,7 +3527,6 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *const Owner, pkgSourceList *const Sourc Local = false; QueueURI(Desc); } -APT_IGNORE_DEPRECATED_POP /*}}}*/ bool pkgAcqArchive::QueueNext() /*{{{*/ { @@ -3865,11 +3852,10 @@ pkgAcqChangelog::~pkgAcqChangelog() /*{{{*/ /*}}}*/ // AcqFile::pkgAcqFile - Constructor /*{{{*/ -APT_IGNORE_DEPRECATED_PUSH pkgAcqFile::pkgAcqFile(pkgAcquire *const Owner, string const &URI, HashStringList const &Hashes, unsigned long long const Size, string const &Dsc, string const &ShortDesc, const string &DestDir, const string &DestFilename, - bool const IsIndexFile) : Item(Owner), d(NULL), Retries(0), IsIndexFile(IsIndexFile), ExpectedHashes(Hashes) + bool const IsIndexFile) : Item(Owner), d(NULL), IsIndexFile(IsIndexFile), ExpectedHashes(Hashes) { if(!DestFilename.empty()) DestFile = DestFilename; @@ -3900,7 +3886,6 @@ pkgAcqFile::pkgAcqFile(pkgAcquire *const Owner, string const &URI, HashStringLis QueueURI(Desc); } -APT_IGNORE_DEPRECATED_POP /*}}}*/ // AcqFile::Done - Item downloaded OK /*{{{*/ void pkgAcqFile::Done(string const &Message,HashStringList const &CalcHashes, diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 70651d9e3..a45e9f7a4 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -102,11 +102,6 @@ class pkgAcquire::Item : public WeakPointable /*{{{*/ /** \brief How much of the object was already fetched. */ unsigned long long PartialSize; - /** \brief If not \b NULL, contains the name of a subprocess that - * is operating on this object (for instance, "gzip" or "gpgv"). - */ - APT_DEPRECATED_MSG("Use the std::string member ActiveSubprocess instead") const char *Mode; - /** \brief contains the name of the subprocess that is operating on this object * (for instance, "gzip", "rred" or "gpgv"). This is obsoleting #Mode from above * as it can manage the lifetime of included string properly. */ @@ -284,15 +279,6 @@ class pkgAcquire::Item : public WeakPointable /*{{{*/ /** \return \b true if this object is being fetched from a trusted source. */ virtual bool IsTrusted() const; - /** \brief Report mirror problem - * - * This allows reporting mirror failures back to a centralized - * server. The apt-report-mirror-failure script is called for this - * - * \param FailCode A short failure string that is send - */ - APT_DEPRECATED_MSG("Item::Failed does this for you") void ReportMirrorFailure(std::string const &FailCode); - /** \brief Set the name of the current active subprocess * * See also #ActiveSubprocess @@ -983,18 +969,6 @@ class pkgAcqArchive : public pkgAcquire::Item */ std::string &StoreFilename; - /** \brief The next file for this version to try to download. */ - APT_DEPRECATED_MSG("Unused member") - pkgCache::VerFileIterator Vf; - - /** \brief How many (more) times to try to find a new source from - * which to download this package version if it fails. - * - * Set from Acquire::Retries. - */ - APT_DEPRECATED_MSG("Unused member. See pkgAcqItem::Retries.") - unsigned int Retries; - /** \brief \b true if this version file is being downloaded from a * trusted source. */ @@ -1167,12 +1141,6 @@ class pkgAcqFile : public pkgAcquire::Item { void * const d; - /** \brief How many times to retry the download, set from - * Acquire::Retries. - */ - APT_DEPRECATED_MSG("Unused member. See pkgAcqItem::Retries.") - unsigned int Retries; - /** \brief Should this file be considered a index file */ bool IsIndexFile; diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc index b36186121..32fcde181 100644 --- a/apt-pkg/acquire-worker.cc +++ b/apt-pkg/acquire-worker.cc @@ -44,7 +44,7 @@ using namespace std; // Worker::Worker - Constructor for Queue startup /*{{{*/ pkgAcquire::Worker::Worker(Queue *Q, MethodConfig *Cnf, pkgAcquireStatus *log) : d(NULL), OwnerQ(Q), Log(log), Config(Cnf), Access(Cnf->Access), - CurrentItem(nullptr), CurrentSize(0), TotalSize(0) + CurrentItem(nullptr) { Construct(); } @@ -369,12 +369,12 @@ bool pkgAcquire::Worker::RunMessages() } CurrentItem = Itm; - CurrentSize = 0; - TotalSize = strtoull(LookupTag(Message,"Size","0").c_str(), NULL, 10); - ResumePoint = strtoull(LookupTag(Message,"Resume-Point","0").c_str(), NULL, 10); + Itm->CurrentSize = 0; + Itm->TotalSize = strtoull(LookupTag(Message,"Size","0").c_str(), NULL, 10); + Itm->ResumePoint = strtoull(LookupTag(Message,"Resume-Point","0").c_str(), NULL, 10); for (auto const Owner: Itm->Owners) { - Owner->Start(Message, TotalSize); + Owner->Start(Message, Itm->TotalSize); // Display update before completion if (Log != nullptr) { @@ -766,7 +766,7 @@ bool pkgAcquire::Worker::QueueItem(pkgAcquire::Queue::QItem *Item) Message += "URI: " + Item->URI; Message += "\nFilename: " + Item->Owner->DestFile; - URI URL = Item->URI; + URI URL(Item->URI); // FIXME: We should not hard code proxy protocols here. if (URL.Access == "http" || URL.Access == "https") { @@ -918,7 +918,7 @@ void pkgAcquire::Worker::Pulse() struct stat Buf; if (stat(CurrentItem->Owner->DestFile.c_str(),&Buf) != 0) return; - CurrentSize = Buf.st_size; + CurrentItem->CurrentSize = Buf.st_size; } /*}}}*/ // Worker::ItemDone - Called when the current item is finished /*{{{*/ @@ -926,9 +926,7 @@ void pkgAcquire::Worker::Pulse() /* */ void pkgAcquire::Worker::ItemDone() { - CurrentItem = 0; - CurrentSize = 0; - TotalSize = 0; + CurrentItem = nullptr; Status = string(); } /*}}}*/ diff --git a/apt-pkg/acquire-worker.h b/apt-pkg/acquire-worker.h index 11e54b060..b6d1628f9 100644 --- a/apt-pkg/acquire-worker.h +++ b/apt-pkg/acquire-worker.h @@ -251,21 +251,6 @@ class pkgAcquire::Worker : public WeakPointable */ std::string Status; - /** \brief How many bytes of the file have been downloaded. Zero - * if the current progress of the file cannot be determined. - */ - unsigned long long CurrentSize; - - /** \brief The total number of bytes to be downloaded. Zero if the - * total size of the final is unknown. - */ - unsigned long long TotalSize; - - /** \brief How much of the file was already downloaded prior to - * starting this worker. - */ - unsigned long long ResumePoint; - /** \brief Tell the subprocess to download the given item. * * \param Item the item to queue up. diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 541785b03..8bb72d549 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -127,25 +127,6 @@ static bool SetupAPTPartialDirectory(std::string const &grand, std::string const return true; } -bool pkgAcquire::Setup(pkgAcquireStatus *Progress, string const &Lock) -{ - Log = Progress; - if (Lock.empty()) - { - string const listDir = _config->FindDir("Dir::State::lists"); - if (SetupAPTPartialDirectory(_config->FindDir("Dir::State"), listDir, "partial", 0700) == false) - return _error->Errno("Acquire", _("List directory %s is missing."), (listDir + "partial").c_str()); - if (SetupAPTPartialDirectory(_config->FindDir("Dir::State"), listDir, "auxfiles", 0755) == false) - { - // not being able to create lists/auxfiles isn't critical as we will use a tmpdir then - } - string const archivesDir = _config->FindDir("Dir::Cache::Archives"); - if (SetupAPTPartialDirectory(_config->FindDir("Dir::Cache"), archivesDir, "partial", 0700) == false) - return _error->Errno("Acquire", _("Archives directory %s is missing."), (archivesDir + "partial").c_str()); - return true; - } - return GetLock(Lock); -} bool pkgAcquire::GetLock(std::string const &Lock) { if (Lock.empty() == true) @@ -415,6 +396,7 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config) if (Config->SingleInstance == true || QueueMode == QueueAccess) return U.Access; + int Limit = 10; string AccessSchema = U.Access + ':'; string FullQueueName; @@ -433,15 +415,15 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config) #ifdef _SC_NPROCESSORS_ONLN long cpuCount = sysconf(_SC_NPROCESSORS_ONLN) * 2; #else - long cpuCount = 10; + long cpuCount = Limit; #endif - cpuCount = _config->FindI("Acquire::QueueHost::Limit", cpuCount); + Limit = _config->FindI("Acquire::QueueHost::Limit", cpuCount); - if (cpuCount <= 0 || existing < cpuCount) + if (Limit <= 0 || existing < Limit) strprintf(FullQueueName, "%s%ld", AccessSchema.c_str(), existing); else { - long const randomQueue = random() % cpuCount; + long const randomQueue = random() % Limit; strprintf(FullQueueName, "%s%ld", AccessSchema.c_str(), randomQueue); } @@ -449,6 +431,7 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config) clog << "Chose random queue " << FullQueueName << " for " << Uri << endl; } else { + Limit = _config->FindI("Acquire::QueueHost::Limit", Limit); FullQueueName = AccessSchema + U.Host; } unsigned int Instances = 0, SchemaLength = AccessSchema.length(); @@ -467,7 +450,7 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config) clog << "Found " << Instances << " instances of " << U.Access << endl; } - if (Instances >= static_cast<decltype(Instances)>(_config->FindI("Acquire::QueueHost::Limit",10))) + if (Instances >= static_cast<decltype(Instances)>(Limit)) return U.Access; return FullQueueName; @@ -654,7 +637,7 @@ static void CheckDropPrivsMustBeDisabled(pkgAcquire const &Fetcher) // if its the source file (e.g. local sources) we might be lucky // by dropping the dropping only for some methods. - URI const source = (*I)->DescURI(); + URI const source((*I)->DescURI()); if (source.Access == "file" || source.Access == "copy") { std::string const conf = "Binary::" + source.Access + "::APT::Sandbox::User"; @@ -1301,13 +1284,13 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) { if (I->CurrentItem != 0 && I->CurrentItem->Owner->Complete == false) { - CurrentBytes += I->CurrentSize; - ResumeSize += I->ResumePoint; + CurrentBytes += I->CurrentItem->CurrentSize; + ResumeSize += I->CurrentItem->ResumePoint; // Files with unknown size always have 100% completion if (I->CurrentItem->Owner->FileSize == 0 && I->CurrentItem->Owner->Complete == false) - TotalBytes += I->CurrentSize; + TotalBytes += I->CurrentItem->CurrentSize; } } @@ -1444,9 +1427,8 @@ void pkgAcquireStatus::Fetched(unsigned long long Size,unsigned long long Resume /*}}}*/ bool pkgAcquireStatus::ReleaseInfoChanges(metaIndex const * const LastRelease, metaIndex const * const CurrentRelease, std::vector<ReleaseInfoChange> &&Changes)/*{{{*/ { - auto const virt = dynamic_cast<pkgAcquireStatus2*>(this); - if (virt != nullptr) - return virt->ReleaseInfoChanges(LastRelease, CurrentRelease, std::move(Changes)); + (void) LastRelease; + (void) CurrentRelease; return ReleaseInfoChangesAsGlobalErrors(std::move(Changes)); } /*}}}*/ @@ -1464,12 +1446,6 @@ bool pkgAcquireStatus::ReleaseInfoChangesAsGlobalErrors(std::vector<ReleaseInfoC return AllOkay; } /*}}}*/ -bool pkgAcquireStatus2::ReleaseInfoChanges(metaIndex const * const, metaIndex const * const, std::vector<ReleaseInfoChange> &&Changes) -{ - return ReleaseInfoChangesAsGlobalErrors(std::move(Changes)); -} -pkgAcquireStatus2::pkgAcquireStatus2() : pkgAcquireStatus() {} -pkgAcquireStatus2::~pkgAcquireStatus2() {} pkgAcquire::UriIterator::UriIterator(pkgAcquire::Queue *Q) : d(NULL), CurQ(Q), CurItem(0) diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 1cf4da5bf..a5c10fd92 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -353,20 +353,6 @@ class pkgAcquire */ unsigned long long PartialPresent(); - /** \brief Delayed constructor - * - * \param Progress indicator associated with this download or - * \b NULL for none. This object is not owned by the - * download process and will not be deleted when the pkgAcquire - * object is destroyed. Naturally, it should live for at least as - * long as the pkgAcquire object does. - * \param Lock defines a lock file that should be acquired to ensure - * only one Acquire class is in action at the time or an empty string - * if no lock file should be used. If set also all needed directories - * will be created. - */ - APT_DEPRECATED_MSG("Use constructors, .SetLog and .GetLock as needed") bool Setup(pkgAcquireStatus *Progress = NULL, std::string const &Lock = ""); - void SetLog(pkgAcquireStatus *Progress) { Log = Progress; } /** \brief acquire lock and perform directory setup @@ -439,6 +425,21 @@ class pkgAcquire::Queue /** \brief The underlying items interested in the download */ std::vector<Item*> Owners; + /** \brief How many bytes of the file have been downloaded. Zero + * if the current progress of the file cannot be determined. + */ + unsigned long long CurrentSize = 0; + + /** \brief The total number of bytes to be downloaded. Zero if the + * total size of the final is unknown. + */ + unsigned long long TotalSize = 0; + + /** \brief How much of the file was already downloaded prior to + * starting this worker. + */ + unsigned long long ResumePoint = 0; + typedef std::vector<Item*>::const_iterator owner_iterator; /** \brief Assign the ItemDesc portion of this QItem from @@ -819,17 +820,13 @@ class pkgAcquireStatus * success it will print for each change the message attached to it via GlobalError either as an * error (if DefaultAction == false) or as a notice otherwise. * - * \b Note: To keep ABI compatibility for now this method isn't marked as - * virtual, but you can derive your class from #pkgAcquireStatus2 which has it - * marked as virtual. TODO on next ABI break: merge both classes. - * * @param LastRelease can be used to extract further information from the previous Release file * @param CurrentRelease can be used to extract further information from the current Release file * @param Changes is an array of changes alongside explanatory messages * which should be presented in some way to the user. * @return \b true if all changes are accepted by user, otherwise or if user can't be asked \b false */ - bool ReleaseInfoChanges(metaIndex const * const LastRelease, metaIndex const * const CurrentRelease, std::vector<ReleaseInfoChange> &&Changes); + virtual bool ReleaseInfoChanges(metaIndex const * const LastRelease, metaIndex const * const CurrentRelease, std::vector<ReleaseInfoChange> &&Changes); APT_HIDDEN static bool ReleaseInfoChangesAsGlobalErrors(std::vector<ReleaseInfoChange> &&Changes); /** \brief Invoked when an item is confirmed to be up-to-date. @@ -872,14 +869,6 @@ class pkgAcquireStatus pkgAcquireStatus(); virtual ~pkgAcquireStatus(); }; -class pkgAcquireStatus2: public pkgAcquireStatus -{ -public: - virtual bool ReleaseInfoChanges(metaIndex const * const LastRelease, metaIndex const * const CurrentRelease, std::vector<ReleaseInfoChange> &&Changes); - - pkgAcquireStatus2(); - virtual ~pkgAcquireStatus2(); -}; /*}}}*/ /** @} */ diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index bb0e2f873..4d4adde3c 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1343,32 +1343,6 @@ bool pkgProblemResolver::ResolveByKeepInternal() return true; } /*}}}*/ -// ProblemResolver::InstallProtect - deprecated cpu-eating no-op /*{{{*/ -// --------------------------------------------------------------------- -/* Actions issued with FromUser bit set are protected from further - modification (expect by other calls with FromUser set) nowadays , so we - don't need to reissue actions here, they are already set in stone. */ -void pkgProblemResolver::InstallProtect() -{ - pkgDepCache::ActionGroup group(Cache); - - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) - { - if ((Flags[I->ID] & Protected) == Protected) - { - if ((Flags[I->ID] & ToRemove) == ToRemove) - Cache.MarkDelete(I); - else - { - // preserve the information whether the package was auto - // or manually installed - bool autoInst = (Cache[I].Flags & pkgCache::Flag::Auto); - Cache.MarkInstall(I, false, 0, !autoInst); - } - } - } -} - /*}}}*/ // PrioSortList - Sort a list of versions by priority /*{{{*/ // --------------------------------------------------------------------- /* This is meant to be used in conjunction with AllTargets to get a list diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h index c5c9f4c69..f6a1ce1fb 100644 --- a/apt-pkg/algorithms.h +++ b/apt-pkg/algorithms.h @@ -147,8 +147,6 @@ class pkgProblemResolver /*{{{*/ bool ResolveByKeep(OpProgress * const Progress = NULL); APT_HIDDEN bool ResolveByKeepInternal(); - APT_DEPRECATED_MSG("NOOP as MarkInstall enforces not overriding FromUser markings") void InstallProtect(); - explicit pkgProblemResolver(pkgDepCache *Cache); virtual ~pkgProblemResolver(); }; diff --git a/apt-pkg/apt-pkg.pc.in b/apt-pkg/apt-pkg.pc.in new file mode 100644 index 000000000..c6491d921 --- /dev/null +++ b/apt-pkg/apt-pkg.pc.in @@ -0,0 +1,8 @@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: apt-pkg +Description: package management runtime library +Version: @PROJECT_VERSION@ +Libs: -L${libdir} -lapt-pkg -pthread +Cflags: -I${includedir} diff --git a/apt-pkg/cachefile.h b/apt-pkg/cachefile.h index ed5d5c57c..998145ee6 100644 --- a/apt-pkg/cachefile.h +++ b/apt-pkg/cachefile.h @@ -65,13 +65,11 @@ class pkgCacheFile inline unsigned char &operator [](pkgCache::DepIterator const &I) const {return (*DCache)[I];}; bool BuildCaches(OpProgress *Progress = NULL,bool WithLock = true); - APT_DEPRECATED_MSG("Pass Progress in as a pointer") bool BuildCaches(OpProgress &Progress,bool const &WithLock = true) { return BuildCaches(&Progress, WithLock); }; bool BuildSourceList(OpProgress *Progress = NULL); bool BuildPolicy(OpProgress *Progress = NULL); bool BuildDepCache(OpProgress *Progress = NULL); bool Open(OpProgress *Progress = NULL, bool WithLock = true); inline bool ReadOnlyOpen(OpProgress *Progress = NULL) { return Open(Progress, false); }; - APT_DEPRECATED_MSG("Pass Progress in as a pointer") bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); }; static void RemoveCaches(); void Close(); diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 20853061e..27daf4c43 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -164,9 +164,6 @@ class pkgCache::PkgIterator: public Iterator<Package, PkgIterator> { // Accessors inline const char *Name() const { return Group().Name(); } - // Versions have sections - and packages can have different versions with different sections - // so this interface is broken by design. Run as fast as you can to Version.Section(). - APT_DEPRECATED_MSG("Use the .Section method of VerIterator instead") inline const char *Section() const; inline bool Purge() const {return S->CurrentState == pkgCache::State::Purge || (S->CurrentVer == 0 && S->CurrentState == pkgCache::State::NotInstalled);} inline const char *Arch() const {return S->Arch == 0?0:Owner->StrP + S->Arch;} @@ -177,7 +174,6 @@ class pkgCache::PkgIterator: public Iterator<Package, PkgIterator> { inline DepIterator RevDependsList() const APT_PURE; inline PrvIterator ProvidesList() const APT_PURE; OkState State() const APT_PURE; - APT_DEPRECATED_MSG("This method does not respect apt_preferences! Use pkgDepCache::GetCandidateVersion(Pkg)") const char *CandVersion() const APT_PURE; const char *CurVersion() const APT_PURE; //Nice printable representation @@ -422,8 +418,6 @@ class pkgCache::RlsFileIterator : public Iterator<ReleaseFile, RlsFileIterator> 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(); // Constructors @@ -458,8 +452,6 @@ class pkgCache::PkgFileIterator : public Iterator<PackageFile, PkgFileIterator> 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(); // Constructors @@ -525,7 +517,5 @@ inline pkgCache::VerFileIterator pkgCache::VerIterator::FileList() const {return VerFileIterator(*Owner,Owner->VerFileP + S->FileList);} inline pkgCache::DescFileIterator pkgCache::DescIterator::FileList() const {return DescFileIterator(*Owner,Owner->DescFileP + S->FileList);} -APT_DEPRECATED_MSG("Use the .Section method of VerIterator instead") inline const char * pkgCache::PkgIterator::Section() const - {return S->VersionList == 0 ? 0 : VersionList().Section();} /*}}}*/ #endif diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index 670cdba3a..0c0f213b7 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -231,33 +231,6 @@ bool CacheSetHelper::PackageFromFnmatch(PackageContainerInterface * const pci, return true; } /*}}}*/ -// PackageFromName - Returns the package defined by this string /*{{{*/ -pkgCache::PkgIterator CacheSetHelper::PackageFromName(pkgCacheFile &Cache, - std::string const &str) { - std::string pkg = str; - size_t archfound = pkg.find_last_of(':'); - std::string arch; - if (archfound != std::string::npos) { - arch = pkg.substr(archfound+1); - pkg.erase(archfound); - } - - if (Cache.GetPkgCache() == 0) - return pkgCache::PkgIterator(Cache, 0); - - pkgCache::PkgIterator Pkg(Cache, 0); - if (arch.empty() == true) { - pkgCache::GrpIterator Grp = Cache.GetPkgCache()->FindGrp(pkg); - if (Grp.end() == false) - Pkg = Grp.FindPreferredPkg(); - } else - Pkg = Cache.GetPkgCache()->FindPkg(pkg, arch); - - if (Pkg.end() == true) - return canNotFindPkgName(Cache, str); - return Pkg; -} - /*}}}*/ // PackageFromPackageName - Returns the package defined by this string /*{{{*/ bool CacheSetHelper::PackageFromPackageName(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pkg) { diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h index b00fc7318..934f6611c 100644 --- a/apt-pkg/cacheset.h +++ b/apt-pkg/cacheset.h @@ -75,7 +75,6 @@ public: /*{{{*/ pkgCacheFile &Cache, const char * cmdline, std::list<PkgModifier> const &mods); - APT_DEPRECATED_MSG("use .PackageFrom(PACKAGENAME, …) instead") pkgCache::PkgIterator PackageFromName(pkgCacheFile &Cache, std::string const &pattern); /** \brief be notified about the package being selected via pattern * @@ -311,11 +310,6 @@ public: inline const char *Name() const {return getType().Name(); } inline std::string FullName(bool const Pretty) const { return getType().FullName(Pretty); } inline std::string FullName() const { return getType().FullName(); } - APT_DEPRECATED_MSG("Use the .Section method of VerIterator instead") inline const char *Section() const { - APT_IGNORE_DEPRECATED_PUSH - return getType().Section(); - APT_IGNORE_DEPRECATED_POP - } inline bool Purge() const {return getType().Purge(); } inline const char *Arch() const {return getType().Arch(); } inline pkgCache::GrpIterator Group() const { return getType().Group(); } @@ -324,7 +318,6 @@ public: inline pkgCache::DepIterator RevDependsList() const { return getType().RevDependsList(); } inline pkgCache::PrvIterator ProvidesList() const { return getType().ProvidesList(); } inline pkgCache::PkgIterator::OkState State() const { return getType().State(); } - APT_DEPRECATED_MSG("This method does not respect apt_preferences! Use pkgDepCache::GetCandidateVersion(Pkg)") inline const char *CandVersion() const { return getType().CandVersion(); } inline const char *CurVersion() const { return getType().CurVersion(); } inline pkgCache *Cache() const { return getType().Cache(); } inline unsigned long Index() const {return getType().Index();} @@ -340,14 +333,6 @@ public: virtual void clear() = 0; virtual size_t size() const = 0; - enum APT_DEPRECATED_MSG("Use CacheSetHelper::PkgSelector instead") Constructor { UNKNOWN = CacheSetHelper::UNKNOWN, - REGEX = CacheSetHelper::REGEX, - TASK = CacheSetHelper::TASK, - FNMATCH = CacheSetHelper::FNMATCH }; -APT_IGNORE_DEPRECATED_PUSH - void setConstructor(Constructor const by) { ConstructedBy = (CacheSetHelper::PkgSelector)by; } -APT_IGNORE_DEPRECATED_POP - void setConstructor(CacheSetHelper::PkgSelector const by) { ConstructedBy = by; } CacheSetHelper::PkgSelector getConstructor() const { return ConstructedBy; } PackageContainerInterface(); @@ -355,30 +340,6 @@ APT_IGNORE_DEPRECATED_POP PackageContainerInterface& operator=(PackageContainerInterface const &other); virtual ~PackageContainerInterface(); - APT_DEPRECATED_MSG("Use helper.PackageFrom(CacheSetHelper::TASK, …) instead") static bool FromTask(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper) { - return helper.PackageFrom(CacheSetHelper::TASK, pci, Cache, pattern); } - APT_DEPRECATED_MSG("Use helper.PackageFrom(CacheSetHelper::REGEX, …) instead") static bool FromRegEx(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper) { - return helper.PackageFrom(CacheSetHelper::REGEX, pci, Cache, pattern); } - APT_DEPRECATED_MSG("Use helper.PackageFrom(CacheSetHelper::FNMATCH, …) instead") static bool FromFnmatch(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper) { - return helper.PackageFrom(CacheSetHelper::FNMATCH, pci, Cache, pattern); } - APT_DEPRECATED_MSG("Use helper.PackageFrom(CacheSetHelper::PACKAGENAME, …) instead") static bool FromGroup(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper) { - return helper.PackageFrom(CacheSetHelper::PACKAGENAME, pci, Cache, pattern); } - APT_DEPRECATED_MSG("Use helper.PackageFrom(CacheSetHelper::STRING, …) instead") static bool FromString(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &pattern, CacheSetHelper &helper) { - return helper.PackageFrom(CacheSetHelper::STRING, pci, Cache, pattern); } - APT_DEPRECATED_MSG("Use helper.PackageFromCommandLine instead") static bool FromCommandLine(PackageContainerInterface * const pci, pkgCacheFile &Cache, const char **cmdline, CacheSetHelper &helper) { - return helper.PackageFromCommandLine(pci, Cache, cmdline); } - - APT_DEPRECATED_MSG("enum moved to CacheSetHelper::PkgModifier") typedef CacheSetHelper::PkgModifier Modifier; - -APT_IGNORE_DEPRECATED_PUSH - APT_DEPRECATED_MSG("Use helper.PackageFromName instead") static pkgCache::PkgIterator FromName(pkgCacheFile &Cache, std::string const &pattern, CacheSetHelper &helper) { - return helper.PackageFromName(Cache, pattern); } - APT_DEPRECATED_MSG("Use helper.PackageFromModifierCommandLine instead") static bool FromModifierCommandLine(unsigned short &modID, PackageContainerInterface * const pci, - pkgCacheFile &Cache, const char * cmdline, - std::list<Modifier> const &mods, CacheSetHelper &helper) { - return helper.PackageFromModifierCommandLine(modID, pci, Cache, cmdline, mods); } -APT_IGNORE_DEPRECATED_POP - private: CacheSetHelper::PkgSelector ConstructedBy; void * const d; @@ -438,9 +399,6 @@ public: /*{{{*/ PackageContainer() : PackageContainerInterface(CacheSetHelper::UNKNOWN) {} explicit PackageContainer(CacheSetHelper::PkgSelector const &by) : PackageContainerInterface(by) {} -APT_IGNORE_DEPRECATED_PUSH - APT_DEPRECATED_MSG("Construct with a CacheSetHelper::PkgSelector instead") explicit PackageContainer(Constructor const &by) : PackageContainerInterface((CacheSetHelper::PkgSelector)by) {} -APT_IGNORE_DEPRECATED_POP template<typename Itr> PackageContainer(Itr first, Itr last) : PackageContainerInterface(CacheSetHelper::UNKNOWN), _cont(first, last) {} #if __cplusplus >= 201103L PackageContainer(std::initializer_list<value_type> list) : PackageContainerInterface(CacheSetHelper::UNKNOWN), _cont(list) {} @@ -508,21 +466,6 @@ APT_IGNORE_DEPRECATED_POP return FromFnmatch(Cache, pattern, helper); } -APT_IGNORE_DEPRECATED_PUSH - /** \brief returns a package specified by a string - - \param Cache the package is in - \param pattern String the package name should be extracted from - \param helper responsible for error and message handling */ - APT_DEPRECATED_MSG("Use helper.PackageFromName instead") static pkgCache::PkgIterator FromName(pkgCacheFile &Cache, std::string const &pattern, CacheSetHelper &helper) { - return helper.PackageFromName(Cache, pattern); - } - APT_DEPRECATED_MSG("Use helper.PackageFromName instead") static pkgCache::PkgIterator FromName(pkgCacheFile &Cache, std::string const &pattern) { - CacheSetHelper helper; - return FromName(Cache, pattern, helper); - } -APT_IGNORE_DEPRECATED_POP - /** \brief returns all packages specified by a string \param Cache the packages are in @@ -792,17 +735,6 @@ public: virtual void clear() = 0; virtual size_t size() const = 0; - /** \brief specifies which version(s) will be returned if non is given */ - enum APT_DEPRECATED_MSG("enum moved to CacheSetHelper::VerSelector instead") Version { - ALL = CacheSetHelper::ALL, - CANDANDINST = CacheSetHelper::CANDANDINST, - CANDIDATE = CacheSetHelper::CANDIDATE, - INSTALLED = CacheSetHelper::INSTALLED, - CANDINST = CacheSetHelper::CANDINST, - INSTCAND = CacheSetHelper::INSTCAND, - NEWEST = CacheSetHelper::NEWEST - }; - struct Modifier { unsigned short const ID; const char * const Alias; @@ -811,45 +743,20 @@ public: Modifier (unsigned short const &id, const char * const alias, Position const &pos, enum CacheSetHelper::VerSelector const select) : ID(id), Alias(alias), Pos(pos), SelectVersion(select) {} -APT_IGNORE_DEPRECATED_PUSH - APT_DEPRECATED_MSG("Construct with a CacheSetHelper::VerSelector instead") Modifier(unsigned short const &id, const char * const alias, Position const &pos, - Version const &select) : ID(id), Alias(alias), Pos(pos), - SelectVersion((CacheSetHelper::VerSelector)select) {} -APT_IGNORE_DEPRECATED_POP }; static bool FromCommandLine(VersionContainerInterface * const vci, pkgCacheFile &Cache, const char **cmdline, CacheSetHelper::VerSelector const fallback, CacheSetHelper &helper); -APT_IGNORE_DEPRECATED_PUSH - APT_DEPRECATED_MSG("Use CacheSetHelper::VerSelector as fallback selector") static bool FromCommandLine(VersionContainerInterface * const vci, pkgCacheFile &Cache, - const char **cmdline, Version const &fallback, - CacheSetHelper &helper) { - return FromCommandLine(vci, Cache, cmdline, (CacheSetHelper::VerSelector)fallback, helper); - } -APT_IGNORE_DEPRECATED_POP static bool FromString(VersionContainerInterface * const vci, pkgCacheFile &Cache, std::string pkg, CacheSetHelper::VerSelector const fallback, CacheSetHelper &helper, bool const onlyFromName = false); -APT_IGNORE_DEPRECATED_PUSH - APT_DEPRECATED_MSG("Use CacheSetHelper::VerSelector as fallback selector") static bool FromString(VersionContainerInterface * const vci, pkgCacheFile &Cache, - std::string pkg, Version const &fallback, CacheSetHelper &helper, - bool const onlyFromName = false) { - return FromString(vci, Cache, pkg, (CacheSetHelper::VerSelector)fallback, helper, onlyFromName); - } -APT_IGNORE_DEPRECATED_POP + static bool FromPackage(VersionContainerInterface * const vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &P, CacheSetHelper::VerSelector const fallback, CacheSetHelper &helper); -APT_IGNORE_DEPRECATED_PUSH - APT_DEPRECATED_MSG("Use CacheSetHelper::VerSelector as fallback selector") static bool FromPackage(VersionContainerInterface * const vci, pkgCacheFile &Cache, - pkgCache::PkgIterator const &P, Version const &fallback, - CacheSetHelper &helper) { - return FromPackage(vci, Cache, P, (CacheSetHelper::VerSelector)fallback, helper); - } -APT_IGNORE_DEPRECATED_POP static bool FromModifierCommandLine(unsigned short &modID, VersionContainerInterface * const vci, @@ -863,15 +770,6 @@ APT_IGNORE_DEPRECATED_POP pkgCache::DepIterator const &D, CacheSetHelper::VerSelector const selector, CacheSetHelper &helper); -APT_IGNORE_DEPRECATED_PUSH - APT_DEPRECATED_MSG("Use CacheSetHelper::VerSelector as fallback selector") static bool FromDependency(VersionContainerInterface * const vci, - pkgCacheFile &Cache, - pkgCache::DepIterator const &D, - Version const &selector, - CacheSetHelper &helper) { - return FromDependency(vci, Cache, D, (CacheSetHelper::VerSelector)selector, helper); - } -APT_IGNORE_DEPRECATED_POP VersionContainerInterface(); VersionContainerInterface& operator=(VersionContainerInterface const &other); @@ -1008,31 +906,7 @@ public: /*{{{*/ static VersionContainer FromString(pkgCacheFile &Cache, std::string pkg) { return FromString(Cache, pkg, CacheSetHelper::CANDINST); } -APT_IGNORE_DEPRECATED_PUSH - static VersionContainer FromCommandLine(pkgCacheFile &Cache, const char **cmdline, - Version const &fallback, CacheSetHelper &helper) { - VersionContainer vercon; - VersionContainerInterface::FromCommandLine(&vercon, Cache, cmdline, (CacheSetHelper::VerSelector)fallback, helper); - return vercon; - } - static VersionContainer FromCommandLine(pkgCacheFile &Cache, const char **cmdline, - Version const &fallback) { - CacheSetHelper helper; - return FromCommandLine(Cache, cmdline, (CacheSetHelper::VerSelector)fallback, helper); - } - static VersionContainer FromString(pkgCacheFile &Cache, std::string const &pkg, - Version const &fallback, CacheSetHelper &helper, - bool const /*onlyFromName = false*/) { - VersionContainer vercon; - VersionContainerInterface::FromString(&vercon, Cache, pkg, (CacheSetHelper::VerSelector)fallback, helper); - return vercon; - } - static VersionContainer FromString(pkgCacheFile &Cache, std::string pkg, - Version const &fallback) { - CacheSetHelper helper; - return FromString(Cache, pkg, (CacheSetHelper::VerSelector)fallback, helper); - } -APT_IGNORE_DEPRECATED_POP + /** \brief returns all versions specified for the package @@ -1051,19 +925,6 @@ APT_IGNORE_DEPRECATED_POP CacheSetHelper helper; return FromPackage(Cache, P, fallback, helper); } -APT_IGNORE_DEPRECATED_PUSH - static VersionContainer FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &P, - Version const &fallback, CacheSetHelper &helper) { - VersionContainer vercon; - VersionContainerInterface::FromPackage(&vercon, Cache, P, (CacheSetHelper::VerSelector)fallback, helper); - return vercon; - } - static VersionContainer FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &P, - Version const &fallback) { - CacheSetHelper helper; - return FromPackage(Cache, P, (CacheSetHelper::VerSelector)fallback, helper); - } -APT_IGNORE_DEPRECATED_POP static VersionContainer FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &P) { return FromPackage(Cache, P, CacheSetHelper::CANDIDATE); } @@ -1104,19 +965,6 @@ APT_IGNORE_DEPRECATED_POP CacheSetHelper helper; return FromDependency(Cache, D, selector, helper); } -APT_IGNORE_DEPRECATED_PUSH - static VersionContainer FromDependency(pkgCacheFile &Cache, pkgCache::DepIterator const &D, - Version const &selector, CacheSetHelper &helper) { - VersionContainer vercon; - VersionContainerInterface::FromDependency(&vercon, Cache, D, (CacheSetHelper::VerSelector)selector, helper); - return vercon; - } - static VersionContainer FromDependency(pkgCacheFile &Cache, pkgCache::DepIterator const &D, - Version const &selector) { - CacheSetHelper helper; - return FromDependency(Cache, D, (CacheSetHelper::VerSelector)selector, helper); - } -APT_IGNORE_DEPRECATED_POP static VersionContainer FromDependency(pkgCacheFile &Cache, pkgCache::DepIterator const &D) { return FromDependency(Cache, D, CacheSetHelper::CANDIDATE); } diff --git a/apt-pkg/clean.cc b/apt-pkg/clean.cc index f335554a3..9dd56e609 100644 --- a/apt-pkg/clean.cc +++ b/apt-pkg/clean.cc @@ -43,17 +43,9 @@ bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache) if (FileExists(Dir) == false) return true; - auto const withoutChangingDir = dynamic_cast<pkgArchiveCleaner2*>(this); int const dirfd = open(Dir.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC); if (dirfd == -1) return _error->Errno("open",_("Unable to read %s"),Dir.c_str()); - std::string CWD; - if (withoutChangingDir == nullptr) - { - CWD = SafeGetCWD(); - if (fchdir(dirfd) != 0) - return _error->Errno("fchdir",_("Unable to change to %s"),Dir.c_str()); - } DIR * const D = fdopendir(dirfd); if (D == nullptr) return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str()); @@ -131,18 +123,9 @@ bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache) continue; } - if (withoutChangingDir == nullptr) - { - APT_IGNORE_DEPRECATED_PUSH - Erase(Dir->d_name, Pkg, Ver, St); - APT_IGNORE_DEPRECATED_POP - } - else - withoutChangingDir->Erase(dirfd, Dir->d_name, Pkg, Ver, St); + Erase(dirfd, Dir->d_name, Pkg, Ver, St); } closedir(D); - if (withoutChangingDir == nullptr && chdir(CWD.c_str()) != 0) - return _error->Errno("chdir", _("Unable to change to %s"),Dir.c_str()); return true; } /*}}}*/ diff --git a/apt-pkg/clean.h b/apt-pkg/clean.h index d6490a0c5..a64e6a935 100644 --- a/apt-pkg/clean.h +++ b/apt-pkg/clean.h @@ -25,8 +25,9 @@ class pkgArchiveCleaner void * const d; protected: - - APT_DEPRECATED_MSG("Use pkgArchiveCleaner2 to avoid CWD expectations and chdir") virtual void Erase(const char * /*File*/,std::string /*Pkg*/,std::string /*Ver*/,struct stat & /*St*/) {}; + virtual void Erase(int const dirfd, char const * const File, + std::string const &Pkg,std::string const &Ver, + struct stat const &St) = 0; public: @@ -35,15 +36,6 @@ class pkgArchiveCleaner pkgArchiveCleaner(); virtual ~pkgArchiveCleaner(); }; -// TODO: merge classes and "erase" the old way -class pkgArchiveCleaner2: public pkgArchiveCleaner -{ - friend class pkgArchiveCleaner; -protected: - using pkgArchiveCleaner::Erase; - virtual void Erase(int const dirfd, char const * const File, - std::string const &Pkg,std::string const &Ver, - struct stat const &St) = 0; -}; + #endif diff --git a/apt-pkg/contrib/arfile.cc b/apt-pkg/contrib/arfile.cc new file mode 100644 index 000000000..3fc3afedb --- /dev/null +++ b/apt-pkg/contrib/arfile.cc @@ -0,0 +1,160 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ###################################################################### + + AR File - Handle an 'AR' archive + + AR Archives have plain text headers at the start of each file + section. The headers are aligned on a 2 byte boundary. + + Information about the structure of AR files can be found in ar(5) + on a BSD system, or in the binutils source. + + ##################################################################### */ + /*}}}*/ +// Include Files /*{{{*/ +#include <config.h> + +#include <apt-pkg/arfile.h> +#include <apt-pkg/error.h> +#include <apt-pkg/fileutl.h> +#include <apt-pkg/strutl.h> + +#include <string> +#include <string.h> +#include <sys/types.h> + +#include <apti18n.h> + /*}}}*/ + +struct ARArchive::MemberHeader +{ + char Name[16]; + char MTime[12]; + char UID[6]; + char GID[6]; + char Mode[8]; + char Size[10]; + char Magic[2]; +}; + +// ARArchive::ARArchive - Constructor /*{{{*/ +// --------------------------------------------------------------------- +/* */ +ARArchive::ARArchive(FileFd &File) : List(0), File(File) +{ + LoadHeaders(); +} + /*}}}*/ +// ARArchive::~ARArchive - Destructor /*{{{*/ +// --------------------------------------------------------------------- +/* */ +ARArchive::~ARArchive() +{ + while (List != 0) + { + Member *Tmp = List; + List = List->Next; + delete Tmp; + } +} + /*}}}*/ +// ARArchive::LoadHeaders - Load the headers from each file /*{{{*/ +// --------------------------------------------------------------------- +/* AR files are structured with a 8 byte magic string followed by a 60 + byte plain text header then the file data, another header, data, etc */ +bool ARArchive::LoadHeaders() +{ + off_t Left = File.Size(); + + // Check the magic byte + char Magic[8]; + if (File.Read(Magic,sizeof(Magic)) == false) + return false; + if (memcmp(Magic,"!<arch>\012",sizeof(Magic)) != 0) + return _error->Error(_("Invalid archive signature")); + Left -= sizeof(Magic); + + // Read the member list + while (Left > 0) + { + MemberHeader Head; + if (File.Read(&Head,sizeof(Head)) == false) + return _error->Error(_("Error reading archive member header")); + Left -= sizeof(Head); + + // Convert all of the integer members + Member *Memb = new Member(); + if (StrToNum(Head.MTime,Memb->MTime,sizeof(Head.MTime)) == false || + StrToNum(Head.UID,Memb->UID,sizeof(Head.UID)) == false || + StrToNum(Head.GID,Memb->GID,sizeof(Head.GID)) == false || + StrToNum(Head.Mode,Memb->Mode,sizeof(Head.Mode),8) == false || + StrToNum(Head.Size,Memb->Size,sizeof(Head.Size)) == false) + { + delete Memb; + return _error->Error(_("Invalid archive member header %s"), Head.Name); + } + + // Check for an extra long name string + if (memcmp(Head.Name,"#1/",3) == 0) + { + char S[300]; + unsigned long Len; + if (StrToNum(Head.Name+3,Len,sizeof(Head.Size)-3) == false || + Len >= sizeof(S)) + { + delete Memb; + return _error->Error(_("Invalid archive member header")); + } + if (File.Read(S,Len) == false) + { + delete Memb; + return false; + } + S[Len] = 0; + Memb->Name = S; + Memb->Size -= Len; + Left -= Len; + } + else + { + unsigned int I = sizeof(Head.Name) - 1; + for (; Head.Name[I] == ' ' || Head.Name[I] == '/'; I--); + Memb->Name = std::string(Head.Name,I+1); + } + + // Account for the AR header alignment + off_t Skip = Memb->Size % 2; + + // Add it to the list + Memb->Next = List; + List = Memb; + Memb->Start = File.Tell(); + if (File.Skip(Memb->Size + Skip) == false) + return false; + if (Left < (off_t)(Memb->Size + Skip)) + return _error->Error(_("Archive is too short")); + Left -= Memb->Size + Skip; + } + if (Left != 0) + return _error->Error(_("Failed to read the archive headers")); + + return true; +} + /*}}}*/ +// ARArchive::FindMember - Find a name in the member list /*{{{*/ +// --------------------------------------------------------------------- +/* Find a member with the given name */ +const ARArchive::Member *ARArchive::FindMember(const char *Name) const +{ + const Member *Res = List; + while (Res != 0) + { + if (Res->Name == Name) + return Res; + Res = Res->Next; + } + + return 0; +} + /*}}}*/ diff --git a/apt-pkg/contrib/arfile.h b/apt-pkg/contrib/arfile.h new file mode 100644 index 000000000..cf454941e --- /dev/null +++ b/apt-pkg/contrib/arfile.h @@ -0,0 +1,69 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ###################################################################### + + AR File - Handle an 'AR' archive + + This is a reader for the usual 4.4 BSD AR format. It allows raw + stream access to a single member at a time. Basically all this class + provides is header parsing and verification. It is up to the client + to correctly make use of the stream start/stop points. + + ##################################################################### */ + /*}}}*/ +#ifndef PKGLIB_ARFILE_H +#define PKGLIB_ARFILE_H + +#include <apt-pkg/macros.h> +#include <string> +#ifndef APT_8_CLEANER_HEADERS +#include <apt-pkg/fileutl.h> +#endif + +class FileFd; + +class ARArchive +{ + struct MemberHeader; + public: + struct Member; + + protected: + + // Linked list of members + Member *List; + + bool LoadHeaders(); + + public: + + // The stream file + FileFd &File; + + // Locate a member by name + const Member *FindMember(const char *Name) const; + inline Member *Members() { return List; } + + explicit ARArchive(FileFd &File); + ~ARArchive(); +}; + +// A member of the archive +struct ARArchive::Member +{ + // Fields from the header + std::string Name; + unsigned long MTime; + unsigned long UID; + unsigned long GID; + unsigned long Mode; + unsigned long long Size; + + // Location of the data. + unsigned long long Start; + Member *Next; + + Member() : Start(0), Next(0) {}; +}; + +#endif diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h index 2a3ae1aa4..b5dfe721f 100644 --- a/apt-pkg/contrib/configuration.h +++ b/apt-pkg/contrib/configuration.h @@ -119,7 +119,7 @@ class Configuration void Dump(std::ostream& str, char const * const root, char const * const format, bool const emptyValue); - Configuration(const Item *Root); + explicit Configuration(const Item *Root); Configuration(); ~Configuration(); @@ -130,7 +130,7 @@ class Configuration APT_HIDDEN void clearPatterns(); public: - MatchAgainstConfig(char const * Config); + explicit MatchAgainstConfig(char const * Config); virtual ~MatchAgainstConfig(); /** \brief Returns \b true for a string matching one of the patterns */ diff --git a/apt-pkg/contrib/extracttar.cc b/apt-pkg/contrib/extracttar.cc new file mode 100644 index 000000000..9bb0a55c0 --- /dev/null +++ b/apt-pkg/contrib/extracttar.cc @@ -0,0 +1,306 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ###################################################################### + + Extract a Tar - Tar Extractor + + Some performance measurements showed that zlib performed quite poorly + in comparison to a forked gzip process. This tar extractor makes use + of the fact that dup'd file descriptors have the same seek pointer + and that gzip will not read past the end of a compressed stream, + even if there is more data. We use the dup property to track extraction + progress and the gzip feature to just feed gzip a fd in the middle + of an AR file. + + ##################################################################### */ + /*}}}*/ +// Include Files /*{{{*/ +#include <config.h> + +#include <apt-pkg/configuration.h> +#include <apt-pkg/dirstream.h> +#include <apt-pkg/error.h> +#include <apt-pkg/extracttar.h> +#include <apt-pkg/fileutl.h> +#include <apt-pkg/strutl.h> + +#include <algorithm> +#include <iostream> +#include <string> +#include <fcntl.h> +#include <signal.h> +#include <string.h> +#include <unistd.h> + +#include <apti18n.h> + /*}}}*/ + +using namespace std; + +// The on disk header for a tar file. +struct ExtractTar::TarHeader +{ + char Name[100]; + char Mode[8]; + char UserID[8]; + char GroupID[8]; + char Size[12]; + char MTime[12]; + char Checksum[8]; + char LinkFlag; + char LinkName[100]; + char MagicNumber[8]; + char UserName[32]; + char GroupName[32]; + char Major[8]; + char Minor[8]; +}; + +// ExtractTar::ExtractTar - Constructor /*{{{*/ +// --------------------------------------------------------------------- +/* */ +ExtractTar::ExtractTar(FileFd &Fd,unsigned long long Max,string DecompressionProgram) + : File(Fd), MaxInSize(Max), DecompressProg(DecompressionProgram) +{ + GZPid = -1; + Eof = false; +} + /*}}}*/ +// ExtractTar::ExtractTar - Destructor /*{{{*/ +// --------------------------------------------------------------------- +/* */ +ExtractTar::~ExtractTar() +{ + // Error close + Done(); +} + /*}}}*/ +// ExtractTar::Done - Reap the gzip sub process /*{{{*/ +bool ExtractTar::Done() +{ + return InFd.Close(); +} + /*}}}*/ +// ExtractTar::StartGzip - Startup gzip /*{{{*/ +// --------------------------------------------------------------------- +/* This creates a gzip sub process that has its input as the file itself. + If this tar file is embedded into something like an ar file then + gzip will efficiently ignore the extra bits. */ +bool ExtractTar::StartGzip() +{ + if (DecompressProg.empty()) + { + InFd.OpenDescriptor(File.Fd(), FileFd::ReadOnly, FileFd::None, false); + return true; + } + + 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 == DecompressProg) { + return InFd.OpenDescriptor(File.Fd(), FileFd::ReadOnly, *compressor, false); + } + } + + return _error->Error(_("Cannot find a configured compressor for '%s'"), + DecompressProg.c_str()); + +} + /*}}}*/ +// ExtractTar::Go - Perform extraction /*{{{*/ +// --------------------------------------------------------------------- +/* This reads each 512 byte block from the archive and extracts the header + information into the Item structure. Then it resolves the UID/GID and + invokes the correct processing function. */ +bool ExtractTar::Go(pkgDirStream &Stream) +{ + if (StartGzip() == false) + return false; + + // Loop over all blocks + string LastLongLink, ItemLink; + string LastLongName, ItemName; + while (1) + { + bool BadRecord = false; + unsigned char Block[512]; + if (InFd.Read(Block,sizeof(Block),true) == false) + return false; + + if (InFd.Eof() == true) + break; + + // Get the checksum + TarHeader *Tar = (TarHeader *)Block; + unsigned long CheckSum; + if (StrToNum(Tar->Checksum,CheckSum,sizeof(Tar->Checksum),8) == false) + return _error->Error(_("Corrupted archive")); + + /* Compute the checksum field. The actual checksum is blanked out + with spaces so it is not included in the computation */ + unsigned long NewSum = 0; + memset(Tar->Checksum,' ',sizeof(Tar->Checksum)); + for (int I = 0; I != sizeof(Block); I++) + NewSum += Block[I]; + + /* Check for a block of nulls - in this case we kill gzip, GNU tar + does this.. */ + if (NewSum == ' '*sizeof(Tar->Checksum)) + return Done(); + + if (NewSum != CheckSum) + return _error->Error(_("Tar checksum failed, archive corrupted")); + + // Decode all of the fields + pkgDirStream::Item Itm; + if (StrToNum(Tar->Mode,Itm.Mode,sizeof(Tar->Mode),8) == false || + (Base256ToNum(Tar->UserID,Itm.UID,8) == false && + StrToNum(Tar->UserID,Itm.UID,sizeof(Tar->UserID),8) == false) || + (Base256ToNum(Tar->GroupID,Itm.GID,8) == false && + StrToNum(Tar->GroupID,Itm.GID,sizeof(Tar->GroupID),8) == false) || + (Base256ToNum(Tar->Size,Itm.Size,12) == false && + StrToNum(Tar->Size,Itm.Size,sizeof(Tar->Size),8) == false) || + (Base256ToNum(Tar->MTime,Itm.MTime,12) == false && + StrToNum(Tar->MTime,Itm.MTime,sizeof(Tar->MTime),8) == false) || + StrToNum(Tar->Major,Itm.Major,sizeof(Tar->Major),8) == false || + StrToNum(Tar->Minor,Itm.Minor,sizeof(Tar->Minor),8) == false) + return _error->Error(_("Corrupted archive")); + + // Grab the filename and link target: use last long name if one was + // set, otherwise use the header value as-is, but remember that it may + // fill the entire 100-byte block and needs to be zero-terminated. + // See Debian Bug #689582. + if (LastLongName.empty() == false) + Itm.Name = (char *)LastLongName.c_str(); + else + Itm.Name = (char *)ItemName.assign(Tar->Name, sizeof(Tar->Name)).c_str(); + if (Itm.Name[0] == '.' && Itm.Name[1] == '/' && Itm.Name[2] != 0) + Itm.Name += 2; + + if (LastLongLink.empty() == false) + Itm.LinkTarget = (char *)LastLongLink.c_str(); + else + Itm.LinkTarget = (char *)ItemLink.assign(Tar->LinkName, sizeof(Tar->LinkName)).c_str(); + + // Convert the type over + switch (Tar->LinkFlag) + { + case NormalFile0: + case NormalFile: + Itm.Type = pkgDirStream::Item::File; + break; + + case HardLink: + Itm.Type = pkgDirStream::Item::HardLink; + break; + + case SymbolicLink: + Itm.Type = pkgDirStream::Item::SymbolicLink; + break; + + case CharacterDevice: + Itm.Type = pkgDirStream::Item::CharDevice; + break; + + case BlockDevice: + Itm.Type = pkgDirStream::Item::BlockDevice; + break; + + case Directory: + Itm.Type = pkgDirStream::Item::Directory; + break; + + case FIFO: + Itm.Type = pkgDirStream::Item::FIFO; + break; + + case GNU_LongLink: + { + unsigned long long Length = Itm.Size; + unsigned char Block[512]; + while (Length > 0) + { + if (InFd.Read(Block,sizeof(Block),true) == false) + return false; + if (Length <= sizeof(Block)) + { + LastLongLink.append(Block,Block+sizeof(Block)); + break; + } + LastLongLink.append(Block,Block+sizeof(Block)); + Length -= sizeof(Block); + } + continue; + } + + case GNU_LongName: + { + unsigned long long Length = Itm.Size; + unsigned char Block[512]; + while (Length > 0) + { + if (InFd.Read(Block,sizeof(Block),true) == false) + return false; + if (Length < sizeof(Block)) + { + LastLongName.append(Block,Block+sizeof(Block)); + break; + } + LastLongName.append(Block,Block+sizeof(Block)); + Length -= sizeof(Block); + } + continue; + } + + default: + BadRecord = true; + _error->Warning(_("Unknown TAR header type %u, member %s"),(unsigned)Tar->LinkFlag,Tar->Name); + break; + } + + int Fd = -1; + if (BadRecord == false) + if (Stream.DoItem(Itm,Fd) == false) + return false; + + // Copy the file over the FD + unsigned long long Size = Itm.Size; + while (Size != 0) + { + unsigned char Junk[32*1024]; + unsigned long Read = min(Size, (unsigned long long)sizeof(Junk)); + if (InFd.Read(Junk,((Read+511)/512)*512) == false) + return false; + + if (BadRecord == false) + { + if (Fd > 0) + { + if (write(Fd,Junk,Read) != (signed)Read) + return Stream.Fail(Itm,Fd); + } + else + { + /* An Fd of -2 means to send to a special processing + function */ + if (Fd == -2) + if (Stream.Process(Itm,Junk,Read,Itm.Size - Size) == false) + return Stream.Fail(Itm,Fd); + } + } + + Size -= Read; + } + + // And finish up + if (BadRecord == false) + if (Stream.FinishedFile(Itm,Fd) == false) + return false; + + LastLongName.erase(); + LastLongLink.erase(); + } + + return Done(); +} + /*}}}*/ diff --git a/apt-pkg/contrib/extracttar.h b/apt-pkg/contrib/extracttar.h new file mode 100644 index 000000000..adde21352 --- /dev/null +++ b/apt-pkg/contrib/extracttar.h @@ -0,0 +1,60 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ###################################################################### + + Extract a Tar - Tar Extractor + + The tar extractor takes an ordinary gzip compressed tar stream from + the given file and explodes it, passing the individual items to the + given Directory Stream for processing. + + ##################################################################### */ + /*}}}*/ +#ifndef PKGLIB_EXTRACTTAR_H +#define PKGLIB_EXTRACTTAR_H + +#include <apt-pkg/fileutl.h> +#include <apt-pkg/macros.h> + +#include <string> + +#ifndef APT_8_CLEANER_HEADERS +#include <apt-pkg/dirstream.h> +#include <algorithm> +using std::min; +#endif + +class pkgDirStream; + +class ExtractTar +{ + protected: + + struct TarHeader; + + // The varios types items can be + enum ItemType {NormalFile0 = '\0',NormalFile = '0',HardLink = '1', + SymbolicLink = '2',CharacterDevice = '3', + BlockDevice = '4',Directory = '5',FIFO = '6', + GNU_LongLink = 'K',GNU_LongName = 'L'}; + + FileFd &File; + unsigned long long MaxInSize; + int GZPid; + FileFd InFd; + bool Eof; + std::string DecompressProg; + + // Fork and reap gzip + bool StartGzip(); + bool Done(); + + public: + + bool Go(pkgDirStream &Stream); + + ExtractTar(FileFd &Fd,unsigned long long Max,std::string DecompressionProgram); + virtual ~ExtractTar(); +}; + +#endif diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 4f123491b..798636647 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -25,7 +25,6 @@ #include <apt-pkg/fileutl.h> #include <apt-pkg/macros.h> #include <apt-pkg/pkgsystem.h> -#include <apt-pkg/sptr.h> #include <apt-pkg/strutl.h> #include <cstdio> @@ -1948,7 +1947,7 @@ class APT_HIDDEN LzmaFileFdPrivate: public FileFdPrivate { /*{{{*/ bool eof; bool compressing; - LZMAFILE(FileFd * const fd) : file(nullptr), filefd(fd), eof(false), compressing(false) { buffer[0] = '\0'; } + explicit LZMAFILE(FileFd * const fd) : file(nullptr), filefd(fd), eof(false), compressing(false) { buffer[0] = '\0'; } ~LZMAFILE() { if (compressing == true && filefd->Failed() == false) @@ -3018,19 +3017,6 @@ bool FileFd::FileFdError(const char *Description,...) { return false; } /*}}}*/ -gzFile FileFd::gzFd() { /*{{{*/ -#ifdef HAVE_ZLIB - GzipFileFdPrivate * const gzipd = dynamic_cast<GzipFileFdPrivate*>(d); - if (gzipd == nullptr) - return nullptr; - else - return gzipd->gz; -#else - return nullptr; -#endif -} - /*}}}*/ - // Glob - wrapper around "glob()" /*{{{*/ std::vector<std::string> Glob(std::string const &pattern, int flags) { @@ -3153,16 +3139,6 @@ bool Rename(std::string From, std::string To) /*{{{*/ return true; } /*}}}*/ -bool Popen(const char* Args[], FileFd &Fd, pid_t &Child, FileFd::OpenMode Mode)/*{{{*/ -{ - return Popen(Args, Fd, Child, Mode, true); -} - /*}}}*/ -bool Popen(const char* Args[], FileFd &Fd, pid_t &Child, FileFd::OpenMode Mode, bool CaptureStderr)/*{{{*/ -{ - return Popen(Args, Fd, Child, Mode, CaptureStderr, false); -} - /*}}}*/ bool Popen(const char *Args[], FileFd &Fd, pid_t &Child, FileFd::OpenMode Mode, bool CaptureStderr, bool Sandbox) /*{{{*/ { int fd; diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 9005b81b5..cc0191192 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -133,20 +133,6 @@ class FileFd unsigned long long FileSize(); time_t ModificationTime(); - /* You want to use 'unsigned long long' if you are talking about a file - to be able to support large files (>2 or >4 GB) properly. - This shouldn't happen all to often for the indexes, but deb's might be… - And as the auto-conversation converts a 'unsigned long *' to a 'bool' - instead of 'unsigned long long *' we need to provide this explicitly - - otherwise applications magically start to fail… */ - bool Read(void *To,unsigned long long Size,unsigned long *Actual) APT_DEPRECATED_MSG("The Actual variable you pass in should be an unsigned long long") - { - unsigned long long R; - bool const T = Read(To, Size, &R); - *Actual = R; - return T; - } - bool Open(std::string FileName,unsigned int const Mode,CompressMode Compress,unsigned long const AccessMode = 0666); bool Open(std::string FileName,unsigned int const Mode,APT::Configuration::Compressor const &compressor,unsigned long const AccessMode = 0666); inline bool Open(std::string const &FileName,unsigned int const Mode, unsigned long const AccessMode = 0666) { @@ -163,7 +149,6 @@ class FileFd // Simple manipulators inline int Fd() {return iFd;}; inline void Fd(int fd) { OpenDescriptor(fd, ReadWrite);}; - gzFile gzFd() APT_DEPRECATED_MSG("Implementation detail, do not use to be able to support bzip2, xz and co") APT_PURE; inline bool IsOpen() {return iFd >= 0;}; inline bool Failed() {return (Flags & Fail) == Fail;}; @@ -294,9 +279,7 @@ std::vector<std::string> Glob(std::string const &pattern, int flags=0); * \param Sandbox True if this should run sandboxed * \return true on success, false on failure with _error set */ -bool Popen(const char *Args[], FileFd &Fd, pid_t &Child, FileFd::OpenMode Mode, bool CaptureStderr, bool Sandbox) APT_HIDDEN; -bool Popen(const char* Args[], FileFd &Fd, pid_t &Child, FileFd::OpenMode Mode, bool CaptureStderr); -bool Popen(const char* Args[], FileFd &Fd, pid_t &Child, FileFd::OpenMode Mode); +bool Popen(const char *Args[], FileFd &Fd, pid_t &Child, FileFd::OpenMode Mode, bool CaptureStderr = true, bool Sandbox = false); APT_HIDDEN bool OpenConfigurationFileFd(std::string const &File, FileFd &Fd); diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index 98b92cc81..d03fb6083 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -312,7 +312,6 @@ bool Hashes::Add(const unsigned char * const Data, unsigned long long const Size if (Size == 0) return true; bool Res = true; -APT_IGNORE_DEPRECATED_PUSH if ((d->CalcHashes & MD5SUM) == MD5SUM) Res &= MD5.Add(Data, Size); if ((d->CalcHashes & SHA1SUM) == SHA1SUM) @@ -321,15 +320,9 @@ APT_IGNORE_DEPRECATED_PUSH Res &= SHA256.Add(Data, Size); if ((d->CalcHashes & SHA512SUM) == SHA512SUM) Res &= SHA512.Add(Data, Size); -APT_IGNORE_DEPRECATED_POP d->FileSize += Size; return Res; } -bool Hashes::Add(const unsigned char * const Data, unsigned long long const Size, unsigned int const Hashes) -{ - d->CalcHashes = Hashes; - return Add(Data, Size); -} bool Hashes::AddFD(int const Fd,unsigned long long Size) { unsigned char Buf[64*64]; @@ -349,11 +342,6 @@ bool Hashes::AddFD(int const Fd,unsigned long long Size) } return true; } -bool Hashes::AddFD(int const Fd,unsigned long long Size, unsigned int const Hashes) -{ - d->CalcHashes = Hashes; - return AddFD(Fd, Size); -} bool Hashes::AddFD(FileFd &Fd,unsigned long long Size) { unsigned char Buf[64*64]; @@ -378,16 +366,10 @@ bool Hashes::AddFD(FileFd &Fd,unsigned long long Size) } return true; } -bool Hashes::AddFD(FileFd &Fd,unsigned long long Size, unsigned int const Hashes) -{ - d->CalcHashes = Hashes; - return AddFD(Fd, Size); -} /*}}}*/ HashStringList Hashes::GetHashStringList() { HashStringList hashes; -APT_IGNORE_DEPRECATED_PUSH if ((d->CalcHashes & MD5SUM) == MD5SUM) hashes.push_back(HashString("MD5Sum", MD5.Result().Value())); if ((d->CalcHashes & SHA1SUM) == SHA1SUM) @@ -396,13 +378,10 @@ APT_IGNORE_DEPRECATED_PUSH hashes.push_back(HashString("SHA256", SHA256.Result().Value())); if ((d->CalcHashes & SHA512SUM) == SHA512SUM) hashes.push_back(HashString("SHA512", SHA512.Result().Value())); -APT_IGNORE_DEPRECATED_POP hashes.FileSize(d->FileSize); return hashes; } -APT_IGNORE_DEPRECATED_PUSH Hashes::Hashes() : d(new PrivateHashes(~0)) { } Hashes::Hashes(unsigned int const Hashes) : d(new PrivateHashes(Hashes)) {} Hashes::Hashes(HashStringList const &Hashes) : d(new PrivateHashes(Hashes)) {} Hashes::~Hashes() { delete d; } -APT_IGNORE_DEPRECATED_POP diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h index 28bfd3459..c636852ec 100644 --- a/apt-pkg/contrib/hashes.h +++ b/apt-pkg/contrib/hashes.h @@ -47,14 +47,12 @@ class HashString public: HashString(std::string Type, std::string Hash); - HashString(std::string StringedHashString); // init from str as "type:hash" + explicit HashString(std::string StringedHashString); // init from str as "type:hash" HashString(); // get hash type used std::string HashType() const { return Type; }; std::string HashValue() const { return Hash; }; - APT_DEPRECATED_MSG("method was const-ified") std::string HashType() { return Type; }; - APT_DEPRECATED_MSG("method was const-ified") std::string HashValue() { return Hash; }; // verify the given filename against the currently loaded hash bool VerifyFile(std::string filename) const; @@ -165,11 +163,11 @@ class HashStringList HashStringList() {} // simplifying API-compatibility constructors - HashStringList(std::string const &hash) { + explicit HashStringList(std::string const &hash) { if (hash.empty() == false) list.push_back(HashString(hash)); } - HashStringList(char const * const hash) { + explicit HashStringList(char const * const hash) { if (hash != NULL && hash[0] != '\0') list.push_back(HashString(hash)); } @@ -182,19 +180,17 @@ class PrivateHashes; class Hashes { PrivateHashes * const d; - - public: - /* those will disappear in the future as it is hard to add new ones this way. + /* TODO: those will disappear in the future as it is hard to add new ones this way. * Use Add* to build the results and get them via GetHashStringList() instead */ - APT_DEPRECATED_MSG("Use general .Add* and .GetHashStringList methods instead of hardcoding specific hashes") MD5Summation MD5; - APT_DEPRECATED_MSG("Use general .Add* and .GetHashStringList methods instead of hardcoding specific hashes") SHA1Summation SHA1; - APT_DEPRECATED_MSG("Use general .Add* and .GetHashStringList methods instead of hardcoding specific hashes") SHA256Summation SHA256; - APT_DEPRECATED_MSG("Use general .Add* and .GetHashStringList methods instead of hardcoding specific hashes") SHA512Summation SHA512; + MD5Summation MD5; + SHA1Summation SHA1; + SHA256Summation SHA256; + SHA512Summation SHA512; + public: static const int UntilEOF = 0; bool Add(const unsigned char * const Data, unsigned long long const Size) APT_NONNULL(2); - APT_DEPRECATED_MSG("Construct accordingly instead of choosing hashes while adding") bool Add(const unsigned char * const Data, unsigned long long const Size, unsigned int const Hashes) APT_NONNULL(2); inline bool Add(const char * const Data) APT_NONNULL(2) {return Add(reinterpret_cast<unsigned char const *>(Data),strlen(Data));}; inline bool Add(const unsigned char * const Beg,const unsigned char * const End) APT_NONNULL(2,3) @@ -203,13 +199,10 @@ class Hashes enum SupportedHashes { MD5SUM = (1 << 0), SHA1SUM = (1 << 1), SHA256SUM = (1 << 2), SHA512SUM = (1 << 3) }; bool AddFD(int const Fd,unsigned long long Size = 0); - APT_DEPRECATED_MSG("Construct accordingly instead of choosing hashes while adding") bool AddFD(int const Fd,unsigned long long Size, unsigned int const Hashes); bool AddFD(FileFd &Fd,unsigned long long Size = 0); - APT_DEPRECATED_MSG("Construct accordingly instead of choosing hashes while adding") bool AddFD(FileFd &Fd,unsigned long long Size, unsigned int const Hashes); HashStringList GetHashStringList(); -APT_IGNORE_DEPRECATED_PUSH /** create a Hashes object to calculate all supported hashes * * If ALL is too much, you can limit which Hashes are calculated @@ -217,34 +210,10 @@ APT_IGNORE_DEPRECATED_PUSH * which hashes to generate. */ Hashes(); /** @param Hashes bitflag composed of #SupportedHashes */ - Hashes(unsigned int const Hashes); + explicit Hashes(unsigned int const Hashes); /** @param Hashes is a list of hashes */ - Hashes(HashStringList const &Hashes); + explicit Hashes(HashStringList const &Hashes); virtual ~Hashes(); -APT_IGNORE_DEPRECATED_POP - - private: - APT_HIDDEN APT_PURE inline unsigned int boolsToFlag(bool const addMD5, bool const addSHA1, bool const addSHA256, bool const addSHA512) - { - unsigned int hashes = ~0; - if (addMD5 == false) hashes &= ~MD5SUM; - if (addSHA1 == false) hashes &= ~SHA1SUM; - if (addSHA256 == false) hashes &= ~SHA256SUM; - if (addSHA512 == false) hashes &= ~SHA512SUM; - return hashes; - } - - public: -APT_IGNORE_DEPRECATED_PUSH - APT_DEPRECATED_MSG("Construct accordingly instead of choosing hashes while adding") bool AddFD(int const Fd, unsigned long long Size, bool const addMD5, - bool const addSHA1, bool const addSHA256, bool const addSHA512) { - return AddFD(Fd, Size, boolsToFlag(addMD5, addSHA1, addSHA256, addSHA512)); - }; - APT_DEPRECATED_MSG("Construct accordingly instead of choosing hashes while adding") bool AddFD(FileFd &Fd, unsigned long long Size, bool const addMD5, - bool const addSHA1, bool const addSHA256, bool const addSHA512) { - return AddFD(Fd, Size, boolsToFlag(addMD5, addSHA1, addSHA256, addSHA512)); - }; -APT_IGNORE_DEPRECATED_POP }; #endif diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h index 57d3f6c22..3648390ce 100644 --- a/apt-pkg/contrib/macros.h +++ b/apt-pkg/contrib/macros.h @@ -166,8 +166,8 @@ // Non-ABI-Breaks should only increase RELEASE number. // See also buildlib/libversion.mak #define APT_PKG_MAJOR 5 -#define APT_PKG_MINOR 0 -#define APT_PKG_RELEASE 2 +#define APT_PKG_MINOR 90 +#define APT_PKG_RELEASE 0 #define APT_PKG_ABI ((APT_PKG_MAJOR * 100) + APT_PKG_MINOR) #endif diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h index 63d54d27c..3af1f47fb 100644 --- a/apt-pkg/contrib/mmap.h +++ b/apt-pkg/contrib/mmap.h @@ -74,7 +74,7 @@ class MMap bool Sync(unsigned long Start,unsigned long Stop); MMap(FileFd &F,unsigned long Flags); - MMap(unsigned long Flags); + explicit MMap(unsigned long Flags); virtual ~MMap(); }; diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc index 48114ba3c..ee1996f8d 100644 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@ -142,15 +142,6 @@ bool MaybeAddAuth(FileFd &NetRCFile, URI &Uri) return false; } -void maybe_add_auth(URI &Uri, std::string NetRCFile) -{ - if (FileExists(NetRCFile) == false) - return; - FileFd fd; - if (fd.Open(NetRCFile, FileFd::ReadOnly)) - MaybeAddAuth(fd, Uri); -} - /* Check if we are authorized. */ bool IsAuthorized(pkgCache::PkgFileIterator const I, std::vector<std::unique_ptr<FileFd>> &authconfs) { diff --git a/apt-pkg/contrib/netrc.h b/apt-pkg/contrib/netrc.h index 80d95acc1..96a5a0973 100644 --- a/apt-pkg/contrib/netrc.h +++ b/apt-pkg/contrib/netrc.h @@ -32,8 +32,6 @@ class URI; class FileFd; -APT_DEPRECATED_MSG("Use FileFd-based MaybeAddAuth instead") -void maybe_add_auth(URI &Uri, std::string NetRCFile); bool MaybeAddAuth(FileFd &NetRCFile, URI &Uri); bool IsAuthorized(pkgCache::PkgFileIterator const I, std::vector<std::unique_ptr<FileFd>> &authconfs) APT_HIDDEN; #endif diff --git a/apt-pkg/contrib/progress.h b/apt-pkg/contrib/progress.h index 4406a388b..903e6613e 100644 --- a/apt-pkg/contrib/progress.h +++ b/apt-pkg/contrib/progress.h @@ -80,9 +80,9 @@ class OpTextProgress : public OpProgress virtual void Done() APT_OVERRIDE; - OpTextProgress(bool NoUpdate = false) : NoUpdate(NoUpdate), + explicit OpTextProgress(bool NoUpdate = false) : NoUpdate(NoUpdate), NoDisplay(false), LastLen(0) {}; - OpTextProgress(Configuration &Config); + explicit OpTextProgress(Configuration &Config); virtual ~OpTextProgress() {Done();}; }; diff --git a/apt-pkg/contrib/sptr.h b/apt-pkg/contrib/sptr.h deleted file mode 100644 index 77806d94d..000000000 --- a/apt-pkg/contrib/sptr.h +++ /dev/null @@ -1,74 +0,0 @@ -// -*- mode: cpp; mode: fold -*- -// Description /*{{{*/ -/* ###################################################################### - - Trivial non-ref counted 'smart pointer' - - This is really only good to eliminate - { - delete Foo; - return; - } - - Blocks from functions. - - I think G++ has become good enough that doing this won't have much - code size implications. - - ##################################################################### */ - /*}}}*/ -#ifndef SMART_POINTER_H -#define SMART_POINTER_H -#include <apt-pkg/macros.h> - -template <class T> -class APT_DEPRECATED_MSG("use std::unique_ptr instead") SPtr -{ - public: - T *Ptr; - - inline T *operator ->() {return Ptr;}; - inline T &operator *() {return *Ptr;}; - inline operator T *() {return Ptr;}; - inline operator void *() {return Ptr;}; - inline T *UnGuard() {T *Tmp = Ptr; Ptr = 0; return Tmp;}; - inline void operator =(T *N) {Ptr = N;}; - inline bool operator ==(T *lhs) const {return Ptr == lhs;}; - inline bool operator !=(T *lhs) const {return Ptr != lhs;}; - inline T*Get() {return Ptr;}; - - inline SPtr(T *Ptr) : Ptr(Ptr) {}; - inline SPtr() : Ptr(0) {}; - inline ~SPtr() {delete Ptr;}; -}; - -template <class T> -class APT_DEPRECATED_MSG("use std::unique_ptr instead") SPtrArray -{ - public: - T *Ptr; - - //inline T &operator *() {return *Ptr;}; - inline operator T *() {return Ptr;}; - inline operator void *() {return Ptr;}; - inline T *UnGuard() {T *Tmp = Ptr; Ptr = 0; return Tmp;}; - //inline T &operator [](signed long I) {return Ptr[I];}; - inline void operator =(T *N) {Ptr = N;}; - inline bool operator ==(T *lhs) const {return Ptr == lhs;}; - inline bool operator !=(T *lhs) const {return Ptr != lhs;}; - inline T *Get() {return Ptr;}; - - inline SPtrArray(T *Ptr) : Ptr(Ptr) {}; - inline SPtrArray() : Ptr(0) {}; -#if __GNUC__ >= 4 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations" - // gcc warns about this, but we can do nothing here… -#endif - inline ~SPtrArray() {delete [] Ptr;}; -#if __GNUC__ >= 4 - #pragma GCC diagnostic pop -#endif -}; - -#endif diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 50344d1fe..e854c5bf1 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -806,10 +806,6 @@ int StringToBool(const string &Text,int Default) // --------------------------------------------------------------------- /* This converts a time_t into a string time representation that is year 2000 compliant and timezone neutral */ -string TimeRFC1123(time_t Date) -{ - return TimeRFC1123(Date, false); -} string TimeRFC1123(time_t Date, bool const NumericTimezone) { struct tm Conv; @@ -1099,57 +1095,6 @@ bool FTPMDTMStrToTime(const char* const str,time_t &time) return true; } /*}}}*/ -// StrToTime - Converts a string into a time_t /*{{{*/ -// --------------------------------------------------------------------- -/* This handles all 3 popular time formats including RFC 1123, RFC 1036 - and the C library asctime format. It requires the GNU library function - 'timegm' to convert a struct tm in UTC to a time_t. For some bizzar - reason the C library does not provide any such function :< This also - handles the weird, but unambiguous FTP time format*/ -bool StrToTime(const string &Val,time_t &Result) -{ - struct tm Tm; - char Month[10]; - - // Skip the day of the week - const char *I = strchr(Val.c_str(), ' '); - - // Handle RFC 1123 time - Month[0] = 0; - if (sscanf(I," %2d %3s %4d %2d:%2d:%2d GMT",&Tm.tm_mday,Month,&Tm.tm_year, - &Tm.tm_hour,&Tm.tm_min,&Tm.tm_sec) != 6) - { - // Handle RFC 1036 time - if (sscanf(I," %2d-%3s-%3d %2d:%2d:%2d GMT",&Tm.tm_mday,Month, - &Tm.tm_year,&Tm.tm_hour,&Tm.tm_min,&Tm.tm_sec) == 6) - Tm.tm_year += 1900; - else - { - // asctime format - if (sscanf(I," %3s %2d %2d:%2d:%2d %4d",Month,&Tm.tm_mday, - &Tm.tm_hour,&Tm.tm_min,&Tm.tm_sec,&Tm.tm_year) != 6) - { - // 'ftp' time - if (sscanf(Val.c_str(),"%4d%2d%2d%2d%2d%2d",&Tm.tm_year,&Tm.tm_mon, - &Tm.tm_mday,&Tm.tm_hour,&Tm.tm_min,&Tm.tm_sec) != 6) - return false; - Tm.tm_mon--; - } - } - } - - Tm.tm_isdst = 0; - if (Month[0] != 0) - Tm.tm_mon = MonthConv(Month); - else - Tm.tm_mon = 0; // we don't have a month, so pick something - Tm.tm_year -= 1900; - - // Convert to local time and then to GMT - Result = timegm(&Tm); - return true; -} - /*}}}*/ // StrToNum - Convert a fixed length string to a number /*{{{*/ // --------------------------------------------------------------------- /* This is used in decoding the crazy fixed length string headers in diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index 9f74f8c2a..ae0aaedf9 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -66,7 +66,6 @@ std::string TimeToStr(unsigned long Sec); std::string Base64Encode(const std::string &Str); std::string OutputInDepth(const unsigned long Depth, const char* Separator=" "); std::string URItoFileName(const std::string &URI); -APT_DEPRECATED_MSG("Specify if GMT is required or a numeric timezone can be used") std::string TimeRFC1123(time_t Date); /** returns a datetime string as needed by HTTP/1.1 and Debian files. * * Note: The date will always be represented in a UTC timezone @@ -94,7 +93,6 @@ std::string TimeRFC1123(time_t Date, bool const NumericTimezone); */ bool RFC1123StrToTime(const char* const str,time_t &time) APT_MUSTCHECK; bool FTPMDTMStrToTime(const char* const str,time_t &time) APT_MUSTCHECK; -APT_DEPRECATED_MSG("Use RFC1123StrToTime or FTPMDTMStrToTime as needed instead") bool StrToTime(const std::string &Val,time_t &Result); std::string LookupTag(const std::string &Message,const char *Tag,const char *Default = 0); int StringToBool(const std::string &Text,int Default = -1); bool ReadMessages(int Fd, std::vector<std::string> &List); @@ -220,8 +218,8 @@ class URI static std::string SiteOnly(const std::string &URI); static std::string ArchiveOnly(const std::string &URI); static std::string NoUserPassword(const std::string &URI); - - URI(std::string Path) {CopyFrom(Path);} + + explicit URI(std::string Path) { CopyFrom(Path); } URI() : Port(0) {} }; diff --git a/apt-pkg/deb/debfile.cc b/apt-pkg/deb/debfile.cc new file mode 100644 index 000000000..f8d752e7f --- /dev/null +++ b/apt-pkg/deb/debfile.cc @@ -0,0 +1,250 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ###################################################################### + + Debian Archive File (.deb) + + .DEB archives are AR files containing two tars and an empty marker + member called 'debian-binary'. The two tars contain the meta data and + the actual archive contents. Thus this class is a very simple wrapper + around ar/tar to simply extract the right tar files. + + It also uses the deb package list parser to parse the control file + into the cache. + + ##################################################################### */ + /*}}}*/ +// Include Files /*{{{*/ +#include <config.h> + +#include <apt-pkg/aptconfiguration.h> +#include <apt-pkg/arfile.h> +#include <apt-pkg/debfile.h> +#include <apt-pkg/dirstream.h> +#include <apt-pkg/error.h> +#include <apt-pkg/extracttar.h> +#include <apt-pkg/fileutl.h> +#include <apt-pkg/tagfile.h> + +#include <string> +#include <vector> +#include <string.h> +#include <sys/stat.h> + +#include <apti18n.h> + /*}}}*/ + +// DebFile::debDebFile - Constructor /*{{{*/ +// --------------------------------------------------------------------- +/* Open the AR file and check for consistency */ +debDebFile::debDebFile(FileFd &File) : File(File), AR(File) +{ + if (_error->PendingError() == true) + return; + + if (!CheckMember("debian-binary")) { + _error->Error(_("This is not a valid DEB archive, missing '%s' member"), "debian-binary"); + return; + } + + if (!CheckMember("control.tar") && + !CheckMember("control.tar.gz") && + !CheckMember("control.tar.xz") && + !CheckMember("control.tar.zst")) + { + _error->Error(_("This is not a valid DEB archive, missing '%s' member"), "control.tar"); + return; + } + + if (!CheckMember("data.tar") && + !CheckMember("data.tar.gz") && + !CheckMember("data.tar.bz2") && + !CheckMember("data.tar.lzma") && + !CheckMember("data.tar.xz") && + !CheckMember("data.tar.zst")) + { + _error->Error(_("This is not a valid DEB archive, missing '%s' member"), "data.tar"); + return; + } +} + /*}}}*/ +// DebFile::CheckMember - Check if a named member is in the archive /*{{{*/ +// --------------------------------------------------------------------- +/* This is used to check for a correct deb and to give nicer error messages + for people playing around. */ +bool debDebFile::CheckMember(const char *Name) +{ + if (AR.FindMember(Name) == 0) + return false; + return true; +} + /*}}}*/ +// DebFile::GotoMember - Jump to a Member /*{{{*/ +// --------------------------------------------------------------------- +/* Jump in the file to the start of a named member and return the information + about that member. The caller can then read from the file up to the + returned size. Note, since this relies on the file position this is + a destructive operation, it also changes the last returned Member + structure - so don't nest them! */ +const ARArchive::Member *debDebFile::GotoMember(const char *Name) +{ + // Get the archive member and positition the file + const ARArchive::Member *Member = AR.FindMember(Name); + if (Member == 0) + { + return 0; + } + if (File.Seek(Member->Start) == false) + return 0; + + return Member; +} + /*}}}*/ +// DebFile::ExtractTarMember - Extract the contents of a tar member /*{{{*/ +// --------------------------------------------------------------------- +/* Simple wrapper around tar.. */ +bool debDebFile::ExtractTarMember(pkgDirStream &Stream,const char *Name) +{ + // Get the archive member + const ARArchive::Member *Member = NULL; + std::string Compressor; + + std::vector<APT::Configuration::Compressor> compressor = APT::Configuration::getCompressors(); + for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressor.begin(); + c != compressor.end(); ++c) + { + Member = AR.FindMember(std::string(Name).append(c->Extension).c_str()); + if (Member == NULL) + continue; + Compressor = c->Name; + break; + } + + if (Member == NULL) + Member = AR.FindMember(std::string(Name).c_str()); + + if (Member == NULL) + { + std::string ext = std::string(Name) + ".{"; + for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressor.begin(); + c != compressor.end(); ++c) { + if (!c->Extension.empty()) + ext.append(c->Extension.substr(1)); + } + ext.append("}"); + return _error->Error(_("Internal error, could not locate member %s"), ext.c_str()); + } + + if (File.Seek(Member->Start) == false) + return false; + + // Prepare Tar + ExtractTar Tar(File,Member->Size,Compressor); + if (_error->PendingError() == true) + return false; + return Tar.Go(Stream); +} + /*}}}*/ +// DebFile::ExtractArchive - Extract the archive data itself /*{{{*/ +// --------------------------------------------------------------------- +/* Simple wrapper around DebFile::ExtractTarMember. */ +bool debDebFile::ExtractArchive(pkgDirStream &Stream) +{ + return ExtractTarMember(Stream, "data.tar"); +} + /*}}}*/ + +// DebFile::ControlExtract::DoItem - Control Tar Extraction /*{{{*/ +// --------------------------------------------------------------------- +/* This directory stream handler for the control tar handles extracting + it into the temporary meta directory. It only extracts files, it does + not create directories, links or anything else. */ +bool debDebFile::ControlExtract::DoItem(Item &Itm,int &Fd) +{ + if (Itm.Type != Item::File) + return true; + + /* Cleanse the file name, prevent people from trying to unpack into + absolute paths, .., etc */ + for (char *I = Itm.Name; *I != 0; I++) + if (*I == '/') + *I = '_'; + + /* Force the ownership to be root and ensure correct permissions, + go-w, the rest are left untouched */ + Itm.UID = 0; + Itm.GID = 0; + Itm.Mode &= ~(S_IWGRP | S_IWOTH); + + return pkgDirStream::DoItem(Itm,Fd); +} + /*}}}*/ + +// MemControlExtract::DoItem - Check if it is the control file /*{{{*/ +// --------------------------------------------------------------------- +/* This sets up to extract the control block member file into a memory + block of just the right size. All other files go into the bit bucket. */ +bool debDebFile::MemControlExtract::DoItem(Item &Itm,int &Fd) +{ + // At the control file, allocate buffer memory. + if (Member == Itm.Name) + { + delete [] Control; + Control = new char[Itm.Size+2]; + IsControl = true; + Fd = -2; // Signal to pass to Process + Length = Itm.Size; + } + else + IsControl = false; + + return true; +} + /*}}}*/ +// MemControlExtract::Process - Process extracting the control file /*{{{*/ +// --------------------------------------------------------------------- +/* Just memcopy the block from the tar extractor and put it in the right + place in the pre-allocated memory block. */ +bool debDebFile::MemControlExtract::Process(Item &/*Itm*/,const unsigned char *Data, + unsigned long long Size,unsigned long long Pos) +{ + memcpy(Control + Pos, Data,Size); + return true; +} + /*}}}*/ +// MemControlExtract::Read - Read the control information from the deb /*{{{*/ +// --------------------------------------------------------------------- +/* This uses the internal tar extractor to fetch the control file, and then + it parses it into a tag section parser. */ +bool debDebFile::MemControlExtract::Read(debDebFile &Deb) +{ + if (Deb.ExtractTarMember(*this, "control.tar") == false) + return false; + + if (Control == 0) + return true; + + Control[Length] = '\n'; + Control[Length+1] = '\n'; + if (Section.Scan(Control,Length+2) == false) + return _error->Error(_("Unparsable control file")); + return true; +} + /*}}}*/ +// MemControlExtract::TakeControl - Parse a memory block /*{{{*/ +// --------------------------------------------------------------------- +/* The given memory block is loaded into the parser and parsed as a control + record. */ +bool debDebFile::MemControlExtract::TakeControl(const void *Data,unsigned long long Size) +{ + delete [] Control; + Control = new char[Size+2]; + Length = Size; + memcpy(Control,Data,Size); + + Control[Length] = '\n'; + Control[Length+1] = '\n'; + return Section.Scan(Control,Length+2); +} + /*}}}*/ + diff --git a/apt-pkg/deb/debfile.h b/apt-pkg/deb/debfile.h new file mode 100644 index 000000000..21c59a567 --- /dev/null +++ b/apt-pkg/deb/debfile.h @@ -0,0 +1,95 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ###################################################################### + + Debian Archive File (.deb) + + This Class handles all the operations performed directly on .deb + files. It makes use of the AR and TAR classes to give the necessary + external interface. + + There are only two things that can be done with a raw package, + extract it's control information and extract the contents itself. + + This should probably subclass an as-yet unwritten super class to + produce a generic archive mechanism. + + The memory control file extractor is useful to extract a single file + into memory from the control.tar.gz + + ##################################################################### */ + /*}}}*/ +#ifndef PKGLIB_DEBFILE_H +#define PKGLIB_DEBFILE_H + +#include <apt-pkg/arfile.h> +#include <apt-pkg/dirstream.h> +#include <apt-pkg/macros.h> +#include <apt-pkg/tagfile.h> + +#include <string> + +#ifndef APT_8_CLEANER_HEADERS +#include <apt-pkg/md5.h> +#endif +#ifndef APT_10_CLEANER_HEADERS +#include <apt-pkg/pkgcache.h> +#endif + +class FileFd; + +class debDebFile +{ + protected: + + FileFd &File; + ARArchive AR; + + bool CheckMember(const char *Name); + + public: + class ControlExtract; + class MemControlExtract; + + bool ExtractTarMember(pkgDirStream &Stream, const char *Name); + bool ExtractArchive(pkgDirStream &Stream); + const ARArchive::Member *GotoMember(const char *Name); + inline FileFd &GetFile() {return File;}; + + explicit debDebFile(FileFd &File); +}; + +class debDebFile::ControlExtract : public pkgDirStream +{ + public: + + virtual bool DoItem(Item &Itm,int &Fd) APT_OVERRIDE; +}; + +class debDebFile::MemControlExtract : public pkgDirStream +{ + bool IsControl; + + public: + + char *Control; + pkgTagSection Section; + unsigned long Length; + std::string Member; + + // Members from DirStream + virtual bool DoItem(Item &Itm,int &Fd) APT_OVERRIDE; + virtual bool Process(Item &Itm,const unsigned char *Data, + unsigned long long Size,unsigned long long Pos) APT_OVERRIDE; + + // Helpers + bool Read(debDebFile &Deb); + bool TakeControl(const void *Data,unsigned long long Size); + + MemControlExtract() : IsControl(false), Control(0), Length(0), Member("control") {}; + explicit MemControlExtract(std::string Member) : IsControl(false), Control(0), Length(0), Member(Member) {}; + ~MemControlExtract() {delete [] Control;}; +}; + /*}}}*/ + +#endif diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index 25e0a3312..279f35a38 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -10,7 +10,9 @@ // Include Files /*{{{*/ #include <config.h> +#include <apti18n.h> #include <apt-pkg/configuration.h> +#include <apt-pkg/debfile.h> #include <apt-pkg/debindexfile.h> #include <apt-pkg/deblistparser.h> #include <apt-pkg/debrecords.h> @@ -172,36 +174,23 @@ bool debDebPkgFileIndex::GetContent(std::ostream &content, std::string const &de if (stat(debfile.c_str(), &Buf) != 0) return false; - // get the control data out of the deb file via dpkg-deb -I - std::string dpkg = _config->Find("Dir::Bin::dpkg","dpkg-deb"); - std::vector<const char *> Args; - Args.push_back(dpkg.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; - if(Popen((const char**)&Args[0], PipeFd, Child, FileFd::ReadOnly) == false) - return _error->Error("Popen failed"); + FileFd debFd(debfile, FileFd::ReadOnly); + debDebFile deb(debFd); + debDebFile::MemControlExtract extractor("control"); - std::string line; - bool first_line_seen = false; - while (PipeFd.ReadLine(line)) - { - if (first_line_seen == false) - { - if (line.empty()) - continue; - first_line_seen = true; - } - else if (line.empty()) - break; - content << line << "\n"; - } + if (not extractor.Read(deb)) + return _error->Error(_("Could not read meta data from %s"), debfile.c_str()); + + // trim off newlines + while (extractor.Control[extractor.Length] == '\n') + extractor.Control[extractor.Length--] = '\0'; + const char *Control = extractor.Control; + while (isspace_ascii(Control[0])) + Control++; + + content << Control; content << "Filename: " << debfile << "\n"; content << "Size: " << std::to_string(Buf.st_size) << "\n"; - ExecWait(Child, "Popen"); return true; } diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h index 5c89f9c54..222fed229 100644 --- a/apt-pkg/deb/debindexfile.h +++ b/apt-pkg/deb/debindexfile.h @@ -44,7 +44,7 @@ public: virtual pkgCacheListParser * CreateListParser(FileFd &Pkg) APT_OVERRIDE; - debStatusIndex(std::string const &File); + explicit debStatusIndex(std::string const &File); virtual ~debStatusIndex(); }; @@ -83,7 +83,7 @@ public: // Interface for the Cache Generator virtual bool HasPackages() const APT_OVERRIDE; - debTranslationsIndex(IndexTarget const &Target); + explicit debTranslationsIndex(IndexTarget const &Target); virtual ~debTranslationsIndex(); }; @@ -141,7 +141,7 @@ public: // Interface for acquire - debDebPkgFileIndex(std::string const &DebFile); + explicit debDebPkgFileIndex(std::string const &DebFile); virtual ~debDebPkgFileIndex(); //FIXME: use proper virtual-handling on next ABI break @@ -162,7 +162,7 @@ public: virtual pkgSrcRecords::Parser *CreateSrcParser() const APT_OVERRIDE; virtual bool HasPackages() const APT_OVERRIDE {return false;}; - debDscFileIndex(std::string const &DscFile); + explicit debDscFileIndex(std::string const &DscFile); virtual ~debDscFileIndex(); }; @@ -191,7 +191,7 @@ public: // Abort if the file does not exist. virtual bool Exists() const APT_OVERRIDE {return true;}; - debStringPackageIndex(std::string const &content); + explicit debStringPackageIndex(std::string const &content); virtual ~debStringPackageIndex(); }; #endif diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index f02252d58..8143f855f 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -121,7 +121,7 @@ class APT_HIDDEN debListParser : public pkgCacheListParser APT_PUBLIC static const char *ConvertRelation(const char *I,unsigned int &Op); - debListParser(FileFd *File); + explicit debListParser(FileFd *File); virtual ~debListParser(); }; @@ -145,15 +145,15 @@ class APT_HIDDEN debTranslationsParser : public debListParser virtual APT::StringView Version() APT_OVERRIDE { return ""; } #endif - debTranslationsParser(FileFd *File) + explicit debTranslationsParser(FileFd *File) : debListParser(File) {}; }; class APT_HIDDEN debStatusListParser : public debListParser { public: - virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver); - debStatusListParser(FileFd *File) + virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver) APT_OVERRIDE; + explicit debStatusListParser(FileFd *File) : debListParser(File) {}; }; #endif diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index f88076abf..fef58f543 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -59,7 +59,7 @@ static std::string NormalizeSignedBy(std::string SignedBy, bool const SupportFil // but fingerprints are harder to fake than the others and this option is set once, // not interactively all the time so easy to type is not really a concern. std::transform(SignedBy.begin(), SignedBy.end(), SignedBy.begin(), [](char const c) { - return (isspace(c) == 0) ? c : ','; + return (isspace_ascii(c) == 0) ? c : ','; }); auto fingers = VectorizeString(SignedBy, ','); auto const isAnEmptyString = [](std::string const &s) { return s.empty(); }; @@ -109,7 +109,7 @@ class APT_HIDDEN debReleaseIndexPrivate /*{{{*/ std::vector<std::string> SupportedComponents; std::map<std::string, std::string> const ReleaseOptions; - debReleaseIndexPrivate(std::map<std::string, std::string> const &Options) : CheckValidUntil(metaIndex::TRI_UNSET), ValidUntilMin(0), ValidUntilMax(0), CheckDate(metaIndex::TRI_UNSET), DateMaxFuture(0), NotBefore(0), ReleaseOptions(Options) {} + explicit debReleaseIndexPrivate(std::map<std::string, std::string> const &Options) : CheckValidUntil(metaIndex::TRI_UNSET), ValidUntilMin(0), ValidUntilMax(0), CheckDate(metaIndex::TRI_UNSET), DateMaxFuture(0), NotBefore(0), ReleaseOptions(Options) {} }; /*}}}*/ // ReleaseIndex::MetaIndex* - display helpers /*{{{*/ @@ -510,9 +510,6 @@ bool debReleaseIndex::Load(std::string const &Filename, std::string * const Erro Sum->MetaKeyFilename = Name; Sum->Size = Size; Sum->Hashes.FileSize(Size); - APT_IGNORE_DEPRECATED_PUSH - Sum->Hash = hs; - APT_IGNORE_DEPRECATED_POP Entries[Name] = Sum; } Entries[Name]->Hashes.push_back(hs); diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h index 7c3b9020c..ea3fc320a 100644 --- a/apt-pkg/deb/debrecords.h +++ b/apt-pkg/deb/debrecords.h @@ -85,7 +85,7 @@ class APT_HIDDEN debDebFileRecordParser : public debRecordParserBase public: virtual std::string FileName() APT_OVERRIDE; - debDebFileRecordParser(std::string FileName); + explicit debDebFileRecordParser(std::string FileName); virtual ~debDebFileRecordParser(); }; diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc index 9656fcac3..0b6cf1ff0 100644 --- a/apt-pkg/deb/debsrcrecords.cc +++ b/apt-pkg/deb/debsrcrecords.cc @@ -158,30 +158,7 @@ bool debSrcRecordParser::BuildDepends(std::vector<pkgSrcRecords::Parser::BuildDe // --------------------------------------------------------------------- /* This parses the list of files and returns it, each file is required to have a complete source package */ -bool debSrcRecordParser::Files(std::vector<pkgSrcRecords::File> &F) -{ - std::vector<pkgSrcRecords::File2> F2; - if (Files2(F2) == false) - return false; - for (std::vector<pkgSrcRecords::File2>::const_iterator f2 = F2.begin(); f2 != F2.end(); ++f2) - { - pkgSrcRecords::File2 f; -#if __GNUC__ >= 4 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#endif - f.MD5Hash = f2->MD5Hash; - f.Size = f2->Size; -#if __GNUC__ >= 4 - #pragma GCC diagnostic pop -#endif - f.Path = f2->Path; - f.Type = f2->Type; - F.push_back(f); - } - return true; -} -bool debSrcRecordParser::Files2(std::vector<pkgSrcRecords::File2> &List) +bool debSrcRecordParser::Files(std::vector<pkgSrcRecords::File> &List) { List.clear(); @@ -231,7 +208,7 @@ bool debSrcRecordParser::Files2(std::vector<pkgSrcRecords::File2> &List) path = Base + path; // look if we have a record for this file already - std::vector<pkgSrcRecords::File2>::iterator file = List.begin(); + std::vector<pkgSrcRecords::File>::iterator file = List.begin(); for (; file != List.end(); ++file) if (file->Path == path) break; @@ -239,12 +216,6 @@ bool debSrcRecordParser::Files2(std::vector<pkgSrcRecords::File2> &List) // we have it already, store the new hash and be done if (file != List.end()) { - if (checksumField == "Files") - { - APT_IGNORE_DEPRECATED_PUSH - file->MD5Hash = hash; - APT_IGNORE_DEPRECATED_POP - } // an error here indicates that we have two different hashes for the same file if (file->Hashes.push_back(hashString) == false) return _error->Error("Error parsing checksum in %s of source package %s", checksumField.c_str(), Package().c_str()); @@ -252,18 +223,12 @@ bool debSrcRecordParser::Files2(std::vector<pkgSrcRecords::File2> &List) } // we haven't seen this file yet - pkgSrcRecords::File2 F; + pkgSrcRecords::File F; F.Path = path; F.FileSize = strtoull(size.c_str(), NULL, 10); F.Hashes.push_back(hashString); F.Hashes.FileSize(F.FileSize); - APT_IGNORE_DEPRECATED_PUSH - F.Size = F.FileSize; - if (checksumField == "Files") - F.MD5Hash = hash; - APT_IGNORE_DEPRECATED_POP - // Try to guess what sort of file it is we are getting. string::size_type Pos = F.Path.length()-1; while (1) diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h index 45617f641..b572d3427 100644 --- a/apt-pkg/deb/debsrcrecords.h +++ b/apt-pkg/deb/debsrcrecords.h @@ -53,7 +53,6 @@ class APT_HIDDEN debSrcRecordParser : public pkgSrcRecords::Parser return std::string(Start,Stop); }; virtual bool Files(std::vector<pkgSrcRecords::File> &F) APT_OVERRIDE; - bool Files2(std::vector<pkgSrcRecords::File2> &F); debSrcRecordParser(std::string const &File,pkgIndexFile const *Index); virtual ~debSrcRecordParser(); diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index ffa880df2..ad5a9007e 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -301,10 +301,6 @@ bool pkgDPkgPM::Remove(PkgIterator Pkg,bool Purge) // --------------------------------------------------------------------- /* This is part of the helper script communication interface, it sends very complete information down to the other end of the pipe.*/ -bool pkgDPkgPM::SendV2Pkgs(FILE *F) -{ - return SendPkgsInfo(F, 2); -} bool pkgDPkgPM::SendPkgsInfo(FILE * const F, unsigned int const &Version) { // This version of APT supports only v3, so don't sent higher versions @@ -1223,17 +1219,6 @@ void pkgDPkgPM::BuildPackagesProgressMap() ++PackagesTotal; } /*}}}*/ -bool pkgDPkgPM::Go(int StatusFd) /*{{{*/ -{ - APT::Progress::PackageManager *progress = NULL; - if (StatusFd == -1) - progress = APT::Progress::PackageManagerProgressFactory(); - else - progress = new APT::Progress::PackageManagerProgressFd(StatusFd); - - return Go(progress); -} - /*}}}*/ void pkgDPkgPM::StartPtyMagic() /*{{{*/ { if (_config->FindB("Dpkg::Use-Pty", true) == false) diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index c073b5024..3ba4770e8 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -93,7 +93,6 @@ class pkgDPkgPM : public pkgPackageManager // Helpers bool RunScriptsWithPkgs(const char *Cnf); - APT_DEPRECATED_MSG("Use SendPkgInfo with the version as parameter instead") bool SendV2Pkgs(FILE *F); bool SendPkgsInfo(FILE * const F, unsigned int const &Version); void WriteHistoryTag(std::string const &tag, std::string value); std::string ExpandShortPackageName(pkgDepCache &Cache, @@ -127,13 +126,12 @@ class pkgDPkgPM : public pkgPackageManager virtual bool Remove(PkgIterator Pkg,bool Purge = false) APT_OVERRIDE; virtual bool Go(APT::Progress::PackageManager *progress) APT_OVERRIDE; - APT_DEPRECATED_MSG("Use overload with explicit progress manager") virtual bool Go(int StatusFd=-1) APT_OVERRIDE; virtual void Reset() APT_OVERRIDE; public: - pkgDPkgPM(pkgDepCache *Cache); + explicit pkgDPkgPM(pkgDepCache *Cache); virtual ~pkgDPkgPM(); APT_HIDDEN static bool ExpandPendingCalls(std::vector<Item> &List, pkgDepCache &Cache); diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 510f2d3f0..052e3de0e 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1723,21 +1723,6 @@ void pkgDepCache::StateCache::Update(PkgIterator Pkg,pkgCache &Cache) Status = 2; } /*}}}*/ -// StateCache::StripEpoch - Remove the epoch specifier from the version /*{{{*/ -// --------------------------------------------------------------------- -/* */ -const char *pkgDepCache::StateCache::StripEpoch(const char *Ver) -{ - if (Ver == 0) - return 0; - - // Strip any epoch - char const * const I = strchr(Ver, ':'); - if (I == nullptr) - return Ver; - return I + 1; -} - /*}}}*/ // Policy::GetCandidateVer - Returns the Candidate install version /*{{{*/ // --------------------------------------------------------------------- /* The default just returns the highest available version that is not diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index 724bf566e..3013c0ddb 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -243,7 +243,6 @@ class pkgDepCache : protected pkgCache::Namespace unsigned char DepState; // DepState Flags // Update of candidate version - APT_DEPRECATED_MSG("Use the method of the same name in contrib/strutl.h instead if you must") const char *StripEpoch(const char *Ver) APT_PURE; void Update(PkgIterator Pkg,pkgCache &Cache); // Various test members for the current status of the package @@ -364,9 +363,6 @@ class pkgDepCache : protected pkgCache::Namespace inline pkgCache &GetCache() {return *Cache;}; inline pkgVersioningSystem &VS() {return *Cache->VS;}; - // Policy implementation - APT_DEPRECATED_MSG("Confusingly named method which returns the candidate as chosen by policy (NOT as chosen via .SetCandidateVersion!). You probably want to use .GetCandidateVersion instead.") inline VerIterator GetCandidateVer(PkgIterator const &Pkg) {return /* GetCandidateVersion(Pkg); but for API compat: */ LocalPolicy->GetCandidateVer(Pkg);}; - inline bool IsImportantDep(DepIterator Dep) const {return LocalPolicy->IsImportantDep(Dep);}; inline Policy &GetPolicy() {return *LocalPolicy;}; diff --git a/apt-pkg/dirstream.cc b/apt-pkg/dirstream.cc new file mode 100644 index 000000000..d6cf0ab3f --- /dev/null +++ b/apt-pkg/dirstream.cc @@ -0,0 +1,118 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ###################################################################### + + Directory Stream + + This class provides a simple basic extractor that can be used for + a number of purposes. + + ##################################################################### */ + /*}}}*/ +// Include Files /*{{{*/ +#include <config.h> + +#include <apt-pkg/dirstream.h> +#include <apt-pkg/error.h> + +#include <errno.h> +#include <fcntl.h> +#include <sys/stat.h> +#include <sys/time.h> +#include <unistd.h> +#include <apti18n.h> + /*}}}*/ + +// DirStream::DoItem - Process an item /*{{{*/ +// --------------------------------------------------------------------- +/* This is a very simple extractor, it does not deal with things like + overwriting directories with files and so on. */ +bool pkgDirStream::DoItem(Item &Itm,int &Fd) +{ + switch (Itm.Type) + { + case Item::File: + { + /* Open the output file, NDELAY is used to prevent this from + blowing up on device special files.. */ + int iFd = open(Itm.Name,O_NDELAY|O_WRONLY|O_CREAT|O_TRUNC|O_APPEND, + Itm.Mode); + if (iFd < 0) + return _error->Errno("open",_("Failed to write file %s"), + Itm.Name); + + // fchmod deals with umask and fchown sets the ownership + if (fchmod(iFd,Itm.Mode) != 0) + { + close(iFd); + return _error->Errno("fchmod",_("Failed to write file %s"), Itm.Name); + } + if (fchown(iFd,Itm.UID,Itm.GID) != 0 && errno != EPERM) + { + close(iFd); + return _error->Errno("fchown",_("Failed to write file %s"), Itm.Name); + } + Fd = iFd; + return true; + } + + case Item::HardLink: + case Item::SymbolicLink: + case Item::CharDevice: + case Item::BlockDevice: + case Item::Directory: + { + struct stat Buf; + // check if the dir is already there, if so return true + if (stat(Itm.Name,&Buf) == 0) + { + if(S_ISDIR(Buf.st_mode)) + return true; + // something else is there already, return false + return false; + } + // nothing here, create the dir + if(mkdir(Itm.Name,Itm.Mode) < 0) + return false; + return true; + } + case Item::FIFO: + break; + } + + return true; +} + /*}}}*/ +// DirStream::FinishedFile - Finished processing a file /*{{{*/ +// --------------------------------------------------------------------- +/* */ +bool pkgDirStream::FinishedFile(Item &Itm,int Fd) +{ + if (Fd < 0) + return true; + + /* Set the modification times. The only way it can fail is if someone + has futzed with our file, which is intolerable :> */ + struct timeval times[2]; + times[0].tv_sec = times[1].tv_sec = Itm.MTime; + times[0].tv_usec = times[1].tv_usec = 0; + if (utimes(Itm.Name, times) != 0) + _error->Errno("utimes", "Failed to set modification time for %s",Itm.Name); + + if (close(Fd) != 0) + return _error->Errno("close",_("Failed to close file %s"),Itm.Name); + return true; +} + /*}}}*/ +// DirStream::Fail - Failed processing a file /*{{{*/ +// --------------------------------------------------------------------- +/* */ +bool pkgDirStream::Fail(Item &/*Itm*/, int Fd) +{ + if (Fd < 0) + return true; + + close(Fd); + return false; +} + /*}}}*/ diff --git a/apt-pkg/dirstream.h b/apt-pkg/dirstream.h new file mode 100644 index 000000000..0f0e348d0 --- /dev/null +++ b/apt-pkg/dirstream.h @@ -0,0 +1,57 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ###################################################################### + + Directory Stream + + When unpacking the contents of the archive are passed into a directory + stream class for analysis and processing. The class controls all aspects + of actually writing the directory stream from disk. The low level + archive handlers are only responsible for decoding the archive format + and sending events (via method calls) to the specified directory + stream. + + When unpacking a real file the archive handler is passed back a file + handle to write the data to, this is to support strange + archives+unpacking methods. If that fd is -1 then the file data is + simply ignored. + + The provided defaults do the 'Right Thing' for a normal unpacking + process (ie 'tar') + + ##################################################################### */ + /*}}}*/ +#ifndef PKGLIB_DIRSTREAM_H +#define PKGLIB_DIRSTREAM_H + +#include <apt-pkg/macros.h> + +class pkgDirStream +{ + public: + + // All possible information about a component + struct Item + { + enum Type_t {File, HardLink, SymbolicLink, CharDevice, BlockDevice, + Directory, FIFO} Type; + char *Name; + char *LinkTarget; + unsigned long Mode; + unsigned long UID; + unsigned long GID; + unsigned long long Size; + unsigned long MTime; + unsigned long Major; + unsigned long Minor; + }; + + virtual bool DoItem(Item &Itm,int &Fd); + virtual bool Fail(Item &Itm,int Fd); + virtual bool FinishedFile(Item &Itm,int Fd); + virtual bool Process(Item &/*Itm*/,const unsigned char * /*Data*/, + unsigned long long /*Size*/,unsigned long long /*Pos*/) {return true;}; + virtual ~pkgDirStream() {}; +}; + +#endif diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index 2e39be377..0d5fe150b 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -73,52 +73,6 @@ template<typename... Data> static bool WriteOkay(FileFd &output, Data&&... data) } /*}}}*/ // WriteScenarioVersion /*{{{*/ -static void WriteScenarioVersion(pkgDepCache &Cache, FILE* output, pkgCache::PkgIterator const &Pkg, - pkgCache::VerIterator const &Ver) -{ - fprintf(output, "Package: %s\n", Pkg.Name()); - fprintf(output, "Source: %s\n", Ver.SourcePkgName()); - fprintf(output, "Architecture: %s\n", Ver.Arch()); - fprintf(output, "Version: %s\n", Ver.VerStr()); - fprintf(output, "Source-Version: %s\n", Ver.SourceVerStr()); - if (Pkg.CurrentVer() == Ver) - fprintf(output, "Installed: yes\n"); - if (Pkg->SelectedState == pkgCache::State::Hold || - (Cache[Pkg].Keep() == true && Cache[Pkg].Protect() == true)) - fprintf(output, "Hold: yes\n"); - fprintf(output, "APT-ID: %d\n", Ver->ID); - if (PrioMap[Ver->Priority] != nullptr) - fprintf(output, "Priority: %s\n", PrioMap[Ver->Priority]); - if ((Pkg->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential) - fprintf(output, "Essential: yes\n"); - if (Ver->Section != 0) - fprintf(output, "Section: %s\n", Ver.Section()); - if ((Ver->MultiArch & pkgCache::Version::Allowed) == pkgCache::Version::Allowed) - fprintf(output, "Multi-Arch: allowed\n"); - else if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign) - fprintf(output, "Multi-Arch: foreign\n"); - else if ((Ver->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same) - fprintf(output, "Multi-Arch: same\n"); - std::set<string> Releases; - for (pkgCache::VerFileIterator I = Ver.FileList(); I.end() == false; ++I) { - pkgCache::PkgFileIterator File = I.File(); - if (File.Flagged(pkgCache::Flag::NotSource) == false) { - string Release = File.RelStr(); - if (!Release.empty()) - Releases.insert(Release); - } - } - if (!Releases.empty()) { - fprintf(output, "APT-Release:\n"); - for (std::set<string>::iterator R = Releases.begin(); R != Releases.end(); ++R) - fprintf(output, " %s\n", R->c_str()); - } - fprintf(output, "APT-Pin: %d\n", Cache.GetPolicy().GetPriority(Ver)); - if (Cache.GetCandidateVersion(Pkg) == Ver) - fprintf(output, "APT-Candidate: yes\n"); - if ((Cache[Pkg].Flags & pkgCache::Flag::Auto) == pkgCache::Flag::Auto) - fprintf(output, "APT-Automatic: yes\n"); -} static bool WriteScenarioVersion(FileFd &output, pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const &Ver) { @@ -138,44 +92,6 @@ static bool WriteScenarioVersion(FileFd &output, pkgCache::PkgIterator const &Pk } /*}}}*/ // WriteScenarioDependency /*{{{*/ -static void WriteScenarioDependency( FILE* output, pkgCache::VerIterator const &Ver) -{ - std::array<std::string, _count(DepMap)> dependencies; - bool orGroup = false; - for (pkgCache::DepIterator Dep = Ver.DependsList(); Dep.end() == false; ++Dep) - { - if (Dep.IsImplicit() == true) - continue; - if (orGroup == false) - dependencies[Dep->Type].append(", "); - dependencies[Dep->Type].append(Dep.TargetPkg().Name()); - if (Dep->Version != 0) - dependencies[Dep->Type].append(" (").append(pkgCache::CompTypeDeb(Dep->CompareOp)).append(" ").append(Dep.TargetVer()).append(")"); - if ((Dep->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or) - { - dependencies[Dep->Type].append(" | "); - orGroup = true; - } - else - orGroup = false; - } - for (size_t i = 1; i < dependencies.size(); ++i) - if (dependencies[i].empty() == false) - fprintf(output, "%s: %s\n", DepMap[i], dependencies[i].c_str()+2); - string provides; - for (pkgCache::PrvIterator Prv = Ver.ProvidesList(); Prv.end() == false; ++Prv) - { - if (Prv.IsMultiArchImplicit() == true) - continue; - if (provides.empty() == false) - provides.append(", "); - provides.append(Prv.Name()); - if (Prv->ProvideVersion != 0) - provides.append(" (= ").append(Prv.ProvideVersion()).append(")"); - } - if (provides.empty() == false) - fprintf(output, "Provides: %s\n", provides.c_str()); -} static bool WriteScenarioDependency(FileFd &output, pkgCache::VerIterator const &Ver, bool const OnlyCritical) { std::array<std::string, _count(DepMap)> dependencies; @@ -220,61 +136,6 @@ static bool WriteScenarioDependency(FileFd &output, pkgCache::VerIterator const } /*}}}*/ // WriteScenarioLimitedDependency /*{{{*/ -static void WriteScenarioLimitedDependency(FILE* output, - pkgCache::VerIterator const &Ver, - APT::PackageSet const &pkgset) -{ - std::array<std::string, _count(DepMap)> dependencies; - bool orGroup = false; - for (pkgCache::DepIterator Dep = Ver.DependsList(); Dep.end() == false; ++Dep) - { - if (Dep.IsImplicit() == true) - continue; - if (orGroup == false) - { - if (pkgset.find(Dep.TargetPkg()) == pkgset.end()) - continue; - if (dependencies[Dep->Type].empty() == false) - dependencies[Dep->Type].append(", "); - } - else if (pkgset.find(Dep.TargetPkg()) == pkgset.end()) - { - if ((Dep->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or) - continue; - dependencies[Dep->Type].erase(dependencies[Dep->Type].end()-3, dependencies[Dep->Type].end()); - orGroup = false; - continue; - } - dependencies[Dep->Type].append(Dep.TargetPkg().Name()); - if (Dep->Version != 0) - dependencies[Dep->Type].append(" (").append(pkgCache::CompTypeDeb(Dep->CompareOp)).append(" ").append(Dep.TargetVer()).append(")"); - if ((Dep->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or) - { - dependencies[Dep->Type].append(" | "); - orGroup = true; - } - else - orGroup = false; - } - for (size_t i = 1; i < dependencies.size(); ++i) - if (dependencies[i].empty() == false) - fprintf(output, "%s: %s\n", DepMap[i], dependencies[i].c_str()); - string provides; - for (pkgCache::PrvIterator Prv = Ver.ProvidesList(); Prv.end() == false; ++Prv) - { - if (Prv.IsMultiArchImplicit() == true) - continue; - if (pkgset.find(Prv.ParentPkg()) == pkgset.end()) - continue; - if (provides.empty() == false) - provides.append(", "); - provides.append(Prv.Name()); - if (Prv->ProvideVersion != 0) - provides.append(" (= ").append(Prv.ProvideVersion()).append(")"); - } - if (provides.empty() == false) - fprintf(output, "Provides: %s\n", provides.c_str()); -} static bool WriteScenarioLimitedDependency(FileFd &output, pkgCache::VerIterator const &Ver, std::vector<bool> const &pkgset, @@ -391,30 +252,6 @@ static bool WriteScenarioEDSPVersion(pkgDepCache &Cache, FileFd &output, pkgCach } /*}}}*/ // EDSP::WriteScenario - to the given file descriptor /*{{{*/ -bool EDSP::WriteScenario(pkgDepCache &Cache, FILE* output, OpProgress *Progress) -{ - if (Progress != NULL) - Progress->SubProgress(Cache.Head().VersionCount, _("Send scenario to solver")); - decltype(Cache.Head().VersionCount) p = 0; - std::vector<std::string> archs = APT::Configuration::getArchitectures(); - for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg) - { - std::string const arch = Pkg.Arch(); - if (std::find(archs.begin(), archs.end(), arch) == archs.end()) - continue; - for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; ++Ver, ++p) - { - if (SkipUnavailableVersions(Cache, Pkg, Ver)) - continue; - WriteScenarioVersion(Cache, output, Pkg, Ver); - WriteScenarioDependency(output, Ver); - fprintf(output, "\n"); - if (Progress != NULL && p % 100 == 0) - Progress->Progress(p); - } - } - return true; -} bool EDSP::WriteScenario(pkgDepCache &Cache, FileFd &output, OpProgress *Progress) { if (Progress != NULL) @@ -443,28 +280,6 @@ bool EDSP::WriteScenario(pkgDepCache &Cache, FileFd &output, OpProgress *Progres } /*}}}*/ // EDSP::WriteLimitedScenario - to the given file descriptor /*{{{*/ -bool EDSP::WriteLimitedScenario(pkgDepCache &Cache, FILE* output, - APT::PackageSet const &pkgset, - OpProgress *Progress) -{ - if (Progress != NULL) - Progress->SubProgress(Cache.Head().VersionCount, _("Send scenario to solver")); - decltype(Cache.Head().PackageCount) p = 0; - for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg, ++p) - for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; ++Ver) - { - if (SkipUnavailableVersions(Cache, Pkg, Ver)) - continue; - WriteScenarioVersion(Cache, output, Pkg, Ver); - WriteScenarioLimitedDependency(output, Ver, pkgset); - fprintf(output, "\n"); - if (Progress != NULL && p % 100 == 0) - Progress->Progress(p); - } - if (Progress != NULL) - Progress->Done(); - return true; -} bool EDSP::WriteLimitedScenario(pkgDepCache &Cache, FileFd &output, std::vector<bool> const &pkgset, OpProgress *Progress) @@ -495,60 +310,6 @@ bool EDSP::WriteLimitedScenario(pkgDepCache &Cache, FileFd &output, } /*}}}*/ // EDSP::WriteRequest - to the given file descriptor /*{{{*/ -bool EDSP::WriteRequest(pkgDepCache &Cache, FILE* output, bool const Upgrade, - bool const DistUpgrade, bool const AutoRemove, - OpProgress *Progress) -{ - if (Progress != NULL) - Progress->SubProgress(Cache.Head().PackageCount, _("Send request to solver")); - decltype(Cache.Head().PackageCount) p = 0; - string del, inst; - for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg, ++p) - { - if (Progress != NULL && p % 100 == 0) - Progress->Progress(p); - string* req; - pkgDepCache::StateCache &P = Cache[Pkg]; - if (P.Delete() == true) - req = &del; - else if (P.NewInstall() == true || P.Upgrade() == true || P.ReInstall() == true || - (P.Mode == pkgDepCache::ModeKeep && (P.iFlags & pkgDepCache::Protected) == pkgDepCache::Protected)) - req = &inst; - else - continue; - req->append(" ").append(Pkg.FullName()); - } - fprintf(output, "Request: EDSP 0.5\n"); - - const char *arch = _config->Find("APT::Architecture").c_str(); - std::vector<string> archs = APT::Configuration::getArchitectures(); - fprintf(output, "Architecture: %s\n", arch); - fprintf(output, "Architectures:"); - for (std::vector<string>::const_iterator a = archs.begin(); a != archs.end(); ++a) - fprintf(output, " %s", a->c_str()); - fprintf(output, "\n"); - - if (del.empty() == false) - fprintf(output, "Remove: %s\n", del.c_str()+1); - if (inst.empty() == false) - fprintf(output, "Install: %s\n", inst.c_str()+1); - if (Upgrade == true) - fprintf(output, "Upgrade: yes\n"); - if (DistUpgrade == true) - fprintf(output, "Dist-Upgrade: yes\n"); - if (AutoRemove == true) - fprintf(output, "Autoremove: yes\n"); - auto const solver = _config->Find("APT::Solver", "internal"); - fprintf(output, "Solver: %s\n", solver.c_str()); - auto const solverconf = std::string("APT::Solver::") + solver + "::"; - if (_config->FindB(solverconf + "Strict-Pinning", _config->FindB("APT::Solver::Strict-Pinning", true)) == false) - fprintf(output, "Strict-Pinning: no\n"); - auto const solverpref = _config->Find(solverconf + "Preferences", _config->Find("APT::Solver::Preferences", "")); - if (solverpref.empty() == false) - fprintf(output, "Preferences: %s\n", solverpref.c_str()); - fprintf(output, "\n"); - return true; -} bool EDSP::WriteRequest(pkgDepCache &Cache, FileFd &output, unsigned int const flags, OpProgress *Progress) @@ -822,33 +583,7 @@ bool EDSP::ReadRequest(int const input, std::list<std::string> &install, } } return false; -} -bool EDSP::ReadRequest(int const input, std::list<std::string> &install, - std::list<std::string> &remove, bool &upgrade, - bool &distUpgrade, bool &autoRemove) -{ - unsigned int flags; - auto const ret = ReadRequest(input, install, remove, flags); - autoRemove = (flags & Request::AUTOREMOVE); - if (flags & Request::UPGRADE_ALL) - { - if (flags & (Request::FORBID_NEW_INSTALL | Request::FORBID_REMOVE)) - { - upgrade = true; - distUpgrade = false; - } else { - upgrade = false; - distUpgrade = false; - } - } - else - { - upgrade = false; - distUpgrade = false; - } - return ret; -} - /*}}}*/ +} /*}}}*/ // EDSP::ApplyRequest - first stanza from the given file descriptor /*{{{*/ bool EDSP::ApplyRequest(std::list<std::string> const &install, std::list<std::string> const &remove, @@ -875,37 +610,6 @@ bool EDSP::ApplyRequest(std::list<std::string> const &install, } /*}}}*/ // EDSP::WriteSolutionStanza - to the given file descriptor /*{{{*/ -bool EDSP::WriteSolution(pkgDepCache &Cache, FILE* output) -{ - bool const Debug = _config->FindB("Debug::EDSP::WriteSolution", false); - for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg) - { - if (Cache[Pkg].Delete() == true) - { - fprintf(output, "Remove: %d\n", _system->GetVersionMapping(Pkg.CurrentVer()->ID)); - if (Debug == true) - fprintf(output, "Package: %s\nVersion: %s\n", Pkg.FullName().c_str(), Pkg.CurrentVer().VerStr()); - } - else if (Cache[Pkg].NewInstall() == true || Cache[Pkg].Upgrade() == true) - { - pkgCache::VerIterator const CandVer = Cache.GetCandidateVersion(Pkg); - fprintf(output, "Install: %d\n", _system->GetVersionMapping(CandVer->ID)); - if (Debug == true) - fprintf(output, "Package: %s\nVersion: %s\n", Pkg.FullName().c_str(), CandVer.VerStr()); - } - else if (Cache[Pkg].Garbage == true) - { - fprintf(output, "Autoremove: %d\n", _system->GetVersionMapping(Pkg.CurrentVer()->ID)); - if (Debug == true) - fprintf(output, "Package: %s\nVersion: %s\n", Pkg.FullName().c_str(), Pkg.CurrentVer().VerStr()); - } - else - continue; - fprintf(output, "\n"); - } - - return true; -} bool EDSP::WriteSolutionStanza(FileFd &output, char const * const Type, pkgCache::VerIterator const &Ver) { bool Okay = output.Failed() == false; @@ -916,13 +620,6 @@ bool EDSP::WriteSolutionStanza(FileFd &output, char const * const Type, pkgCache } /*}}}*/ // EDSP::WriteProgess - pulse to the given file descriptor /*{{{*/ -bool EDSP::WriteProgress(unsigned short const percent, const char* const message, FILE* output) { - fprintf(output, "Progress: %s\n", TimeRFC1123(time(NULL), true).c_str()); - fprintf(output, "Percentage: %d\n", percent); - fprintf(output, "Message: %s\n\n", message); - fflush(output); - return true; -} bool EDSP::WriteProgress(unsigned short const percent, const char* const message, FileFd &output) { return WriteOkay(output, "Progress: ", TimeRFC1123(time(NULL), true), "\n", "Percentage: ", percent, "\n", @@ -934,11 +631,6 @@ static std::string formatMessage(std::string const &msg) { return SubstVar(SubstVar(APT::String::Strip(msg), "\n\n", "\n.\n"), "\n", "\n "); } -bool EDSP::WriteError(char const * const uuid, std::string const &message, FILE* output) { - fprintf(output, "Error: %s\n", uuid); - fprintf(output, "Message: %s\n\n", formatMessage(message).c_str()); - return true; -} bool EDSP::WriteError(char const * const uuid, std::string const &message, FileFd &output) { return WriteOkay(output, "Error: ", uuid, "\n", "Message: ", formatMessage(message), @@ -1020,11 +712,6 @@ static pid_t ExecuteExternal(char const* const type, char const * const binary, pid_t EDSP::ExecuteSolver(const char* const solver, int * const solver_in, int * const solver_out, bool) { return ExecuteExternal("solver", solver, "Dir::Bin::Solvers", solver_in, solver_out); } -bool EDSP::ExecuteSolver(const char* const solver, int *solver_in, int *solver_out) { - if (ExecuteSolver(solver, solver_in, solver_out, true) == 0) - return false; - return true; -} /*}}}*/ static bool CreateDumpFile(char const * const id, char const * const type, FileFd &output)/*{{{*/ { @@ -1086,20 +773,7 @@ bool EDSP::ResolveExternal(const char* const solver, pkgDepCache &Cache, if (ExecWait(solver_pid, solver)) return ret; return false; -} -bool EDSP::ResolveExternal(const char* const solver, pkgDepCache &Cache, - bool const upgrade, bool const distUpgrade, - bool const autoRemove, OpProgress *Progress) { - unsigned int flags = 0; - if (autoRemove) - flags |= Request::AUTOREMOVE; - if (upgrade) - flags |= Request::UPGRADE_ALL | Request::FORBID_REMOVE | Request::FORBID_NEW_INSTALL; - if (distUpgrade) - flags |= Request::UPGRADE_ALL; - return ResolveExternal(solver, Cache, flags, Progress); -} - /*}}}*/ +} /*}}}*/ bool EIPP::OrderInstall(char const * const solver, pkgPackageManager * const PM, /*{{{*/ unsigned int const flags, OpProgress * const Progress) diff --git a/apt-pkg/edsp.h b/apt-pkg/edsp.h index 2f18d76eb..5eb72d48d 100644 --- a/apt-pkg/edsp.h +++ b/apt-pkg/edsp.h @@ -56,11 +56,6 @@ namespace EDSP /*{{{*/ bool WriteRequest(pkgDepCache &Cache, FileFd &output, unsigned int const flags = 0, OpProgress *Progress = NULL); - bool WriteRequest(pkgDepCache &Cache, FILE* output, - bool const upgrade = false, - bool const distUpgrade = false, - bool const autoRemove = false, - OpProgress *Progress = NULL) APT_DEPRECATED_MSG("Use FileFd-based interface instead"); /** \brief creates the scenario representing the package universe * @@ -80,7 +75,6 @@ namespace EDSP /*{{{*/ * \return true if universe was composed successfully, otherwise false */ bool WriteScenario(pkgDepCache &Cache, FileFd &output, OpProgress *Progress = NULL); - bool WriteScenario(pkgDepCache &Cache, FILE* output, OpProgress *Progress = NULL) APT_DEPRECATED_MSG("Use FileFd-based interface instead"); /** \brief creates a limited scenario representing the package universe * @@ -100,9 +94,6 @@ namespace EDSP /*{{{*/ bool WriteLimitedScenario(pkgDepCache &Cache, FileFd &output, std::vector<bool> const &pkgset, OpProgress *Progress = NULL); - bool WriteLimitedScenario(pkgDepCache &Cache, FILE* output, - APT::PackageSet const &pkgset, - OpProgress *Progress = NULL) APT_DEPRECATED_MSG("Use FileFd-based interface instead"); /** \brief waits and acts on the information returned from the solver * @@ -138,9 +129,6 @@ namespace EDSP /*{{{*/ */ bool ReadRequest(int const input, std::list<std::string> &install, std::list<std::string> &remove, unsigned int &flags); - APT_DEPRECATED_MSG("use the flag-based version instead") bool ReadRequest(int const input, std::list<std::string> &install, - std::list<std::string> &remove, bool &upgrade, - bool &distUpgrade, bool &autoRemove); /** \brief takes the request lists and applies it on the cache * @@ -171,7 +159,6 @@ namespace EDSP /*{{{*/ * \return true if stanza could be written, otherwise false */ bool WriteSolutionStanza(FileFd &output, char const * const Type, pkgCache::VerIterator const &Ver); - bool WriteSolution(pkgDepCache &Cache, FILE* output) APT_DEPRECATED_MSG("Use FileFd-based single-stanza interface instead"); /** \brief sends a progress report * @@ -180,7 +167,6 @@ namespace EDSP /*{{{*/ * \param output the front-end listens for progress report */ bool WriteProgress(unsigned short const percent, const char* const message, FileFd &output); - bool WriteProgress(unsigned short const percent, const char* const message, FILE* output) APT_DEPRECATED_MSG("Use FileFd-based interface instead"); /** \brief sends an error report * @@ -198,7 +184,6 @@ namespace EDSP /*{{{*/ * \param output the front-end listens for error messages */ bool WriteError(char const * const uuid, std::string const &message, FileFd &output); - bool WriteError(char const * const uuid, std::string const &message, FILE* output) APT_DEPRECATED_MSG("Use FileFd-based interface instead"); /** \brief executes the given solver and returns the pipe ends @@ -213,7 +198,6 @@ namespace EDSP /*{{{*/ * \return PID of the started solver or 0 if failure occurred */ pid_t ExecuteSolver(const char* const solver, int * const solver_in, int * const solver_out, bool /*overload*/); - APT_DEPRECATED_MSG("add a dummy bool parameter to use the overload returning a pid_t") bool ExecuteSolver(const char* const solver, int *solver_in, int *solver_out); /** \brief call an external resolver to handle the request * @@ -230,9 +214,6 @@ namespace EDSP /*{{{*/ bool ResolveExternal(const char* const solver, pkgDepCache &Cache, unsigned int const flags = 0, OpProgress *Progress = NULL); - APT_DEPRECATED_MSG("use the flag-based version instead") bool ResolveExternal(const char* const solver, pkgDepCache &Cache, - bool const upgrade, bool const distUpgrade, - bool const autoRemove, OpProgress *Progress = NULL); } /*}}}*/ class pkgPackageManager; diff --git a/apt-pkg/edsp/edspindexfile.h b/apt-pkg/edsp/edspindexfile.h index 4ac0f9d72..8fa8fdd60 100644 --- a/apt-pkg/edsp/edspindexfile.h +++ b/apt-pkg/edsp/edspindexfile.h @@ -29,7 +29,7 @@ public: virtual bool Exists() const APT_OVERRIDE; virtual bool HasPackages() const APT_OVERRIDE; - edspLikeIndex(std::string const &File); + explicit edspLikeIndex(std::string const &File); virtual ~edspLikeIndex(); }; @@ -42,7 +42,7 @@ protected: public: virtual const Type *GetType() const APT_OVERRIDE APT_PURE; - edspIndex(std::string const &File); + explicit edspIndex(std::string const &File); virtual ~edspIndex(); }; @@ -55,7 +55,7 @@ protected: public: virtual const Type *GetType() const APT_OVERRIDE APT_PURE; - eippIndex(std::string const &File); + explicit eippIndex(std::string const &File); virtual ~eippIndex(); }; diff --git a/apt-pkg/edsp/edsplistparser.h b/apt-pkg/edsp/edsplistparser.h index 59c759f9d..8f56f8abf 100644 --- a/apt-pkg/edsp/edsplistparser.h +++ b/apt-pkg/edsp/edsplistparser.h @@ -35,7 +35,7 @@ class APT_HIDDEN edspLikeListParser : public debListParser virtual APT::StringView Description_md5() APT_OVERRIDE; virtual unsigned short VersionHash() APT_OVERRIDE; - edspLikeListParser(FileFd *File); + explicit edspLikeListParser(FileFd *File); virtual ~edspLikeListParser(); }; @@ -48,7 +48,7 @@ protected: virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver) APT_OVERRIDE; public: - edspListParser(FileFd *File); + explicit edspListParser(FileFd *File); virtual ~edspListParser(); }; @@ -58,7 +58,7 @@ protected: virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver) APT_OVERRIDE; public: - eippListParser(FileFd *File); + explicit eippListParser(FileFd *File); virtual ~eippListParser(); }; #endif diff --git a/apt-pkg/edsp/edspsystem.h b/apt-pkg/edsp/edspsystem.h index 0855bb53f..8f5452dcb 100644 --- a/apt-pkg/edsp/edspsystem.h +++ b/apt-pkg/edsp/edspsystem.h @@ -37,7 +37,7 @@ public: virtual bool FindIndex(pkgCache::PkgFileIterator File, pkgIndexFile *&Found) const APT_OVERRIDE; - edspLikeSystem(char const * const Label); + explicit edspLikeSystem(char const * const Label); virtual ~edspLikeSystem(); }; diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 41cecdec1..9fa9361a3 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -640,16 +640,6 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList, return true; } /*}}}*/ -// SigVerify::RunGPGV - deprecated wrapper calling ExecGPGV /*{{{*/ -APT_NORETURN bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut, - int const &statusfd, int fd[2]) { - ExecGPGV(File, FileOut, statusfd, fd); -} -APT_NORETURN bool SigVerify::RunGPGV(std::string const &File, std::string const &FileOut, - int const &statusfd) { - ExecGPGV(File, FileOut, statusfd); -} - /*}}}*/ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ vector<string> &List, pkgCdromStatus *log) { diff --git a/apt-pkg/indexcopy.h b/apt-pkg/indexcopy.h index dc3b985a2..8dfd68d9a 100644 --- a/apt-pkg/indexcopy.h +++ b/apt-pkg/indexcopy.h @@ -116,11 +116,6 @@ class SigVerify /*{{{*/ bool CopyAndVerify(std::string CDROM,std::string Name,std::vector<std::string> &SigList, std::vector<std::string> PkgList,std::vector<std::string> SrcList); - APT_DEPRECATED_MSG("Use ExecGPGV instead") static bool RunGPGV(std::string const &File, std::string const &FileOut, - int const &statusfd, int fd[2]); - APT_DEPRECATED_MSG("Use ExecGPGV instead") static bool RunGPGV(std::string const &File, std::string const &FileOut, - int const &statusfd = -1); - SigVerify(); virtual ~SigVerify(); }; diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc index 85d0e87cd..a7290c653 100644 --- a/apt-pkg/indexfile.cc +++ b/apt-pkg/indexfile.cc @@ -86,32 +86,6 @@ std::string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &/*Record*/, return std::string(); } /*}}}*/ -// IndexFile::TranslationsAvailable - Check if will use Translation /*{{{*/ -bool pkgIndexFile::TranslationsAvailable() { - return (APT::Configuration::getLanguages().empty() != true); -} - /*}}}*/ -// IndexFile::CheckLanguageCode - Check the Language Code /*{{{*/ -bool pkgIndexFile::CheckLanguageCode(const char * const Lang) -{ - if (strlen(Lang) == 2 || (strlen(Lang) == 5 && Lang[2] == '_')) - return true; - - if (strcmp(Lang,"C") != 0) - _error->Warning("Wrong language code %s", Lang); - - return false; -} - /*}}}*/ -// IndexFile::LanguageCode - Return the Language Code /*{{{*/ -std::string pkgIndexFile::LanguageCode() { -APT_IGNORE_DEPRECATED_PUSH - if (TranslationsAvailable() == false) - return ""; - return APT::Configuration::getLanguages()[0]; -APT_IGNORE_DEPRECATED_POP -} - /*}}}*/ // IndexTarget - Constructor /*{{{*/ IndexTarget::IndexTarget(std::string const &MetaKey, std::string const &ShortDesc, diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h index 31b95172e..d69d84d39 100644 --- a/apt-pkg/indexfile.h +++ b/apt-pkg/indexfile.h @@ -150,15 +150,6 @@ class pkgIndexFile virtual bool Merge(pkgCacheGenerator &/*Gen*/, OpProgress* const /*Prog*/) { return true; }; virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const; - APT_DEPRECATED_MSG("These methods make no sense anymore with multi-language support") static bool TranslationsAvailable(); - /* No intern need for this method anymore as the check for correctness - is already done in getLanguages(). Note also that this check is - rather bad (doesn't take three character like ast into account).*/ - APT_DEPRECATED_MSG("These methods make no sense anymore with multi-language support") static bool CheckLanguageCode(const char * const Lang); - /* As we have now possibly more than one LanguageCode this method is - superseded by a) private classmembers or b) getLanguages() */ - APT_DEPRECATED_MSG("These methods make no sense anymore with multi-language support") static std::string LanguageCode(); - bool IsTrusted() const { return Trusted; }; explicit pkgIndexFile(bool const Trusted); diff --git a/apt-pkg/metaindex.h b/apt-pkg/metaindex.h index 08664305e..08affe888 100644 --- a/apt-pkg/metaindex.h +++ b/apt-pkg/metaindex.h @@ -30,16 +30,12 @@ class metaIndexPrivate; class metaIndex { public: - APT_IGNORE_DEPRECATED_PUSH struct checkSum { std::string MetaKeyFilename; HashStringList Hashes; unsigned long long Size; - - APT_DEPRECATED_MSG("Use the HashStringList member Hashes instead of a hardcoded HashString") HashString Hash; }; - APT_IGNORE_DEPRECATED_POP enum APT_HIDDEN TriState { TRI_YES, TRI_DONTCARE, TRI_NO, TRI_UNSET diff --git a/apt-pkg/orderlist.h b/apt-pkg/orderlist.h index 3fa02342b..bb21e1d7d 100644 --- a/apt-pkg/orderlist.h +++ b/apt-pkg/orderlist.h @@ -47,7 +47,6 @@ class pkgOrderList : protected pkgCache::Namespace bool Debug; // Main visit function - APT_DEPRECATED_MSG("Add a unique calling identifier as parameter for debugging output") bool VisitNode(PkgIterator Pkg) { return VisitNode(Pkg, "UNKNOWN"); }; bool VisitNode(PkgIterator Pkg, char const* from); bool VisitDeps(DepFunc F,PkgIterator Pkg); bool VisitRDeps(DepFunc F,PkgIterator Pkg); diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 156f7adb5..21905c7b6 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -632,10 +632,6 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth) // PM::EarlyRemove - Perform removal of packages before their time /*{{{*/ // --------------------------------------------------------------------- /* This is called to deal with conflicts arising from unpacking */ -bool pkgPackageManager::EarlyRemove(PkgIterator Pkg) -{ - return EarlyRemove(Pkg, NULL); -} bool pkgPackageManager::EarlyRemove(PkgIterator Pkg, DepIterator const * const Dep) { if (List->IsNow(Pkg) == false) @@ -1128,19 +1124,6 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() return Completed; } -// PM::DoInstallPostFork - compat /*{{{*/ -// --------------------------------------------------------------------- - /*}}}*/ -pkgPackageManager::OrderResult -pkgPackageManager::DoInstallPostFork(int statusFd) -{ - APT::Progress::PackageManager *progress = new - APT::Progress::PackageManagerProgressFd(statusFd); - pkgPackageManager::OrderResult res = DoInstallPostFork(progress); - delete progress; - return res; -} - /*}}}*/ // PM::DoInstallPostFork - Does install part that happens after the fork /*{{{*/ // --------------------------------------------------------------------- pkgPackageManager::OrderResult @@ -1160,19 +1143,6 @@ pkgPackageManager::DoInstallPostFork(APT::Progress::PackageManager *progress) /*}}}*/ // PM::DoInstall - Does the installation /*{{{*/ // --------------------------------------------------------------------- -/* compat */ -pkgPackageManager::OrderResult -pkgPackageManager::DoInstall(int statusFd) -{ - APT::Progress::PackageManager *progress = new - APT::Progress::PackageManagerProgressFd(statusFd); - OrderResult res = DoInstall(progress); - delete progress; - return res; - } - /*}}}*/ -// PM::DoInstall - Does the installation /*{{{*/ -// --------------------------------------------------------------------- /* This uses the filenames in FileNames and the information in the DepCache to perform the installation of packages.*/ pkgPackageManager::OrderResult diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h index d9443443d..9a06e2875 100644 --- a/apt-pkg/packagemanager.h +++ b/apt-pkg/packagemanager.h @@ -92,14 +92,12 @@ class pkgPackageManager : protected pkgCache::Namespace bool SmartUnPack(PkgIterator Pkg, bool const Immediate, int const Depth) APT_MUSTCHECK; bool SmartRemove(PkgIterator Pkg) APT_MUSTCHECK; bool EarlyRemove(PkgIterator Pkg, DepIterator const * const Dep) APT_MUSTCHECK; - APT_DEPRECATED bool EarlyRemove(PkgIterator Pkg) APT_MUSTCHECK; // The Actual installation implementation virtual bool Install(PkgIterator /*Pkg*/,std::string /*File*/) {return false;}; virtual bool Configure(PkgIterator /*Pkg*/) {return false;}; virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;}; virtual bool Go(APT::Progress::PackageManager * /*progress*/) {return true;}; - APT_DEPRECATED_MSG("Use overload with explicit progress manager") virtual bool Go(int /*statusFd*/=-1) {return true;}; virtual void Reset() {}; @@ -114,8 +112,6 @@ class pkgPackageManager : protected pkgCache::Namespace // Do the installation OrderResult DoInstall(APT::Progress::PackageManager *progress); - // compat - APT_DEPRECATED_MSG("Use APT::Progress::PackageManager subclass instead of fd") OrderResult DoInstall(int statusFd=-1); friend bool EIPP::OrderInstall(char const * const planner, pkgPackageManager * const PM, unsigned int const version, OpProgress * const Progress); @@ -131,7 +127,6 @@ class pkgPackageManager : protected pkgCache::Namespace // stuff that needs to be done after the fork OrderResult DoInstallPostFork(APT::Progress::PackageManager *progress); // compat - APT_DEPRECATED_MSG("Use APT::Progress::PackageManager subclass instead of fd") OrderResult DoInstallPostFork(int statusFd=-1); // ? bool FixMissing(); diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 80dd1d1fa..5819a9b4a 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -125,7 +125,6 @@ bool pkgCache::Header::CheckSizes(Header &Against) const // Cache::pkgCache - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -APT_IGNORE_DEPRECATED_PUSH pkgCache::pkgCache(MMap *Map, bool DoMap) : Map(*Map), VS(nullptr), d(NULL) { // call getArchitectures() with cached=false to ensure that the @@ -135,7 +134,6 @@ pkgCache::pkgCache(MMap *Map, bool DoMap) : Map(*Map), VS(nullptr), d(NULL) if (DoMap == true) ReMap(); } -APT_IGNORE_DEPRECATED_POP /*}}}*/ // Cache::ReMap - Reopen the cache file /*{{{*/ // --------------------------------------------------------------------- @@ -562,19 +560,6 @@ pkgCache::PkgIterator::OkState pkgCache::PkgIterator::State() const return NeedsNothing; } /*}}}*/ -// PkgIterator::CandVersion - Returns the candidate version string /*{{{*/ -// --------------------------------------------------------------------- -/* Return string representing of the candidate version. */ -const char * -pkgCache::PkgIterator::CandVersion() const -{ - //TargetVer is empty, so don't use it. - VerIterator version = pkgPolicy(Owner).GetCandidateVer(*this); - if (version.IsGood()) - return version.VerStr(); - return 0; -} - /*}}}*/ // PkgIterator::CurVersion - Returns the current version string /*{{{*/ // --------------------------------------------------------------------- /* Return string representing of the current version. */ @@ -600,15 +585,10 @@ operator<<(std::ostream& out, pkgCache::PkgIterator Pkg) return out << "invalid package"; string current = string(Pkg.CurVersion() == 0 ? "none" : Pkg.CurVersion()); -APT_IGNORE_DEPRECATED_PUSH - string candidate = string(Pkg.CandVersion() == 0 ? "none" : Pkg.CandVersion()); -APT_IGNORE_DEPRECATED_POP string newest = string(Pkg.VersionList().end() ? "none" : Pkg.VersionList().VerStr()); out << Pkg.Name() << " [ " << Pkg.Arch() << " ] < " << current; - if (current != candidate) - out << " -> " << candidate; - if ( newest != "none" && candidate != newest) + if ( newest != "none") out << " | " << newest; if (Pkg->VersionList == 0) out << " > ( none )"; @@ -1009,16 +989,6 @@ const char * pkgCache::VerIterator::MultiArchType() const return "none"; } /*}}}*/ -// RlsFileIterator::IsOk - Checks if the cache is in sync with the file /*{{{*/ -// --------------------------------------------------------------------- -/* This stats the file and compares its stats with the ones that were - stored during generation. Date checks should probably also be - included here. */ -bool pkgCache::RlsFileIterator::IsOk() -{ - return true; -} - /*}}}*/ // RlsFileIterator::RelStr - Return the release string /*{{{*/ string pkgCache::RlsFileIterator::RelStr() { @@ -1036,16 +1006,6 @@ string pkgCache::RlsFileIterator::RelStr() return Res; } /*}}}*/ -// PkgFileIterator::IsOk - Checks if the cache is in sync with the file /*{{{*/ -// --------------------------------------------------------------------- -/* This stats the file and compares its stats with the ones that were - stored during generation. Date checks should probably also be - included here. */ -bool pkgCache::PkgFileIterator::IsOk() -{ - return true; -} - /*}}}*/ string pkgCache::PkgFileIterator::RelStr() /*{{{*/ { std::string Res; diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h index 787e3995f..c20320a56 100644 --- a/apt-pkg/pkgcache.h +++ b/apt-pkg/pkgcache.h @@ -220,7 +220,6 @@ class pkgCache /*{{{*/ Provides *ProvideP; Dependency *DepP; DependencyData *DepDataP; - APT_DEPRECATED_MSG("Not used anymore in cache generation and without a replacement") StringItem *StringItemP; char *StrP; virtual bool ReMap(bool const &Errorchecks = true); @@ -438,11 +437,6 @@ struct pkgCache::Group */ struct pkgCache::Package { - /** \brief Name of the package - * Note that the access method Name() will remain. It is just this data member - * deprecated as this information is already stored and available via the - * associated Group – so it is wasting precious binary cache space */ - APT_DEPRECATED_MSG("Use the .Name() method instead of accessing the member directly") map_stringitem_t Name; /** \brief Architecture of the package */ map_stringitem_t Arch; /** \brief Base of a singly linked list of versions @@ -607,7 +601,6 @@ struct pkgCache::DescFile The version list is always sorted from highest version to lowest version by the generator. Equal version numbers are either merged or handled as separate versions based on the Hash value. */ -APT_IGNORE_DEPRECATED_PUSH struct pkgCache::Version { /** \brief complete version string */ @@ -630,9 +623,6 @@ struct pkgCache::Version AllForeign = All | Foreign, AllAllowed = All | Allowed }; - /** \brief deprecated variant of No */ - static const APT_DEPRECATED_MSG("The default value of the Multi-Arch field is no, not none") VerMultiArch None = No; - /** \brief stores the MultiArch capabilities of this version Flags used are defined in pkgCache::Version::VerMultiArch @@ -675,7 +665,6 @@ struct pkgCache::Version /** \brief parsed priority value */ map_number_t Priority; }; -APT_IGNORE_DEPRECATED_POP /*}}}*/ // Description structure /*{{{*/ /** \brief datamember of a linked list of available description for a version */ @@ -770,15 +759,6 @@ struct pkgCache::Provides map_pointer_t NextPkgProv; // Provides }; /*}}}*/ -// UNUSED StringItem structure /*{{{*/ -struct APT_DEPRECATED_MSG("No longer used in cache generation without a replacement") pkgCache::StringItem -{ - /** \brief string this refers to */ - map_ptrloc String; // StringItem - /** \brief Next link in the chain */ - map_ptrloc NextItem; // StringItem -}; - /*}}}*/ inline char const * pkgCache::NativeArch() { return StrP + HeaderP->Architecture; } diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 5a3b65b3a..030f4df0a 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -600,9 +600,6 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg, StringView Name, Pkg = pkgCache::PkgIterator(Cache,Cache.PkgP + Package); // Set the name, arch and the ID - APT_IGNORE_DEPRECATED_PUSH - Pkg->Name = Grp->Name; - APT_IGNORE_DEPRECATED_POP Pkg->Group = Grp.Index(); // all is mapped to the native architecture map_stringitem_t const idxArch = (Arch == "all") ? Cache.HeaderP->Architecture : StoreString(MIXED, Arch); @@ -1644,9 +1641,6 @@ static bool loadBackMMapFromFile(std::unique_ptr<pkgCacheGenerator> &Gen, Gen.reset(new pkgCacheGenerator(Map.get(),Progress)); return Gen->Start(); } -bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, - MMap **OutMap, bool AllowMem) - { return pkgCacheGenerator::MakeStatusCache(List, &Progress, OutMap, AllowMem); } bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress, MMap **OutMap,bool) { @@ -1809,8 +1803,6 @@ public: ScopedErrorMerge() { _error->PushToStack(); } ~ScopedErrorMerge() { _error->MergeWithStack(); } }; -bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap) - { return pkgCacheGenerator::MakeOnlyStatusCache(&Progress, OutMap); } bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **OutMap) { std::vector<pkgIndexFile *> Files; diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h index e11e97e09..42ea3aa34 100644 --- a/apt-pkg/pkgcachegen.h +++ b/apt-pkg/pkgcachegen.h @@ -245,8 +245,4 @@ class APT_HIDDEN pkgCacheListParser }; /*}}}*/ -APT_DEPRECATED_MSG("Use pkgCacheGenerator::MakeStatusCache instead") bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, - MMap **OutMap = 0,bool AllowMem = false); -APT_DEPRECATED_MSG("Use pkgCacheGenerator::MakeOnlyStatusCache instead") bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap); - #endif diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h index 6d1342d45..25cc07f2f 100644 --- a/apt-pkg/pkgrecords.h +++ b/apt-pkg/pkgrecords.h @@ -67,10 +67,6 @@ class pkgRecords::Parser /*{{{*/ * choose the hash to be used. */ virtual HashStringList Hashes() const { return HashStringList(); }; - APT_DEPRECATED_MSG("Use .Hashes instead of a hardcoded hash algorithm") std::string MD5Hash() const { return GetHashFromHashes("MD5Sum"); }; - APT_DEPRECATED_MSG("Use .Hashes instead of a hardcoded hash algorithm") std::string SHA1Hash() const { return GetHashFromHashes("SHA1"); }; - APT_DEPRECATED_MSG("Use .Hashes instead of a hardcoded hash algorithm") std::string SHA256Hash() const { return GetHashFromHashes("SHA256"); }; - APT_DEPRECATED_MSG("Use .Hashes instead of a hardcoded hash algorithm") std::string SHA512Hash() const { return GetHashFromHashes("SHA512"); }; // These are some general stats about the package virtual std::string Maintainer() {return std::string();}; diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index a3d693151..eef4d8a7f 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -571,8 +571,8 @@ bool pkgSourceList::AddVolatileFile(std::string const &File, std::vector<std::st else if (ext == "changes") { debDscRecordParser changes(File, nullptr); - std::vector<pkgSrcRecords::File2> fileslst; - if (changes.Files2(fileslst) == false || fileslst.empty()) + std::vector<pkgSrcRecords::File> fileslst; + if (changes.Files(fileslst) == false || fileslst.empty()) return false; auto const basedir = flNotFile(File); for (auto && file: fileslst) @@ -623,21 +623,4 @@ void pkgSourceList::AddVolatileFiles(CommandLine &CmdL, std::vector<std::string> return false; }); } -void pkgSourceList::AddVolatileFiles(CommandLine &CmdL, std::vector<const char*> * const VolatileCmdL) -{ - std::remove_if(CmdL.FileList + 1, CmdL.FileList + 1 + CmdL.FileSize(), [&](char const * const I) { - if (I != nullptr && (I[0] == '/' || (I[0] == '.' && (I[1] == '\0' || (I[1] == '.' && (I[2] == '\0' || I[2] == '/')) || I[1] == '/')))) - { - if (AddVolatileFile(I)) - { - if (VolatileCmdL != nullptr) - VolatileCmdL->push_back(I); - } - else - _error->Error(_("Unsupported file %s given on commandline"), I); - return true; - } - return false; - }); -} /*}}}*/ diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h index fedf90fa6..255c99868 100644 --- a/apt-pkg/sourcelist.h +++ b/apt-pkg/sourcelist.h @@ -131,7 +131,6 @@ class pkgSourceList void AddVolatileFile(pkgIndexFile * const File); bool AddVolatileFile(std::string const &File); bool AddVolatileFile(std::string const &File, std::vector<std::string> * const VolatileCmdL); - APT_DEPRECATED_MSG("Use the overload with string-vector") void AddVolatileFiles(CommandLine &CmdL, std::vector<const char*> * const VolatileCmdL); void AddVolatileFiles(CommandLine &CmdL, std::vector<std::string> * const VolatileCmdL); /** @return list of files registered with #AddVolatileFile */ diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc index 9d515ae75..a830a28f0 100644 --- a/apt-pkg/srcrecords.cc +++ b/apt-pkg/srcrecords.cc @@ -146,36 +146,6 @@ const char *pkgSrcRecords::Parser::BuildDepType(unsigned char const &Type) return fields[Type]; } /*}}}*/ -bool pkgSrcRecords::Parser::Files2(std::vector<pkgSrcRecords::File2> &F2)/*{{{*/ -{ - debSrcRecordParser * const deb = dynamic_cast<debSrcRecordParser*>(this); - if (deb != NULL) - return deb->Files2(F2); - - std::vector<pkgSrcRecords::File> F; - if (Files(F) == false) - return false; - for (std::vector<pkgSrcRecords::File>::const_iterator f = F.begin(); f != F.end(); ++f) - { - pkgSrcRecords::File2 f2; -#if __GNUC__ >= 4 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#endif - f2.MD5Hash = f->MD5Hash; - f2.Size = f->Size; - f2.Hashes.push_back(HashString("MD5Sum", f->MD5Hash)); - f2.FileSize = f->Size; -#if __GNUC__ >= 4 - #pragma GCC diagnostic pop -#endif - f2.Path = f->Path; - f2.Type = f->Type; - F2.push_back(f2); - } - return true; -} - /*}}}*/ pkgSrcRecords::Parser::Parser(const pkgIndexFile *Index) : d(NULL), iIndex(Index) {} diff --git a/apt-pkg/srcrecords.h b/apt-pkg/srcrecords.h index 8c52f5683..77d648fa8 100644 --- a/apt-pkg/srcrecords.h +++ b/apt-pkg/srcrecords.h @@ -29,21 +29,14 @@ class pkgSrcRecords { public: -APT_IGNORE_DEPRECATED_PUSH // Describes a single file struct File { - APT_DEPRECATED_MSG("Use Hashes member instead of hardcoded hash algorithm") std::string MD5Hash; - APT_DEPRECATED_MSG("Use FileSize member instead") unsigned long Size; std::string Path; std::string Type; - }; - struct File2 : public File - { unsigned long long FileSize; HashStringList Hashes; }; -APT_IGNORE_DEPRECATED_POP // Abstract parser for each source record class Parser @@ -86,7 +79,6 @@ APT_IGNORE_DEPRECATED_POP static const char *BuildDepType(unsigned char const &Type) APT_PURE; virtual bool Files(std::vector<pkgSrcRecords::File> &F) = 0; - bool Files2(std::vector<pkgSrcRecords::File2> &F); explicit Parser(const pkgIndexFile *Index); virtual ~Parser(); diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index 1e7f2867c..bbece1d7e 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -69,7 +69,7 @@ public: { bool const good; size_t length; - FileChunk(bool const pgood, size_t const plength) : good(pgood), length(plength) {} + FileChunk(bool const pgood, size_t const plength) noexcept : good(pgood), length(plength) {} }; std::list<FileChunk> chunks; @@ -473,14 +473,12 @@ bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long long Offset) // pkgTagSection::pkgTagSection - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -APT_IGNORE_DEPRECATED_PUSH pkgTagSection::pkgTagSection() : Section(0), d(new pkgTagSectionPrivate()), Stop(0) { memset(&AlphaIndexes, 0, sizeof(AlphaIndexes)); memset(&BetaIndexes, 0, sizeof(BetaIndexes)); } -APT_IGNORE_DEPRECATED_POP /*}}}*/ // TagSection::Scan - Scan for the end of the header information /*{{{*/ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength, bool const Restart) @@ -538,14 +536,12 @@ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength, bool const R } else { if (BetaIndexes[lastTagHash] != 0) lastTagData.NextInBucket = BetaIndexes[lastTagHash]; - APT_IGNORE_DEPRECATED_PUSH BetaIndexes[lastTagHash] = TagCount; - APT_IGNORE_DEPRECATED_POP } d->Tags.push_back(lastTagData); } - APT_IGNORE_DEPRECATED(++TagCount;) + ++TagCount; lastTagData = pkgTagSectionPrivate::TagData(Stop - Section); // find the colon separating tag and value char const * Colon = (char const *) memchr(Stop, ':', End - Stop); @@ -590,7 +586,7 @@ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength, bool const R } else { if (BetaIndexes[lastTagHash] != 0) lastTagData.NextInBucket = BetaIndexes[lastTagHash]; - APT_IGNORE_DEPRECATED(BetaIndexes[lastTagHash] = TagCount;) + BetaIndexes[lastTagHash] = TagCount; } d->Tags.push_back(lastTagData); } @@ -1065,146 +1061,6 @@ bool pkgTagSection::Write(FileFd &File, char const * const * const Order, std::v } /*}}}*/ -void pkgUserTagSection::TrimRecord(bool /*BeforeRecord*/, const char* &End)/*{{{*/ -{ - for (; Stop < End && (Stop[0] == '\n' || Stop[0] == '\r' || Stop[0] == '#'); Stop++) - if (Stop[0] == '#') - Stop = (const char*) memchr(Stop,'\n',End-Stop); -} - /*}}}*/ - #include "tagfile-order.c" -// TFRewrite - Rewrite a control record /*{{{*/ -// --------------------------------------------------------------------- -/* This writes the control record to stdout rewriting it as necessary. The - override map item specificies the rewriting rules to follow. This also - takes the time to sort the feild list. */ -APT_IGNORE_DEPRECATED_PUSH -bool TFRewrite(FILE *Output,pkgTagSection const &Tags,const char *Order[], - TFRewriteData *Rewrite) -{ - unsigned char Visited[256]; // Bit 1 is Order, Bit 2 is Rewrite - for (unsigned I = 0; I != 256; I++) - Visited[I] = 0; - - // Set new tag up as necessary. - for (unsigned int J = 0; Rewrite != 0 && Rewrite[J].Tag != 0; J++) - { - if (Rewrite[J].NewTag == 0) - Rewrite[J].NewTag = Rewrite[J].Tag; - } - - // Write all of the tags, in order. - if (Order != NULL) - { - for (unsigned int I = 0; Order[I] != 0; I++) - { - bool Rewritten = false; - - // See if this is a field that needs to be rewritten - for (unsigned int J = 0; Rewrite != 0 && Rewrite[J].Tag != 0; J++) - { - if (strcasecmp(Rewrite[J].Tag,Order[I]) == 0) - { - Visited[J] |= 2; - if (Rewrite[J].Rewrite != 0 && Rewrite[J].Rewrite[0] != 0) - { - if (isspace_ascii(Rewrite[J].Rewrite[0])) - fprintf(Output,"%s:%s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite); - else - fprintf(Output,"%s: %s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite); - } - Rewritten = true; - break; - } - } - - // See if it is in the fragment - unsigned Pos; - if (Tags.Find(StringView(Order[I]),Pos) == false) - continue; - Visited[Pos] |= 1; - - if (Rewritten == true) - continue; - - /* Write out this element, taking a moment to rewrite the tag - in case of changes of case. */ - const char *Start; - const char *Stop; - Tags.Get(Start,Stop,Pos); - - if (fputs(Order[I],Output) < 0) - return _error->Errno("fputs","IO Error to output"); - Start += strlen(Order[I]); - if (fwrite(Start,Stop - Start,1,Output) != 1) - return _error->Errno("fwrite","IO Error to output"); - if (Stop[-1] != '\n') - fprintf(Output,"\n"); - } - } - - // Now write all the old tags that were missed. - for (unsigned int I = 0; I != Tags.Count(); I++) - { - if ((Visited[I] & 1) == 1) - continue; - - const char *Start; - const char *Stop; - Tags.Get(Start,Stop,I); - const char *End = Start; - for (; End < Stop && *End != ':'; End++); - - // See if this is a field that needs to be rewritten - bool Rewritten = false; - for (unsigned int J = 0; Rewrite != 0 && Rewrite[J].Tag != 0; J++) - { - if (stringcasecmp(Start,End,Rewrite[J].Tag) == 0) - { - Visited[J] |= 2; - if (Rewrite[J].Rewrite != 0 && Rewrite[J].Rewrite[0] != 0) - { - if (isspace_ascii(Rewrite[J].Rewrite[0])) - fprintf(Output,"%s:%s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite); - else - fprintf(Output,"%s: %s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite); - } - - Rewritten = true; - break; - } - } - - if (Rewritten == true) - continue; - - // Write out this element - if (fwrite(Start,Stop - Start,1,Output) != 1) - return _error->Errno("fwrite","IO Error to output"); - if (Stop[-1] != '\n') - fprintf(Output,"\n"); - } - - // Now write all the rewrites that were missed - for (unsigned int J = 0; Rewrite != 0 && Rewrite[J].Tag != 0; J++) - { - if ((Visited[J] & 2) == 2) - continue; - - if (Rewrite[J].Rewrite != 0 && Rewrite[J].Rewrite[0] != 0) - { - if (isspace_ascii(Rewrite[J].Rewrite[0])) - fprintf(Output,"%s:%s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite); - else - fprintf(Output,"%s: %s\n",Rewrite[J].NewTag,Rewrite[J].Rewrite); - } - } - - return true; -} -APT_IGNORE_DEPRECATED_POP - /*}}}*/ - pkgTagSection::~pkgTagSection() { delete d; } diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index 8b59c43de..de7bfcbaf 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -187,11 +187,6 @@ class pkgTagSection }; -class APT_DEPRECATED_MSG("Use pkgTagFile with the SUPPORT_COMMENTS flag instead") pkgUserTagSection : public pkgTagSection -{ - virtual void TrimRecord(bool BeforeRecord, const char* &End) APT_OVERRIDE; -}; - /** \class pkgTagFile reads and prepares a deb822 formatted file for parsing * via #pkgTagSection. The default mode tries to be as fast as possible and * assumes perfectly valid (machine generated) files like Packages. Support @@ -227,15 +222,4 @@ public: extern const char **TFRewritePackageOrder; extern const char **TFRewriteSourceOrder; -APT_IGNORE_DEPRECATED_PUSH -struct APT_DEPRECATED_MSG("Use pkgTagSection::Tag and pkgTagSection::Write() instead") TFRewriteData -{ - const char *Tag; - const char *Rewrite; - const char *NewTag; -}; -APT_DEPRECATED_MSG("Use pkgTagSection::Tag and pkgTagSection::Write() instead") bool TFRewrite(FILE *Output,pkgTagSection const &Tags,const char *Order[], - TFRewriteData *Rewrite); -APT_IGNORE_DEPRECATED_POP - #endif diff --git a/apt-pkg/upgrade.cc b/apt-pkg/upgrade.cc index c9432aa64..06c3751e0 100644 --- a/apt-pkg/upgrade.cc +++ b/apt-pkg/upgrade.cc @@ -119,12 +119,7 @@ static bool pkgDistUpgrade(pkgDepCache &Cache, OpProgress * const Progress) if (Progress != NULL) Progress->Done(); return success; -} -bool pkgDistUpgrade(pkgDepCache &Cache) -{ - return pkgDistUpgrade(Cache, NULL); -} - /*}}}*/ +} /*}}}*/ // AllUpgradeNoNewPackages - Upgrade but no removals or new pkgs /*{{{*/ static bool pkgAllUpgradeNoNewPackages(pkgDepCache &Cache, OpProgress * const Progress) { @@ -224,20 +219,6 @@ static bool pkgAllUpgradeWithNewPackages(pkgDepCache &Cache, OpProgress * const return success; } /*}}}*/ -// AllUpgrade - Upgrade as many packages as possible /*{{{*/ -// --------------------------------------------------------------------- -/* Right now the system must be consistent before this can be called. - It also will not change packages marked for install, it only tries - to install packages not marked for install */ -static bool pkgAllUpgrade(pkgDepCache &Cache, OpProgress * const Progress) -{ - return pkgAllUpgradeNoNewPackages(Cache, Progress); -} -bool pkgAllUpgrade(pkgDepCache &Cache) -{ - return pkgAllUpgrade(Cache, NULL); -} - /*}}}*/ // MinimizeUpgrade - Minimizes the set of packages to be upgraded /*{{{*/ // --------------------------------------------------------------------- /* This simply goes over the entire set of packages and tries to keep @@ -286,7 +267,6 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache) // APT::Upgrade::Upgrade - Upgrade using a specific strategy /*{{{*/ bool APT::Upgrade::Upgrade(pkgDepCache &Cache, int mode, OpProgress * const Progress) { -APT_IGNORE_DEPRECATED_PUSH if (mode == ALLOW_EVERYTHING) return pkgDistUpgrade(Cache, Progress); else if ((mode & ~FORBID_REMOVE_PACKAGES) == 0) @@ -295,7 +275,6 @@ APT_IGNORE_DEPRECATED_PUSH return pkgAllUpgradeNoNewPackages(Cache, Progress); else _error->Error("pkgAllUpgrade called with unsupported mode %i", mode); -APT_IGNORE_DEPRECATED_POP return false; } /*}}}*/ diff --git a/apt-pkg/upgrade.h b/apt-pkg/upgrade.h index 5612acfcb..c3d0852b2 100644 --- a/apt-pkg/upgrade.h +++ b/apt-pkg/upgrade.h @@ -28,8 +28,5 @@ namespace APT { } } -APT_DEPRECATED_MSG("Use APT::Upgrade::Upgrade() instead") bool pkgDistUpgrade(pkgDepCache &Cache); -APT_DEPRECATED_MSG("Use APT::Upgrade::Upgrade() instead") bool pkgAllUpgrade(pkgDepCache &Cache); - bool pkgMinimizeUpgrade(pkgDepCache &Cache); #endif |