void finish_install_cleanup () { g_debug ("finish install cleanup\n"); static gboolean cleaned = FALSE; if (cleaned) { g_warning ("finish install cleanup:already cleaned\n"); return; } cleaned = TRUE; extern const gchar *target; if (target == NULL) { g_warning ("finish install:target is NULL\n"); } extern gboolean in_chroot; extern int chroot_fd; if (in_chroot) { fix_networkmanager (); remove_packages (); if (fchdir (chroot_fd) < 0) { g_warning ("finish install:reset to chroot fd dir failed\n"); } else { int i = 0; for (i = 0; i < 1024; i++) { chdir (".."); } chroot ("."); } in_chroot = FALSE; } unmount_target (); ped_device_free_all (); }
/* * The hash table is to keep track of leaves which have already been displayed * to the user. */ int main(int argc, char **argv) { int i; /* Initialize space for blacklist hash table */ if(hcreate(10000)==0) { fputs("Cannot create hash table.\n",stderr); return(EX_UNAVAILABLE); } i=0; do { if(read_pkglist(i++)) break; if(display_menu()) break; if(remove_packages()) break; free_menu(); } while(keep_going()); hdestroy(); fputs("\nProgram Terminated Successfully\n",stderr); return(0); }
int main(int argc, char **argv) { unsigned i; conf_t *conf; dict_t *repositories; dict_t *ports_dict; dict_t *not_founds; list_t *ports_list; list_t *packages; list_t *list; list_t *drivers; struct arguments arguments; arguments.action = 0; arguments.no_favourite_repositories = 0; arguments.no_locked_versions = 0; arguments.no_aliases = 0; arguments.no_colors = 0; arguments.no_deps = 1; arguments.all = 0; arguments.fetch_only = 0; arguments.no_repositories_hierarchy = 0; arguments.tree = 0; arguments.verbose = 0; arguments.rebuild_cache = 0; arguments.args = list_new(); if (argc < 2) { char *fake_arg[2]; fake_arg[0] = "ilenia"; fake_arg[1] = "--help"; argp_parse(&argp, 2, fake_arg, 0, 0, &arguments); } argp_parse(&argp, argc, argv, 0, 0, &arguments); conf = conf_init(); if (arguments.no_repositories_hierarchy) { list_free(conf->repositories_hierarchy, free); conf->repositories_hierarchy = list_new(); } if (arguments.no_favourite_repositories) { dict_free(conf->favourite_repositories, NULL); conf->favourite_repositories = dict_new(); } if (arguments.no_locked_versions) { dict_free(conf->locked_versions, free); conf->locked_versions = dict_new(); } if (arguments.no_aliases) { aliases_free(conf->aliases); conf->aliases = dict_new(); } drivers = drivers_list_init(); repositories = repositories_dict_init(drivers, conf->repositories_hierarchy); if (!conf->enable_colors || arguments.no_colors) cprintf = uncoloredprintf; else cprintf = coloredprintf; if (arguments.rebuild_cache) cache_build(repositories); packages = packages_list_init(); if ((ports_list = ports_list_init(repositories)) == NULL) { list_free(arguments.args, NULL); dict_free(repositories, repository_free); list_free(packages, port_free); list_free(drivers, free); dict_free(conf->favourite_repositories, free); conf->favourite_repositories = dict_new(); conf_free(conf); return 1; } conf_reparse(conf, ports_list); ports_dict = ports_dict_init(ports_list, packages, conf); not_founds = dict_new(); if (!arguments.verbose) arguments.verbose = conf->verbose; switch (arguments.action) { case ACT_LIST: if (!arguments.args->length) { list_dump(ports_list, port_dump); break; } for (i = 0; i < arguments.args->length; i++) { if (dict_get(repositories, list_get(arguments.args, i)) == NULL) { warning("repository %s not found!", list_get(arguments.args, i)); continue; } list = list_query(ports_list, port_query_by_repository, list_get(arguments.args, i)); list_dump(list, port_dump); list_free(list, NULL); } break; case ACT_SEARCH: if (!arguments.args->length) { warning("action --search (-s) requires at least an " "argument!"); break; } for (i = 0; i < arguments.args->length; i++) { list = list_query(ports_list, port_query_by_name, list_get(arguments.args, i)); if (arguments.verbose) list_dump(list, port_info_dump); else list_dump(list, port_dump); if (list->length == 0) printf("%s not found!\n", (char *)list_get(arguments.args, i)); list_free(list, NULL); } break; case ACT_SEARCHDESC: if (!arguments.args->length) { warning("action --search-desc requires at least an " "argument!"); break; } for (i = 0; i < arguments.args->length; i++) { char *key = xstrdup(list_get(arguments.args, i)); if (isalpha(*key) && isalpha(*(key + strlen(key) - 1))) { strprepend(&key, "*"); strappend(&key, "*"); } list = list_query(ports_list, port_query_by_description, key); if (arguments.verbose) list_dump(list, port_info_dump); else list_dump(list, port_dump); list_free(list, NULL); free(key); } break; case ACT_DIFF: port_show_diffs(ports_dict, packages); break; case ACT_UPDATED: port_show_outdated(ports_dict, packages); break; case ACT_DEPENDENCIES: if (!arguments.args->length) { warning("action --dependencies (-D) requires at " "least an argument!"); break; } //for (i = 0; i < arguments.args->length; i++) dependencies_dump(arguments.args, ports_dict, conf->aliases, not_founds, arguments.tree, arguments.verbose); break; case ACT_DEPENDENTS: if (!arguments.args->length) { warning("action --dependents (-T) requires at " "least an argument!"); break; } for (i = 0; i < arguments.args->length; i++) dependents_dump(list_get(arguments.args, i), ports_dict, conf->aliases, arguments.tree, arguments.verbose, arguments.all); break; case ACT_INFO: if (!arguments.args->length) { warning("action --info requires at " "least an argument!"); break; } for (i = 0; i < arguments.args->length; i++) info_dump(list_get(arguments.args, i), ports_dict); break; case ACT_README: if (!arguments.args->length) { warning("action --show-readme requires at " "least an argument!"); break; } for (i = 0; i < arguments.args->length; i++) readme_dump(list_get(arguments.args, i), ports_dict); break; case ACT_REPOSITORY_LIST: repositories_dict_dump(repositories); break; case ACT_UPDATE: if (arguments.args->length) repositories_dict_update(repositories, arguments.args); else repositories_dict_update_all(repositories); break; case ACT_REMOVE: if (!arguments.args->length) { warning("action --remove (-R) requires at " "least an argument!"); break; } remove_packages(arguments.args, packages, ports_dict, conf, arguments.all); break; case ACT_UPDATE_PKG: if (!arguments.args->length) { update_system(ports_dict, conf->aliases, arguments.fetch_only, conf->ask_for_update, conf->not_found_policy); break; } update_package(arguments.args, ports_dict, conf, arguments.fetch_only); break; default: if (!arguments.rebuild_cache) warning("What can I do for you?"); } list_free(arguments.args, NULL); dict_free(repositories, repository_free); list_free(ports_list, port_free); list_free(packages, port_free); dict_free(ports_dict, NULL); list_free(drivers, free); conf_free(conf); dict_free(not_founds, port_free); return 0; }
/* * The thread that performs a SimulateRemovePackages operation. Should be * invoked by the pk_backend_simulate_remove_packages hook. */ gboolean simulate_remove_packages_thread(PkBackend *backend) { return remove_packages(backend, true); }
/* * The thread that performs an removePackages operation. Should be invoked by * the pk_backend_remove_packages hook. */ gboolean remove_packages_thread(PkBackend *backend) { return remove_packages(backend, false); }