summaryrefslogtreecommitdiff
path: root/src/apk.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2014-05-19 11:48:36 +0300
committerTimo Teräs <timo.teras@iki.fi>2014-05-19 11:48:36 +0300
commit7e64edfad62da8e180f660820bfa7a2fc321a72a (patch)
treeca6e1b258253ec31bceea3a9ada878aa74b26699 /src/apk.c
parent2c4f6bb5031636ccb87c340efd0ad6d24912cab0 (diff)
downloadapk-tools-7e64edfad62da8e180f660820bfa7a2fc321a72a.tar.gz
apk-tools-7e64edfad62da8e180f660820bfa7a2fc321a72a.tar.bz2
apk-tools-7e64edfad62da8e180f660820bfa7a2fc321a72a.tar.xz
apk-tools-7e64edfad62da8e180f660820bfa7a2fc321a72a.zip
test: improve loading of repositories, fix broken install-if test
Diffstat (limited to 'src/apk.c')
-rw-r--r--src/apk.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/apk.c b/src/apk.c
index daf4d7f..970bbb1 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -513,6 +513,13 @@ int main(int argc, char **argv)
apk_blob_t spec = APK_BLOB_STR(test_repos->item[i]), name, tag;
int repo_tag = 0, repo = APK_REPOSITORY_FIRST_CONFIGURED + i;
+ if (spec.ptr[0] == '!') {
+ /* cache's installed repository */
+ spec.ptr++;
+ spec.len--;
+ repo = -2;
+ }
+
if (apk_blob_split(spec, APK_BLOB_STR(":"), &tag, &name)) {
repo_tag = apk_db_get_tag_id(&db, tag);
} else {
@@ -520,9 +527,14 @@ int main(int argc, char **argv)
}
bs = apk_bstream_from_file(AT_FDCWD, name.ptr);
- if (bs != NULL) {
- apk_db_index_read(&db, bs, repo);
- bs->close(bs, NULL);
+ if (bs == NULL) {
+ apk_error("Failed to open repository: " BLOB_FMT, BLOB_PRINTF(name));
+ goto err;
+ }
+
+ apk_db_index_read(&db, bs, repo);
+ bs->close(bs, NULL);
+ if (repo != -2) {
if (!(apk_flags & APK_NO_NETWORK))
db.available_repos |= BIT(repo);
db.repo_tags[repo_tag].allowed_repos |= BIT(repo);