From 10f0dceaf9ed1dea7c2ed7d41e7a748d34dd9324 Mon Sep 17 00:00:00 2001 From: ticktock35 Date: Fri, 17 Apr 2009 03:59:05 -0400 Subject: adding new flag flag_maintainer This flag is used for maintainer can use the latest conffile. this flag need to be set manually. git-svn-id: http://opkg.googlecode.com/svn/trunk@212 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358 --- diff --git a/libopkg/args.c b/libopkg/args.c index 1f681c7..71692f0 100644 --- a/libopkg/args.c +++ b/libopkg/args.c @@ -31,6 +31,7 @@ static void print_version(void); enum long_args_opt { ARGS_OPT_FORCE_DEFAULTS = 129, + ARGS_OPT_FORCE_MAINTAINER, ARGS_OPT_FORCE_DEPENDS, ARGS_OPT_FORCE_OVERWRITE, ARGS_OPT_FORCE_DOWNGRADE, @@ -65,6 +66,7 @@ int args_init(args_t *args) ARGS_DEFAULT_CONF_FILE_NAME); args->force_defaults = ARGS_DEFAULT_FORCE_DEFAULTS; + args->force_maintainer = ARGS_DEFAULT_FORCE_MAINTAINER; args->force_depends = ARGS_DEFAULT_FORCE_DEPENDS; args->force_overwrite = ARGS_DEFAULT_FORCE_OVERWRITE; args->force_downgrade = ARGS_DEFAULT_FORCE_DOWNGRADE; @@ -114,6 +116,8 @@ int args_parse(args_t *args, int argc, char *argv[]) {"dest", 1, 0, 'd'}, {"force-defaults", 0, 0, ARGS_OPT_FORCE_DEFAULTS}, {"force_defaults", 0, 0, ARGS_OPT_FORCE_DEFAULTS}, + {"force-maintainer", 0, 0, ARGS_OPT_FORCE_MAINTAINER}, + {"force_maintainer", 0, 0, ARGS_OPT_FORCE_MAINTAINER}, {"force-depends", 0, 0, ARGS_OPT_FORCE_DEPENDS}, {"force_depends", 0, 0, ARGS_OPT_FORCE_DEPENDS}, {"force-overwrite", 0, 0, ARGS_OPT_FORCE_OVERWRITE}, @@ -197,6 +201,9 @@ int args_parse(args_t *args, int argc, char *argv[]) case ARGS_OPT_FORCE_DEFAULTS: args->force_defaults = 1; break; + case ARGS_OPT_FORCE_MAINTAINER: + args->force_maintainer = 1; + break; case ARGS_OPT_FORCE_DEPENDS: args->force_depends = 1; break; diff --git a/libopkg/args.h b/libopkg/args.h index 60f1219..b05bab1 100644 --- a/libopkg/args.h +++ b/libopkg/args.h @@ -24,6 +24,7 @@ struct args char *dest; char *tmp_dir; int force_defaults; + int force_maintainer; int force_depends; int force_overwrite; int force_downgrade; @@ -51,6 +52,7 @@ typedef struct args args_t; #define ARGS_DEFAULT_CONF_FILE_NAME "opkg.conf" #define ARGS_DEFAULT_DEST NULL #define ARGS_DEFAULT_FORCE_DEFAULTS 0 +#define ARGS_DEFAULT_FORCE_MAINTAINER 0 #define ARGS_DEFAULT_FORCE_DEPENDS 0 #define ARGS_DEFAULT_FORCE_OVERWRITE 0 #define ARGS_DEFAULT_FORCE_DOWNGRADE 0 diff --git a/libopkg/opkg.c b/libopkg/opkg.c index 735fb58..4799dc1 100644 --- a/libopkg/opkg.c +++ b/libopkg/opkg.c @@ -249,6 +249,7 @@ opkg_re_read_config_files (opkg_t *opkg) a->autoremove = c->autoremove; a->force_depends = c->force_depends; a->force_defaults = c->force_defaults; + a->force_maintainer = c->force_maintainer; a->force_overwrite = c->force_overwrite; a->force_downgrade = c->force_downgrade; a->force_reinstall = c->force_reinstall; diff --git a/libopkg/opkg_conf.c b/libopkg/opkg_conf.c index 45e3d2b..0479b8a 100644 --- a/libopkg/opkg_conf.c +++ b/libopkg/opkg_conf.c @@ -51,6 +51,7 @@ int opkg_init_options_array(const opkg_conf_t *conf, opkg_option_t **options) opkg_option_t tmp[] = { { "cache", OPKG_OPT_TYPE_STRING, &conf->cache}, { "force_defaults", OPKG_OPT_TYPE_BOOL, &conf->force_defaults }, + { "force_maintainer", OPKG_OPT_TYPE_BOOL, &conf->force_maintainer }, { "force_depends", OPKG_OPT_TYPE_BOOL, &conf->force_depends }, { "force_overwrite", OPKG_OPT_TYPE_BOOL, &conf->force_overwrite }, { "force_downgrade", OPKG_OPT_TYPE_BOOL, &conf->force_downgrade }, @@ -238,6 +239,9 @@ int opkg_conf_init(opkg_conf_t *conf, const args_t *args) if (args->force_defaults) { conf->force_defaults = 1; } + if (args->force_maintainer) { + conf->force_maintainer = 1; + } if (args->force_overwrite) { conf->force_overwrite = 1; } diff --git a/libopkg/opkg_conf.h b/libopkg/opkg_conf.h index c2f9015..ca2661b 100644 --- a/libopkg/opkg_conf.h +++ b/libopkg/opkg_conf.h @@ -57,6 +57,7 @@ struct opkg_conf int autoremove; int force_depends; int force_defaults; + int force_maintainer; int force_overwrite; int force_downgrade; int force_reinstall; diff --git a/libopkg/opkg_install.c b/libopkg/opkg_install.c index 719090b..aba0d1e 100644 --- a/libopkg/opkg_install.c +++ b/libopkg/opkg_install.c @@ -1590,18 +1590,20 @@ static int resolve_conffiles(opkg_conf_t *conf, pkg_t *pkg) cf_backup = backup_filename_alloc(root_filename); - if (file_exists(cf_backup)) { - /* Let's compute md5 to test if files are changed */ - md5sum = file_md5sum_alloc(cf_backup); - if (strcmp( cf->value,md5sum) != 0 ) { - if (conf->force_defaults - || user_prefers_old_conffile(cf->name, cf_backup) ) { - rename(cf_backup, root_filename); - } - } - unlink(cf_backup); - free(md5sum); - } + if (file_exists(cf_backup)) { + /* Let's compute md5 to test if files are changed */ + md5sum = file_md5sum_alloc(cf_backup); + if (strcmp( cf->value,md5sum) != 0 ) { + if (conf->force_maintainer) { + opkg_message(conf, OPKG_NOTICE, "Conffile %s using maintainer's setting.\n", cf_backup); + } else if (conf->force_defaults + || user_prefers_old_conffile(cf->name, cf_backup) ) { + rename(cf_backup, root_filename); + } + } + unlink(cf_backup); + free(md5sum); + } free(cf_backup); free(root_filename); -- cgit v0.9.1