xbps-install(1): added -D, --download-only.

Added `-D, --download-only` flag to allow downloading
packages to the cache without attempting to install them.

Contributed by Toyam Cox via #9

Adapted to master by yours truly.

Close #9
This commit is contained in:
Juan RP 2019-06-21 15:57:25 +02:00
parent 4f717dc597
commit fe943eb7d2
No known key found for this signature in database
GPG Key ID: AF19F6CB482F9368
5 changed files with 29 additions and 5 deletions

6
NEWS
View File

@ -1,6 +1,10 @@
xbps-0.55 (???):
* xbps-install(1): added `-I --ignore-file-conflicts` to not abort
* xbps-install(1): Added `-D, --download-only` flag to allow
downloading packages to the cache without attempting to
install them. [Toyam Cox]
* xbps-install(1): added `-I, --ignore-file-conflicts` to not abort
the transaction even if file conflicts were detected. [xtraeme]
* xbps-install(1): return 0 if package is already installed,

View File

@ -47,6 +47,7 @@ usage(bool fail)
" -C --config <dir> Path to confdir (xbps.d)\n"
" -c --cachedir <dir> Path to cachedir\n"
" -d --debug Debug mode shown to stderr\n"
" -D --download-only Download packages and check integrity, nothing else.\n"
" -f --force Force package re-installation\n"
" If specified twice, all files will be\n"
" overwritten.\n"
@ -95,12 +96,13 @@ repo_import_key_cb(struct xbps_repo *repo, void *arg UNUSED, bool *done UNUSED)
int
main(int argc, char **argv)
{
const char *shortopts = "AC:c:dfhIiMnR:r:SuUVvy";
const char *shortopts = "AC:c:DdfhIiMnR:r:SuUVvy";
const struct option longopts[] = {
{ "automatic", no_argument, NULL, 'A' },
{ "config", required_argument, NULL, 'C' },
{ "cachedir", required_argument, NULL, 'c' },
{ "debug", no_argument, NULL, 'd' },
{ "download-only", no_argument, NULL, 'D' },
{ "force", no_argument, NULL, 'f' },
{ "help", no_argument, NULL, 'h' },
{ "ignore-conf-repos", no_argument, NULL, 'i' },
@ -144,6 +146,9 @@ main(int argc, char **argv)
case 'd':
flags |= XBPS_FLAG_DEBUG;
break;
case 'D':
flags |= XBPS_FLAG_DOWNLOAD_ONLY;
break;
case 'f':
fflag++;
if (fflag > 1)

View File

@ -72,6 +72,11 @@ If the first character is not '/' then it's a relative path of
.Ar rootdir .
.It Fl d, Fl -debug
Enables extra debugging shown to stderr.
.It Fl D, Fl -download-only
Only download packages to the cache, do not do any other installation steps.
This may be useful for doing system upgrades while offline, or automatically
downloading updates while leaving you with the option of still manually running
the update.
.It Fl f, Fl -force
Force downgrade installation (if package version in repos is less than installed version),
or reinstallation (if package version in repos is the same) to the target

View File

@ -210,11 +210,18 @@
#define XBPS_FLAG_UNPACK_ONLY 0x00001000
/**
* @def XBPS_FLAG_DOWNLOAD_ONLY
* Only download packages to the cache, do not do any installation steps.
* Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_DOWNLOAD_ONLY 0x00002000
/*
* @def XBPS_FLAG_IGNORE_FILE_CONFLICTS
* Continue with transaction even if there are file conflicts.
* Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_IGNORE_FILE_CONFLICTS 0x00002000
#define XBPS_FLAG_IGNORE_FILE_CONFLICTS 0x00004000
/**
* @def XBPS_FETCH_CACHECONN
@ -1282,7 +1289,6 @@ xbps_dictionary_t xbps_archive_fetch_plist(const char *url, const char *p);
/** @addtogroup repopool */
/*@{*/
/**
* @struct xbps_repo xbps.h "xbps.h"
* @brief Repository structure
@ -1633,7 +1639,6 @@ xbps_array_t xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg);
*/
int xbps_repo_key_import(struct xbps_repo *repo);
/*@}*/
/** @addtogroup archive_util */

View File

@ -255,6 +255,10 @@ xbps_transaction_commit(struct xbps_handle *xhp)
"%s\n", strerror(rv));
goto out;
}
if (xhp->flags & XBPS_FLAG_DOWNLOAD_ONLY) {
goto out;
}
/*
* Collect files in the transaction and find some issues
* like multiple packages installing the same file.
@ -265,6 +269,7 @@ xbps_transaction_commit(struct xbps_handle *xhp)
"%s\n", strerror(rv));
goto out;
}
/*
* Install, update, configure or remove packages as specified
* in the transaction dictionary.