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=31eb544919a46c6170ac39f5eebd17ba6d48d508 commit 31eb544919a46c6170ac39f5eebd17ba6d48d508 Author: Guillem Jover <[email protected]> AuthorDate: Wed Nov 21 03:44:15 2018 +0100 libdpkg: Rename pkg_db symbols to pkg_hash These are handling a package hash, and db seems to imply some kind of on-disk storage. Rename the pkgiterator too to pkg_hash_iter to make it consistent. --- debian/changelog | 1 + dselect/pkglist.cc | 10 ++--- lib/dpkg/db-ctrl-upgrade.c | 2 +- lib/dpkg/db-fsys-divert.c | 2 +- lib/dpkg/db-fsys-files.c | 4 +- lib/dpkg/dbmodify.c | 2 +- lib/dpkg/dpkg-db.h | 43 +++++++++++++------- lib/dpkg/dump.c | 2 +- lib/dpkg/fields.c | 6 +-- lib/dpkg/libdpkg.map | 26 ++++++------ lib/dpkg/parse.c | 16 ++++---- lib/dpkg/pkg-array.c | 12 +++--- lib/dpkg/pkg-array.h | 2 +- lib/dpkg/pkg-hash.c | 40 +++++++++---------- lib/dpkg/pkg-spec.c | 14 +++---- lib/dpkg/pkg-spec.h | 2 +- lib/dpkg/t/t-pkg-hash.c | 98 +++++++++++++++++++++++----------------------- lib/dpkg/t/t-pkg-show.c | 2 +- lib/dpkg/trignote.c | 2 +- src/depcon.c | 8 ++-- src/divertcmd.c | 12 +++--- src/enquiry.c | 32 +++++++-------- src/help.c | 8 ++-- src/main.c | 8 ++-- src/packages.c | 8 ++-- src/querycmd.c | 4 +- src/select.c | 10 ++--- src/trigproc.c | 24 ++++++------ src/unpack.c | 8 ++-- src/verify.c | 8 ++-- 30 files changed, 215 insertions(+), 201 deletions(-) diff --git a/debian/changelog b/debian/changelog index af1ba3c9c..04d98a183 100644 --- a/debian/changelog +++ b/debian/changelog @@ -114,6 +114,7 @@ dpkg (1.19.3) UNRELEASED; urgency=medium - libdpkg, dpkg: Rename r variables to fnn. - libdpkg: Rename ret variable to next. - libdpkg: Cleanup fsys module symbol names. + - libdpkg: Rename pkg_db symbols to pkg_hash. * Build system: - get-version: Use a format string with printf. - run-script: Use $() instead of deprecated ``. diff --git a/dselect/pkglist.cc b/dselect/pkglist.cc index ced7487d6..9882802bb 100644 --- a/dselect/pkglist.cc +++ b/dselect/pkglist.cc @@ -365,7 +365,7 @@ void packagelist::sortmakeheads() { void packagelist::initialsetup() { debug(dbg_general, "packagelist[%p]::initialsetup()", this); - int allpackages = pkg_db_count_pkg(); + int allpackages = pkg_hash_count_pkg(); datatable= new struct perpackagestate[allpackages]; nallocated= allpackages+150; // will realloc if necessary, so 150 not critical @@ -390,13 +390,13 @@ void packagelist::finalsetup() { packagelist::packagelist(keybindings *kb) : baselist(kb) { // nonrecursive initialsetup(); - struct pkgiterator *iter; + struct pkg_hash_iter *iter; struct pkginfo *pkg; nitems = 0; - iter = pkg_db_iter_new(); - while ((pkg = pkg_db_iter_next_pkg(iter))) { + iter = pkg_hash_iter_new(); + while ((pkg = pkg_hash_iter_next_pkg(iter))) { struct perpackagestate *state= &datatable[nitems]; state->pkg= pkg; if (pkg->status == PKG_STAT_NOTINSTALLED && @@ -426,7 +426,7 @@ packagelist::packagelist(keybindings *kb) : baselist(kb) { table[nitems]= state; nitems++; } - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); if (!nitems) ohshit(_("there are no packages")); diff --git a/lib/dpkg/db-ctrl-upgrade.c b/lib/dpkg/db-ctrl-upgrade.c index 1770ecaeb..9b6d735cc 100644 --- a/lib/dpkg/db-ctrl-upgrade.c +++ b/lib/dpkg/db-ctrl-upgrade.c @@ -114,7 +114,7 @@ pkg_infodb_link_multiarch_files(void) if (strchr(pkgname.buf, ':')) continue; - set = pkg_db_find_set(pkgname.buf); + set = pkg_hash_find_set(pkgname.buf); for (pkg = &set->pkg; pkg; pkg = pkg->arch_next) if (pkg->status != PKG_STAT_NOTINSTALLED) break; diff --git a/lib/dpkg/db-fsys-divert.c b/lib/dpkg/db-fsys-divert.c index 985ed1bbe..bf0b7ff5a 100644 --- a/lib/dpkg/db-fsys-divert.c +++ b/lib/dpkg/db-fsys-divert.c @@ -113,7 +113,7 @@ ensure_diversions(void) fgets_must(linebuf, sizeof(linebuf), file, diversionsname); oicontest->pkgset = strcmp(linebuf, ":") ? - pkg_db_find_set(linebuf) : NULL; + pkg_hash_find_set(linebuf) : NULL; oialtname->pkgset = oicontest->pkgset; if (oialtname->camefrom->divert || diff --git a/lib/dpkg/db-fsys-files.c b/lib/dpkg/db-fsys-files.c index c944d5339..ffd26cee2 100644 --- a/lib/dpkg/db-fsys-files.c +++ b/lib/dpkg/db-fsys-files.c @@ -252,13 +252,13 @@ void ensure_allinstfiles_available(void) { if (allpackagesdone) return; if (saidread < PKG_FILESDB_LOAD_DONE) { - int max = pkg_db_count_pkg(); + int max = pkg_hash_count_pkg(); saidread = PKG_FILESDB_LOAD_INPROGRESS; progress_init(&progress, _("(Reading database ... "), max); } - pkg_array_init_from_db(&array); + pkg_array_init_from_hash(&array); pkg_files_optimize_load(&array); diff --git a/lib/dpkg/dbmodify.c b/lib/dpkg/dbmodify.c index 7351f3d00..f29c6745f 100644 --- a/lib/dpkg/dbmodify.c +++ b/lib/dpkg/dbmodify.c @@ -367,7 +367,7 @@ void modstatdb_shutdown(void) { break; } - pkg_db_reset(); + pkg_hash_reset(); modstatdb_done(); } diff --git a/lib/dpkg/dpkg-db.h b/lib/dpkg/dpkg-db.h index 6ea525657..3e9158def 100644 --- a/lib/dpkg/dpkg-db.h +++ b/lib/dpkg/dpkg-db.h @@ -294,21 +294,34 @@ void pkg_blank(struct pkginfo *pp); void pkgbin_blank(struct pkgbin *pkgbin); bool pkg_is_informative(struct pkginfo *pkg, struct pkgbin *info); -struct pkgset *pkg_db_find_set(const char *name); -struct pkginfo *pkg_db_get_singleton(struct pkgset *set); -struct pkginfo *pkg_db_find_singleton(const char *name); -struct pkginfo *pkg_db_get_pkg(struct pkgset *set, const struct dpkg_arch *arch); -struct pkginfo *pkg_db_find_pkg(const char *name, const struct dpkg_arch *arch); -int pkg_db_count_set(void); -int pkg_db_count_pkg(void); -void pkg_db_reset(void); - -struct pkgiterator *pkg_db_iter_new(void); -struct pkgset *pkg_db_iter_next_set(struct pkgiterator *iter); -struct pkginfo *pkg_db_iter_next_pkg(struct pkgiterator *iter); -void pkg_db_iter_free(struct pkgiterator *iter); - -void pkg_db_report(FILE *); +struct pkgset * +pkg_hash_find_set(const char *name); +struct pkginfo * +pkg_hash_get_singleton(struct pkgset *set); +struct pkginfo * +pkg_hash_find_singleton(const char *name); +struct pkginfo * +pkg_hash_get_pkg(struct pkgset *set, const struct dpkg_arch *arch); +struct pkginfo * +pkg_hash_find_pkg(const char *name, const struct dpkg_arch *arch); +int +pkg_hash_count_set(void); +int +pkg_hash_count_pkg(void); +void +pkg_hash_reset(void); + +struct pkg_hash_iter * +pkg_hash_iter_new(void); +struct pkgset * +pkg_hash_iter_next_set(struct pkg_hash_iter *iter); +struct pkginfo * +pkg_hash_iter_next_pkg(struct pkg_hash_iter *iter); +void +pkg_hash_iter_free(struct pkg_hash_iter *iter); + +void +pkg_hash_report(FILE *); /*** from parse.c ***/ diff --git a/lib/dpkg/dump.c b/lib/dpkg/dump.c index c400ae307..c58a4d59a 100644 --- a/lib/dpkg/dump.c +++ b/lib/dpkg/dump.c @@ -510,7 +510,7 @@ writedb_records(FILE *fp, const char *filename, enum writedb_flags flags) if (setvbuf(fp, writebuf, _IOFBF, sizeof(writebuf))) ohshite(_("unable to set buffering on %s database file"), which); - pkg_array_init_from_db(&array); + pkg_array_init_from_hash(&array); pkg_array_sort(&array, pkg_sorter_by_nonambig_name_arch); for (i = 0; i < array.n_pkgs; i++) { diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c index 39044e2a5..1389e6ebc 100644 --- a/lib/dpkg/fields.c +++ b/lib/dpkg/fields.c @@ -104,8 +104,8 @@ f_name(struct pkginfo *pkg, struct pkgbin *pkgbin, e = pkg_name_is_illegal(value); if (e != NULL) parse_error(ps, _("invalid package name (%.250s)"), e); - /* We use the new name, as pkg_db_find_set() may have done a tolower for us. */ - pkg->set->name = pkg_db_find_set(value)->name; + /* We use the new name, as pkg_hash_find_set() may have done a tolower for us. */ + pkg->set->name = pkg_hash_find_set(value)->name; } void @@ -440,7 +440,7 @@ f_dependency(struct pkginfo *pkg, struct pkgbin *pkgbin, fip->name, depname.buf, emsg); dop = nfmalloc(sizeof(*dop)); dop->up= dyp; - dop->ed = pkg_db_find_set(depname.buf); + dop->ed = pkg_hash_find_set(depname.buf); dop->next= NULL; *ldopp= dop; ldopp= &dop->next; /* Don't link this (which is after all only ‘new_pkg’ from diff --git a/lib/dpkg/libdpkg.map b/lib/dpkg/libdpkg.map index c337ee662..fe4e299ee 100644 --- a/lib/dpkg/libdpkg.map +++ b/lib/dpkg/libdpkg.map @@ -304,7 +304,7 @@ LIBDPKG_PRIVATE { pkg_list_prepend; # Package array handling - pkg_array_init_from_db; + pkg_array_init_from_hash; pkg_array_init_from_names; pkg_array_foreach; pkg_array_sort; @@ -317,6 +317,18 @@ LIBDPKG_PRIVATE { pkg_queue_push; pkg_queue_pop; + # Package in-core database functions + pkg_hash_find_set; + pkg_hash_find_singleton; + pkg_hash_find_pkg; + pkg_hash_count_set; + pkg_hash_count_pkg; + pkg_hash_reset; + pkg_hash_iter_new; + pkg_hash_iter_next_set; + pkg_hash_iter_next_pkg; + pkg_hash_iter_free; + # Package field handling fieldinfos; # XXX variable, do not export find_field_info; @@ -340,18 +352,6 @@ LIBDPKG_PRIVATE { pkg_spec_iter_next_pkg; pkg_spec_iter_destroy; - # Package in-core database functions - pkg_db_find_set; - pkg_db_find_singleton; - pkg_db_find_pkg; - pkg_db_count_set; - pkg_db_count_pkg; - pkg_db_reset; - pkg_db_iter_new; - pkg_db_iter_next_set; - pkg_db_iter_next_pkg; - pkg_db_iter_free; - # Dependency and Conflict functions pkg_virtual_deppossi_satisfied; deparchsatisfied; diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c index 14d6192f5..8d1195694 100644 --- a/lib/dpkg/parse.c +++ b/lib/dpkg/parse.c @@ -342,7 +342,7 @@ parse_find_set_slot(struct parsedb_state *ps, struct pkgset *set; struct pkginfo *pkg; - set = pkg_db_find_set(new_pkg->set->name); + set = pkg_hash_find_set(new_pkg->set->name); /* Sanity checks: verify that the db is in a consistent state. */ @@ -405,9 +405,9 @@ parse_find_pkg_slot(struct parsedb_state *ps, * possible architecture switch, for example from native to all. */ if (pkgset_installed_instances(db_set) == 1 && new_pkgbin->multiarch != PKG_MULTIARCH_SAME) - return pkg_db_get_singleton(db_set); + return pkg_hash_get_singleton(db_set); else - return pkg_db_get_pkg(db_set, new_pkgbin->arch); + return pkg_hash_get_pkg(db_set, new_pkgbin->arch); } else { bool selection = false; @@ -427,20 +427,20 @@ parse_find_pkg_slot(struct parsedb_state *ps, /* If we are parsing the status file, use a slot per arch. */ if (ps->type == pdb_file_status) - return pkg_db_get_pkg(db_set, new_pkgbin->arch); + return pkg_hash_get_pkg(db_set, new_pkgbin->arch); /* If we are doing an update, from the log or a new package, then * handle cross-grades. */ if (pkgset_installed_instances(db_set) == 1) { - db_pkg = pkg_db_get_singleton(db_set); + db_pkg = pkg_hash_get_singleton(db_set); if (db_pkg->installed.multiarch == PKG_MULTIARCH_SAME && new_pkgbin->multiarch == PKG_MULTIARCH_SAME) - return pkg_db_get_pkg(db_set, new_pkgbin->arch); + return pkg_hash_get_pkg(db_set, new_pkgbin->arch); else return db_pkg; } else { - return pkg_db_get_pkg(db_set, new_pkgbin->arch); + return pkg_hash_get_pkg(db_set, new_pkgbin->arch); } } } @@ -490,7 +490,7 @@ pkg_parse_copy(struct parsedb_state *ps, pkg_name(ta->aw, pnaw_always), pkgbin_name(src_pkg, src_pkgbin, pnaw_always)); ta->aw = dst_pkg; - /* ->othertrigaw_head is updated by trig_note_aw in *(pkg_db_find()) + /* ->othertrigaw_head is updated by trig_note_aw in *(pkg_hash_find()) * rather than in dst_pkg. */ } } else if (!(ps->flags & pdb_ignore_archives)) { diff --git a/lib/dpkg/pkg-array.c b/lib/dpkg/pkg-array.c index cf5c34d3f..0ce285e92 100644 --- a/lib/dpkg/pkg-array.c +++ b/lib/dpkg/pkg-array.c @@ -59,19 +59,19 @@ pkg_array_init_from_names(struct pkg_array *a, pkg_mapper_func pkg_mapper, * @param a The array to initialize. */ void -pkg_array_init_from_db(struct pkg_array *a) +pkg_array_init_from_hash(struct pkg_array *a) { - struct pkgiterator *iter; + struct pkg_hash_iter *iter; struct pkginfo *pkg; int i; - a->n_pkgs = pkg_db_count_pkg(); + a->n_pkgs = pkg_hash_count_pkg(); a->pkgs = m_malloc(sizeof(a->pkgs[0]) * a->n_pkgs); - iter = pkg_db_iter_new(); - for (i = 0; (pkg = pkg_db_iter_next_pkg(iter)); i++) + iter = pkg_hash_iter_new(); + for (i = 0; (pkg = pkg_hash_iter_next_pkg(iter)); i++) a->pkgs[i] = pkg; - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); if (i != a->n_pkgs) internerr("inconsistent state in pkg array: i=%d != npkgs=%d", diff --git a/lib/dpkg/pkg-array.h b/lib/dpkg/pkg-array.h index 858b4fe46..f9ea385b6 100644 --- a/lib/dpkg/pkg-array.h +++ b/lib/dpkg/pkg-array.h @@ -44,7 +44,7 @@ typedef struct pkginfo *pkg_mapper_func(const char *name); typedef void pkg_array_visitor_func(struct pkg_array *a, struct pkginfo *pkg, void *pkg_data); -void pkg_array_init_from_db(struct pkg_array *a); +void pkg_array_init_from_hash(struct pkg_array *a); void pkg_array_init_from_names(struct pkg_array *a, pkg_mapper_func *pkg_mapper, const char **pkg_names); void pkg_array_foreach(struct pkg_array *a, pkg_array_visitor_func *pkg_visitor, diff --git a/lib/dpkg/pkg-hash.c b/lib/dpkg/pkg-hash.c index 398c20607..e7de951b0 100644 --- a/lib/dpkg/pkg-hash.c +++ b/lib/dpkg/pkg-hash.c @@ -60,7 +60,7 @@ static int npkg, nset; * @return The package set. */ struct pkgset * -pkg_db_find_set(const char *inname) +pkg_hash_find_set(const char *inname) { struct pkgset **setp, *new_set; char *name = m_strdup(inname), *p; @@ -104,7 +104,7 @@ pkg_db_find_set(const char *inname) * @return The singleton package instance. */ struct pkginfo * -pkg_db_get_singleton(struct pkgset *set) +pkg_hash_get_singleton(struct pkgset *set) { struct pkginfo *pkg; @@ -138,13 +138,13 @@ pkg_db_get_singleton(struct pkgset *set) * @return The package instance. */ struct pkginfo * -pkg_db_find_singleton(const char *name) +pkg_hash_find_singleton(const char *name) { struct pkgset *set; struct pkginfo *pkg; - set = pkg_db_find_set(name); - pkg = pkg_db_get_singleton(set); + set = pkg_hash_find_set(name); + pkg = pkg_hash_get_singleton(set); if (pkg == NULL) ohshit(_("ambiguous package name '%s' with more " "than one installed instance"), set->name); @@ -166,7 +166,7 @@ pkg_db_find_singleton(const char *name) * @return The package instance. */ struct pkginfo * -pkg_db_get_pkg(struct pkgset *set, const struct dpkg_arch *arch) +pkg_hash_get_pkg(struct pkgset *set, const struct dpkg_arch *arch) { struct pkginfo *pkg, **pkgp; @@ -218,13 +218,13 @@ pkg_db_get_pkg(struct pkgset *set, const struct dpkg_arch *arch) * @return The package instance. */ struct pkginfo * -pkg_db_find_pkg(const char *name, const struct dpkg_arch *arch) +pkg_hash_find_pkg(const char *name, const struct dpkg_arch *arch) { struct pkgset *set; struct pkginfo *pkg; - set = pkg_db_find_set(name); - pkg = pkg_db_get_pkg(set, arch); + set = pkg_hash_find_set(name); + pkg = pkg_hash_get_pkg(set, arch); return pkg; } @@ -235,7 +235,7 @@ pkg_db_find_pkg(const char *name, const struct dpkg_arch *arch) * @return The number of package sets. */ int -pkg_db_count_set(void) +pkg_hash_count_set(void) { return nset; } @@ -246,12 +246,12 @@ pkg_db_count_set(void) * @return The number of package instances. */ int -pkg_db_count_pkg(void) +pkg_hash_count_pkg(void) { return npkg; } -struct pkgiterator { +struct pkg_hash_iter { struct pkginfo *pkg; int nbinn; }; @@ -263,10 +263,10 @@ struct pkgiterator { * * @return The iterator. */ -struct pkgiterator * -pkg_db_iter_new(void) +struct pkg_hash_iter * +pkg_hash_iter_new(void) { - struct pkgiterator *iter; + struct pkg_hash_iter *iter; iter = m_malloc(sizeof(*iter)); iter->pkg = NULL; @@ -285,7 +285,7 @@ pkg_db_iter_new(void) * @return A package set. */ struct pkgset * -pkg_db_iter_next_set(struct pkgiterator *iter) +pkg_hash_iter_next_set(struct pkg_hash_iter *iter) { struct pkgset *set; @@ -320,7 +320,7 @@ pkg_db_iter_next_set(struct pkgiterator *iter) * @return A package instance. */ struct pkginfo * -pkg_db_iter_next_pkg(struct pkgiterator *iter) +pkg_hash_iter_next_pkg(struct pkg_hash_iter *iter) { struct pkginfo *pkg; @@ -349,13 +349,13 @@ pkg_db_iter_next_pkg(struct pkgiterator *iter) * @name iter The iterator. */ void -pkg_db_iter_free(struct pkgiterator *iter) +pkg_hash_iter_free(struct pkg_hash_iter *iter) { free(iter); } void -pkg_db_reset(void) +pkg_hash_reset(void) { int i; @@ -367,7 +367,7 @@ pkg_db_reset(void) } void -pkg_db_report(FILE *file) +pkg_hash_report(FILE *file) { int i, c; struct pkgset *pkg; diff --git a/lib/dpkg/pkg-spec.c b/lib/dpkg/pkg-spec.c index 9b4d0da31..3e3f59fa0 100644 --- a/lib/dpkg/pkg-spec.c +++ b/lib/dpkg/pkg-spec.c @@ -97,7 +97,7 @@ pkg_spec_is_illegal(struct pkg_spec *ps) if (!ps->arch_is_pattern && ps->flags & PKG_SPEC_ARCH_SINGLE) { struct pkgset *set; - set = pkg_db_find_set(ps->name); + set = pkg_hash_find_set(ps->name); /* Single instancing only applies with no architecture. */ if (ps->arch->type == DPKG_ARCH_NONE && @@ -195,9 +195,9 @@ static struct pkginfo * pkg_spec_get_pkg(struct pkg_spec *ps) { if (ps->arch->type == DPKG_ARCH_NONE) - return pkg_db_find_singleton(ps->name); + return pkg_hash_find_singleton(ps->name); else - return pkg_db_find_pkg(ps->name, ps->arch); + return pkg_hash_find_pkg(ps->name, ps->arch); } struct pkginfo * @@ -245,9 +245,9 @@ void pkg_spec_iter_init(struct pkg_spec *ps) { if (ps->name_is_pattern) - ps->pkg_iter = pkg_db_iter_new(); + ps->pkg_iter = pkg_hash_iter_new(); else - ps->pkg_next = &pkg_db_find_set(ps->name)->pkg; + ps->pkg_next = &pkg_hash_find_set(ps->name)->pkg; } static struct pkginfo * @@ -255,7 +255,7 @@ pkg_spec_iter_next_pkgname(struct pkg_spec *ps) { struct pkginfo *pkg; - while ((pkg = pkg_db_iter_next_pkg(ps->pkg_iter))) { + while ((pkg = pkg_hash_iter_next_pkg(ps->pkg_iter))) { if (pkg_spec_match_pkg(ps, pkg, &pkg->installed)) return pkg; } @@ -290,7 +290,7 @@ pkg_spec_iter_next_pkg(struct pkg_spec *ps) void pkg_spec_iter_destroy(struct pkg_spec *ps) { - pkg_db_iter_free(ps->pkg_iter); + pkg_hash_iter_free(ps->pkg_iter); pkg_spec_iter_blank(ps); } diff --git a/lib/dpkg/pkg-spec.h b/lib/dpkg/pkg-spec.h index 956b7fe3c..964f0d982 100644 --- a/lib/dpkg/pkg-spec.h +++ b/lib/dpkg/pkg-spec.h @@ -60,7 +60,7 @@ struct pkg_spec { bool arch_is_pattern; /** Used for the pkg_db iterator. */ - struct pkgiterator *pkg_iter; + struct pkg_hash_iter *pkg_iter; /** Used for the pkgset iterator. */ struct pkginfo *pkg_next; }; diff --git a/lib/dpkg/t/t-pkg-hash.c b/lib/dpkg/t/t-pkg-hash.c index c6ab20e28..72185a2f1 100644 --- a/lib/dpkg/t/t-pkg-hash.c +++ b/lib/dpkg/t/t-pkg-hash.c @@ -32,102 +32,102 @@ test_pkg_hash(void) struct dpkg_arch *arch; struct pkgset *set; struct pkginfo *pkg; - struct pkgiterator *iter; + struct pkg_hash_iter *iter; int pkginstance; - test_pass(pkg_db_count_set() == 0); - test_pass(pkg_db_count_pkg() == 0); + test_pass(pkg_hash_count_set() == 0); + test_pass(pkg_hash_count_pkg() == 0); - set = pkg_db_find_set("pkg-aa"); + set = pkg_hash_find_set("pkg-aa"); test_pass(set != NULL); test_str(set->name, ==, "pkg-aa"); - test_pass(pkg_db_count_set() == 1); - test_pass(pkg_db_count_pkg() == 1); + test_pass(pkg_hash_count_set() == 1); + test_pass(pkg_hash_count_pkg() == 1); - set = pkg_db_find_set("pkg-aa"); + set = pkg_hash_find_set("pkg-aa"); test_pass(set != NULL); test_str(set->name, ==, "pkg-aa"); - test_pass(pkg_db_count_set() == 1); - test_pass(pkg_db_count_pkg() == 1); + test_pass(pkg_hash_count_set() == 1); + test_pass(pkg_hash_count_pkg() == 1); - set = pkg_db_find_set("Pkg-AA"); + set = pkg_hash_find_set("Pkg-AA"); test_pass(set != NULL); test_str(set->name, ==, "pkg-aa"); - test_pass(pkg_db_count_set() == 1); - test_pass(pkg_db_count_pkg() == 1); + test_pass(pkg_hash_count_set() == 1); + test_pass(pkg_hash_count_pkg() == 1); - set = pkg_db_find_set("pkg-bb"); + set = pkg_hash_find_set("pkg-bb"); pkg_set_status(&set->pkg, PKG_STAT_INSTALLED); test_pass(set != NULL); test_str(set->name, ==, "pkg-bb"); - test_pass(pkg_db_count_set() == 2); - test_pass(pkg_db_count_pkg() == 2); + test_pass(pkg_hash_count_set() == 2); + test_pass(pkg_hash_count_pkg() == 2); - set = pkg_db_find_set("pkg-cc"); + set = pkg_hash_find_set("pkg-cc"); test_pass(set != NULL); test_str(set->name, ==, "pkg-cc"); - test_pass(pkg_db_count_set() == 3); - test_pass(pkg_db_count_pkg() == 3); + test_pass(pkg_hash_count_set() == 3); + test_pass(pkg_hash_count_pkg() == 3); arch = dpkg_arch_find("arch-xx"); - pkg = pkg_db_find_pkg("pkg-aa", arch); + pkg = pkg_hash_find_pkg("pkg-aa", arch); pkg_set_status(pkg, PKG_STAT_INSTALLED); test_pass(pkg != NULL); test_str(pkg->set->name, ==, "pkg-aa"); test_str(pkg->installed.arch->name, ==, "arch-xx"); test_str(pkg->available.arch->name, ==, "arch-xx"); - test_pass(pkg_db_count_set() == 3); - test_pass(pkg_db_count_pkg() == 3); + test_pass(pkg_hash_count_set() == 3); + test_pass(pkg_hash_count_pkg() == 3); arch = dpkg_arch_find("arch-yy"); - pkg = pkg_db_find_pkg("pkg-aa", arch); + pkg = pkg_hash_find_pkg("pkg-aa", arch); test_pass(pkg != NULL); test_str(pkg->set->name, ==, "pkg-aa"); test_str(pkg->installed.arch->name, ==, "arch-yy"); test_str(pkg->available.arch->name, ==, "arch-yy"); - test_pass(pkg_db_count_set() == 3); - test_pass(pkg_db_count_pkg() == 4); + test_pass(pkg_hash_count_set() == 3); + test_pass(pkg_hash_count_pkg() == 4); arch = dpkg_arch_find("arch-zz"); - pkg = pkg_db_find_pkg("pkg-aa", arch); + pkg = pkg_hash_find_pkg("pkg-aa", arch); pkg_set_status(pkg, PKG_STAT_UNPACKED); test_pass(pkg != NULL); test_str(pkg->set->name, ==, "pkg-aa"); test_str(pkg->installed.arch->name, ==, "arch-zz"); test_str(pkg->available.arch->name, ==, "arch-zz"); - test_pass(pkg_db_count_set() == 3); - test_pass(pkg_db_count_pkg() == 5); + test_pass(pkg_hash_count_set() == 3); + test_pass(pkg_hash_count_pkg() == 5); arch = dpkg_arch_find("arch-xx"); - pkg = pkg_db_find_pkg("pkg-aa", arch); + pkg = pkg_hash_find_pkg("pkg-aa", arch); test_pass(pkg != NULL); test_str(pkg->set->name, ==, "pkg-aa"); test_str(pkg->installed.arch->name, ==, "arch-xx"); test_str(pkg->available.arch->name, ==, "arch-xx"); - test_pass(pkg_db_count_set() == 3); - test_pass(pkg_db_count_pkg() == 5); + test_pass(pkg_hash_count_set() == 3); + test_pass(pkg_hash_count_pkg() == 5); - set = pkg_db_find_set("pkg-aa"); + set = pkg_hash_find_set("pkg-aa"); test_str(set->name, ==, "pkg-aa"); - pkg = pkg_db_get_singleton(set); + pkg = pkg_hash_get_singleton(set); test_pass(pkg == NULL); - test_pass(pkg_db_count_set() == 3); - test_pass(pkg_db_count_pkg() == 5); + test_pass(pkg_hash_count_set() == 3); + test_pass(pkg_hash_count_pkg() == 5); - pkg = pkg_db_find_singleton("pkg-bb"); + pkg = pkg_hash_find_singleton("pkg-bb"); test_pass(pkg != NULL); test_str(pkg->set->name, ==, "pkg-bb"); - test_pass(pkg_db_count_set() == 3); - test_pass(pkg_db_count_pkg() == 5); + test_pass(pkg_hash_count_set() == 3); + test_pass(pkg_hash_count_pkg() == 5); - pkg = pkg_db_find_singleton("pkg-cc"); + pkg = pkg_hash_find_singleton("pkg-cc"); test_pass(pkg != NULL); test_str(pkg->set->name, ==, "pkg-cc"); - test_pass(pkg_db_count_set() == 3); - test_pass(pkg_db_count_pkg() == 5); + test_pass(pkg_hash_count_set() == 3); + test_pass(pkg_hash_count_pkg() == 5); - iter = pkg_db_iter_new(); - while ((set = pkg_db_iter_next_set(iter))) { + iter = pkg_hash_iter_new(); + while ((set = pkg_hash_iter_next_set(iter))) { if (strcmp(set->name, "pkg-aa") == 0) test_str(set->name, ==, "pkg-aa"); else if (strcmp(set->name, "pkg-bb") == 0) @@ -137,11 +137,11 @@ test_pkg_hash(void) else test_fail("unknown fsys_namenode"); } - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); pkginstance = 0; - iter = pkg_db_iter_new(); - while ((pkg = pkg_db_iter_next_pkg(iter))) { + iter = pkg_hash_iter_new(); + while ((pkg = pkg_hash_iter_next_pkg(iter))) { pkginstance++; if (strcmp(pkg->set->name, "pkg-aa") == 0) { struct pkgbin *pkgbin = &pkg->installed; @@ -163,11 +163,11 @@ test_pkg_hash(void) test_fail("unknown fsys_namenode"); } } - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); - pkg_db_reset(); - test_pass(pkg_db_count_set() == 0); - test_pass(pkg_db_count_pkg() == 0); + pkg_hash_reset(); + test_pass(pkg_hash_count_set() == 0); + test_pass(pkg_hash_count_pkg() == 0); } TEST_ENTRY(test) diff --git a/lib/dpkg/t/t-pkg-show.c b/lib/dpkg/t/t-pkg-show.c index f5a978e81..0f6ece061 100644 --- a/lib/dpkg/t/t-pkg-show.c +++ b/lib/dpkg/t/t-pkg-show.c @@ -35,7 +35,7 @@ test_pkg_show_name(void) arch = dpkg_arch_find("arch"); test_pass(arch); - pkg = pkg_db_find_pkg("test", arch); + pkg = pkg_hash_find_pkg("test", arch); test_pass(pkg); test_str(pkg->set->name, ==, "test"); test_pass(pkg->installed.arch->type == DPKG_ARCH_UNKNOWN); diff --git a/lib/dpkg/trignote.c b/lib/dpkg/trignote.c index 1029a030e..957e80859 100644 --- a/lib/dpkg/trignote.c +++ b/lib/dpkg/trignote.c @@ -76,7 +76,7 @@ trig_note_pend(struct pkginfo *pend, const char *trig) /* * Note: This is called also from fields.c where *aw is a temporary - * but pend is from pkg_db_find()! + * but pend is from pkg_hash_find()! * * @retval true For done. * @retval false For already noted. diff --git a/src/depcon.c b/src/depcon.c index 071a67b06..593edfb8c 100644 --- a/src/depcon.c +++ b/src/depcon.c @@ -224,16 +224,16 @@ findbreakcyclerecursive(struct pkginfo *pkg, struct cyclesofarlink *sofar) bool findbreakcycle(struct pkginfo *pkg) { - struct pkgiterator *iter; + struct pkg_hash_iter *iter; struct pkginfo *tpkg; /* Clear the visited flag of all packages before we traverse them. */ - iter = pkg_db_iter_new(); - while ((tpkg = pkg_db_iter_next_pkg(iter))) { + iter = pkg_hash_iter_new(); + while ((tpkg = pkg_hash_iter_next_pkg(iter))) { ensure_package_clientdata(tpkg); tpkg->clientdata->color = PKG_CYCLE_WHITE; } - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); return findbreakcyclerecursive(pkg, NULL); } diff --git a/src/divertcmd.c b/src/divertcmd.c index 202b77066..61b382f0e 100644 --- a/src/divertcmd.c +++ b/src/divertcmd.c @@ -410,16 +410,16 @@ static bool diversion_is_essential(struct fsys_namenode *namenode) { struct pkginfo *pkg; - struct pkgiterator *pkg_iter; + struct pkg_hash_iter *pkg_iter; struct fsys_node_pkgs_iter *iter; bool essential = false; - pkg_iter = pkg_db_iter_new(); - while ((pkg = pkg_db_iter_next_pkg(pkg_iter))) { + pkg_iter = pkg_hash_iter_new(); + while ((pkg = pkg_hash_iter_next_pkg(pkg_iter))) { if (pkg->installed.essential) ensure_packagefiles_available(pkg); } - pkg_db_iter_free(pkg_iter); + pkg_hash_iter_free(pkg_iter); iter = fsys_node_pkgs_iter_new(namenode); while ((pkg = fsys_node_pkgs_iter_next(iter))) { @@ -500,7 +500,7 @@ diversion_add(const char *const *argv) if (opt_pkgname == NULL) pkgset = NULL; else - pkgset = pkg_db_find_set(opt_pkgname); + pkgset = pkg_hash_find_set(opt_pkgname); /* Check we are not stomping over an existing diversion. */ if (fnn_from->divert || fnn_to->divert) { @@ -622,7 +622,7 @@ diversion_remove(const char *const *argv) if (opt_pkgname == NULL) pkgset = NULL; else - pkgset = pkg_db_find_set(opt_pkgname); + pkgset = pkg_hash_find_set(opt_pkgname); contest = namenode->divert; altname = contest->useinstead->divert; diff --git a/src/enquiry.c b/src/enquiry.c index 632322faa..dd7069eb8 100644 --- a/src/enquiry.c +++ b/src/enquiry.c @@ -198,7 +198,7 @@ audit(const char *const *argv) modstatdb_open(msdbrw_readonly); if (!*argv) - pkg_array_init_from_db(&array); + pkg_array_init_from_hash(&array); else pkg_array_init_from_names(&array, pkg_array_mapper, (const char **)argv); @@ -273,7 +273,7 @@ unpackchk(const char *const *argv) { int totalcount, sects; struct sectionentry *sectionentries, *se, **sep; - struct pkgiterator *iter; + struct pkg_hash_iter *iter; struct pkginfo *pkg; const char *thissect; char buf[20]; @@ -287,8 +287,8 @@ unpackchk(const char *const *argv) totalcount= 0; sectionentries = NULL; sects= 0; - iter = pkg_db_iter_new(); - while ((pkg = pkg_db_iter_next_pkg(iter))) { + iter = pkg_hash_iter_new(); + while ((pkg = pkg_hash_iter_next_pkg(iter))) { if (!yettobeunpacked(pkg, &thissect)) continue; for (se= sectionentries; se && strcasecmp(thissect,se->name); se= se->next); if (!se) { @@ -304,27 +304,27 @@ unpackchk(const char *const *argv) } se->count++; totalcount++; } - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); if (totalcount == 0) return 0; if (totalcount <= 12) { - iter = pkg_db_iter_new(); - while ((pkg = pkg_db_iter_next_pkg(iter))) { + iter = pkg_hash_iter_new(); + while ((pkg = pkg_hash_iter_next_pkg(iter))) { if (!yettobeunpacked(pkg, NULL)) continue; describebriefly(pkg); } - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); } else if (sects <= 12) { for (se= sectionentries; se; se= se->next) { sprintf(buf,"%d",se->count); printf(_(" %d in %s: "),se->count,se->name); width= 70-strlen(se->name)-strlen(buf); while (width > 59) { putchar(' '); width--; } - iter = pkg_db_iter_new(); - while ((pkg = pkg_db_iter_next_pkg(iter))) { + iter = pkg_hash_iter_new(); + while ((pkg = pkg_hash_iter_next_pkg(iter))) { const char *pkgname; if (!yettobeunpacked(pkg,&thissect)) continue; @@ -335,7 +335,7 @@ unpackchk(const char *const *argv) if (width < 4) { printf(" ..."); break; } printf(" %s", pkgname); } - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); putchar('\n'); } } else { @@ -369,7 +369,7 @@ assert_version_support(const char *const *argv, modstatdb_open(msdbrw_readonly); - pkg = pkg_db_find_singleton("dpkg"); + pkg = pkg_hash_find_singleton("dpkg"); switch (pkg->status) { case PKG_STAT_INSTALLED: case PKG_STAT_TRIGGERSPENDING: @@ -458,7 +458,7 @@ predeppackage(const char *const *argv) { static struct varbuf vb; - struct pkgiterator *iter; + struct pkg_hash_iter *iter; struct pkginfo *pkg = NULL, *startpkg, *trypkg; struct dependency *dep; struct deppossi *possi, *provider; @@ -471,8 +471,8 @@ predeppackage(const char *const *argv) clear_istobes(); dep = NULL; - iter = pkg_db_iter_new(); - while (!dep && (pkg = pkg_db_iter_next_pkg(iter))) { + iter = pkg_hash_iter_new(); + while (!dep && (pkg = pkg_hash_iter_next_pkg(iter))) { /* Ignore packages user doesn't want. */ if (pkg->want != PKG_WANT_INSTALL) continue; @@ -490,7 +490,7 @@ predeppackage(const char *const *argv) pkg->clientdata->istobe = PKG_ISTOBE_NORMAL; /* If dep is NULL we go and get the next package. */ } - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); if (!dep) return 1; /* Not found. */ diff --git a/src/help.c b/src/help.c index f9b8d6b88..f168e8374 100644 --- a/src/help.c +++ b/src/help.c @@ -202,16 +202,16 @@ force_conflicts(struct deppossi *possi) } void clear_istobes(void) { - struct pkgiterator *iter; + struct pkg_hash_iter *iter; struct pkginfo *pkg; - iter = pkg_db_iter_new(); - while ((pkg = pkg_db_iter_next_pkg(iter)) != NULL) { + iter = pkg_hash_iter_new(); + while ((pkg = pkg_hash_iter_next_pkg(iter)) != NULL) { ensure_package_clientdata(pkg); pkg->clientdata->istobe = PKG_ISTOBE_NORMAL; pkg->clientdata->replacingfilesandsaid= 0; } - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); } /* diff --git a/src/main.c b/src/main.c index 0932695f1..a6b225c51 100644 --- a/src/main.c +++ b/src/main.c @@ -560,7 +560,7 @@ arch_remove(const char *const *argv) { const char *archname = *argv++; struct dpkg_arch *arch; - struct pkgiterator *iter; + struct pkg_hash_iter *iter; struct pkginfo *pkg; if (archname == NULL || *argv) @@ -575,8 +575,8 @@ arch_remove(const char *const *argv) } /* Check if it's safe to remove the architecture from the db. */ - iter = pkg_db_iter_new(); - while ((pkg = pkg_db_iter_next_pkg(iter))) { + iter = pkg_hash_iter_new(); + while ((pkg = pkg_hash_iter_next_pkg(iter))) { if (pkg->status < PKG_STAT_HALFINSTALLED) continue; if (pkg->installed.arch == arch) { @@ -589,7 +589,7 @@ arch_remove(const char *const *argv) break; } } - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); dpkg_arch_unmark(arch); dpkg_arch_save_list(); diff --git a/src/packages.c b/src/packages.c index 55b56569e..bc93c7c89 100644 --- a/src/packages.c +++ b/src/packages.c @@ -72,11 +72,11 @@ enqueue_package_mark_seen(struct pkginfo *pkg) static void enqueue_pending(void) { - struct pkgiterator *iter; + struct pkg_hash_iter *iter; struct pkginfo *pkg; - iter = pkg_db_iter_new(); - while ((pkg = pkg_db_iter_next_pkg(iter)) != NULL) { + iter = pkg_hash_iter_new(); + while ((pkg = pkg_hash_iter_next_pkg(iter)) != NULL) { switch (cipaction->arg_int) { case act_configure: if (!(pkg->status == PKG_STAT_UNPACKED || @@ -108,7 +108,7 @@ enqueue_pending(void) } enqueue_package(pkg); } - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); } static void diff --git a/src/querycmd.c b/src/querycmd.c index 3d5284044..6ee555e4e 100644 --- a/src/querycmd.c +++ b/src/querycmd.c @@ -260,7 +260,7 @@ listpackages(const char *const *argv) else modstatdb_open(msdbrw_readonly | msdbrw_available_readonly); - pkg_array_init_from_db(&array); + pkg_array_init_from_hash(&array); pkg_array_sort(&array, pkg_sorter_by_nonambig_name_arch); memset(&fmt, 0, sizeof(fmt)); @@ -571,7 +571,7 @@ showpackages(const char *const *argv) else modstatdb_open(msdbrw_readonly | msdbrw_available_readonly); - pkg_array_init_from_db(&array); + pkg_array_init_from_hash(&array); pkg_array_sort(&array, pkg_sorter_by_nonambig_name_arch); if (!*argv) { diff --git a/src/select.c b/src/select.c index 3eae4cbcf..a49d6c33b 100644 --- a/src/select.c +++ b/src/select.c @@ -67,7 +67,7 @@ getselections(const char *const *argv) modstatdb_open(msdbrw_readonly); - pkg_array_init_from_db(&array); + pkg_array_init_from_hash(&array); pkg_array_sort(&array, pkg_sorter_by_nonambig_name_arch); if (!*argv) { @@ -212,7 +212,7 @@ int clearselections(const char *const *argv) { enum modstatdb_rw msdbflags; - struct pkgiterator *iter; + struct pkg_hash_iter *iter; struct pkginfo *pkg; if (*argv) @@ -226,12 +226,12 @@ clearselections(const char *const *argv) modstatdb_open(msdbflags); pkg_infodb_upgrade(); - iter = pkg_db_iter_new(); - while ((pkg = pkg_db_iter_next_pkg(iter))) { + iter = pkg_hash_iter_new(); + while ((pkg = pkg_hash_iter_next_pkg(iter))) { if (!pkg->installed.essential) pkg_set_want(pkg, PKG_WANT_DEINSTALL); } - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); modstatdb_shutdown(); diff --git a/src/trigproc.c b/src/trigproc.c index 174683348..59e30d143 100644 --- a/src/trigproc.c +++ b/src/trigproc.c @@ -122,11 +122,11 @@ trigproc_enqueue_deferred(struct pkginfo *pend) void trigproc_populate_deferred(void) { - struct pkgiterator *iter; + struct pkg_hash_iter *iter; struct pkginfo *pkg; - iter = pkg_db_iter_new(); - while ((pkg = pkg_db_iter_next_pkg(iter))) { + iter = pkg_hash_iter_new(); + while ((pkg = pkg_hash_iter_next_pkg(iter))) { if (!pkg->trigpend_head) continue; @@ -139,7 +139,7 @@ trigproc_populate_deferred(void) trigproc_enqueue_deferred(pkg); } - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); } void @@ -256,15 +256,15 @@ trigproc_new_cyclenode(struct pkginfo *processing_now) struct trigcyclenode *tcn; struct trigcycleperpkg *tcpp; struct pkginfo *pkg; - struct pkgiterator *iter; + struct pkg_hash_iter *iter; tcn = nfmalloc(sizeof(*tcn)); tcn->pkgs = NULL; tcn->next = NULL; tcn->then_processed = processing_now; - iter = pkg_db_iter_new(); - while ((pkg = pkg_db_iter_next_pkg(iter))) { + iter = pkg_hash_iter_new(); + while ((pkg = pkg_hash_iter_next_pkg(iter))) { if (!pkg->trigpend_head) continue; tcpp = nfmalloc(sizeof(*tcpp)); @@ -273,7 +273,7 @@ trigproc_new_cyclenode(struct pkginfo *processing_now) tcpp->next = tcn->pkgs; tcn->pkgs = tcpp; } - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); return tcn; } @@ -515,11 +515,11 @@ transitional_interest_callback(const char *trig, struct pkginfo *pkg, static void trig_transitional_activate(enum modstatdb_rw cstatus) { - struct pkgiterator *iter; + struct pkg_hash_iter *iter; struct pkginfo *pkg; - iter = pkg_db_iter_new(); - while ((pkg = pkg_db_iter_next_pkg(iter))) { + iter = pkg_hash_iter_new(); + while ((pkg = pkg_hash_iter_next_pkg(iter))) { if (pkg->status <= PKG_STAT_HALFINSTALLED) continue; debug(dbg_triggersdetail, "trig_transitional_activate %s %s", @@ -546,7 +546,7 @@ trig_transitional_activate(enum modstatdb_rw cstatus) else pkg_set_status(pkg, PKG_STAT_INSTALLED); } - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); if (cstatus >= msdbrw_write) { modstatdb_checkpoint(); diff --git a/src/unpack.c b/src/unpack.c index ceb17a2c3..e8b06d289 100644 --- a/src/unpack.c +++ b/src/unpack.c @@ -836,15 +836,15 @@ pkg_disappear(struct pkginfo *pkg, struct pkginfo *infavour) static void pkg_disappear_others(struct pkginfo *pkg) { - struct pkgiterator *iter; + struct pkg_hash_iter *iter; struct pkginfo *otherpkg; struct fsys_namenode_list *cfile; struct deppossi *pdep; struct dependency *providecheck; struct varbuf depprobwhy = VARBUF_INIT; - iter = pkg_db_iter_new(); - while ((otherpkg = pkg_db_iter_next_pkg(iter)) != NULL) { + iter = pkg_hash_iter_new(); + while ((otherpkg = pkg_hash_iter_next_pkg(iter)) != NULL) { ensure_package_clientdata(otherpkg); if (otherpkg == pkg || @@ -939,7 +939,7 @@ pkg_disappear_others(struct pkginfo *pkg) * what can we do ? It has to be run this late. */ pkg_disappear(otherpkg, pkg); } /* while (otherpkg= ... */ - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); } /** diff --git a/src/verify.c b/src/verify.c index 4190981f7..9b6e18ad4 100644 --- a/src/verify.c +++ b/src/verify.c @@ -147,12 +147,12 @@ verify(const char *const *argv) ensure_diversions(); if (!*argv) { - struct pkgiterator *iter; + struct pkg_hash_iter *iter; - iter = pkg_db_iter_new(); - while ((pkg = pkg_db_iter_next_pkg(iter))) + iter = pkg_hash_iter_new(); + while ((pkg = pkg_hash_iter_next_pkg(iter))) verify_package(pkg); - pkg_db_iter_free(iter); + pkg_hash_iter_free(iter); } else { const char *thisarg; -- Dpkg.Org's dpkg

