Commit 32064c35 authored by Natanael Copa's avatar Natanael Copa

add: create csum for virtuals. only add the virtual to world

parent 7950a2b5
...@@ -40,6 +40,14 @@ static int add_parse(void *ctx, int optch, int optindex, const char *optarg) ...@@ -40,6 +40,14 @@ static int add_parse(void *ctx, int optch, int optindex, const char *optarg)
return 0; return 0;
} }
static void md5_str(const char *str, md5sum_t csum)
{
struct md5_ctx ctx;
md5_init(&ctx);
md5_process(&ctx, str, strlen(str));
md5_finish(&ctx, csum);
}
static int add_main(void *ctx, int argc, char **argv) static int add_main(void *ctx, int argc, char **argv)
{ {
struct add_ctx *actx = (struct add_ctx *) ctx; struct add_ctx *actx = (struct add_ctx *) ctx;
...@@ -61,6 +69,7 @@ static int add_main(void *ctx, int argc, char **argv) ...@@ -61,6 +69,7 @@ static int add_main(void *ctx, int argc, char **argv)
goto err; goto err;
} }
virtpkg->name = apk_db_get_name(&db, APK_BLOB_STR(actx->virtpkg)); virtpkg->name = apk_db_get_name(&db, APK_BLOB_STR(actx->virtpkg));
md5_str(virtpkg->name->name, virtpkg->csum);
virtpkg->version = strdup("0"); virtpkg->version = strdup("0");
virtpkg->description = strdup("virtual meta package"); virtpkg->description = strdup("virtual meta package");
virtdep = (struct apk_dependency) { virtdep = (struct apk_dependency) {
...@@ -103,8 +112,10 @@ static int add_main(void *ctx, int argc, char **argv) ...@@ -103,8 +112,10 @@ static int add_main(void *ctx, int argc, char **argv)
apk_deps_add(&pkgs, &dep); apk_deps_add(&pkgs, &dep);
} }
if (virtpkg) if (virtpkg) {
apk_deps_add(&pkgs, &virtdep); apk_deps_add(&pkgs, &virtdep);
apk_deps_add(&db.world, &virtdep);
}
state = apk_state_new(&db); state = apk_state_new(&db);
for (i = 0; i < pkgs->num; i++) { for (i = 0; i < pkgs->num; i++) {
...@@ -113,7 +124,8 @@ static int add_main(void *ctx, int argc, char **argv) ...@@ -113,7 +124,8 @@ static int add_main(void *ctx, int argc, char **argv)
apk_error("Unable to install '%s'", pkgs->item[i].name->name); apk_error("Unable to install '%s'", pkgs->item[i].name->name);
goto err; goto err;
} }
apk_deps_add(&db.world, &pkgs->item[i]); if (!virtpkg)
apk_deps_add(&db.world, &pkgs->item[i]);
} }
r = apk_state_commit(state, &db); r = apk_state_commit(state, &db);
err: err:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment