From 7e64edfad62da8e180f660820bfa7a2fc321a72a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Mon, 19 May 2014 11:48:36 +0300 Subject: [PATCH] test: improve loading of repositories, fix broken install-if test --- src/apk.c | 18 +++++++++++++++--- test/installif2.repo | 8 ++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 test/installif2.repo 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); diff --git a/test/installif2.repo b/test/installif2.repo new file mode 100644 index 0000000..32ca131 --- /dev/null +++ b/test/installif2.repo @@ -0,0 +1,8 @@ +C:Q16m4HrGizBiH4lG6Mxd5EL239FFU= +P:appiif1 +V:2 +S:1 +I:1 +D:app broken-deps +i:app foo +