fetch: add --url option to print the download URLs
parent
3e6261392f
commit
3cb5ce2a37
|
@ -37,3 +37,6 @@ specified.
|
||||||
|
|
||||||
*Note*: this option is unreliable if needed indexes are not up-to-date
|
*Note*: this option is unreliable if needed indexes are not up-to-date
|
||||||
as this omits refresing or downloading of missing indexes.
|
as this omits refresing or downloading of missing indexes.
|
||||||
|
|
||||||
|
*--url*
|
||||||
|
Print the full URL for downloaded packages.
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#define FETCH_RECURSIVE 1
|
#define FETCH_RECURSIVE 1
|
||||||
#define FETCH_STDOUT 2
|
#define FETCH_STDOUT 2
|
||||||
#define FETCH_LINK 4
|
#define FETCH_LINK 4
|
||||||
|
#define FETCH_URL 8
|
||||||
|
|
||||||
struct fetch_ctx {
|
struct fetch_ctx {
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
|
@ -72,7 +73,8 @@ static int cup(void)
|
||||||
OPT(OPT_FETCH_recursive, APK_OPT_SH("R") "recursive") \
|
OPT(OPT_FETCH_recursive, APK_OPT_SH("R") "recursive") \
|
||||||
OPT(OPT_FETCH_output, APK_OPT_ARG APK_OPT_SH("o") "output") \
|
OPT(OPT_FETCH_output, APK_OPT_ARG APK_OPT_SH("o") "output") \
|
||||||
OPT(OPT_FETCH_simulate, "simulate") \
|
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);
|
APK_OPT_APPLET(option_desc, FETCH_OPTIONS);
|
||||||
|
|
||||||
|
@ -96,6 +98,9 @@ static int option_parse_applet(void *ctx, struct apk_ctx *ac, int opt, const cha
|
||||||
case OPT_FETCH_output:
|
case OPT_FETCH_output:
|
||||||
fctx->outdir_fd = openat(AT_FDCWD, optarg, O_RDONLY | O_CLOEXEC);
|
fctx->outdir_fd = openat(AT_FDCWD, optarg, O_RDONLY | O_CLOEXEC);
|
||||||
break;
|
break;
|
||||||
|
case OPT_FETCH_url:
|
||||||
|
fctx->flags |= FETCH_URL;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
@ -146,14 +151,17 @@ static int fetch_package(apk_hash_item item, void *pctx)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r = apk_repo_format_item(db, repo, pkg, &urlfd, url, sizeof(url));
|
||||||
|
if (r < 0) goto err;
|
||||||
|
|
||||||
|
if (ctx->flags & FETCH_URL)
|
||||||
|
apk_msg(out, "%s", url);
|
||||||
|
else
|
||||||
apk_msg(out, "Downloading " PKG_VER_FMT, PKG_VER_PRINTF(pkg));
|
apk_msg(out, "Downloading " PKG_VER_FMT, PKG_VER_PRINTF(pkg));
|
||||||
|
|
||||||
if (db->ctx->flags & APK_SIMULATE)
|
if (db->ctx->flags & APK_SIMULATE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = apk_repo_format_item(db, repo, pkg, &urlfd, url, sizeof(url));
|
|
||||||
if (r < 0)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
if (ctx->flags & FETCH_STDOUT) {
|
if (ctx->flags & FETCH_STDOUT) {
|
||||||
os = apk_ostream_to_fd(STDOUT_FILENO);
|
os = apk_ostream_to_fd(STDOUT_FILENO);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue