xbps-install: make -f preserve conf files; use it twice to overwrite all files.

This commit is contained in:
Juan RP 2013-02-02 11:30:42 +01:00
parent 7d8f0bb686
commit 5c1688944d
5 changed files with 23 additions and 9 deletions

5
NEWS
View File

@ -1,5 +1,10 @@
xbps-0.21 (???): 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 * Fix regression in xbps_fetch_file() when fetching files from HTTP
servers that don't provide us enough details (file length, mtime, etc). servers that don't provide us enough details (file length, mtime, etc).

View File

@ -47,7 +47,9 @@ usage(bool fail)
" -C --config <file> Full path to configuration file\n" " -C --config <file> Full path to configuration file\n"
" -c --cachedir <dir> Full path to cachedir\n" " -c --cachedir <dir> Full path to cachedir\n"
" -d --debug Debug mode shown to stderr\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" " -h --help Print help usage\n"
" -n --dry-run Dry-run mode\n" " -n --dry-run Dry-run mode\n"
" -R --repository <uri> Default repository to be used if config not set\n" " -R --repository <uri> Default repository to be used if config not set\n"
@ -84,7 +86,7 @@ main(int argc, char **argv)
struct xbps_handle xh; struct xbps_handle xh;
struct xferstat xfer; struct xferstat xfer;
const char *rootdir, *cachedir, *conffile, *defrepo; const char *rootdir, *cachedir, *conffile, *defrepo;
int i, c, flags, rv; int i, c, flags, rv, fflag = 0;
bool sync, yes, reinstall, drun, update; bool sync, yes, reinstall, drun, update;
size_t maxcols; size_t maxcols;
@ -107,7 +109,9 @@ main(int argc, char **argv)
flags |= XBPS_FLAG_DEBUG; flags |= XBPS_FLAG_DEBUG;
break; break;
case 'f': case 'f':
flags |= XBPS_FLAG_FORCE_INSTALL; fflag++;
if (fflag > 1)
flags |= XBPS_FLAG_FORCE_UNPACK;
reinstall = true; reinstall = true;
break; break;
case 'h': case 'h':

View File

@ -1,4 +1,4 @@
.Dd January 31, 2013 .Dd February 2, 2013
.Os Void Linux .Os Void Linux
.Dt xbps-install 8 .Dt xbps-install 8
.Sh NAME .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. Enables extra debugging shown to stderr.
.It Fl f, Fl -force .It Fl f, Fl -force
Forcefully install target package even if another version is already installed, 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 .It Fl h, Fl -help
Show the help usage. Show the help usage.
.It Fl n, Fl -dry-run .It Fl n, Fl -dry-run

View File

@ -64,7 +64,7 @@
*/ */
#define XBPS_PKGINDEX_VERSION "1.6" #define XBPS_PKGINDEX_VERSION "1.6"
#define XBPS_API_VERSION "20121215" #define XBPS_API_VERSION "20130202"
#ifndef XBPS_VERSION #ifndef XBPS_VERSION
#define XBPS_VERSION "UNSET" #define XBPS_VERSION "UNSET"
@ -189,12 +189,12 @@
#define XBPS_FLAG_DEBUG 0x00000040 #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 * Force flag used in xbps_unpack_binary_pkg(). If set its package
* files will be unpacked overwritting the current ones. * files will be unpacked overwritting the current ones.
* Must be set through the xbps_handle::flags member. * 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 * @def XBPS_FETCH_CACHECONN

View File

@ -122,7 +122,7 @@ unpack_archive(struct xbps_handle *xhp,
euid = geteuid(); euid = geteuid();
if (xhp->flags & XBPS_FLAG_FORCE_INSTALL) if (xhp->flags & XBPS_FLAG_FORCE_UNPACK)
force = true; force = true;
if (xhp->unpack_cb != NULL) { if (xhp->unpack_cb != NULL) {