X-Git-Url: https://git.librecmc.org/?p=oweals%2Fopkg-lede.git;a=blobdiff_plain;f=libopkg%2Fopkg_cmd.c;h=427b356f0257cc8b76b05f13eebf4d4c7be7f681;hp=d03e27c0e7a18b9f71da9a85e9712f99b6a86bbd;hb=04ac0b44dfcf848e30bfa6c29894dbe908007385;hpb=4ea955bc7e5575bc1d8b34c364591c47653f2cfd diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c index d03e27c..427b356 100644 --- a/libopkg/opkg_cmd.c +++ b/libopkg/opkg_cmd.c @@ -15,8 +15,6 @@ General Public License for more details. */ -#include "config.h" - #include #include #include @@ -46,11 +44,12 @@ static void print_pkg(pkg_t * pkg) { char *version = pkg_version_str_alloc(pkg); + char *description = pkg_get_string(pkg, PKG_DESCRIPTION); printf("%s - %s", pkg->name, version); if (conf->size) - printf(" - %lu", pkg->size); - if (pkg->description) - printf(" - %s", pkg->description); + printf(" - %lu", (unsigned long) pkg_get_int(pkg, PKG_SIZE)); + if (description) + printf(" - %s", description); printf("\n"); free(version); } @@ -143,7 +142,7 @@ static int opkg_update_cmd(int argc, char **argv) list_file_name); } free(url); -#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) || defined(HAVE_USIGN) +#if defined(HAVE_OPENSSL) || defined(HAVE_USIGN) if (pkglist_dl_error == 0 && conf->check_signature) { /* download detached signitures to verify the package lists */ /* get the url for the sig file */ @@ -284,7 +283,6 @@ opkg_recurse_pkgs_in_order(pkg_t * pkg, pkg_vec_t * all, pkg_vec_t * visited, pkg_vec_t * ordered) { int j, k, l, m; - int count; pkg_t *dep; compound_depend_t *compound_depend; depend_t **possible_satisfiers; @@ -311,17 +309,13 @@ opkg_recurse_pkgs_in_order(pkg_t * pkg, pkg_vec_t * all, pkg_vec_insert(visited, pkg); - count = pkg->pre_depends_count + pkg->depends_count + - pkg->recommends_count + pkg->suggests_count; - opkg_msg(DEBUG, "pkg %s.\n", pkg->name); /* Iterate over all the dependencies of pkg. For each one, find a package that is either installed or unpacked and satisfies this dependency. (there should only be one such package per dependency installed or unpacked). Then recurse to the dependency package */ - for (j = 0; j < count; j++) { - compound_depend = &pkg->depends[j]; + for (compound_depend = pkg_get_ptr(pkg, PKG_DEPENDS); compound_depend && compound_depend->type; compound_depend++) { possible_satisfiers = compound_depend->possibilities; for (k = 0; k < compound_depend->possibility_count; k++) { abpkg = possible_satisfiers[k]->pkg; @@ -439,14 +433,6 @@ static int opkg_install_cmd(int argc, char **argv) char *arg; int err = 0; - if (conf->force_reinstall) { - int saved_force_depends = conf->force_depends; - conf->force_depends = 1; - (void)opkg_remove_cmd(argc, argv); - conf->force_depends = saved_force_depends; - conf->force_reinstall = 0; - } - signal(SIGINT, sigint_handler); /* @@ -459,6 +445,18 @@ static int opkg_install_cmd(int argc, char **argv) if (opkg_prepare_url_for_install(arg, &argv[i])) return -1; } + + pkg_hash_load_package_details(); + pkg_hash_load_status_files(); + + if (conf->force_reinstall) { + int saved_force_depends = conf->force_depends; + conf->force_depends = 1; + (void)opkg_remove_cmd(argc, argv); + conf->force_depends = saved_force_depends; + conf->force_reinstall = 0; + } + pkg_info_preinstall_check(); for (i = 0; i < argc; i++) { @@ -553,7 +551,7 @@ static int opkg_download_cmd(int argc, char **argv) opkg_msg(ERROR, "Failed to download %s.\n", pkg->name); } else { opkg_msg(NOTICE, "Downloaded %s as %s.\n", - pkg->name, pkg->local_filename); + pkg->name, pkg_get_string(pkg, PKG_LOCAL_FILENAME)); } } @@ -566,6 +564,7 @@ static int opkg_list_find_cmd(int argc, char **argv, int use_desc) pkg_vec_t *available; pkg_t *pkg; char *pkg_name = NULL; + char *description; if (argc > 0) { pkg_name = argv[0]; @@ -575,10 +574,11 @@ static int opkg_list_find_cmd(int argc, char **argv, int use_desc) pkg_vec_sort(available, pkg_compare_names); for (i = 0; i < available->len; i++) { pkg = available->pkgs[i]; + description = use_desc ? pkg_get_string(pkg, PKG_DESCRIPTION) : NULL; /* if we have package name or pattern and pkg does not match, then skip it */ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase) && - (!use_desc || !pkg->description - || fnmatch(pkg_name, pkg->description, conf->nocase))) + (!use_desc || !description + || fnmatch(pkg_name, description, conf->nocase))) continue; print_pkg(pkg); } @@ -630,6 +630,7 @@ static int opkg_list_changed_conffiles_cmd(int argc, char **argv) pkg_t *pkg; char *pkg_name = NULL; conffile_list_elt_t *iter; + conffile_list_t *cl; conffile_t *cf; if (argc > 0) { @@ -640,13 +641,14 @@ static int opkg_list_changed_conffiles_cmd(int argc, char **argv) pkg_vec_sort(available, pkg_compare_names); for (i = 0; i < available->len; i++) { pkg = available->pkgs[i]; + cl = pkg_get_ptr(pkg, PKG_CONFFILES); /* if we have package name or pattern and pkg does not match, then skip it */ if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase)) continue; - if (nv_pair_list_empty(&pkg->conffiles)) + if (!cl || nv_pair_list_empty(cl)) continue; - for (iter = nv_pair_list_first(&pkg->conffiles); iter; - iter = nv_pair_list_next(&pkg->conffiles, iter)) { + for (iter = nv_pair_list_first(cl); iter; + iter = nv_pair_list_next(cl, iter)) { cf = (conffile_t *) iter->data; if (cf->name && cf->value && conffile_has_been_modified(cf)) @@ -665,7 +667,7 @@ static int opkg_list_upgradable_cmd(int argc, char **argv) char *old_v, *new_v; for (node = active_list_next(head, head); node; node = active_list_next(head, node)) { - _old_pkg = list_entry(node, pkg_t, list); + _old_pkg = node->pkg; _new_pkg = pkg_hash_fetch_best_installation_candidate_by_name (_old_pkg->name); @@ -687,6 +689,7 @@ static int opkg_info_status_cmd(int argc, char **argv, int installed_only) pkg_vec_t *available; pkg_t *pkg; char *pkg_name = NULL; + conffile_list_t *cl; if (argc > 0) { pkg_name = argv[0]; @@ -706,10 +709,12 @@ static int opkg_info_status_cmd(int argc, char **argv, int installed_only) pkg_formatted_info(stdout, pkg); - if (conf->verbosity >= NOTICE) { + cl = pkg_get_ptr(pkg, PKG_CONFFILES); + + if (conf->verbosity >= NOTICE && cl) { conffile_list_elt_t *iter; - for (iter = nv_pair_list_first(&pkg->conffiles); iter; - iter = nv_pair_list_next(&pkg->conffiles, iter)) { + for (iter = nv_pair_list_first(cl); iter; + iter = nv_pair_list_next(cl, iter)) { conffile_t *cf = (conffile_t *) iter->data; int modified = conffile_has_been_modified(cf); if (cf->value) @@ -894,7 +899,6 @@ static int opkg_files_cmd(int argc, char **argv) static int opkg_depends_cmd(int argc, char **argv) { int i, j, k; - int depends_count; pkg_vec_t *available_pkgs; compound_depend_t *cdep; pkg_t *pkg; @@ -915,15 +919,9 @@ static int opkg_depends_cmd(int argc, char **argv) if (fnmatch(argv[i], pkg->name, conf->nocase) != 0) continue; - depends_count = pkg->depends_count + - pkg->pre_depends_count + - pkg->recommends_count + pkg->suggests_count; - opkg_msg(NOTICE, "%s depends on:\n", pkg->name); - for (k = 0; k < depends_count; k++) { - cdep = &pkg->depends[k]; - + for (k = 0, cdep = pkg_get_ptr(pkg, PKG_DEPENDS); cdep && cdep->type; k++, cdep++) { if (cdep->type != DEPEND) continue; @@ -941,13 +939,15 @@ static int opkg_depends_cmd(int argc, char **argv) static int pkg_mark_provides(pkg_t * pkg) { - int provides_count = pkg->provides_count; - abstract_pkg_t **provides = pkg->provides; - int i; + abstract_pkg_t **provider = pkg_get_ptr(pkg, PKG_PROVIDES); + pkg->parent->state_flag |= SF_MARKED; - for (i = 0; i < provides_count; i++) { - provides[i]->state_flag |= SF_MARKED; + + while (provider && *provider) { + (*provider)->state_flag |= SF_MARKED; + provider++; } + return 0; } @@ -965,11 +965,11 @@ opkg_what_depends_conflicts_cmd(enum depend_type what_field_type, int recursive, int argc, char **argv) { depend_t *possibility; - compound_depend_t *cdep; + compound_depend_t *cdep, *deps; pkg_vec_t *available_pkgs; pkg_t *pkg; - int i, j, k, l; - int changed, count; + int i, j, l; + int changed; const char *rel_str = NULL; char *ver; @@ -1019,21 +1019,21 @@ opkg_what_depends_conflicts_cmd(enum depend_type what_field_type, int recursive, for (j = 0; j < available_pkgs->len; j++) { pkg = available_pkgs->pkgs[j]; + /* count = ((what_field_type == CONFLICTS) ? pkg->conflicts_count : pkg->pre_depends_count + pkg->depends_count + pkg->recommends_count + pkg->suggests_count); + */ /* skip this package if it is already marked */ if (pkg->parent->state_flag & SF_MARKED) continue; - for (k = 0; k < count; k++) { - cdep = (what_field_type == CONFLICTS) - ? &pkg->conflicts[k] - : &pkg->depends[k]; + deps = pkg_get_ptr(pkg, (what_field_type == CONFLICTS) ? PKG_CONFLICTS : PKG_DEPENDS); + for (cdep = deps; cdep->type; cdep++) { if (what_field_type != cdep->type) continue; @@ -1112,6 +1112,7 @@ static int opkg_what_provides_replaces_cmd(enum what_field_type what_field_type, int argc, char **argv) { + abstract_pkg_t *apkg, **abpkgs; if (argc > 0) { pkg_vec_t *available_pkgs = pkg_vec_alloc(); @@ -1132,33 +1133,22 @@ opkg_what_provides_replaces_cmd(enum what_field_type what_field_type, int argc, opkg_msg(NOTICE, "What %s %s\n", rel_str, target); for (j = 0; j < available_pkgs->len; j++) { pkg_t *pkg = available_pkgs->pkgs[j]; - int k; - int count = - (what_field_type == - WHATPROVIDES) ? pkg->provides_count : pkg-> - replaces_count; - for (k = 0; k < count; k++) { - abstract_pkg_t *apkg = - ((what_field_type == WHATPROVIDES) - ? pkg->provides[k] - : pkg->replaces[k]); - if (fnmatch - (target, apkg->name, - conf->nocase) == 0) { - opkg_msg(NOTICE, " %s", - pkg->name); - if ((conf-> - nocase ? strcasecmp(target, - apkg-> - name) : - strcmp(target, - apkg->name)) != 0) - opkg_msg(NOTICE, - "\t%s %s\n", - rel_str, - apkg->name); - opkg_message(NOTICE, "\n"); - } + abpkgs = pkg_get_ptr(pkg, (what_field_type == WHATPROVIDES) ? PKG_PROVIDES : PKG_REPLACES); + + while (abpkgs && *abpkgs) { + apkg = *abpkgs; + + if (fnmatch(target, apkg->name, conf->nocase)) + continue; + + opkg_msg(NOTICE, " %s", pkg->name); + + if ((conf->nocase ? strcasecmp(target, apkg->name) + : strcmp(target, apkg->name))) + opkg_msg(NOTICE, "\t%s %s\n", rel_str, apkg->name); + + opkg_message(NOTICE, "\n"); + abpkgs++; } } }