diff options
author | Timo Teräs <timo.teras@iki.fi> | 2021-11-12 13:10:31 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2021-11-12 13:17:22 +0200 |
commit | 43e8a865ec9a911b68fb6b8e016d0084b9c2c1bc (patch) | |
tree | e7766f92d206170ac1c51924448d2252c2680127 /src/app_fetch.c | |
parent | 3aa64ea1e7484a4c4d17cf6bbca3c3f6897ba976 (diff) | |
download | apk-tools-43e8a865ec9a911b68fb6b8e016d0084b9c2c1bc.tar.gz apk-tools-43e8a865ec9a911b68fb6b8e016d0084b9c2c1bc.tar.bz2 apk-tools-43e8a865ec9a911b68fb6b8e016d0084b9c2c1bc.tar.xz apk-tools-43e8a865ec9a911b68fb6b8e016d0084b9c2c1bc.zip |
fetch: add --url option to print the download URLs
Diffstat (limited to 'src/app_fetch.c')
-rw-r--r-- | src/app_fetch.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/app_fetch.c b/src/app_fetch.c index 4704b0b..adac2af 100644 --- a/src/app_fetch.c +++ b/src/app_fetch.c @@ -23,6 +23,7 @@ #define FETCH_RECURSIVE 1 #define FETCH_STDOUT 2 #define FETCH_LINK 4 +#define FETCH_URL 8 struct fetch_ctx { unsigned int flags; @@ -71,7 +72,8 @@ static int cup(void) OPT(OPT_FETCH_recursive, APK_OPT_SH("R") "recursive") \ OPT(OPT_FETCH_output, APK_OPT_ARG APK_OPT_SH("o") "output") \ OPT(OPT_FETCH_simulate, "simulate") \ - OPT(OPT_FETCH_stdout, APK_OPT_SH("s") "stdout") + OPT(OPT_FETCH_stdout, APK_OPT_SH("s") "stdout") \ + OPT(OPT_FETCH_url, "url") \ APK_OPT_APPLET(option_desc, FETCH_OPTIONS); @@ -95,6 +97,9 @@ static int option_parse_applet(void *ctx, struct apk_db_options *dbopts, int opt case OPT_FETCH_output: fctx->outdir_fd = openat(AT_FDCWD, optarg, O_RDONLY | O_CLOEXEC); break; + case OPT_FETCH_url: + fctx->flags |= FETCH_URL; + break; default: return -ENOTSUP; } @@ -143,14 +148,17 @@ static int fetch_package(apk_hash_item item, void *pctx) return 0; } - apk_message("Downloading " PKG_VER_FMT, PKG_VER_PRINTF(pkg)); + r = apk_repo_format_item(db, repo, pkg, &urlfd, url, sizeof(url)); + if (r < 0) goto err; + + if (ctx->flags & FETCH_URL) + apk_message("%s", url); + else + apk_message("Downloading " PKG_VER_FMT, PKG_VER_PRINTF(pkg)); + if (apk_flags & APK_SIMULATE) return 0; - r = apk_repo_format_item(db, repo, pkg, &urlfd, url, sizeof(url)); - if (r < 0) - goto err; - if (ctx->flags & FETCH_STDOUT) { fd = STDOUT_FILENO; } else { |