xbps-install: -f will also overwrite pkg files.
This commit is contained in:
@ -118,6 +118,7 @@ main(int argc, char **argv)
|
|||||||
flags |= XBPS_FLAG_DEBUG;
|
flags |= XBPS_FLAG_DEBUG;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
|
flags |= XBPS_FLAG_FORCE_INSTALL;
|
||||||
reinstall = true;
|
reinstall = true;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
*/
|
*/
|
||||||
#define XBPS_PKGINDEX_VERSION "1.5"
|
#define XBPS_PKGINDEX_VERSION "1.5"
|
||||||
|
|
||||||
#define XBPS_API_VERSION "20121119-1"
|
#define XBPS_API_VERSION "20121119-2"
|
||||||
|
|
||||||
#ifndef XBPS_VERSION
|
#ifndef XBPS_VERSION
|
||||||
#define XBPS_VERSION "UNSET"
|
#define XBPS_VERSION "UNSET"
|
||||||
@ -177,6 +177,14 @@
|
|||||||
*/
|
*/
|
||||||
#define XBPS_FLAG_DEBUG 0x00000040
|
#define XBPS_FLAG_DEBUG 0x00000040
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def XBPS_FLAG_FORCE_INSTALL
|
||||||
|
* 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
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def XBPS_FETCH_CACHECONN
|
* @def XBPS_FETCH_CACHECONN
|
||||||
* Default (global) limit of cached connections used in libfetch.
|
* Default (global) limit of cached connections used in libfetch.
|
||||||
|
@ -97,13 +97,13 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
char *dname, *buf, *buf2, *p, *p2;
|
char *dname, *buf, *buf2, *p, *p2;
|
||||||
int ar_rv, rv, rv_stat, flags;
|
int ar_rv, rv, rv_stat, flags;
|
||||||
bool preserve, update, conf_file, file_exists, skip_obsoletes;
|
bool preserve, update, conf_file, file_exists, skip_obsoletes;
|
||||||
bool softreplace, skip_extract;
|
bool softreplace, skip_extract, force;
|
||||||
uid_t euid;
|
uid_t euid;
|
||||||
|
|
||||||
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 = conf_file = file_exists = false;
|
force = preserve = update = conf_file = file_exists = false;
|
||||||
skip_obsoletes = softreplace = false;
|
skip_obsoletes = softreplace = false;
|
||||||
|
|
||||||
prop_dictionary_get_bool(pkg_repod, "preserve", &preserve);
|
prop_dictionary_get_bool(pkg_repod, "preserve", &preserve);
|
||||||
@ -118,6 +118,9 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
|
|
||||||
euid = geteuid();
|
euid = geteuid();
|
||||||
|
|
||||||
|
if (xhp->flags & XBPS_FLAG_FORCE_INSTALL)
|
||||||
|
force = true;
|
||||||
|
|
||||||
if (xhp->unpack_cb != NULL) {
|
if (xhp->unpack_cb != NULL) {
|
||||||
/* initialize data for unpack cb */
|
/* initialize data for unpack cb */
|
||||||
memset(&xucd, 0, sizeof(xucd));
|
memset(&xucd, 0, sizeof(xucd));
|
||||||
@ -282,7 +285,7 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
if (rv_stat == 0)
|
if (rv_stat == 0)
|
||||||
file_exists = true;
|
file_exists = true;
|
||||||
|
|
||||||
if (S_ISREG(entry_statp->st_mode)) {
|
if (!force && S_ISREG(entry_statp->st_mode)) {
|
||||||
buf = strchr(entry_pname, '.') + 1;
|
buf = strchr(entry_pname, '.') + 1;
|
||||||
assert(buf != NULL);
|
assert(buf != NULL);
|
||||||
if (file_exists) {
|
if (file_exists) {
|
||||||
@ -335,7 +338,7 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (S_ISLNK(entry_statp->st_mode)) {
|
} else if (!force && S_ISLNK(entry_statp->st_mode)) {
|
||||||
/*
|
/*
|
||||||
* Check if current link from binpkg hasn't been
|
* Check if current link from binpkg hasn't been
|
||||||
* modified, otherwise extract new link.
|
* modified, otherwise extract new link.
|
||||||
@ -376,7 +379,7 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
* Check if current file mode differs from file mode
|
* Check if current file mode differs from file mode
|
||||||
* in binpkg and apply perms if true.
|
* in binpkg and apply perms if true.
|
||||||
*/
|
*/
|
||||||
if (file_exists && skip_extract &&
|
if (!force && file_exists && skip_extract &&
|
||||||
(entry_statp->st_mode != st.st_mode)) {
|
(entry_statp->st_mode != st.st_mode)) {
|
||||||
if (chmod(entry_pname,
|
if (chmod(entry_pname,
|
||||||
entry_statp->st_mode) != 0) {
|
entry_statp->st_mode) != 0) {
|
||||||
@ -398,7 +401,7 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
* Check if current uid/gid differs from file in binpkg,
|
* Check if current uid/gid differs from file in binpkg,
|
||||||
* and change permissions if true.
|
* and change permissions if true.
|
||||||
*/
|
*/
|
||||||
if ((file_exists && skip_extract && (euid == 0)) &&
|
if ((!force && file_exists && skip_extract && (euid == 0)) &&
|
||||||
(((entry_statp->st_uid != st.st_uid)) ||
|
(((entry_statp->st_uid != st.st_uid)) ||
|
||||||
((entry_statp->st_gid != st.st_gid)))) {
|
((entry_statp->st_gid != st.st_gid)))) {
|
||||||
if (chown(entry_pname,
|
if (chown(entry_pname,
|
||||||
@ -433,7 +436,7 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
"`%s' to `%s.old'.", entry_pname, entry_pname);
|
"`%s' to `%s.old'.", entry_pname, entry_pname);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skip_extract) {
|
if (!force && skip_extract) {
|
||||||
archive_read_data_skip(ar);
|
archive_read_data_skip(ar);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user