summaryrefslogtreecommitdiff
path: root/src/add.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2012-02-28 14:56:08 +0200
committerTimo Teräs <timo.teras@iki.fi>2012-02-28 14:56:08 +0200
commit2e8fe783a11bcd6ccc7f1a08d8b38eb76d87dc35 (patch)
treee0c267032223eb04182b37125fd4664d56a58e86 /src/add.c
parentfd812dc722cad1bcdbf98799a036e94c88b1b9b0 (diff)
downloadapk-tools-2e8fe783a11bcd6ccc7f1a08d8b38eb76d87dc35.tar.gz
apk-tools-2e8fe783a11bcd6ccc7f1a08d8b38eb76d87dc35.tar.bz2
apk-tools-2e8fe783a11bcd6ccc7f1a08d8b38eb76d87dc35.tar.xz
apk-tools-2e8fe783a11bcd6ccc7f1a08d8b38eb76d87dc35.zip
add: allow specifying repository tag with added virtual packages
Diffstat (limited to 'src/add.c')
-rw-r--r--src/add.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/add.c b/src/add.c
index 36f51cf..2afe834 100644
--- a/src/add.c
+++ b/src/add.c
@@ -69,21 +69,31 @@ static int add_main(void *ctx, struct apk_database *db, int argc, char **argv)
apk_dependency_array_copy(&world, db->world);
if (actx->virtpkg) {
+ apk_blob_t b = APK_BLOB_STR(actx->virtpkg);
+
if (non_repository_check(db))
return -1;
+ apk_blob_pull_dep(&b, db, &virtdep);
+ if (APK_BLOB_IS_NULL(b) ||
+ virtdep.result_mask != APK_DEPMASK_REQUIRE ||
+ virtdep.version != &apk_null_blob) {
+ apk_error("%s: bad package specifier");
+ return -1;
+ }
+
virtpkg = apk_pkg_new();
if (virtpkg == NULL) {
apk_error("Failed to allocate virtual meta package");
return -1;
}
- virtpkg->name = apk_db_get_name(db, APK_BLOB_STR(actx->virtpkg));
+ virtpkg->name = virtdep.name;
apk_blob_checksum(APK_BLOB_STR(virtpkg->name->name),
apk_checksum_default(), &virtpkg->csum);
virtpkg->version = apk_blob_atomize(APK_BLOB_STR("0"));
virtpkg->description = strdup("virtual meta package");
virtpkg->arch = apk_blob_atomize(APK_BLOB_STR("noarch"));
- apk_dep_from_pkg(&virtdep, db, virtpkg);
+ virtpkg->repos |= db->repo_tags[virtdep.repository_tag].allowed_repos;
virtpkg = apk_db_pkg_add(db, virtpkg);
}