libxbps: abort pkg unpacking as soon as a file cannot be written.
Close #74
This commit is contained in:
parent
9d8e2d0250
commit
d11230a29d
4
NEWS
4
NEWS
@ -1,5 +1,9 @@
|
|||||||
xbps-0.44 (???):
|
xbps-0.44 (???):
|
||||||
|
|
||||||
|
* libxbps: abort package unpacking as soon as a file failed
|
||||||
|
to be written and return a meaningful error; close #74
|
||||||
|
https://github.com/voidlinux/xbps/issues/74
|
||||||
|
|
||||||
* Change the xbps utils to just check for the first character when it
|
* Change the xbps utils to just check for the first character when it
|
||||||
asks for confirmation, rather than "yes" or "no". This implements issue #73.
|
asks for confirmation, rather than "yes" or "no". This implements issue #73.
|
||||||
https://github.com/voidlinux/xbps/issues/73
|
https://github.com/voidlinux/xbps/issues/73
|
||||||
|
@ -86,7 +86,7 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
ssize_t entry_size;
|
ssize_t entry_size;
|
||||||
const char *file, *entry_pname, *transact;
|
const char *file, *entry_pname, *transact;
|
||||||
char *pkgname, *buf;
|
char *pkgname, *buf;
|
||||||
int ar_rv, rv, entry_type, flags;
|
int ar_rv, rv, error, entry_type, flags;
|
||||||
bool preserve, update, file_exists, skip_obsoletes;
|
bool preserve, update, file_exists, skip_obsoletes;
|
||||||
bool skip_extract, force, xucd_stats;
|
bool skip_extract, force, xucd_stats;
|
||||||
uid_t euid;
|
uid_t euid;
|
||||||
@ -94,7 +94,7 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
binpkg_filesd = pkg_filesd = NULL;
|
binpkg_filesd = pkg_filesd = NULL;
|
||||||
force = preserve = update = file_exists = false;
|
force = preserve = update = file_exists = false;
|
||||||
skip_obsoletes = xucd_stats = false;
|
skip_obsoletes = xucd_stats = false;
|
||||||
ar_rv = rv = entry_type = flags = 0;
|
ar_rv = rv = error = entry_type = flags = 0;
|
||||||
|
|
||||||
xbps_dictionary_get_bool(pkg_repod, "preserve", &preserve);
|
xbps_dictionary_get_bool(pkg_repod, "preserve", &preserve);
|
||||||
xbps_dictionary_get_bool(pkg_repod, "skip-obsoletes", &skip_obsoletes);
|
xbps_dictionary_get_bool(pkg_repod, "skip-obsoletes", &skip_obsoletes);
|
||||||
@ -403,10 +403,12 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
* Extract entry from archive.
|
* Extract entry from archive.
|
||||||
*/
|
*/
|
||||||
if (archive_read_extract(ar, entry, flags) != 0) {
|
if (archive_read_extract(ar, entry, flags) != 0) {
|
||||||
|
error = archive_errno(ar);
|
||||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||||
archive_errno(ar), pkgver,
|
error, pkgver,
|
||||||
"%s: [unpack] failed to extract file `%s': %s",
|
"%s: [unpack] failed to extract file `%s': %s",
|
||||||
pkgver, entry_pname, archive_error_string(ar));
|
pkgver, entry_pname, strerror(error));
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (xhp->unpack_cb != NULL) {
|
if (xhp->unpack_cb != NULL) {
|
||||||
xucd.entry_extract_count++;
|
xucd.entry_extract_count++;
|
||||||
@ -417,10 +419,13 @@ unpack_archive(struct xbps_handle *xhp,
|
|||||||
/*
|
/*
|
||||||
* If there was any error extracting files from archive, error out.
|
* If there was any error extracting files from archive, error out.
|
||||||
*/
|
*/
|
||||||
if (ar_rv == ARCHIVE_FATAL) {
|
if (error || ar_rv == ARCHIVE_FATAL) {
|
||||||
|
rv = error;
|
||||||
|
if (!rv)
|
||||||
|
rv = ar_rv;
|
||||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL, rv, pkgver,
|
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL, rv, pkgver,
|
||||||
"%s: [unpack] failed to extract files: %s",
|
"%s: [unpack] failed to extract files: %s",
|
||||||
pkgver, archive_error_string(ar));
|
pkgver, strerror(rv));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user