diff --git a/NEWS b/NEWS
index 91058c45..74e66246 100644
--- a/NEWS
+++ b/NEWS
@@ -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,
diff --git a/bin/xbps-install/main.c b/bin/xbps-install/main.c
index e09fa40b..8cbba174 100644
--- a/bin/xbps-install/main.c
+++ b/bin/xbps-install/main.c
@@ -47,6 +47,7 @@ usage(bool fail)
" -C --config
Path to confdir (xbps.d)\n"
" -c --cachedir 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)
diff --git a/bin/xbps-install/xbps-install.1 b/bin/xbps-install/xbps-install.1
index 33d1996d..f551fcec 100644
--- a/bin/xbps-install/xbps-install.1
+++ b/bin/xbps-install/xbps-install.1
@@ -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
diff --git a/include/xbps.h.in b/include/xbps.h.in
index a33737b4..36e92e3f 100644
--- a/include/xbps.h.in
+++ b/include/xbps.h.in
@@ -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 */
diff --git a/lib/transaction_commit.c b/lib/transaction_commit.c
index 3db3b598..08da1194 100644
--- a/lib/transaction_commit.c
+++ b/lib/transaction_commit.c
@@ -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.