Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xbps-install add -T option to skip disk space check #371

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bin/xbps-install/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trust doesn't feel like the correct word; also, if it's going to be a command line arg I think it should exclusively be a long opt; but Duncaen has expressed preference for an env var.

{ "memory-sync", no_argument, NULL, 'M' },
{ "dry-run", no_argument, NULL, 'n' },
{ "repository", required_argument, NULL, 'R' },
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions include/xbps.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
27 changes: 14 additions & 13 deletions lib/transaction_prepare.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this using the wrong logic?

/* 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;
}

Expand Down