From: Aleksei Nikiforov <darktemplar@altlinux.org> To: devel@lists.altlinux.org Cc: Aleksei Nikiforov <darktemplar@altlinux.org> Subject: [devel] [PATCH for apt] Properly process duplicated 3rd-party packages Date: Fri, 31 Jan 2020 16:53:09 +0300 Message-ID: <20200131135309.62873-1-darktemplar@altlinux.org> (raw) If apt is configured via RPM::Allow-Duplicated configuration option to recognize 3rd-party duplicate packages, and such packages lack '%NAME = %EVR' provide or some similar form of provide with package name, apt currently can only find such package via full name form, which in addition to name may include %EVR, %DISTTAG and %BUILDTIME if such tags are present. This change would allow apt to find such packages using their names only. --- apt/apt-pkg/pkgcachegen.cc | 17 +++++++++++++++++ apt/apt-pkg/pkgcachegen.h | 4 +++- apt/apt-pkg/rpm/rpmlistparser.cc | 5 +++++ apt/apt-pkg/rpm/rpmlistparser.h | 1 + 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/apt/apt-pkg/pkgcachegen.cc b/apt/apt-pkg/pkgcachegen.cc index 56716b5..f6e2153 100644 --- a/apt/apt-pkg/pkgcachegen.cc +++ b/apt/apt-pkg/pkgcachegen.cc @@ -302,6 +302,23 @@ bool pkgCacheGenerator::MergeList(ListParser &List, Ver->ParentPkg = Pkg.Index(); Ver->Hash = Hash; + + if (List.IsDuplicatePackage()) + { + /* Some duplicated third-party packages don't have a provide + * in form of "name = version", so add one. + * It'll be useful when user tries to remove such package by it's name + * or interact with it in some other way. + * It may be a good idea to check if such virtual provide exists before adding one, + * but skipping this check shouldn't introduce a lot of additional overhead + * since only duplicate packages are affected, and there shouldn't be a lot of them. + */ + if (not List.NewProvides(Ver, PackageName.substr(0, PackageName.find('#')), Version)) + { + return _error->Error(_("Error occured while processing %s (NewProvides%d)"), PackageName.c_str(), 1); + } + } + if (List.NewVersion(Ver) == false) return _error->Error(_("Error occured while processing %s (NewVersion%d)"), PackageName.c_str(), 2); diff --git a/apt/apt-pkg/pkgcachegen.h b/apt/apt-pkg/pkgcachegen.h index 77075a6..9d42bbd 100644 --- a/apt/apt-pkg/pkgcachegen.h +++ b/apt/apt-pkg/pkgcachegen.h @@ -169,15 +169,17 @@ class pkgCacheGenerator::ListParser bool NewDepends(pkgCache::VerIterator &Ver, const string &Package, const string &Version,unsigned int Op, unsigned int Type); - bool NewProvides(pkgCache::VerIterator &Ver,const string &Package, const string &Version); public: + + bool NewProvides(pkgCache::VerIterator &Ver,const string &Package, const string &Version); // These all operate against the current section virtual string Package() = 0; virtual string Version() = 0; // CNC:2002-07-09 virtual string Architecture() {return string();}; + virtual bool IsDuplicatePackage() { return false; } virtual bool NewVersion(pkgCache::VerIterator &Ver) = 0; virtual unsigned short VersionHash() = 0; virtual bool UsePackage(pkgCache::PkgIterator &Pkg, diff --git a/apt/apt-pkg/rpm/rpmlistparser.cc b/apt/apt-pkg/rpm/rpmlistparser.cc index 9b2e9ad..abeabaa 100644 --- a/apt/apt-pkg/rpm/rpmlistparser.cc +++ b/apt/apt-pkg/rpm/rpmlistparser.cc @@ -197,6 +197,11 @@ string rpmListParser::Architecture() res = headerGetEntry(header, RPMTAG_ARCH, &type, (void **)&arch, &count); return string(res?arch:""); } + +bool rpmListParser::IsDuplicatePackage() +{ + return Duplicated; +} /*}}}*/ #include <sstream> diff --git a/apt/apt-pkg/rpm/rpmlistparser.h b/apt/apt-pkg/rpm/rpmlistparser.h index 6862f09..c4e1c7c 100644 --- a/apt/apt-pkg/rpm/rpmlistparser.h +++ b/apt/apt-pkg/rpm/rpmlistparser.h @@ -63,6 +63,7 @@ class rpmListParser : public pkgCacheGenerator::ListParser virtual string Package() override; virtual string Version() override; virtual string Architecture() override; + virtual bool IsDuplicatePackage() override; virtual bool NewVersion(pkgCache::VerIterator &Ver) override; virtual unsigned short VersionHash() override; virtual bool UsePackage(pkgCache::PkgIterator &Pkg, -- 2.24.1
reply other threads:[~2020-01-31 13:53 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200131135309.62873-1-darktemplar@altlinux.org \ --to=darktemplar@altlinux.org \ --cc=devel@lists.altlinux.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
ALT Linux Team development discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \ devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru public-inbox-index devel Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.devel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git