aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2015-12-07 10:41:13 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2015-12-07 12:50:32 +0000
commitc43bfed8deaa0dab47c54db9b8f374853d345a6b (patch)
tree0a257c0462ea99483946b142b1dd03424add1496
parent14b74c4dc097ff71280e99edc651b685b9582950 (diff)
downloadaports-c43bfed8deaa0dab47c54db9b8f374853d345a6b.tar.bz2
aports-c43bfed8deaa0dab47c54db9b8f374853d345a6b.tar.xz
db: add support for --no-cache
Implement --no-cache. The index is read directly from network and not cached. This is useful for docker, where you install a set of packages and directly after purge the cache. (see https://github.com/gliderlabs/docker-alpine/blob/1fc9e59d1689fc4eaf930ec66389fe58062fccec/builder/scripts/apk-install) fixes #4905
-rw-r--r--src/apk.c4
-rw-r--r--src/apk_defines.h1
-rw-r--r--src/database.c8
3 files changed, 12 insertions, 1 deletions
diff --git a/src/apk.c b/src/apk.c
index 8632587a3c..91673d8dc5 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -124,6 +124,9 @@ static int option_parse_global(void *ctx, struct apk_db_options *dbopts, int opt
case 0x109:
apk_flags |= APK_NO_NETWORK;
break;
+ case 0x115:
+ apk_flags |= APK_NO_CACHE;
+ break;
case 0x112:
dbopts->arch = optarg;
break;
@@ -173,6 +176,7 @@ static const struct apk_option options_global[] = {
{ 0x108, "repositories-file", "Override repositories file",
required_argument, "REPOFILE" },
{ 0x109, "no-network", "Do not use network (cache is still used)" },
+ { 0x115, "no-cache", "Read uncached index from network" },
{ 0x112, "arch", "Use architecture with --root",
required_argument, "ARCH" },
{ 0x114, "print-arch", "Print default arch and exit" },
diff --git a/src/apk_defines.h b/src/apk_defines.h
index 69113b4b72..2aca36459a 100644
--- a/src/apk_defines.h
+++ b/src/apk_defines.h
@@ -76,6 +76,7 @@ extern char **apk_argv;
#define APK_NO_NETWORK 0x1000
#define APK_OVERLAY_FROM_STDIN 0x2000
#define APK_NO_SCRIPTS 0x4000
+#define APK_NO_CACHE 0x8000
/* default architecture for APK packages. */
#if defined(__x86_64__)
diff --git a/src/database.c b/src/database.c
index 8a56401f5b..31ac3e4ef4 100644
--- a/src/database.c
+++ b/src/database.c
@@ -2198,7 +2198,13 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t _repository)
if (apk_flags & APK_UPDATE_CACHE)
apk_repository_update(db, repo);
}
- r = apk_repo_format_cache_index(APK_BLOB_BUF(buf), repo);
+ if (apk_flags & APK_NO_CACHE) {
+ r = apk_repo_format_real_url(db, repo, NULL, buf, sizeof(buf));
+ if (r == 0)
+ apk_message("fetch %s", buf);
+ } else {
+ r = apk_repo_format_cache_index(APK_BLOB_BUF(buf), repo);
+ }
} else {
db->local_repos |= BIT(repo_num);
db->available_repos |= BIT(repo_num);