summaryrefslogtreecommitdiff
path: root/src/fetch.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-08-06 16:00:20 +0300
committerTimo Teras <timo.teras@iki.fi>2009-08-06 16:00:20 +0300
commitf02f326238fd1e6424bf914e102ce265e7c156ec (patch)
treeceded7eb995efa68086b613cbc286d198b60da0a /src/fetch.c
parentced1fa83d6361ebfdc40920d98eb292ca4661b4e (diff)
downloadapk-tools-f02f326238fd1e6424bf914e102ce265e7c156ec.tar.gz
apk-tools-f02f326238fd1e6424bf914e102ce265e7c156ec.tar.bz2
apk-tools-f02f326238fd1e6424bf914e102ce265e7c156ec.tar.xz
apk-tools-f02f326238fd1e6424bf914e102ce265e7c156ec.zip
db: prefer local repositories, and implement --no-network
this helps boots sequence when network is not available.
Diffstat (limited to 'src/fetch.c')
-rw-r--r--src/fetch.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/fetch.c b/src/fetch.c
index 9d10f7c..f827d95 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -95,8 +95,9 @@ static int fetch_package(struct fetch_ctx *fctx,
struct apk_package *pkg)
{
struct apk_istream *is;
+ struct apk_repository *repo;
char pkgfile[PATH_MAX], url[PATH_MAX];
- int r, i, fd;
+ int r, fd;
apk_pkg_format_plain(pkg, APK_BLOB_BUF(pkgfile));
@@ -110,12 +111,9 @@ static int fetch_package(struct fetch_ctx *fctx,
}
apk_message("Downloading %s-%s", pkg->name->name, pkg->version);
- for (i = 0; i < APK_MAX_REPOS; i++)
- if (pkg->repos & BIT(i))
- break;
-
- if (i >= APK_MAX_REPOS) {
- apk_error("%s-%s: not present in any repository",
+ repo = apk_db_select_repo(db, pkg);
+ if (repo == NULL) {
+ apk_error("%s-%s: package is not currently available",
pkg->name->name, pkg->version);
return -1;
}
@@ -123,8 +121,8 @@ static int fetch_package(struct fetch_ctx *fctx,
if (apk_flags & APK_SIMULATE)
return 0;
- snprintf(url, sizeof(url), "%s%s%s", db->repos[i].url,
- db->repos[i].url[strlen(db->repos[i].url)-1] == '/' ? "" : "/",
+ snprintf(url, sizeof(url), "%s%s%s", repo->url,
+ repo->url[strlen(repo->url)-1] == '/' ? "" : "/",
pkgfile);
if (fctx->flags & FETCH_STDOUT) {