summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2011-03-16 14:51:44 +0200
committerTimo Teräs <timo.teras@iki.fi>2011-03-16 14:56:13 +0200
commit1e17da9d704097523e337b64d2b0e424caa4a9ef (patch)
tree2454e273ce75830e31fe6c0f61a3b3763b101052
parent15badbfd975b2a898acaacfc943e4df2cb1c7864 (diff)
downloadapk-tools-1e17da9d704097523e337b64d2b0e424caa4a9ef.tar.gz
apk-tools-1e17da9d704097523e337b64d2b0e424caa4a9ef.tar.bz2
apk-tools-1e17da9d704097523e337b64d2b0e424caa4a9ef.tar.xz
apk-tools-1e17da9d704097523e337b64d2b0e424caa4a9ef.zip
db: handle arch similarly to stable branch
if package arch is not set, do not append anything to repository. if arch is set, it is appended to repository.
-rw-r--r--src/apk_database.h2
-rw-r--r--src/cache.c3
-rw-r--r--src/database.c37
3 files changed, 26 insertions, 16 deletions
diff --git a/src/apk_database.h b/src/apk_database.h
index b79253d..64c4fed 100644
--- a/src/apk_database.h
+++ b/src/apk_database.h
@@ -183,7 +183,7 @@ int apk_repository_update(struct apk_database *db, struct apk_repository *repo);
int apk_db_cache_active(struct apk_database *db);
void apk_cache_format_index(apk_blob_t to, struct apk_repository *repo);
-int apk_cache_download(struct apk_database *db, const char *url,
+int apk_cache_download(struct apk_database *db, const char *url, apk_blob_t *arch,
const char *item, const char *cache_item, int verify);
int apk_db_install_pkg(struct apk_database *db,
diff --git a/src/cache.c b/src/cache.c
index 60c7aeb..f827cc1 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -58,7 +58,8 @@ static int cache_download(struct apk_database *db)
continue;
apk_pkg_format_plain(pkg, APK_BLOB_BUF(item));
- apk_cache_download(db, repo->url, item, cacheitem,
+ apk_cache_download(db, repo->url, pkg->arch,
+ item, cacheitem,
APK_SIGN_VERIFY_IDENTITY);
}
diff --git a/src/database.c b/src/database.c
index eea852a..4531eeb 100644
--- a/src/database.c
+++ b/src/database.c
@@ -428,9 +428,7 @@ struct apk_package *apk_db_pkg_add(struct apk_database *db, struct apk_package *
struct apk_package *idb;
if (pkg->license == NULL)
- pkg->license = apk_blob_atomize(APK_BLOB_NULL);
- if (pkg->arch == NULL)
- pkg->arch = apk_blob_atomize(APK_BLOB_STR(APK_DEFAULT_ARCH));
+ pkg->license = apk_blob_atomize(APK_BLOB_NULL);
idb = apk_hash_get(&db->available.packages, APK_BLOB_CSUM(pkg->csum));
if (idb == NULL) {
@@ -464,15 +462,20 @@ void apk_cache_format_index(apk_blob_t to, struct apk_repository *repo)
apk_blob_push_blob(&to, APK_BLOB_PTR_LEN("", 1));
}
-int apk_cache_download(struct apk_database *db, const char *url,
+int apk_cache_download(struct apk_database *db, const char *url, apk_blob_t *arch,
const char *item, const char *cacheitem, int verify)
{
char fullurl[PATH_MAX];
int r;
- snprintf(fullurl, sizeof(fullurl), "%s%s" BLOB_FMT "/%s",
- url, url[strlen(url)-1] == '/' ? "" : "/",
- BLOB_PRINTF(*db->arch), item);
+ if (arch != NULL)
+ snprintf(fullurl, sizeof(fullurl), "%s%s" BLOB_FMT "/%s",
+ url, url[strlen(url)-1] == '/' ? "" : "/",
+ BLOB_PRINTF(*arch), item);
+ else
+ snprintf(fullurl, sizeof(fullurl), "%s%s/%s",
+ url, url[strlen(url)-1] == '/' ? "" : "/",
+ item);
apk_message("fetch %s", fullurl);
if (apk_flags & APK_SIMULATE)
@@ -1432,15 +1435,20 @@ static int apk_repo_is_remote(struct apk_repository *repo)
}
static struct apk_bstream *apk_repo_file_open(struct apk_repository *repo,
- apk_blob_t arch,
+ apk_blob_t *arch,
const char *file,
char *buf, int buflen)
{
const char *url = repo->url;
- snprintf(buf, buflen, "%s%s" BLOB_FMT "/%s",
- url, url[strlen(url)-1] == '/' ? "" : "/",
- BLOB_PRINTF(arch), file);
+ if (arch != NULL)
+ snprintf(buf, buflen, "%s%s" BLOB_FMT "/%s",
+ url, url[strlen(url)-1] == '/' ? "" : "/",
+ BLOB_PRINTF(*arch), file);
+ else
+ snprintf(buf, buflen, "%s%s/%s",
+ url, url[strlen(url)-1] == '/' ? "" : "/",
+ file);
if ((apk_flags & APK_NO_NETWORK) && apk_repo_is_remote(repo))
return NULL;
@@ -1500,7 +1508,7 @@ int apk_repository_update(struct apk_database *db, struct apk_repository *repo)
return 0;
apk_cache_format_index(APK_BLOB_BUF(cacheitem), repo);
- r = apk_cache_download(db, repo->url, apkindex_tar_gz, cacheitem,
+ r = apk_cache_download(db, repo->url, db->arch, apkindex_tar_gz, cacheitem,
(apk_flags & APK_ALLOW_UNTRUSTED) ?
APK_SIGN_NONE : APK_SIGN_VERIFY);
if (r != 0)
@@ -1608,7 +1616,7 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t repository)
bs = apk_bstream_from_file(db->cache_fd, buf);
} else {
db->local_repos |= BIT(r);
- bs = apk_repo_file_open(repo, *db->arch, apkindex_tar_gz, buf, sizeof(buf));
+ bs = apk_repo_file_open(repo, db->arch, apkindex_tar_gz, buf, sizeof(buf));
}
if (bs == NULL) {
apk_warning("%s: index failed to open", buf);
@@ -2018,7 +2026,8 @@ static int apk_db_unpack_pkg(struct apk_database *db,
if (bs == NULL) {
apk_pkg_format_plain(pkg, APK_BLOB_BUF(item));
- bs = apk_repo_file_open(repo, *(pkg->arch ?: db->arch), item, file, sizeof(file));
+ bs = apk_repo_file_open(repo, pkg->arch,
+ item, file, sizeof(file));
if (apk_repo_is_remote(repo))
need_copy = TRUE;
}