From 45a1e33a048f479b15b99d09df3dd1b62fef0253 Mon Sep 17 00:00:00 2001 From: Paul Barker Date: Fri, 28 Mar 2014 15:20:22 +0000 Subject: [PATCH 2/2] opkg-0.2.x: add-exclude Add a way to exclude specific packages from the install When an excluded package is required by another package an error will be generated. If the excluded package is only recommended, no error will be generated. The lifespan of the exclude_list covers the execution of the process, so there is no need to free the data. Upstream-Status: Pending Signed-off-by: Mark Hatle Signed-off-by: Jonathan Liu --- libopkg/opkg_conf.c | 1 + libopkg/opkg_conf.h | 2 ++ libopkg/pkg_depends.c | 16 ++++++++++++++++ src/opkg-cl.c | 15 +++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/libopkg/opkg_conf.c b/libopkg/opkg_conf.c index 1e65bad..9c4c854 100644 --- a/libopkg/opkg_conf.c +++ b/libopkg/opkg_conf.c @@ -442,6 +442,7 @@ opkg_conf_init(void) pkg_dest_list_init(&conf->pkg_dest_list); pkg_dest_list_init(&conf->tmp_dest_list); nv_pair_list_init(&conf->arch_list); + conf->exclude_list = NULL; return 0; } diff --git a/libopkg/opkg_conf.h b/libopkg/opkg_conf.h index 6045a58..ad58849 100644 --- a/libopkg/opkg_conf.h +++ b/libopkg/opkg_conf.h @@ -51,6 +51,8 @@ struct opkg_conf pkg_dest_list_t pkg_dest_list; pkg_dest_list_t tmp_dest_list; nv_pair_list_t arch_list; + size_t exclude_count; + char ** exclude_list; int restrict_to_default_dest; pkg_dest_t *default_dest; diff --git a/libopkg/pkg_depends.c b/libopkg/pkg_depends.c index d2d279e..b572e18 100644 --- a/libopkg/pkg_depends.c +++ b/libopkg/pkg_depends.c @@ -212,6 +212,22 @@ pkg_hash_fetch_unsatisfied_dependencies(pkg_t * pkg, pkg_vec_t *unsatisfied, continue; } + /* Check for excluded packages */ + if (satisfying_pkg != NULL && conf->exclude_list) { + int i, exclude = 0; + for (i = 0; i < conf->exclude_count; i++) { + if (!strcmp(satisfying_pkg->name, conf->exclude_list[i])) { + opkg_msg(NOTICE, "%s: exclude required package %s" + "at users request\n", + pkg->name, satisfying_pkg->name); + exclude = 1; + break; + } + } + if (exclude) + continue; + } + opkg_msg(DEBUG, "satisfying_pkg=%p\n", satisfying_pkg); if (satisfying_pkg != NULL) { satisfier_entry_pkg = satisfying_pkg; diff --git a/src/opkg-cl.c b/src/opkg-cl.c index 0315d41..0db2794 100644 --- a/src/opkg-cl.c +++ b/src/opkg-cl.c @@ -45,6 +45,7 @@ enum { ARGS_OPT_PREFER_ARCH_TO_VERSION, ARGS_OPT_ADD_ARCH, ARGS_OPT_ADD_DEST, + ARGS_OPT_ADD_EXCLUDE, ARGS_OPT_NOACTION, ARGS_OPT_DOWNLOAD_ONLY, ARGS_OPT_NODEPS, @@ -95,6 +96,7 @@ static struct option long_options[] = { {"offline-root", 1, 0, 'o'}, {"add-arch", 1, 0, ARGS_OPT_ADD_ARCH}, {"add-dest", 1, 0, ARGS_OPT_ADD_DEST}, + {"add-exclude", 1, 0, ARGS_OPT_ADD_EXCLUDE}, {"test", 0, 0, ARGS_OPT_NOACTION}, {"tmp-dir", 1, 0, 't'}, {"tmp_dir", 1, 0, 't'}, @@ -198,6 +200,18 @@ args_parse(int argc, char *argv[]) } free(tuple); break; + case ARGS_OPT_ADD_EXCLUDE: + tuple = xstrdup(optarg); + if (!conf->exclude_list) { + conf->exclude_count = 1; + conf->exclude_list = malloc(sizeof(char *) * conf->exclude_count); + conf->exclude_list[conf->exclude_count - 1] = tuple; + } else { + conf->exclude_count++; + conf->exclude_list = realloc(conf->exclude_list, sizeof(char *) * conf->exclude_count); + conf->exclude_list[conf->exclude_count - 1] = tuple; + } + break; case ARGS_OPT_NOACTION: conf->noaction = 1; break; @@ -282,6 +296,7 @@ usage() printf("\t--offline-root offline installation of packages.\n"); printf("\t--add-arch : Register architecture with given priority\n"); printf("\t--add-dest : Register destination with given path\n"); + printf("\t--add-exclude Register package to be excluded from install\n"); printf("\t--prefer-arch-to-version Use the architecture priority package rather\n"); printf("\t than the higher version one if more\n"); printf("\t than one candidate is found.\n"); -- 1.9.1