Implement support to "preserve" existent on-disk files.

See NEWS for more information. Fix #51
This commit is contained in:
Juan RP
2014-08-01 15:09:51 +02:00
parent fa960c2425
commit f8d8f91a08
18 changed files with 269 additions and 88 deletions

View File

@@ -208,7 +208,7 @@ rcv_init(rcv_t *rcv, const char *prog)
rcv->have_vars = 0;
rcv->ptr = rcv->input = NULL;
if (rcv->xbps_conf != NULL)
rcv->xhp.conffile = rcv->xbps_conf;
strncpy(rcv->xhp.conffile, rcv->xbps_conf, sizeof(rcv->xhp.conffile));
if (rcv->rootdir != NULL)
strncpy(rcv->xhp.rootdir, rcv->rootdir, sizeof(rcv->xhp.rootdir));
xbps_init(&rcv->xhp);

View File

@@ -190,7 +190,8 @@ main(int argc, char **argv)
strncpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (cachedir)
strncpy(xh.cachedir, cachedir, sizeof(xh.cachedir));
xh.conffile = conffile;
if (conffile)
strncpy(xh.conffile, conffile, sizeof(xh.conffile));
xh.flags = flags;
if (flags & XBPS_FLAG_VERBOSE)
xh.unpack_cb = unpack_progress_cb;

View File

@@ -136,6 +136,9 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbdata _unused)
case XBPS_STATE_SHOW_INSTALL_MSG:
printf("%s: post-install message:\n%s", xscd->arg, xscd->desc);
break;
case XBPS_STATE_UNPACK_FILE_PRESERVED:
printf("%s\n", xscd->desc);
break;
/* errors */
case XBPS_STATE_UNPACK_FAIL:
case XBPS_STATE_UPDATE_FAIL:

View File

@@ -137,7 +137,8 @@ main(int argc, char **argv)
memset(&xh, 0, sizeof(xh));
if (rootdir)
strncpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
xh.conffile = conffile;
if (conffile)
strncpy(xh.conffile, conffile, sizeof(xh.conffile));
xh.flags = flags;
if ((rv = xbps_init(&xh)) != 0) {

View File

@@ -213,7 +213,9 @@ main(int argc, char **argv)
strncpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (cachedir)
strncpy(xh.cachedir, cachedir, sizeof(xh.cachedir));
xh.conffile = conffile;
if (conffile)
strncpy(xh.conffile, conffile, sizeof(xh.conffile));
xh.flags = flags;
if ((rv = xbps_init(&xh)) != 0) {

View File

@@ -147,7 +147,9 @@ main(int argc, char **argv)
xh.state_cb = state_cb;
if (rootdir)
strncpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
xh.conffile = conffile;
if (conffile)
strncpy(xh.conffile, conffile, sizeof(xh.conffile));
xh.flags = flags;
if ((rv = xbps_init(&xh)) != 0) {

View File

@@ -251,7 +251,9 @@ main(int argc, char **argv)
strncpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
if (cachedir)
strncpy(xh.cachedir, cachedir, sizeof(xh.cachedir));
xh.conffile = conffile;
if (conffile)
strncpy(xh.conffile, conffile, sizeof(xh.conffile));
xh.flags = flags;
if ((rv = xbps_init(&xh)) != 0) {

View File

@@ -87,14 +87,14 @@ main(int argc, char **argv)
xbps_dictionary_t dict;
struct xbps_handle xh;
struct xferstat xfer;
const char *version, *rootdir = NULL, *confdir = NULL;
const char *version, *rootdir = NULL, *conffile = NULL;
char *pkgname, *hash, *sep;
int flags = 0, c, rv = 0;
while ((c = getopt(argc, argv, "C:dr:V")) != -1) {
switch (c) {
case 'C':
confdir = optarg;
conffile = optarg;
break;
case 'r':
/* To specify the root directory */
@@ -131,7 +131,8 @@ main(int argc, char **argv)
xh.fetch_cb_data = &xfer;
if (rootdir)
strncpy(xh.rootdir, rootdir, sizeof(xh.rootdir));
xh.conffile = confdir;
if (conffile)
strncpy(xh.conffile, conffile, sizeof(xh.conffile));
if ((rv = xbps_init(&xh)) != 0) {
xbps_error_printf("xbps-uhelper: failed to "
"initialize libxbps: %s.\n", strerror(rv));