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=683e95c0b13b6274d1785741d63551cd39b6ee45 commit 683e95c0b13b6274d1785741d63551cd39b6ee45 Author: Guillem Jover <[email protected]> AuthorDate: Sat Aug 11 03:10:09 2018 +0200 libdpkg: Dump database package records in alphabetical order When dumping all stanzas from the package database, do it in alphabetical order, so that we get reproducible output, both on disk and for the upcoming output to stdout. --- debian/changelog | 3 +++ lib/dpkg/dump.c | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index 4cf04b4c1..c0e1bea44 100644 --- a/debian/changelog +++ b/debian/changelog @@ -78,6 +78,9 @@ dpkg (1.19.1) UNRELEASED; urgency=medium virtual field to dpkg-query show format. * Add new dpkg-buildpackage --no-post-clean option, to be able to explicitly select the current default behavior. + * Dump database package records in alphabetical order. This will give + reproducible status and available database files, and make it possible + to output other deb822 formatted data in a deterministic way. * Architecture support: - Add support for riscv64 CPU. Closes: #822914 Thanks to Manuel A. Fernandez Montecelo <[email protected]> diff --git a/lib/dpkg/dump.c b/lib/dpkg/dump.c index 0933b6dff..c400ae307 100644 --- a/lib/dpkg/dump.c +++ b/lib/dpkg/dump.c @@ -40,6 +40,8 @@ #include <dpkg/i18n.h> #include <dpkg/dpkg.h> #include <dpkg/dpkg-db.h> +#include <dpkg/pkg-array.h> +#include <dpkg/pkg-show.h> #include <dpkg/string.h> #include <dpkg/dir.h> #include <dpkg/parsedump.h> @@ -496,23 +498,29 @@ writedb_records(FILE *fp, const char *filename, enum writedb_flags flags) { static char writebuf[8192]; - struct pkgiterator *iter; + struct pkg_array array; struct pkginfo *pkg; struct pkgbin *pkgbin; const char *which; struct varbuf vb = VARBUF_INIT; + int i; which = (flags & wdb_dump_available) ? "available" : "status"; if (setvbuf(fp, writebuf, _IOFBF, sizeof(writebuf))) ohshite(_("unable to set buffering on %s database file"), which); - iter = pkg_db_iter_new(); - while ((pkg = pkg_db_iter_next_pkg(iter)) != NULL) { + pkg_array_init_from_db(&array); + pkg_array_sort(&array, pkg_sorter_by_nonambig_name_arch); + + for (i = 0; i < array.n_pkgs; i++) { + pkg = array.pkgs[i]; pkgbin = (flags & wdb_dump_available) ? &pkg->available : &pkg->installed; + /* Don't dump records which have no useful content. */ if (!pkg_is_informative(pkg, pkgbin)) continue; + varbufrecord(&vb, pkg, pkgbin); varbuf_add_char(&vb, '\n'); varbuf_end_str(&vb); @@ -521,7 +529,8 @@ writedb_records(FILE *fp, const char *filename, enum writedb_flags flags) which, pkgbin_name(pkg, pkgbin, pnaw_nonambig), filename); varbuf_reset(&vb); } - pkg_db_iter_free(iter); + + pkg_array_destroy(&array); varbuf_destroy(&vb); } -- Dpkg.Org's dpkg

