This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=08c257b8f1fa1c25e5fdacdb50edcbf650094630

commit 08c257b8f1fa1c25e5fdacdb50edcbf650094630
Author: Guillem Jover <[email protected]>
AuthorDate: Fri Sep 7 18:41:33 2018 +0200

    dpkg-statoverride: Switch from --force option to new --force-<thing> options
    
    Deprecate --force option which will be considered an alias for
    --force-all for now.
---
 debian/changelog          |  3 +++
 man/dpkg-statoverride.man |  8 ++++++++
 man/dpkg.man              |  6 ++++++
 src/force.c               | 10 ++++++++++
 src/force.h               |  2 ++
 src/statcmd.c             | 22 ++++++++++++++++------
 6 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index fdb018381..75325fbc4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,9 @@ dpkg (1.19.5) UNRELEASED; urgency=medium
   * dpkg: Parse and set new DPKG_FORCE environment variable for subprocesses.
     Closes: #666147
   * dpkg-statoverride: Add support for --force-* options.
+  * dpkg-statoverride: Switch from --force option to new --force-<thing>
+    options. Deprecate --force option which will be considered an alias for
+    --force-all for now.
   * Documentation:
     - start-stop-daemon(1): Document behavior of --pidfile security checks.
       Closes: #921557
diff --git a/man/dpkg-statoverride.man b/man/dpkg-statoverride.man
index c89f7eee7..8b235097e 100644
--- a/man/dpkg-statoverride.man
+++ b/man/dpkg-statoverride.man
@@ -102,10 +102,18 @@ system.\fP
 
 \fBall\fP:
 Turns on (or off) all force options.
+
+\fBstatoverride\-add\fP:
+Overwrite an existing stat override when adding it (since dpkg 1.19.5).
+
+\fBstatoverride\-remove\fP:
+Ignore a missing stat override when removing it (since dpkg 1.19.5).
 .TP
 .B \-\-force
 Force an action, even if a sanity check would otherwise prohibit it.
 This is necessary to override an existing override.
+This option is deprecated (since dpkg 1.19.5), it is replaced by
+\fB\-\-force\-all\fP.
 .TP
 .B \-\-update
 Immediately try to change the \fIpath\fP to the new owner and mode if it
diff --git a/man/dpkg.man b/man/dpkg.man
index bf56510ed..3f1637a10 100644
--- a/man/dpkg.man
+++ b/man/dpkg.man
@@ -618,6 +618,12 @@ Overwrite one package's directory with another's file.
 \fBoverwrite\-diverted\fP:
 Overwrite a diverted file with an undiverted version.
 
+\fBstatoverride\-add\fP:
+Overwrite an existing stat override when adding it (since dpkg 1.19.5).
+
+\fBstatoverride\-remove\fP:
+Ignore a missing stat override when removing it (since dpkg 1.19.5).
+
 \fBunsafe\-io\fP:
 Do not perform safe I/O operations when unpacking (since dpkg 1.15.8.6).
 Currently this
diff --git a/src/force.c b/src/force.c
index 2418bd8ac..a341b5bbb 100644
--- a/src/force.c
+++ b/src/force.c
@@ -108,6 +108,16 @@ static const struct forceinfo {
                FORCETYPE_DISABLED,
                N_("Process even packages with wrong versions"),
        }, {
+               "statoverride-add",
+               FORCE_STATOVERRIDE_ADD,
+               FORCETYPE_DISABLED,
+               N_("Overwrite an existing stat override when adding it"),
+       }, {
+               "statoverride-remove",
+               FORCE_STATOVERRIDE_DEL,
+               FORCETYPE_DISABLED,
+               N_("Ignore a missing stat override when removing it"),
+       }, {
                "overwrite",
                FORCE_OVERWRITE,
                FORCETYPE_DISABLED,
diff --git a/src/force.h b/src/force.h
index 671b260a7..05b2b34e9 100644
--- a/src/force.h
+++ b/src/force.h
@@ -50,6 +50,8 @@ enum force_flags {
        FORCE_REMOVE_REINSTREQ = DPKG_BIT(21),
        FORCE_SCRIPT_CHROOTLESS = DPKG_BIT(22),
        FORCE_UNSAFE_IO = DPKG_BIT(23),
+       FORCE_STATOVERRIDE_ADD = DPKG_BIT(24),
+       FORCE_STATOVERRIDE_DEL = DPKG_BIT(25),
        FORCE_ALL = 0xffffffff,
 };
 
diff --git a/src/statcmd.c b/src/statcmd.c
index e3b73afec..2220b82d4 100644
--- a/src/statcmd.c
+++ b/src/statcmd.c
@@ -89,7 +89,7 @@ usage(const struct cmdinfo *cip, const char *value)
 "  --instdir <directory>    set the root directory, but not the admin dir.\n"
 "  --root <directory>       set the directory of the root filesystem.\n"
 "  --update                 immediately update <path> permissions.\n"
-"  --force                  force an action even if a sanity check fails.\n"
+"  --force                  deprecated alias for --force-all.\n"
 "  --force-...              override problems (see --force-help).\n"
 "  --no-force-...           stop when problems encountered.\n"
 "  --refuse-...             ditto.\n"
@@ -103,11 +103,13 @@ usage(const struct cmdinfo *cip, const char *value)
        exit(0);
 }
 
+#define FORCE_STATCMD_MASK \
+       FORCE_STATOVERRIDE_ADD | FORCE_STATOVERRIDE_DEL
+
 static const char *admindir;
 const char *instdir;
 
 static int opt_verbose = 1;
-static int opt_force = 0;
 static int opt_update = 0;
 
 static void
@@ -268,7 +270,7 @@ statoverride_add(const char *const *argv)
 
        filestat = statdb_node_find(filename);
        if (*filestat != NULL) {
-               if (opt_force)
+               if (in_force(FORCE_STATOVERRIDE_ADD))
                        warning(_("an override for '%s' already exists, "
                                  "but --force specified so will be ignored"),
                                filename);
@@ -319,7 +321,7 @@ statoverride_remove(const char *const *argv)
        if (!statdb_node_remove(filename)) {
                if (opt_verbose)
                        warning(_("no override present"));
-               if (opt_force)
+               if (in_force(FORCE_STATOVERRIDE_DEL))
                        return 0;
                else
                        return 2;
@@ -371,6 +373,14 @@ statoverride_list(const char *const *argv)
        return ret;
 }
 
+static void
+set_force_obsolete(const struct cmdinfo *cip, const char *value)
+{
+       warning(_("deprecated --%s option; use --%s instead"),
+               cip->olong, "force-all");
+       set_force(FORCE_ALL);
+}
+
 static const struct cmdinfo cmdinfos[] = {
        ACTION("add",    0, act_install,   statoverride_add),
        ACTION("remove", 0, act_remove,    statoverride_remove),
@@ -380,7 +390,7 @@ static const struct cmdinfo cmdinfos[] = {
        { "instdir",    0,   1,  NULL,         NULL,      set_instdir,  0 },
        { "root",       0,   1,  NULL,         NULL,      set_root,     0 },
        { "quiet",      0,   0,  &opt_verbose, NULL,      NULL, 0       },
-       { "force",      0,   0,  &opt_force,   NULL,      NULL, 1       },
+       { "force",      0,   0,  NULL,         NULL,      set_force_obsolete },
        { "force",      0,   2,  NULL,         NULL,      set_force_option, 1 },
        { "no-force",   0,   2,  NULL,         NULL,      set_force_option, 0 },
        { "refuse",     0,   2,  NULL,         NULL,      set_force_option, 0 },
@@ -397,7 +407,7 @@ main(int argc, const char *const *argv)
 
        dpkg_locales_init(PACKAGE);
        dpkg_program_init("dpkg-statoverride");
-       set_force_default(0);
+       set_force_default(FORCE_STATCMD_MASK);
        dpkg_options_parse(&argv, cmdinfos, printforhelp);
 
        admindir = dpkg_db_set_dir(admindir);

-- 
Dpkg.Org's dpkg

Reply via email to