From 3a2f421109344a66b4275206b9164f0cdc52f8e0 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 28 Oct 2009 03:39:13 +0100 Subject: [PATCH] xbps-bin: added "show-manual" target. This targets shows the list of packages that were installed manually, i.e not as dependencies. --HG-- extra : convert_revision : xtraeme%40gmail.com-20091028023913-i4qh7ky1puezyhrt --- bin/xbps-bin/main.c | 49 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/bin/xbps-bin/main.c b/bin/xbps-bin/main.c index 32b5a339..80cc25ae 100644 --- a/bin/xbps-bin/main.c +++ b/bin/xbps-bin/main.c @@ -43,18 +43,18 @@ usage(void) { printf("Usage: xbps-bin [options] [target] [arguments]\n\n" " Available targets:\n" - " autoremove, autoupdate, check, install, list, purge\n" - " remove, show, show-deps, show-files, show-revdeps, update\n" - "\n" - " Targets with arguments:\n" + " autoremove\n" + " autoupdate\n" " check\t\t[|]\n" " install\t\t\n" + " list\n" " purge\t\t[|]\n" " reconfigure\t\t[|]\n" " remove\t\t\n" " show\t\t\n" " show-deps\t\t\n" " show-files\t\t\n" + " show-manual\n" " show-revdeps\t\n" " update\t\t\n" " Options shared by all targets:\n" @@ -89,13 +89,34 @@ list_pkgs_in_dict(prop_object_t obj, void *arg, bool *loop_done) return EINVAL; } +static int +list_manual_packages(prop_object_t obj, void *arg, bool *loop_done) +{ + const char *pkgname, *version; + bool automatic = false; + + (void)arg; + (void)loop_done; + + prop_dictionary_get_bool(obj, "automatic-install", &automatic); + if (automatic == false) { + prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); + prop_dictionary_get_cstring_nocopy(obj, "version", &version); + printf("%s-%s\n", pkgname, version); + } + + return 0; +} + int main(int argc, char **argv) { prop_dictionary_t dict; struct sigaction sa; int c, flags = 0, rv = 0; - bool force = false, verbose = false; + bool force, verbose; + + force = verbose = false; while ((c = getopt(argc, argv, "CVfr:v")) != -1) { switch (c) { @@ -269,6 +290,17 @@ main(int argc, char **argv) rv = xbps_show_pkg_deps(argv[1]); + } else if (strcasecmp(argv[0], "show-manual") == 0) { + /* + * Show packages that were installed manually, not as + * dependencies. + */ + if (argc != 1) + usage(); + + rv = xbps_callback_array_iter_in_dict(dict, "packages", + list_manual_packages, NULL); + } else if (strcasecmp(argv[0], "show-revdeps") == 0) { /* * Show reverse dependencies for a package. @@ -289,13 +321,6 @@ out: static void cleanup(int signum) { - switch (signum) { - case SIGINT: - case SIGTERM: - case SIGQUIT: - printf("\nSignal caught, cleaning up...\n"); - break; - } xbps_release_repolist_data(); xbps_release_regpkgdb_dict();