diff options
author | Timo Teräs <timo.teras@iki.fi> | 2023-03-21 13:05:39 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2023-03-21 13:05:39 +0200 |
commit | c1d34a07f45cd6e8d6ddc98e40390e86c7268201 (patch) | |
tree | 9cce5168420266ecdaeb8d980348ab64198c83eb /src | |
parent | 337734941831dae9a6aa441e38611c43a5fd72c0 (diff) | |
download | apk-tools-c1d34a07f45cd6e8d6ddc98e40390e86c7268201.tar.gz apk-tools-c1d34a07f45cd6e8d6ddc98e40390e86c7268201.tar.bz2 apk-tools-c1d34a07f45cd6e8d6ddc98e40390e86c7268201.tar.xz apk-tools-c1d34a07f45cd6e8d6ddc98e40390e86c7268201.zip |
fetch: implement --built-after
ref #10873
Diffstat (limited to 'src')
-rw-r--r-- | src/app_fetch.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/app_fetch.c b/src/app_fetch.c index 54f3e47..1f05a80 100644 --- a/src/app_fetch.c +++ b/src/app_fetch.c @@ -29,6 +29,7 @@ struct fetch_ctx { unsigned int flags; int outdir_fd, errors; + time_t built_after; struct apk_database *db; struct apk_progress prog; size_t done, total; @@ -70,6 +71,7 @@ static int cup(void) } #define FETCH_OPTIONS(OPT) \ + OPT(OPT_FETCH_built_after, APK_OPT_ARG "built-after") \ OPT(OPT_FETCH_link, APK_OPT_SH("l") "link") \ OPT(OPT_FETCH_recursive, APK_OPT_SH("R") "recursive") \ OPT(OPT_FETCH_output, APK_OPT_ARG APK_OPT_SH("o") "output") \ @@ -80,11 +82,30 @@ static int cup(void) APK_OPT_APPLET(option_desc, FETCH_OPTIONS); +static time_t parse_time(const char *timestr) +{ + struct tm tm; + char *p; + time_t t; + + p = strptime(optarg, "%Y-%m-%d %H:%M:%S", &tm); + if (p && *p == 0) return mktime(&tm); + + t = strtoul(optarg, &p, 10); + if (p && *p == 0) return t; + + return 0; +} + static int option_parse_applet(void *ctx, struct apk_ctx *ac, int opt, const char *optarg) { struct fetch_ctx *fctx = (struct fetch_ctx *) ctx; switch (opt) { + case OPT_FETCH_built_after: + fctx->built_after = parse_time(optarg); + if (!fctx->built_after) return -EINVAL; + break; case OPT_FETCH_simulate: ac->flags |= APK_SIMULATE; break; @@ -207,6 +228,8 @@ static void mark_package(struct fetch_ctx *ctx, struct apk_package *pkg) { if (pkg == NULL || pkg->marked) return; + if (ctx->built_after && pkg->build_time && ctx->built_after >= pkg->build_time) + return; ctx->total += pkg->size; pkg->marked = 1; } |