diff options
author | Guillem Jover <guillem@debian.org> | 2018-09-12 00:46:32 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2019-02-23 15:27:54 +0100 |
commit | 52427d9075b4b062fa0db16a70d2c2bda6407857 (patch) | |
tree | e96af423ba3fb00470cd3c16cd00e85690319340 | |
parent | a02734aed1b235395fb753d5f07381f4ec13543a (diff) | |
download | dpkg-52427d9075b4b062fa0db16a70d2c2bda6407857.tar.gz |
dpkg: Switch to set the default force option from the forceinfos array
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | src/force.c | 16 | ||||
-rw-r--r-- | src/force.h | 2 | ||||
-rw-r--r-- | src/main.c | 1 |
4 files changed, 18 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog index 69799d8b9..6dfe1f6f8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -19,6 +19,7 @@ dpkg (1.19.5) UNRELEASED; urgency=medium - dpkg: Do not hardcode the program name in the --force-help output. - dpkg: Switch force options from individual variables to bit fields. - dpkg: Switch from a char to an enum to track the force options types. + - dpkg: Switch to set the default force option from the forceinfos array. * Build system: - Check whether this dist is a release, based only on the version format. This will avoid having to do a two staged release to get a proper perl diff --git a/src/force.c b/src/force.c index 7fabfb541..15895faf4 100644 --- a/src/force.c +++ b/src/force.c @@ -37,8 +37,8 @@ #include "force.h" -static int force_mask = FORCE_ALL; -static int force_flags = FORCE_DOWNGRADE; +static int force_mask; +static int force_flags; enum forcetype { FORCETYPE_DISABLED, @@ -321,6 +321,18 @@ parse_force(const char *value, bool set) } void +set_force_default(int mask) +{ + const struct forceinfo *fip; + + force_mask = mask; + + for (fip = forceinfos; fip->name; fip++) + if (fip->type == FORCETYPE_ENABLED) + set_force(fip->flag); +} + +void set_force_option(const struct cmdinfo *cip, const char *value) { bool set = cip->arg_int; diff --git a/src/force.h b/src/force.h index 28776eefc..671b260a7 100644 --- a/src/force.h +++ b/src/force.h @@ -67,6 +67,8 @@ void parse_force(const char *value, bool set); void +set_force_default(int mask); +void set_force_option(const struct cmdinfo *cip, const char *value); void reset_force_option(const struct cmdinfo *cip, const char *value); diff --git a/src/main.c b/src/main.c index 35be30d20..6ba5c5090 100644 --- a/src/main.c +++ b/src/main.c @@ -743,6 +743,7 @@ int main(int argc, const char *const *argv) { dpkg_locales_init(PACKAGE); dpkg_program_init("dpkg"); dpkg_options_load(DPKG, cmdinfos); + set_force_default(FORCE_ALL); dpkg_options_parse(&argv, cmdinfos, printforhelp); /* When running as root, make sure our primary group is also root, so |