Always preserve current conffiles while installing new packages.
This commit is contained in:
parent
79fd316f8e
commit
c40c40e08e
7
NEWS
7
NEWS
@ -1,5 +1,12 @@
|
|||||||
xbps-0.11.0 (???):
|
xbps-0.11.0 (???):
|
||||||
|
|
||||||
|
* While unpacking a binary package, always check that file to be extracted
|
||||||
|
exists on filesystem, if true and its hash is matched, skip extraction.
|
||||||
|
|
||||||
|
* While installing a package always preserve configuration files if they
|
||||||
|
exist, but if hash don't match rename configuration files to
|
||||||
|
<filename>.old.
|
||||||
|
|
||||||
* New shared configuration file via libconfuse that replaces the
|
* New shared configuration file via libconfuse that replaces the
|
||||||
plist configuration files: xbps.conf. That means that libxbps
|
plist configuration files: xbps.conf. That means that libxbps
|
||||||
now requires confuse >= 2.7 available at
|
now requires confuse >= 2.7 available at
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
*/
|
*/
|
||||||
#define XBPS_PKGINDEX_VERSION "1.3"
|
#define XBPS_PKGINDEX_VERSION "1.3"
|
||||||
|
|
||||||
#define XBPS_API_VERSION "20111216-1"
|
#define XBPS_API_VERSION "20111219"
|
||||||
#define XBPS_VERSION "0.11.0"
|
#define XBPS_VERSION "0.11.0"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -169,12 +169,12 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
|||||||
const char *entry_pname, *transact, *pkgname, *version, *pkgver, *fname;
|
const char *entry_pname, *transact, *pkgname, *version, *pkgver, *fname;
|
||||||
char *buf = NULL, *pkgfilesd = NULL;
|
char *buf = NULL, *pkgfilesd = NULL;
|
||||||
int rv, flags;
|
int rv, flags;
|
||||||
bool preserve, update, replace;
|
bool preserve, update, conf_file, file_exists;
|
||||||
|
|
||||||
assert(prop_object_type(pkg_repod) == PROP_TYPE_DICTIONARY);
|
assert(prop_object_type(pkg_repod) == PROP_TYPE_DICTIONARY);
|
||||||
assert(ar != NULL);
|
assert(ar != NULL);
|
||||||
|
|
||||||
preserve = update = false;
|
preserve = update = conf_file = file_exists = false;
|
||||||
prop_dictionary_get_bool(pkg_repod, "preserve", &preserve);
|
prop_dictionary_get_bool(pkg_repod, "preserve", &preserve);
|
||||||
prop_dictionary_get_cstring_nocopy(pkg_repod,
|
prop_dictionary_get_cstring_nocopy(pkg_repod,
|
||||||
"transaction", &transact);
|
"transaction", &transact);
|
||||||
@ -368,60 +368,21 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
|||||||
xucd->entry_total_count +=
|
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,
|
* Always check that extracted file exists and hash
|
||||||
"replacing-package", &replace) && replace) {
|
* doesn't match, in that case overwrite the file.
|
||||||
/*
|
* Otherwise skip extracting it.
|
||||||
* The package we are currently unpacking replaced
|
*/
|
||||||
* another package that it was removed, respect
|
conf_file = false;
|
||||||
* configuration files if they exist.
|
file_exists = false;
|
||||||
*/
|
if (S_ISREG(entry_statp->st_mode)) {
|
||||||
if (S_ISREG(entry_statp->st_mode) &&
|
if (xbps_entry_is_a_conf_file(propsd, entry_pname))
|
||||||
xbps_entry_is_a_conf_file(propsd, entry_pname) &&
|
conf_file = true;
|
||||||
(access(entry_pname, R_OK) == 0)) {
|
if (access(entry_pname, R_OK) == 0) {
|
||||||
xbps_dbg_printf("%s: preserving conf_file %s.\n",
|
file_exists = true;
|
||||||
pkgname, entry_pname);
|
|
||||||
archive_read_data_skip(ar);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (update && S_ISREG(entry_statp->st_mode)) {
|
|
||||||
/*
|
|
||||||
* Handle configuration files. Check if current entry is
|
|
||||||
* a configuration file and take action if required. Skip
|
|
||||||
* packages that don't have the "conf_files" array in
|
|
||||||
* the XBPS_PKGPROPS dictionary.
|
|
||||||
*/
|
|
||||||
rv = xbps_entry_is_a_conf_file(propsd, entry_pname);
|
|
||||||
if (rv == -1) {
|
|
||||||
/* error */
|
|
||||||
goto out;
|
|
||||||
} else if (rv == 1) {
|
|
||||||
/* configuration file */
|
|
||||||
if (xucd != NULL)
|
|
||||||
xucd->entry_is_conf = true;
|
|
||||||
|
|
||||||
rv = xbps_entry_install_conf_file(filesd,
|
|
||||||
entry, entry_pname, pkgname, version);
|
|
||||||
if (rv == -1) {
|
|
||||||
/* error */
|
|
||||||
goto out;
|
|
||||||
} else if (rv == 0) {
|
|
||||||
/*
|
|
||||||
* Keep current configuration file
|
|
||||||
* as is now and pass to next entry.
|
|
||||||
*/
|
|
||||||
archive_read_data_skip(ar);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Current entry is not a configuration file,
|
|
||||||
* check if installed file matches sha256 hash.
|
|
||||||
* If true, there is no need to extract it.
|
|
||||||
*/
|
|
||||||
rv = xbps_file_hash_check_dictionary(filesd,
|
rv = xbps_file_hash_check_dictionary(filesd,
|
||||||
"files", entry_pname);
|
conf_file ? "conf_files" : "files",
|
||||||
|
entry_pname);
|
||||||
if (rv == -1) {
|
if (rv == -1) {
|
||||||
xbps_dbg_printf("%s-%s: failed to check"
|
xbps_dbg_printf("%s-%s: failed to check"
|
||||||
" hash for `%s': %s\n", pkgname,
|
" hash for `%s': %s\n", pkgname,
|
||||||
@ -438,8 +399,46 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
|||||||
archive_read_data_skip(ar);
|
archive_read_data_skip(ar);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
rv = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!update && conf_file && file_exists) {
|
||||||
|
/*
|
||||||
|
* If installing new package preserve old configuration
|
||||||
|
* file but renaming it to <file>.old.
|
||||||
|
*/
|
||||||
|
buf = xbps_xasprintf("%s.old", entry_pname);
|
||||||
|
(void)rename(entry_pname, buf);
|
||||||
|
free(buf);
|
||||||
|
xbps_set_cb_state(XBPS_STATE_CONFIG_FILE, 0,
|
||||||
|
pkgname, version,
|
||||||
|
"Renamed old configuration file "
|
||||||
|
"`%s' to `%s.old'.", entry_pname, entry_pname);
|
||||||
|
} else if (update && conf_file && file_exists) {
|
||||||
|
/*
|
||||||
|
* Handle configuration files. Check if current entry is
|
||||||
|
* a configuration file and take action if required. Skip
|
||||||
|
* packages that don't have the "conf_files" array in
|
||||||
|
* the XBPS_PKGPROPS dictionary.
|
||||||
|
*/
|
||||||
|
if (xucd != NULL)
|
||||||
|
xucd->entry_is_conf = true;
|
||||||
|
|
||||||
|
rv = xbps_entry_install_conf_file(filesd,
|
||||||
|
entry, entry_pname, pkgname, version);
|
||||||
|
if (rv == -1) {
|
||||||
|
/* error */
|
||||||
|
goto out;
|
||||||
|
} else if (rv == 0) {
|
||||||
|
/*
|
||||||
|
* Keep current configuration file
|
||||||
|
* as is now and pass to next entry.
|
||||||
|
*/
|
||||||
|
archive_read_data_skip(ar);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
rv = 0;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Extract entry from archive.
|
* Extract entry from archive.
|
||||||
*/
|
*/
|
||||||
|
@ -135,8 +135,6 @@ 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);
|
|
||||||
prop_dictionary_set_bool(instd,
|
prop_dictionary_set_bool(instd,
|
||||||
"remove-and-purge", true);
|
"remove-and-purge", true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user