libxbps: preserve config file if they exist for replaced pkgs.

This commit is contained in:
Juan RP 2011-10-30 10:32:56 +01:00
parent 07d47ab09a
commit 858e616f41
4 changed files with 30 additions and 6 deletions

4
NEWS
View File

@ -1,5 +1,9 @@
xbps-0.11.0 (???): xbps-0.11.0 (???):
* libxbps: when unpacking a package that replaced another package
due to virtual packages, preserve its configuration files if
they already existed.
* xbps-bin(8)/xbps-repo(8): new flag '-o' (option). This can be used * xbps-bin(8)/xbps-repo(8): new flag '-o' (option). This can be used
in the 'show' target to print only a set of objects stored in package's in the 'show' target to print only a set of objects stored in package's
properties dictionary, example: properties dictionary, example:

View File

@ -55,7 +55,7 @@
*/ */
#define XBPS_PKGINDEX_VERSION "1.2" #define XBPS_PKGINDEX_VERSION "1.2"
#define XBPS_API_VERSION "20111027-1" #define XBPS_API_VERSION "20111030"
#define XBPS_VERSION "0.11.0" #define XBPS_VERSION "0.11.0"
/** /**

View File

@ -163,7 +163,7 @@ unpack_archive(prop_dictionary_t pkg_repod,
const char *entry_pname, *transact; const char *entry_pname, *transact;
char *buf; char *buf;
int rv, flags; int rv, flags;
bool preserve, update; bool preserve, update, replace;
assert(prop_object_type(pkg_repod) == PROP_TYPE_DICTIONARY); assert(prop_object_type(pkg_repod) == PROP_TYPE_DICTIONARY);
assert(ar != NULL); assert(ar != NULL);
@ -326,6 +326,23 @@ unpack_archive(prop_dictionary_t pkg_repod,
xhp->xucd->entry_total_count += xhp->xucd->entry_total_count +=
(ssize_t)prop_array_count(array); (ssize_t)prop_array_count(array);
replace = false;
if (prop_dictionary_get_bool(pkg_repod,
"replacing-package", &replace) && replace) {
/*
* The package we are currently unpacking replaced
* another package that it was removed, respect
* configuration files if they exist.
*/
if (S_ISREG(entry_statp->st_mode) &&
xbps_entry_is_a_conf_file(propsd, entry_pname) &&
(access(entry_pname, R_OK) == 0)) {
xbps_dbg_printf("%s: preserving conf_file %s.\n",
pkgname, entry_pname);
archive_read_data_skip(ar);
continue;
}
}
if (update && S_ISREG(entry_statp->st_mode)) { if (update && S_ISREG(entry_statp->st_mode)) {
/* /*
* Handle configuration files. Check if current entry is * Handle configuration files. Check if current entry is
@ -338,6 +355,7 @@ unpack_archive(prop_dictionary_t pkg_repod,
/* error */ /* error */
goto out; goto out;
} else if (rv == 1) { } else if (rv == 1) {
/* configuration file */
if (xhp->xucd != NULL) if (xhp->xucd != NULL)
xhp->xucd->entry_is_conf = true; xhp->xucd->entry_is_conf = true;
@ -352,7 +370,6 @@ unpack_archive(prop_dictionary_t pkg_repod,
* as is now and pass to next entry. * as is now and pass to next entry.
*/ */
archive_read_data_skip(ar); archive_read_data_skip(ar);
RUN_PROGRESS_CB();
continue; continue;
} }
} else { } else {
@ -372,8 +389,11 @@ unpack_archive(prop_dictionary_t pkg_repod,
goto out; goto out;
} else if (rv == 0) { } else if (rv == 0) {
/* hash match, skip */ /* hash match, skip */
xbps_dbg_printf("%s-%s: entry %s "
"matches current SHA256, "
"skipping...\n", pkgname,
version, entry_pname);
archive_read_data_skip(ar); archive_read_data_skip(ar);
RUN_PROGRESS_CB();
continue; continue;
} }
} }
@ -392,8 +412,6 @@ unpack_archive(prop_dictionary_t pkg_repod,
if (xhp->flags & XBPS_FLAG_VERBOSE) if (xhp->flags & XBPS_FLAG_VERBOSE)
xbps_warn_printf("ignoring existing " xbps_warn_printf("ignoring existing "
"entry: %s\n", entry_pname); "entry: %s\n", entry_pname);
RUN_PROGRESS_CB();
continue; continue;
} }
} }

View File

@ -134,6 +134,8 @@ xbps_transaction_package_replace(prop_dictionary_t transd)
} }
prop_dictionary_set_bool(pkg_repod, prop_dictionary_set_bool(pkg_repod,
"automatic-install", instd_auto); "automatic-install", instd_auto);
prop_dictionary_set_bool(pkg_repod,
"replacing-package", true);
} }
/* /*
* Add package dictionary into the transaction and mark * Add package dictionary into the transaction and mark