configuration: add keepconf option

Add configuration option keepconf that stops xbps from overwriting
unchanged configuration files. If keepconf=true, xbps will store the new
configuration as <name>.new-<version> instead of overwriting unchanged
configuration files.
This commit is contained in:
Andreas Kempe
2020-01-24 23:09:12 +01:00
committed by Juan RP
parent 71a594f681
commit 02c9cb11c4
7 changed files with 115 additions and 5 deletions

View File

@ -171,6 +171,7 @@ enum {
KEY_ROOTDIR,
KEY_SYSLOG,
KEY_VIRTUALPKG,
KEY_KEEPCONF,
};
static const struct key {
@ -189,6 +190,7 @@ static const struct key {
{ "rootdir", 7, KEY_ROOTDIR },
{ "syslog", 6, KEY_SYSLOG },
{ "virtualpkg", 10, KEY_VIRTUALPKG },
{ "keepconf", 8, KEY_KEEPCONF },
};
static int
@ -356,6 +358,15 @@ parse_file(struct xbps_handle *xhp, const char *path, bool nested)
case KEY_PRESERVE:
store_preserved_file(xhp, val);
break;
case KEY_KEEPCONF:
if (strcasecmp(val, "true") == 0) {
xhp->flags |= XBPS_FLAG_KEEP_CONFIG;
xbps_dbg_printf(xhp, "%s: config preservation enabled\n", path);
} else {
xhp->flags &= ~XBPS_FLAG_KEEP_CONFIG;
xbps_dbg_printf(xhp, "%s: config preservation disabled\n", path);
}
break;
case KEY_BESTMATCHING:
if (strcasecmp(val, "true") == 0) {
xhp->flags |= XBPS_FLAG_BESTMATCH;