This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch master in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=55eaddc5411b6eae85686a511a9b122e84c0e7fd commit 55eaddc5411b6eae85686a511a9b122e84c0e7fd Author: Guillem Jover <[email protected]> AuthorDate: Wed Aug 15 06:45:56 2018 +0200 libdpkg: Factor out cached arch-qualified package name generation Move this into a proper function so that we can call it from multiple places. In addition we always return a non-freeing allocated string, in case the architecture is empty or none. --- debian/changelog | 2 ++ lib/dpkg/dpkg-db.h | 4 ++++ lib/dpkg/parse.c | 9 +-------- lib/dpkg/pkg-show.c | 17 +++++++++++++++++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index b877839c1..094971925 100644 --- a/debian/changelog +++ b/debian/changelog @@ -172,6 +172,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Change pkgbin_name_needs_arch() to never arch-qualify packages that have an empty or no architecture, which was already handled as part of varbuf_add_archqual(). + - libdpkg: Factor out cached arch-qualified package name generation into + new pkgbin_name_archqual() function. * Build system: - Set distribution tarball format to ustar, instead of default v7 format. - Mark PO4A and POD2MAN as precious variables. diff --git a/lib/dpkg/dpkg-db.h b/lib/dpkg/dpkg-db.h index 2152ba26d..a7b77aaa9 100644 --- a/lib/dpkg/dpkg-db.h +++ b/lib/dpkg/dpkg-db.h @@ -379,6 +379,10 @@ enum pkg_name_arch_when { void varbuf_add_pkgbin_name(struct varbuf *vb, const struct pkginfo *pkg, const struct pkgbin *pkgbin, enum pkg_name_arch_when pnaw); + +const char * +pkgbin_name_archqual(const struct pkginfo *pkg, const struct pkgbin *pkgbin); + const char *pkgbin_name(const struct pkginfo *pkg, const struct pkgbin *pkgbin, enum pkg_name_arch_when pnaw); const char *pkg_name(const struct pkginfo *pkg, enum pkg_name_arch_when pnaw); diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c index 221067881..155f80ad2 100644 --- a/lib/dpkg/parse.c +++ b/lib/dpkg/parse.c @@ -219,14 +219,7 @@ pkg_parse_verify(struct parsedb_state *ps, "Multi-Arch: same"); /* Generate the fully qualified package name representation. */ - if (pkgbin->arch->type != DPKG_ARCH_NONE && - pkgbin->arch->type != DPKG_ARCH_EMPTY) { - char *pkgname = nfmalloc(strlen(pkg->set->name) + 1 + - strlen(pkgbin->arch->name) + 1); - - str_concat(pkgname, pkg->set->name, ":", pkgbin->arch->name, NULL); - pkgbin->pkgname_archqual = pkgname; - } + pkgbin->pkgname_archqual = pkgbin_name_archqual(pkg, pkgbin); /* Initialize deps to be arch-specific unless stated otherwise. */ for (dep = pkgbin->depends; dep; dep = dep->next) diff --git a/lib/dpkg/pkg-show.c b/lib/dpkg/pkg-show.c index 6767b5ca4..47bd55cab 100644 --- a/lib/dpkg/pkg-show.c +++ b/lib/dpkg/pkg-show.c @@ -79,6 +79,23 @@ varbuf_add_pkgbin_name(struct varbuf *vb, varbuf_end_str(vb); } +const char * +pkgbin_name_archqual(const struct pkginfo *pkg, const struct pkgbin *pkgbin) +{ + char *pkgname; + + if (pkgbin->arch->type == DPKG_ARCH_NONE || + pkgbin->arch->type == DPKG_ARCH_EMPTY) + return pkg->set->name; + + pkgname = nfmalloc(strlen(pkg->set->name) + 1 + + strlen(pkgbin->arch->name) + 1); + str_concat(pkgname, pkg->set->name, ":", + pkgbin->arch->name, NULL); + + return pkgname; +} + /** * Return a string representation of the package name. * -- Dpkg.Org's dpkg

