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

@ -170,11 +170,13 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
/*
* Orig = X, Curr = X, New = Y
*
* Install new file (installed file hasn't been modified).
* Install new file (installed file hasn't been modified) if
* configuration option keepconfig is NOT set.
*/
} else if ((strcmp(sha256_orig, sha256_cur) == 0) &&
(strcmp(sha256_orig, sha256_new)) &&
(strcmp(sha256_cur, sha256_new))) {
(strcmp(sha256_cur, sha256_new)) &&
(!(xhp->flags & XBPS_FLAG_KEEP_CONFIG))) {
xbps_set_cb_state(xhp, XBPS_STATE_CONFIG_FILE,
0, pkgver,
"Updating configuration file `%s' provided "
@ -212,12 +214,15 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
break;
/*
* Orig = X, Curr = Y, New = Z
* or
* Orig = X, Curr = X, New = Y if keepconf is set
*
* Install new file as <file>.new-<version>
*/
} else if ((strcmp(sha256_orig, sha256_cur)) &&
} else if (((strcmp(sha256_orig, sha256_cur)) &&
(strcmp(sha256_cur, sha256_new)) &&
(strcmp(sha256_orig, sha256_new))) {
(strcmp(sha256_orig, sha256_new))) ||
(xhp->flags & XBPS_FLAG_KEEP_CONFIG)) {
version = xbps_pkg_version(pkgver);
assert(version);
snprintf(buf, sizeof(buf), ".%s.new-%s", cffile, version);