diff --git a/bin/xbps-install/main.c b/bin/xbps-install/main.c index c626d407b..0a88b800d 100644 --- a/bin/xbps-install/main.c +++ b/bin/xbps-install/main.c @@ -53,6 +53,7 @@ usage(bool fail) " -h, --help Show usage\n" " -i, --ignore-conf-repos Ignore repositories defined in xbps.d\n" " -I, --ignore-file-conflicts Ignore detected file conflicts\n" + " -T, --trust-disk-space Don't fail from insufficient disk space for transaction\n" " -U, --unpack-only Unpack packages in transaction, do not configure them\n" " -M, --memory-sync Remote repository data is fetched and stored\n" " in memory, ignoring on-disk repodata archives\n" @@ -107,6 +108,7 @@ main(int argc, char **argv) { "help", no_argument, NULL, 'h' }, { "ignore-conf-repos", no_argument, NULL, 'i' }, { "ignore-file-conflicts", no_argument, NULL, 'I' }, + { "trust-disk-space", no_argument, NULL, 'T' }, { "memory-sync", no_argument, NULL, 'M' }, { "dry-run", no_argument, NULL, 'n' }, { "repository", required_argument, NULL, 'R' }, @@ -183,6 +185,9 @@ main(int argc, char **argv) case 'S': syncf = true; break; + case 'T': + flags |= XBPS_FLAG_IGNORE_DISK_SPACE; + break; case 'U': flags |= XBPS_FLAG_UNPACK_ONLY; break; diff --git a/include/xbps.h.in b/include/xbps.h.in index b0f421569..8e3194893 100644 --- a/include/xbps.h.in +++ b/include/xbps.h.in @@ -240,6 +240,13 @@ */ #define XBPS_FLAG_KEEP_CONFIG 0x00010000 +/** + * @def XBPS_FLAG_IGNORE_DISK_SPACE + * Skips checking disk space available and disk space needed. + * Must be set through the xbps_handle::flags member. + */ +#define XBPS_FLAG_IGNORE_DISK_SPACE 0x00020000 + /** * @def XBPS_FETCH_CACHECONN * Default (global) limit of cached connections used in libfetch. diff --git a/lib/transaction_prepare.c b/lib/transaction_prepare.c index b6ff1a9d1..bb4ec7d06 100644 --- a/lib/transaction_prepare.c +++ b/lib/transaction_prepare.c @@ -169,21 +169,22 @@ compute_transaction_stats(struct xbps_handle *xhp) "total-removed-size", rmsize)) return EINVAL; - /* Get free space from target rootdir: return ENOSPC if there's not enough space */ - if (statvfs(xhp->rootdir, &svfs) == -1) { - xbps_dbg_printf(xhp, "%s: statvfs failed: %s\n", __func__, strerror(errno)); - return 0; - } - /* compute free space on disk */ - rootdir_free_size = svfs.f_bfree * svfs.f_bsize; - - if (!xbps_dictionary_set_uint64(xhp->transd, - "disk-free-size", rootdir_free_size)) - return EINVAL; + if (xhp->flags & XBPS_FLAG_IGNORE_DISK_SPACE) { + /* Get free space from target rootdir: return ENOSPC if there's not enough space */ + if (statvfs(xhp->rootdir, &svfs) == -1) { + xbps_dbg_printf(xhp, "%s: statvfs failed: %s\n", __func__, strerror(errno)); + return 0; + } + /* compute free space on disk */ + rootdir_free_size = svfs.f_bfree * svfs.f_bsize; - if (instsize > rootdir_free_size) - return ENOSPC; + if (!xbps_dictionary_set_uint64(xhp->transd, + "disk-free-size", rootdir_free_size)) + return EINVAL; + if (instsize > rootdir_free_size) + return ENOSPC; + } return 0; }