Split packages() into bite-sized pieces. No functional change intended. Signed-off-by: Jonathan Nieder <jrnie...@gmail.com> --- src/packages.c | 124 ++++++++++++++++++++++++++++++------------------------- 1 files changed, 68 insertions(+), 56 deletions(-)
diff --git a/src/packages.c b/src/packages.c index 2e3c23a..f180434 100644 --- a/src/packages.c +++ b/src/packages.c @@ -54,16 +54,72 @@ add_to_queue(struct pkginfo *pkg) pkg_queue_push(&queue, pkg); } -/* - * Act on the packages listed in argv. - * cipaction->arg contains the requested action (e.g., --configure) - */ -void packages(const char *const *argv) { +/* Fill queue with pending packages. */ +static void queue_pending(void) +{ + struct pkgiterator *it; + struct pkginfo *pkg; + + it= iterpkgstart(); + while ((pkg = iterpkgnext(it)) != NULL) { + switch (cipaction->arg) { + case act_configure: + if (!(pkg->status == stat_unpacked || + pkg->status == stat_halfconfigured || + pkg->trigpend_head)) + continue; + if (pkg->want != want_install) + continue; + break; + case act_triggers: + if (!pkg->trigpend_head) + continue; + if (pkg->want != want_install) + continue; + break; + case act_remove: + case act_purge: + if (pkg->want != want_purge) { + if (pkg->want != want_deinstall) continue; + if (pkg->status == stat_configfiles) continue; + } + if (pkg->status == stat_notinstalled) + continue; + break; + default: + internerr("unknown action '%d'", cipaction->arg); + } + add_to_queue(pkg); + } + iterpkgend(it); +} + +/* Fill queue with specified packages. */ +static void queue_specified(const char *const *argv) +{ struct pkgiterator *it; struct pkginfo *pkg; const char *thisarg; size_t l; - + + while ((thisarg = *argv++) != NULL) { + pkg= findpackage(thisarg); + if (pkg->status == stat_notinstalled) { + l= strlen(pkg->name); + if (l >= sizeof(DEBEXT) && !strcmp(pkg->name+l-sizeof(DEBEXT)+1,DEBEXT)) + badusage(_("you must specify packages by their own names," + " not by quoting the names of the files they come in")); + } + add_to_queue(pkg); + } +} + +/* + * Act on the packages listed in argv. + * cipaction->arg contains the requested action (e.g., --configure) + */ +void packages(const char *const *argv) +{ trigproc_install_hooks(); modstatdb_init(admindir, @@ -74,59 +130,15 @@ void packages(const char *const *argv) { log_message("startup packages %s", cipaction->olong); if (f_pending) { - if (*argv) - badusage(_("--%s --pending does not take any non-option arguments"),cipaction->olong); - - it= iterpkgstart(); - while ((pkg = iterpkgnext(it)) != NULL) { - switch (cipaction->arg) { - case act_configure: - if (!(pkg->status == stat_unpacked || - pkg->status == stat_halfconfigured || - pkg->trigpend_head)) - continue; - if (pkg->want != want_install) - continue; - break; - case act_triggers: - if (!pkg->trigpend_head) - continue; - if (pkg->want != want_install) - continue; - break; - case act_remove: - case act_purge: - if (pkg->want != want_purge) { - if (pkg->want != want_deinstall) continue; - if (pkg->status == stat_configfiles) continue; - } - if (pkg->status == stat_notinstalled) - continue; - break; - default: - internerr("unknown action '%d'", cipaction->arg); - } - add_to_queue(pkg); - } - iterpkgend(it); - + badusage(_("--%s --pending does not take any non-option arguments"), + cipaction->olong); + queue_pending(); } else { - if (!*argv) - badusage(_("--%s needs at least one package name argument"), cipaction->olong); - - while ((thisarg = *argv++) != NULL) { - pkg= findpackage(thisarg); - if (pkg->status == stat_notinstalled) { - l= strlen(pkg->name); - if (l >= sizeof(DEBEXT) && !strcmp(pkg->name+l-sizeof(DEBEXT)+1,DEBEXT)) - badusage(_("you must specify packages by their own names," - " not by quoting the names of the files they come in")); - } - add_to_queue(pkg); - } - + badusage(_("--%s needs at least one package name argument"), + cipaction->olong); + queue_specified(argv); } ensure_diversions(); -- 1.7.0.4 -- To UNSUBSCRIBE, email to debian-dpkg-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20100408113350.gc27...@progeny.tock