diff options
author | Guillem Jover <guillem@debian.org> | 2019-02-23 04:47:25 +0100 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2019-02-23 15:27:01 +0100 |
commit | 56ae35c4312c056811239ebe1e90ad565b6fbe48 (patch) | |
tree | 510a1155a82ba33d2593e164f915058205044d86 /src | |
parent | e566532b04c4d263001f798b4cea3488be00400c (diff) | |
download | dpkg-56ae35c4312c056811239ebe1e90ad565b6fbe48.tar.gz |
dpkg: Switch force options from individual variables to bit fields
This makes it easier to generalize to be used by other modules with
different force options, and to operate on the force options.
Diffstat (limited to 'src')
-rw-r--r-- | src/archives.c | 28 | ||||
-rw-r--r-- | src/configure.c | 16 | ||||
-rw-r--r-- | src/errors.c | 2 | ||||
-rw-r--r-- | src/force.c | 135 | ||||
-rw-r--r-- | src/force.h | 66 | ||||
-rw-r--r-- | src/help.c | 8 | ||||
-rw-r--r-- | src/main.c | 12 | ||||
-rw-r--r-- | src/packages.c | 17 | ||||
-rw-r--r-- | src/remove.c | 4 | ||||
-rw-r--r-- | src/script.c | 8 | ||||
-rw-r--r-- | src/unpack.c | 6 |
11 files changed, 165 insertions, 137 deletions
diff --git a/src/archives.c b/src/archives.c index ab93551b8..f74bceed8 100644 --- a/src/archives.c +++ b/src/archives.c @@ -399,7 +399,7 @@ tarobject_extract(struct tarcontext *tc, struct tar_entry *te, ohshite(_("error setting permissions of '%.255s'"), te->name); /* Postpone the fsync, to try to avoid massive I/O degradation. */ - if (!fc_unsafe_io) + if (!in_force(FORCE_UNSAFE_IO)) namenode->flags |= FNNF_DEFERRED_FSYNC; pop_cleanup(ehflag_normaltidy); /* fd = open(path) */ @@ -591,7 +591,7 @@ tarobject_matches(struct tarcontext *tc, internerr("unknown tar type '%d', but already checked", te->type); } - forcibleerr(fc_overwrite, + forcibleerr(FORCE_OVERWRITE, _("trying to overwrite shared '%.250s', which is different " "from other instances of package %.250s"), namenode->name, pkg_name(tc->pkg, pnaw_nonambig)); @@ -712,13 +712,13 @@ tarobject(struct tar_archive *tar, struct tar_entry *ti) divpkgset = nifd->namenode->divert->pkgset; if (divpkgset) { - forcibleerr(fc_overwritediverted, + forcibleerr(FORCE_OVERWRITE_DIVERTED, _("trying to overwrite '%.250s', which is the " "diverted version of '%.250s' (package: %.100s)"), nifd->namenode->name, nifd->namenode->divert->camefrom->name, divpkgset->name); } else { - forcibleerr(fc_overwritediverted, + forcibleerr(FORCE_OVERWRITE_DIVERTED, _("trying to overwrite '%.250s', which is the " "diverted version of '%.250s'"), nifd->namenode->name, nifd->namenode->divert->camefrom->name); @@ -910,14 +910,14 @@ tarobject(struct tar_archive *tar, struct tar_entry *ti) } else { /* At this point we are replacing something without a Replaces. */ if (!statr && S_ISDIR(stab.st_mode)) { - forcibleerr(fc_overwritedir, + forcibleerr(FORCE_OVERWRITE_DIR, _("trying to overwrite directory '%.250s' " "in package %.250s %.250s with nondirectory"), nifd->namenode->name, pkg_name(otherpkg, pnaw_nonambig), versiondescribe(&otherpkg->installed.version, vdew_nonambig)); } else { - forcibleerr(fc_overwrite, + forcibleerr(FORCE_OVERWRITE, _("trying to overwrite '%.250s', " "which is also in package %.250s %.250s"), nifd->namenode->name, pkg_name(otherpkg, pnaw_nonambig), @@ -962,7 +962,7 @@ tarobject(struct tar_archive *tar, struct tar_entry *ti) } } - if (refcounting && !fc_overwrite) { + if (refcounting && !in_force(FORCE_OVERWRITE)) { /* If we are not forced to overwrite the path and are refcounting, * just compute the hash w/o extracting the object. */ tarobject_hash(tc, ti, nifd->namenode); @@ -992,7 +992,7 @@ tarobject(struct tar_archive *tar, struct tar_entry *ti) fnamenewvb.buf, ti, nifd->namenode); /* If we didn't extract anything, there's nothing else to do. */ - if (refcounting && !fc_overwrite) + if (refcounting && !in_force(FORCE_OVERWRITE)) return 0; tarobject_set_perms(ti, fnamenewvb.buf, &nodestat); @@ -1235,7 +1235,7 @@ try_deconfigure_can(bool (*force_p)(struct deppossi *), struct pkginfo *pkg, return 2; } else if (f_autodeconf) { if (pkg->installed.essential) { - if (fc_removeessential) { + if (in_force(FORCE_REMOVE_ESSENTIAL)) { warning(_("considering deconfiguration of essential\n" " package %s, to enable %s"), pkg_name(pkg, pnaw_nonambig), action); @@ -1347,14 +1347,12 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg, (((fixbyrm->want != PKG_WANT_INSTALL && fixbyrm->want != PKG_WANT_HOLD) || does_replace(pkg, &pkg->available, fixbyrm, &fixbyrm->installed)) && - (!fixbyrm->installed.essential || fc_removeessential)))) { - + (!fixbyrm->installed.essential || in_force(FORCE_REMOVE_ESSENTIAL))))) { if (fixbyrm->clientdata->istobe != PKG_ISTOBE_NORMAL && fixbyrm->clientdata->istobe != PKG_ISTOBE_DECONFIGURE) internerr("package %s to be fixed by removal is not to be normal " "nor deconfigure, is to be %d", pkg_name(pkg, pnaw_always), fixbyrm->clientdata->istobe); - fixbyrm->clientdata->istobe = PKG_ISTOBE_REMOVE; notice(_("considering removing %s in favour of %s ..."), pkg_name(fixbyrm, pnaw_nonambig), @@ -1405,7 +1403,7 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg, pdep= &flagdeppossi; } if (!pdep && (fixbyrm->eflag & PKG_EFLAG_REINSTREQ)) { - if (fc_removereinstreq) { + if (in_force(FORCE_REMOVE_REINSTREQ)) { notice(_("package %s requires reinstallation, but will " "remove anyway as you requested"), pkg_name(fixbyrm, pnaw_nonambig)); @@ -1466,7 +1464,7 @@ archivefiles(const char *const *argv) msdbflags = msdbrw_readonly; else if (cipaction->arg_int == act_avail) msdbflags = msdbrw_readonly | msdbrw_available_write; - else if (fc_nonroot) + else if (in_force(FORCE_NON_ROOT)) msdbflags = msdbrw_write; else msdbflags = msdbrw_needsuperuser; @@ -1638,7 +1636,7 @@ wanttoinstall(struct pkginfo *pkg) return true; } } else { - if (fc_downgrade) { + if (in_force(FORCE_DOWNGRADE)) { warning(_("downgrading %.250s from %.250s to %.250s"), pkg_name(pkg, pnaw_nonambig), versiondescribe(&pkg->installed.version, vdew_nonambig), diff --git a/src/configure.c b/src/configure.c index a6d02791c..12f290451 100644 --- a/src/configure.c +++ b/src/configure.c @@ -119,13 +119,13 @@ show_prompt(const char *cfgfile, const char *realold, const char *realnew, /* No --force-confdef but a forcible situation. */ /* TODO: check if this condition can not be simplified to - * just !fc_conff_def */ - if (!(fc_conff_def && (what & (CFOF_INSTALL | CFOF_KEEP)))) { - if (fc_conff_new) { + * just !in_force(FORCE_CONFF_DEF) */ + if (!(in_force(FORCE_CONFF_DEF) && (what & (CFOF_INSTALL | CFOF_KEEP)))) { + if (in_force(FORCE_CONFF_NEW)) { fprintf(stderr, _(" ==> Using new file as you requested.\n")); return 'y'; - } else if (fc_conff_old) { + } else if (in_force(FORCE_CONFF_OLD)) { fprintf(stderr, _(" ==> Using current old file as you requested.\n")); return 'n'; @@ -133,7 +133,7 @@ show_prompt(const char *cfgfile, const char *realold, const char *realnew, } /* Force the default action (if there is one. */ - if (fc_conff_def) { + if (in_force(FORCE_CONFF_DEF)) { if (what & CFOF_KEEP) { fprintf(stderr, _(" ==> Keeping old config file as default.\n")); @@ -430,7 +430,7 @@ deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff) useredited = -1; distedited = -1; what = CFO_IDENTICAL; - } else if (strcmp(currenthash, NONEXISTENTFLAG) == 0 && fc_conff_miss) { + } else if (strcmp(currenthash, NONEXISTENTFLAG) == 0 && in_force(FORCE_CONFF_MISS)) { fprintf(stderr, _("\n" "Configuration file '%s', does not exist on system.\n" @@ -454,7 +454,7 @@ deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff) useredited = strcmp(conff->hash, currenthash) != 0; distedited = strcmp(conff->hash, newdisthash) != 0; - if (fc_conff_ask && useredited) + if (in_force(FORCE_CONFF_ASK) && useredited) what = CFO_PROMPT_KEEP; else what = conffoptcells[useredited][distedited]; @@ -624,7 +624,7 @@ deferred_configure(struct pkginfo *pkg) sincenothing = 0; if (pkg->eflag & PKG_EFLAG_REINSTREQ) - forcibleerr(fc_removereinstreq, + forcibleerr(FORCE_REMOVE_REINSTREQ, _("package is in a very bad inconsistent state; you should\n" " reinstall it before attempting configuration")); diff --git a/src/errors.c b/src/errors.c index 2c5d147a5..ca405b172 100644 --- a/src/errors.c +++ b/src/errors.c @@ -124,7 +124,7 @@ skip_due_to_hold(struct pkginfo *pkg) { if (pkg->want != PKG_WANT_HOLD) return false; - if (fc_hold) { + if (in_force(FORCE_HOLD)) { notice(_("package %s was on hold, processing it anyway as you requested"), pkg_name(pkg, pnaw_nonambig)); return false; diff --git a/src/force.c b/src/force.c index f3e4d902d..d8dc7619c 100644 --- a/src/force.c +++ b/src/force.c @@ -37,30 +37,8 @@ #include "force.h" -int fc_architecture = 0; -int fc_badpath = 0; -int fc_badverify = 0; -int fc_badversion = 0; -int fc_breaks = 0; -int fc_conff_ask = 0; -int fc_conff_def = 0; -int fc_conff_miss = 0; -int fc_conff_new = 0; -int fc_conff_old = 0; -int fc_configureany = 0; -int fc_conflicts = 0; -int fc_depends = 0; -int fc_dependsversion = 0; -int fc_downgrade = 1; -int fc_hold = 0; -int fc_nonroot = 0; -int fc_overwrite = 0; -int fc_overwritedir = 0; -int fc_overwritediverted = 0; -int fc_removeessential = 0; -int fc_removereinstreq = 0; -int fc_script_chrootless = 0; -int fc_unsafe_io = 0; +static int force_mask = FORCE_ALL; +static int force_flags = FORCE_DOWNGRADE; static const char * forcetype_str(char type) @@ -80,88 +58,88 @@ forcetype_str(char type) static const struct forceinfo { const char *name; - int *opt; + int flag; char type; const char *desc; } forceinfos[] = { { "all", - NULL, + FORCE_ALL, '!', N_("Set all force options"), }, { "downgrade", - &fc_downgrade, + FORCE_DOWNGRADE, '*', N_("Replace a package with a lower version"), }, { "configure-any", - &fc_configureany, + FORCE_CONFIGURE_ANY, ' ', N_("Configure any package which may help this one"), }, { "hold", - &fc_hold, + FORCE_HOLD, ' ', N_("Process incidental packages even when on hold"), }, { "not-root", - &fc_nonroot, + FORCE_NON_ROOT, ' ', N_("Try to (de)install things even when not root"), }, { "bad-path", - &fc_badpath, + FORCE_BAD_PATH, ' ', N_("PATH is missing important programs, problems likely"), }, { "bad-verify", - &fc_badverify, + FORCE_BAD_VERIFY, ' ', N_("Install a package even if it fails authenticity check"), }, { "bad-version", - &fc_badversion, + FORCE_BAD_VERSION, ' ', N_("Process even packages with wrong versions"), }, { "overwrite", - &fc_overwrite, + FORCE_OVERWRITE, ' ', N_("Overwrite a file from one package with another"), }, { "overwrite-diverted", - &fc_overwritediverted, + FORCE_OVERWRITE_DIVERTED, ' ', N_("Overwrite a diverted file with an undiverted version"), }, { "overwrite-dir", - &fc_overwritedir, + FORCE_OVERWRITE_DIR, '!', N_("Overwrite one package's directory with another's file"), }, { "unsafe-io", - &fc_unsafe_io, + FORCE_UNSAFE_IO, '!', N_("Do not perform safe I/O operations when unpacking"), }, { "script-chrootless", - &fc_script_chrootless, + FORCE_SCRIPT_CHROOTLESS, '!', N_("Do not chroot into maintainer script environment"), }, { "confnew", - &fc_conff_new, + FORCE_CONFF_NEW, '!', N_("Always use the new config files, don't prompt"), }, { "confold", - &fc_conff_old, + FORCE_CONFF_OLD, '!', N_("Always use the old config files, don't prompt"), }, { "confdef", - &fc_conff_def, + FORCE_CONFF_DEF, '!', N_("Use the default option for new config files if one\n" "is available, don't prompt. If no default can be found,\n" @@ -169,47 +147,47 @@ static const struct forceinfo { "confnew options is also given"), }, { "confmiss", - &fc_conff_miss, + FORCE_CONFF_MISS, '!', N_("Always install missing config files"), }, { "confask", - &fc_conff_ask, + FORCE_CONFF_ASK, '!', N_("Offer to replace config files with no new versions"), }, { "architecture", - &fc_architecture, + FORCE_ARCHITECTURE, '!', N_("Process even packages with wrong or no architecture"), }, { "breaks", - &fc_breaks, + FORCE_BREAKS, '!', N_("Install even if it would break another package"), }, { "conflicts", - &fc_conflicts, + FORCE_CONFLICTS, '!', N_("Allow installation of conflicting packages"), }, { "depends", - &fc_depends, + FORCE_DEPENDS, '!', N_("Turn all dependency problems into warnings"), }, { "depends-version", - &fc_dependsversion, + FORCE_DEPENDS_VERSION, '!', N_("Turn dependency version problems into warnings"), }, { "remove-reinstreq", - &fc_removereinstreq, + FORCE_REMOVE_REINSTREQ, '!', N_("Remove packages which require installation"), }, { "remove-essential", - &fc_removeessential, + FORCE_REMOVE_ESSENTIAL, '!', N_("Remove an essential package"), }, { @@ -217,6 +195,24 @@ static const struct forceinfo { } }; +bool +in_force(int flags) +{ + return (flags & force_flags) == flags; +} + +void +set_force(int flags) +{ + force_flags |= flags; +} + +void +reset_force(int flags) +{ + force_flags &= ~flags; +} + char * get_force_string(void) { @@ -224,7 +220,9 @@ get_force_string(void) struct varbuf vb = VARBUF_INIT; for (fip = forceinfos; fip->name; fip++) { - if (fip->opt == NULL || !*fip->opt) + if ((enum force_flags)fip->flag == FORCE_ALL || + (fip->flag & force_mask) != fip->flag || + !in_force(fip->flag)) continue; if (vb.used) @@ -258,7 +256,7 @@ print_forceinfo(const struct forceinfo *fi) } void -set_force(const struct cmdinfo *cip, const char *value) +parse_force(const char *value, bool set) { const char *comma; size_t l; @@ -272,7 +270,9 @@ set_force(const struct cmdinfo *cip, const char *value) " Forcing things:\n"), dpkg_get_progname()); for (fip = forceinfos; fip->name; fip++) - print_forceinfo(fip); + if ((enum force_flags)fip->flag == FORCE_ALL || + (fip->flag & force_mask) == fip->flag) + print_forceinfo(fip); printf(_( "\n" @@ -299,12 +299,11 @@ set_force(const struct cmdinfo *cip, const char *value) if (!fip->name) { badusage(_("unknown force/refuse option '%.*s'"), (int)min(l, 250), value); - } else if (strcmp(fip->name, "all") == 0) { - for (fip = forceinfos; fip->name; fip++) - if (fip->opt) - *fip->opt = cip->arg_int; - } else if (fip->opt) { - *fip->opt = cip->arg_int; + } else if (fip->flag) { + if (set) + set_force(fip->flag); + else + reset_force(fip->flag); } else { warning(_("obsolete force/refuse option '%s'"), fip->name); @@ -317,12 +316,26 @@ set_force(const struct cmdinfo *cip, const char *value) } void +set_force_option(const struct cmdinfo *cip, const char *value) +{ + bool set = cip->arg_int; + + parse_force(value, set); +} + +void +reset_force_option(const struct cmdinfo *cip, const char *value) +{ + reset_force(cip->arg_int); +} + +void forcibleerr(int forceflag, const char *fmt, ...) { va_list args; va_start(args, fmt); - if (forceflag) { + if (in_force(forceflag)) { warning(_("overriding problem because --force enabled:")); warningv(fmt, args); } else { @@ -334,7 +347,7 @@ forcibleerr(int forceflag, const char *fmt, ...) int forcible_nonroot_error(int rc) { - if (fc_nonroot && errno == EPERM) + if (in_force(FORCE_NON_ROOT) && errno == EPERM) return 0; return rc; } diff --git a/src/force.h b/src/force.h index 769163bd6..28776eefc 100644 --- a/src/force.h +++ b/src/force.h @@ -25,35 +25,51 @@ #include <dpkg/dpkg.h> #include <dpkg/options.h> -extern int fc_architecture; -extern int fc_badpath; -extern int fc_badverify; -extern int fc_badversion; -extern int fc_breaks; -extern int fc_conff_ask; -extern int fc_conff_def; -extern int fc_conff_miss; -extern int fc_conff_new; -extern int fc_conff_old; -extern int fc_configureany; -extern int fc_conflicts; -extern int fc_depends; -extern int fc_dependsversion; -extern int fc_downgrade; -extern int fc_hold; -extern int fc_nonroot; -extern int fc_overwrite; -extern int fc_overwritedir; -extern int fc_overwritediverted; -extern int fc_removeessential; -extern int fc_removereinstreq; -extern int fc_script_chrootless; -extern int fc_unsafe_io; +enum force_flags { + FORCE_ARCHITECTURE = DPKG_BIT(0), + FORCE_BAD_PATH = DPKG_BIT(1), + FORCE_BAD_VERIFY = DPKG_BIT(2), + FORCE_BAD_VERSION = DPKG_BIT(3), + FORCE_BREAKS = DPKG_BIT(4), + FORCE_CONFF_ASK = DPKG_BIT(5), + FORCE_CONFF_DEF = DPKG_BIT(6), + FORCE_CONFF_MISS = DPKG_BIT(7), + FORCE_CONFF_NEW = DPKG_BIT(8), + FORCE_CONFF_OLD = DPKG_BIT(9), + FORCE_CONFIGURE_ANY = DPKG_BIT(10), + FORCE_CONFLICTS = DPKG_BIT(11), + FORCE_DEPENDS = DPKG_BIT(12), + FORCE_DEPENDS_VERSION = DPKG_BIT(13), + FORCE_DOWNGRADE = DPKG_BIT(14), + FORCE_HOLD = DPKG_BIT(15), + FORCE_NON_ROOT = DPKG_BIT(16), + FORCE_OVERWRITE = DPKG_BIT(17), + FORCE_OVERWRITE_DIR = DPKG_BIT(18), + FORCE_OVERWRITE_DIVERTED = DPKG_BIT(19), + FORCE_REMOVE_ESSENTIAL = DPKG_BIT(20), + FORCE_REMOVE_REINSTREQ = DPKG_BIT(21), + FORCE_SCRIPT_CHROOTLESS = DPKG_BIT(22), + FORCE_UNSAFE_IO = DPKG_BIT(23), + FORCE_ALL = 0xffffffff, +}; + +bool +in_force(int flags); +void +set_force(int flags); +void +reset_force(int flags); char * get_force_string(void); + +void +parse_force(const char *value, bool set); + +void +set_force_option(const struct cmdinfo *cip, const char *value); void -set_force(const struct cmdinfo *cip, const char *value); +reset_force_option(const struct cmdinfo *cip, const char *value); void forcibleerr(int forceflag, const char *format, ...) DPKG_ATTR_PRINTF(2); diff --git a/src/help.c b/src/help.c index f168e8374..382b3638c 100644 --- a/src/help.c +++ b/src/help.c @@ -143,7 +143,7 @@ void checkpath(void) { } if (warned) - forcibleerr(fc_badpath, + forcibleerr(FORCE_BAD_PATH, P_("%d expected program not found in PATH or not executable\n%s", "%d expected programs not found in PATH or not executable\n%s", warned), @@ -182,7 +182,7 @@ ignore_depends_possi(struct deppossi *possi) bool force_depends(struct deppossi *possi) { - return fc_depends || + return in_force(FORCE_DEPENDS) || ignore_depends_possi(possi) || ignore_depends(possi->up->up); } @@ -190,7 +190,7 @@ force_depends(struct deppossi *possi) bool force_breaks(struct deppossi *possi) { - return fc_breaks || + return in_force(FORCE_BREAKS) || ignore_depends_possi(possi) || ignore_depends(possi->up->up); } @@ -198,7 +198,7 @@ force_breaks(struct deppossi *possi) bool force_conflicts(struct deppossi *possi) { - return fc_conflicts; + return in_force(FORCE_CONFLICTS); } void clear_istobes(void) { diff --git a/src/main.c b/src/main.c index d3488d52a..35be30d20 100644 --- a/src/main.c +++ b/src/main.c @@ -492,7 +492,7 @@ arch_remove(const char *const *argv) if (pkg->status < PKG_STAT_HALFINSTALLED) continue; if (pkg->installed.arch == arch) { - if (fc_architecture) + if (in_force(FORCE_ARCHITECTURE)) warning(_("removing architecture '%s' currently in use by database"), arch->name); else @@ -579,7 +579,7 @@ static const struct cmdinfo cmdinfos[]= { { "no-pager", 0, 0, NULL, NULL, set_no_pager, 0 }, { "no-debsig", 0, 0, &f_nodebsig, NULL, NULL, 1 }, /* Alias ('G') for --refuse. */ - { NULL, 'G', 0, &fc_downgrade, NULL, NULL, 0 }, + { NULL, 'G', 0, NULL, NULL, reset_force_option, FORCE_DOWNGRADE }, { "selected-only", 'O', 0, &f_alsoselect, NULL, NULL, 0 }, { "triggers", 0, 0, &f_triggers, NULL, NULL, 1 }, { "no-triggers", 0, 0, &f_triggers, NULL, NULL, -1 }, @@ -592,9 +592,9 @@ static const struct cmdinfo cmdinfos[]= { { "admindir", 0, 1, NULL, &admindir, NULL, 0 }, { "instdir", 0, 1, NULL, NULL, set_instdir, 0 }, { "ignore-depends", 0, 1, NULL, NULL, set_ignore_depends, 0 }, - { "force", 0, 2, NULL, NULL, set_force, 1 }, - { "refuse", 0, 2, NULL, NULL, set_force, 0 }, - { "no-force", 0, 2, NULL, NULL, set_force, 0 }, + { "force", 0, 2, NULL, NULL, set_force_option, 1 }, + { "refuse", 0, 2, NULL, NULL, set_force_option, 0 }, + { "no-force", 0, 2, NULL, NULL, set_force_option, 0 }, { "debug", 'D', 1, NULL, NULL, set_debug, 0 }, { "help", '?', 0, NULL, NULL, usage, 0 }, { "version", 0, 0, NULL, NULL, printversion, 0 }, @@ -747,7 +747,7 @@ int main(int argc, const char *const *argv) { /* When running as root, make sure our primary group is also root, so * that files created by maintainer scripts have correct ownership. */ - if (!fc_nonroot && getuid() == 0) + if (!in_force(FORCE_NON_ROOT) && getuid() == 0) if (setgid(0) < 0) ohshite(_("cannot set primary group ID to root")); diff --git a/src/packages.c b/src/packages.c index bc93c7c89..bd8047ac9 100644 --- a/src/packages.c +++ b/src/packages.c @@ -137,9 +137,9 @@ packages(const char *const *argv) { trigproc_install_hooks(); - modstatdb_open(f_noact ? msdbrw_readonly : - fc_nonroot ? msdbrw_write : - msdbrw_needsuperuser); + modstatdb_open(f_noact ? msdbrw_readonly : + in_force(FORCE_NON_ROOT) ? msdbrw_write : + msdbrw_needsuperuser); checkpath(); pkg_infodb_upgrade(); @@ -416,7 +416,7 @@ deppossi_ok_found(struct pkginfo *possdependee, struct pkginfo *requiredby, checkversion->ed->name, pkg_name(possdependee, pnaw_always), versiondescribe(&provider->version, vdew_nonambig)); - if (fc_dependsversion) + if (in_force(FORCE_DEPENDS_VERSION)) thisf = found_forced_on(DEPEND_TRY_FORCE_DEPENDS_VERSION); debug(dbg_depcondetail, " bad version"); goto unsuitable; @@ -429,7 +429,7 @@ deppossi_ok_found(struct pkginfo *possdependee, struct pkginfo *requiredby, pkg_name(possdependee, pnaw_nonambig), versiondescribe(&possdependee->installed.version, vdew_nonambig)); - if (fc_dependsversion) + if (in_force(FORCE_DEPENDS_VERSION)) thisf = found_forced_on(DEPEND_TRY_FORCE_DEPENDS_VERSION); debug(dbg_depcondetail, " bad version"); goto unsuitable; @@ -484,7 +484,7 @@ deppossi_ok_found(struct pkginfo *possdependee, struct pkginfo *requiredby, possdependee->clientdata->istobe == PKG_ISTOBE_INSTALLNEW) { debug(dbg_depcondetail," unpacked/halfconfigured, defer"); return FOUND_DEFER; - } else if (!removing && fc_configureany && + } else if (!removing && in_force(FORCE_CONFIGURE_ANY) && !skip_due_to_hold(possdependee) && !(possdependee->status == PKG_STAT_HALFCONFIGURED)) { notice(_("also configuring '%s' (required by '%s')"), @@ -573,7 +573,8 @@ breaks_check_one(struct varbuf *aemsgs, enum dep_check *ok, varbuf_printf(aemsgs, _(" Version of %s to be configured is %s.\n"), pkg_name(broken, pnaw_nonambig), versiondescribe(&broken->installed.version, vdew_nonambig)); - if (fc_dependsversion) return; + if (in_force(FORCE_DEPENDS_VERSION)) + return; } if (force_breaks(breaks)) return; *ok = DEP_CHECK_HALT; @@ -698,7 +699,7 @@ dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing, debug(dbg_depcondetail," found %d",found); if (thisf > found) found= thisf; } - if (fc_depends) { + if (in_force(FORCE_DEPENDS)) { thisf = found_forced_on(DEPEND_TRY_FORCE_DEPENDS); if (thisf > found) { found = thisf; diff --git a/src/remove.c b/src/remove.c index 39584aa85..b63d699e1 100644 --- a/src/remove.c +++ b/src/remove.c @@ -126,7 +126,7 @@ void deferred_remove(struct pkginfo *pkg) { } if (pkg->installed.essential && pkg->status != PKG_STAT_CONFIGFILES) - forcibleerr(fc_removeessential, + forcibleerr(FORCE_REMOVE_ESSENTIAL, _("this is an essential package; it should not be removed")); debug(dbg_general, "checking dependencies for remove '%s'", @@ -159,7 +159,7 @@ void deferred_remove(struct pkginfo *pkg) { sincenothing= 0; if (pkg->eflag & PKG_EFLAG_REINSTREQ) - forcibleerr(fc_removereinstreq, + forcibleerr(FORCE_REMOVE_REINSTREQ, _("package is in a very bad inconsistent state; you should\n" " reinstall it before attempting a removal")); diff --git a/src/script.c b/src/script.c index ea63093af..abe65b6f7 100644 --- a/src/script.c +++ b/src/script.c @@ -100,12 +100,12 @@ maintscript_pre_exec(struct command *cmd) const char *changedir; size_t instdirlen = strlen(instdir); - if (instdirlen > 0 && fc_script_chrootless) + if (instdirlen > 0 && in_force(FORCE_SCRIPT_CHROOTLESS)) changedir = instdir; else changedir = "/"; - if (instdirlen > 0 && !fc_script_chrootless) { + if (instdirlen > 0 && !in_force(FORCE_SCRIPT_CHROOTLESS)) { int rc; if (strncmp(admindir, instdir, instdirlen) != 0) @@ -116,7 +116,7 @@ maintscript_pre_exec(struct command *cmd) ohshite(_("unable to setenv for subprocesses")); rc = chroot(instdir); - if (rc && fc_nonroot && errno == EPERM) + if (rc && in_force(FORCE_NON_ROOT) && errno == EPERM) ohshit(_("not enough privileges to change root " "directory with --force-not-root, consider " "using --force-script-chrootless?")); @@ -140,7 +140,7 @@ maintscript_pre_exec(struct command *cmd) args.buf); varbuf_destroy(&args); } - if (instdirlen == 0 || fc_script_chrootless) + if (instdirlen == 0 || in_force(FORCE_SCRIPT_CHROOTLESS)) return cmd->filename; if (strlen(cmd->filename) < instdirlen) diff --git a/src/unpack.c b/src/unpack.c index ad1e05f56..ee453a88d 100644 --- a/src/unpack.c +++ b/src/unpack.c @@ -147,7 +147,7 @@ deb_verify(const char *filename) status = subproc_reap(pid, "debsig-verify", SUBPROC_NOCHECK); if (!(WIFEXITED(status) && WEXITSTATUS(status) == 0)) { - if (!fc_badverify) + if (!in_force(FORCE_BAD_VERIFY)) ohshit(_("verification on package %s failed!"), filename); else notice(_("verification on package %s failed; " @@ -1136,7 +1136,7 @@ void process_archive(const char *filename) { else parsedb_flags = pdb_parse_binary; parsedb_flags |= pdb_ignore_archives; - if (fc_badversion) + if (in_force(FORCE_BAD_VERSION)) parsedb_flags |= pdb_lax_version_parser; parsedb(cidir, parsedb_flags, &pkg); @@ -1164,7 +1164,7 @@ void process_archive(const char *filename) { if (pkg->available.arch->type != DPKG_ARCH_ALL && pkg->available.arch->type != DPKG_ARCH_NATIVE && pkg->available.arch->type != DPKG_ARCH_FOREIGN) - forcibleerr(fc_architecture, + forcibleerr(FORCE_ARCHITECTURE, _("package architecture (%s) does not match system (%s)"), pkg->available.arch->name, dpkg_arch_get(DPKG_ARCH_NATIVE)->name); |