From 5c1688944ddb96f2d156160d4a44ecfdd4957bf1 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 2 Feb 2013 11:30:42 +0100 Subject: [PATCH] xbps-install: make -f preserve conf files; use it twice to overwrite all files. --- NEWS | 5 +++++ bin/xbps-install/main.c | 10 +++++++--- bin/xbps-install/xbps-install.8 | 9 +++++++-- include/xbps_api.h.in | 6 +++--- lib/package_unpack.c | 2 +- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 0c2a4421..5c9e6626 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,10 @@ xbps-0.21 (???): + * xbps-install(8): the -f, --force flag will now preserve configuration + files if they were modified, and only unpack files that have been + modified when re-installing packages. If -f is specified twice (-ff) + all package files will be overwritten from new package. + * Fix regression in xbps_fetch_file() when fetching files from HTTP servers that don't provide us enough details (file length, mtime, etc). diff --git a/bin/xbps-install/main.c b/bin/xbps-install/main.c index 81b5247a..72f77c67 100644 --- a/bin/xbps-install/main.c +++ b/bin/xbps-install/main.c @@ -47,7 +47,9 @@ usage(bool fail) " -C --config Full path to configuration file\n" " -c --cachedir Full path to cachedir\n" " -d --debug Debug mode shown to stderr\n" - " -f --force Force package installation\n" + " -f --force Force package re-installation\n" + " If specified twice, all files will be\n" + " overwritten.\n" " -h --help Print help usage\n" " -n --dry-run Dry-run mode\n" " -R --repository Default repository to be used if config not set\n" @@ -84,7 +86,7 @@ main(int argc, char **argv) struct xbps_handle xh; struct xferstat xfer; const char *rootdir, *cachedir, *conffile, *defrepo; - int i, c, flags, rv; + int i, c, flags, rv, fflag = 0; bool sync, yes, reinstall, drun, update; size_t maxcols; @@ -107,7 +109,9 @@ main(int argc, char **argv) flags |= XBPS_FLAG_DEBUG; break; case 'f': - flags |= XBPS_FLAG_FORCE_INSTALL; + fflag++; + if (fflag > 1) + flags |= XBPS_FLAG_FORCE_UNPACK; reinstall = true; break; case 'h': diff --git a/bin/xbps-install/xbps-install.8 b/bin/xbps-install/xbps-install.8 index 84afd805..41cb18bb 100644 --- a/bin/xbps-install/xbps-install.8 +++ b/bin/xbps-install/xbps-install.8 @@ -1,4 +1,4 @@ -.Dd January 31, 2013 +.Dd February 2, 2013 .Os Void Linux .Dt xbps-install 8 .Sh NAME @@ -59,7 +59,12 @@ Specifies a full path to the cache directory, where binary packages are stored. Enables extra debugging shown to stderr. .It Fl f, Fl -force Forcefully install target package even if another version is already installed, -overwritting its package files. +overwritting regular package files and symlinks (if they have been modified) but +.Em preserving configuration files . +If +.Fl f +is specified twice, +.Em configuration files will also be overwritten . .It Fl h, Fl -help Show the help usage. .It Fl n, Fl -dry-run diff --git a/include/xbps_api.h.in b/include/xbps_api.h.in index 28d515ce..39d61b8e 100644 --- a/include/xbps_api.h.in +++ b/include/xbps_api.h.in @@ -64,7 +64,7 @@ */ #define XBPS_PKGINDEX_VERSION "1.6" -#define XBPS_API_VERSION "20121215" +#define XBPS_API_VERSION "20130202" #ifndef XBPS_VERSION #define XBPS_VERSION "UNSET" @@ -189,12 +189,12 @@ #define XBPS_FLAG_DEBUG 0x00000040 /** - * @def XBPS_FLAG_FORCE_INSTALL + * @def XBPS_FLAG_FORCE_UNPACK * Force flag used in xbps_unpack_binary_pkg(). If set its package * files will be unpacked overwritting the current ones. * Must be set through the xbps_handle::flags member. */ -#define XBPS_FLAG_FORCE_INSTALL 0x00000080 +#define XBPS_FLAG_FORCE_UNPACK 0x00000080 /** * @def XBPS_FETCH_CACHECONN diff --git a/lib/package_unpack.c b/lib/package_unpack.c index f8fd0625..8e78e59d 100644 --- a/lib/package_unpack.c +++ b/lib/package_unpack.c @@ -122,7 +122,7 @@ unpack_archive(struct xbps_handle *xhp, euid = geteuid(); - if (xhp->flags & XBPS_FLAG_FORCE_INSTALL) + if (xhp->flags & XBPS_FLAG_FORCE_UNPACK) force = true; if (xhp->unpack_cb != NULL) {