xbps-install: print required size and free size on ENOSPC.

This commit is contained in:
Juan RP 2015-05-09 07:02:21 +02:00
parent da74e3dd9e
commit 2c0e27a001
2 changed files with 21 additions and 1 deletions

3
NEWS
View File

@ -1,5 +1,8 @@
xbps-0.45 (???):
* xbps-install(8): if there's not enough sufficient free space on rootdir,
print the required size by the transaction and free space.
* libxbps: if a pkg signature file cannot be verified, don't continue processing
other files, stop and return error immediately.

View File

@ -287,6 +287,8 @@ exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun)
{
xbps_array_t array;
struct transaction *trans;
uint64_t fsize = 0, isize = 0;
char freesize[8], instsize[8];
int rv = 0;
trans = calloc(1, sizeof(*trans));
@ -315,7 +317,22 @@ exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun)
fprintf(stderr, "Transaction aborted due to conflicting packages.\n");
} else if (rv == ENOSPC) {
/* not enough free space */
fprintf(stderr, "Transaction aborted due to insufficient disk space.\n");
xbps_dictionary_get_uint64(xhp->transd,
"total-installed-size", &isize);
if (xbps_humanize_number(instsize, (int64_t)isize) == -1) {
xbps_error_printf("humanize_number2 returns "
"%s\n", strerror(errno));
return -1;
}
xbps_dictionary_get_uint64(xhp->transd,
"disk-free-size", &fsize);
if (xbps_humanize_number(freesize, (int64_t)fsize) == -1) {
xbps_error_printf("humanize_number2 returns "
"%s\n", strerror(errno));
return -1;
}
fprintf(stderr, "Transaction aborted due to insufficient disk "
"space (need %s, got %s free).\n", instsize, freesize);
} else {
xbps_dbg_printf(xhp, "Empty transaction dictionary: %s\n",
strerror(errno));