Commit a787038d authored by Timo Teräs's avatar Timo Teräs

pkg, info: remember installed packages "replaces"

"replaces" is now turned to a full dependency type list, so you can
make package overwrite files only certain versions of the package
(though, we should probably take this into account already at solution
calculation phase).

Also make 'info --replaces' print the "replaces" of the package.

This is in preparation for the policy package support, which still
requires "replacement priority" field to decide which packages' files
get the preference.
parent afd854a3
...@@ -107,8 +107,9 @@ static int add_main(void *ctx, struct apk_database *db, int argc, char **argv) ...@@ -107,8 +107,9 @@ static int add_main(void *ctx, struct apk_database *db, int argc, char **argv)
} }
apk_dep_from_pkg(&dep, db, pkg); apk_dep_from_pkg(&dep, db, pkg);
} else { } else {
r = apk_dep_from_blob(&dep, db, APK_BLOB_STR(argv[i])); apk_blob_t b = APK_BLOB_STR(argv[i]);
if (r != 0) apk_blob_pull_dep(&b, db, &dep);
if (APK_BLOB_IS_NULL(b))
return -1; return -1;
} }
......
...@@ -74,6 +74,7 @@ struct apk_installed_package { ...@@ -74,6 +74,7 @@ struct apk_installed_package {
apk_blob_t script[APK_SCRIPT_MAX]; apk_blob_t script[APK_SCRIPT_MAX];
struct apk_string_array *triggers; struct apk_string_array *triggers;
struct apk_string_array *pending_triggers; struct apk_string_array *pending_triggers;
struct apk_dependency_array *replaces;
}; };
#define APK_PKG_UNINSTALLABLE ((char*) -1) #define APK_PKG_UNINSTALLABLE ((char*) -1)
...@@ -115,22 +116,21 @@ int apk_sign_ctx_verify_tar(void *ctx, const struct apk_file_info *fi, ...@@ -115,22 +116,21 @@ int apk_sign_ctx_verify_tar(void *ctx, const struct apk_file_info *fi,
struct apk_istream *is); struct apk_istream *is);
int apk_sign_ctx_mpart_cb(void *ctx, int part, apk_blob_t blob); int apk_sign_ctx_mpart_cb(void *ctx, int part, apk_blob_t blob);
int apk_dep_from_blob(struct apk_dependency *dep, struct apk_database *db,
apk_blob_t blob);
void apk_dep_from_pkg(struct apk_dependency *dep, struct apk_database *db, void apk_dep_from_pkg(struct apk_dependency *dep, struct apk_database *db,
struct apk_package *pkg); struct apk_package *pkg);
int apk_dep_is_satisfied(struct apk_dependency *dep, struct apk_package *pkg); int apk_dep_is_satisfied(struct apk_dependency *dep, struct apk_package *pkg);
void apk_blob_push_dep(apk_blob_t *to, struct apk_dependency *dep); void apk_blob_push_dep(apk_blob_t *to, struct apk_dependency *dep);
void apk_blob_push_deps(apk_blob_t *to, struct apk_dependency_array *deps);
void apk_blob_pull_dep(apk_blob_t *from, struct apk_database *, struct apk_dependency *);
void apk_blob_pull_deps(apk_blob_t *from, struct apk_database *, struct apk_dependency_array **);
int apk_deps_write(struct apk_dependency_array *deps, struct apk_ostream *os);
int apk_deps_add(struct apk_dependency_array **depends, int apk_deps_add(struct apk_dependency_array **depends,
struct apk_dependency *dep); struct apk_dependency *dep);
void apk_deps_del(struct apk_dependency_array **deps, void apk_deps_del(struct apk_dependency_array **deps,
struct apk_name *name); struct apk_name *name);
void apk_deps_parse(struct apk_database *db,
struct apk_dependency_array **depends,
apk_blob_t blob);
int apk_deps_write(struct apk_dependency_array *deps, struct apk_ostream *os);
int apk_script_type(const char *name); int apk_script_type(const char *name);
void apk_pkg_format_plain(struct apk_package *pkg, apk_blob_t to); void apk_pkg_format_plain(struct apk_package *pkg, apk_blob_t to);
......
...@@ -75,7 +75,6 @@ struct install_ctx { ...@@ -75,7 +75,6 @@ struct install_ctx {
struct apk_db_dir_instance *diri; struct apk_db_dir_instance *diri;
struct apk_checksum data_csum; struct apk_checksum data_csum;
struct apk_sign_ctx sctx; struct apk_sign_ctx sctx;
struct apk_name_array *replaces;
apk_progress_cb cb; apk_progress_cb cb;
void *cb_ctx; void *cb_ctx;
...@@ -668,6 +667,10 @@ int apk_db_index_read(struct apk_database *db, struct apk_bstream *bs, int repo) ...@@ -668,6 +667,10 @@ int apk_db_index_read(struct apk_database *db, struct apk_bstream *bs, int repo)
} }
apk_blob_pull_csum(&l, &file->csum); apk_blob_pull_csum(&l, &file->csum);
break; break;
case 'r':
if (ipkg != NULL)
apk_blob_pull_deps(&l, db, &ipkg->replaces);
break;
default: default:
if (r != 0 && !(apk_flags & APK_FORCE)) { if (r != 0 && !(apk_flags & APK_FORCE)) {
/* Installed db should not have unsupported fields */ /* Installed db should not have unsupported fields */
...@@ -704,6 +707,12 @@ static int apk_db_write_fdb(struct apk_database *db, struct apk_ostream *os) ...@@ -704,6 +707,12 @@ static int apk_db_write_fdb(struct apk_database *db, struct apk_ostream *os)
if (r < 0) if (r < 0)
return r; return r;
if (ipkg->replaces->num) {
apk_blob_push_blob(&bbuf, APK_BLOB_STR("r:"));
apk_blob_push_deps(&bbuf, ipkg->replaces);
apk_blob_push_blob(&bbuf, APK_BLOB_STR("\n"));
}
hlist_for_each_entry(diri, c1, &ipkg->owned_dirs, pkg_dirs_list) { hlist_for_each_entry(diri, c1, &ipkg->owned_dirs, pkg_dirs_list) {
apk_blob_push_blob(&bbuf, APK_BLOB_STR("F:")); apk_blob_push_blob(&bbuf, APK_BLOB_STR("F:"));
apk_blob_push_blob(&bbuf, APK_BLOB_PTR_LEN(diri->dir->name, diri->dir->namelen)); apk_blob_push_blob(&bbuf, APK_BLOB_PTR_LEN(diri->dir->name, diri->dir->namelen));
...@@ -897,7 +906,7 @@ static int apk_db_read_state(struct apk_database *db, int flags) ...@@ -897,7 +906,7 @@ static int apk_db_read_state(struct apk_database *db, int flags)
blob = apk_blob_from_file(db->root_fd, apk_world_file); blob = apk_blob_from_file(db->root_fd, apk_world_file);
if (APK_BLOB_IS_NULL(blob)) if (APK_BLOB_IS_NULL(blob))
return -ENOENT; return -ENOENT;
apk_deps_parse(db, &db->world, blob); apk_blob_pull_deps(&blob, db, &db->world);
free(blob.ptr); free(blob.ptr);
} }
...@@ -1757,17 +1766,6 @@ static int apk_db_run_pending_script(struct install_ctx *ctx) ...@@ -1757,17 +1766,6 @@ static int apk_db_run_pending_script(struct install_ctx *ctx)
return r; return r;
} }
static int parse_replaces(void *_ctx, apk_blob_t blob)
{
struct install_ctx *ctx = (struct install_ctx *) _ctx;
if (blob.len == 0)
return 0;
*apk_name_array_add(&ctx->replaces) = apk_db_get_name(ctx->db, blob);
return 0;
}
static int read_info_line(void *_ctx, apk_blob_t line) static int read_info_line(void *_ctx, apk_blob_t line)
{ {
struct install_ctx *ctx = (struct install_ctx *) _ctx; struct install_ctx *ctx = (struct install_ctx *) _ctx;
...@@ -1782,7 +1780,7 @@ static int read_info_line(void *_ctx, apk_blob_t line) ...@@ -1782,7 +1780,7 @@ static int read_info_line(void *_ctx, apk_blob_t line)
return 0; return 0;
if (apk_blob_compare(APK_BLOB_STR("replaces"), l) == 0) { if (apk_blob_compare(APK_BLOB_STR("replaces"), l) == 0) {
apk_blob_for_each_segment(r, " ", parse_replaces, ctx); apk_blob_pull_deps(&r, db, &ctx->ipkg->replaces);
} else if (apk_blob_compare(APK_BLOB_STR("triggers"), l) == 0) { } else if (apk_blob_compare(APK_BLOB_STR("triggers"), l) == 0) {
apk_string_array_resize(&ipkg->triggers, 0); apk_string_array_resize(&ipkg->triggers, 0);
apk_blob_for_each_segment(r, " ", parse_triggers, ctx->ipkg); apk_blob_for_each_segment(r, " ", parse_triggers, ctx->ipkg);
...@@ -1878,11 +1876,20 @@ static int apk_db_install_archive_entry(void *_ctx, ...@@ -1878,11 +1876,20 @@ static int apk_db_install_archive_entry(void *_ctx,
/* Upgrading package? */ /* Upgrading package? */
if (opkg->name == pkg->name) if (opkg->name == pkg->name)
break; break;
/* If we have been replaced, skip file silently. */
for (i = 0; i < opkg->ipkg->replaces->num; i++) {
if (apk_dep_is_satisfied(&opkg->ipkg->replaces->item[i], pkg)) {
apk_warning("%s: Dropping silently %s owned by %s.",
pkg->name->name, ae->name,
opkg->name->name);
return 0;
}
}
/* Overwriting with permission? */ /* Overwriting with permission? */
for (i = 0; i < ctx->replaces->num; i++) for (i = 0; i < ctx->ipkg->replaces->num; i++)
if (opkg->name == ctx->replaces->item[i]) if (apk_dep_is_satisfied(&ctx->ipkg->replaces->item[i], opkg))
break; break;
if (i < ctx->replaces->num) if (i < ctx->ipkg->replaces->num)
break; break;
if (!(apk_flags & APK_FORCE)) { if (!(apk_flags & APK_FORCE)) {
...@@ -2159,12 +2166,10 @@ static int apk_db_unpack_pkg(struct apk_database *db, ...@@ -2159,12 +2166,10 @@ static int apk_db_unpack_pkg(struct apk_database *db,
.cb = cb, .cb = cb,
.cb_ctx = cb_ctx, .cb_ctx = cb_ctx,
}; };
apk_name_array_init(&ctx.replaces);
apk_sign_ctx_init(&ctx.sctx, APK_SIGN_VERIFY_IDENTITY, &pkg->csum, db->keys_fd); apk_sign_ctx_init(&ctx.sctx, APK_SIGN_VERIFY_IDENTITY, &pkg->csum, db->keys_fd);
tar = apk_bstream_gunzip_mpart(bs, apk_sign_ctx_mpart_cb, &ctx.sctx); tar = apk_bstream_gunzip_mpart(bs, apk_sign_ctx_mpart_cb, &ctx.sctx);
r = apk_tar_parse(tar, apk_db_install_archive_entry, &ctx, TRUE, &db->id_cache); r = apk_tar_parse(tar, apk_db_install_archive_entry, &ctx, TRUE, &db->id_cache);
apk_sign_ctx_free(&ctx.sctx); apk_sign_ctx_free(&ctx.sctx);
apk_name_array_free(&ctx.replaces);
tar->close(tar); tar->close(tar);
if (need_copy) { if (need_copy) {
......
...@@ -34,6 +34,7 @@ struct info_ctx { ...@@ -34,6 +34,7 @@ struct info_ctx {
#define APK_INFO_TRIGGERS 0x40 #define APK_INFO_TRIGGERS 0x40
#define APK_INFO_INSTALL_IF 0x80 #define APK_INFO_INSTALL_IF 0x80
#define APK_INFO_RINSTALL_IF 0x100 #define APK_INFO_RINSTALL_IF 0x100
#define APK_INFO_REPLACES 0x200
static void verbose_print_pkg(struct apk_package *pkg, int minimal_verbosity) static void verbose_print_pkg(struct apk_package *pkg, int minimal_verbosity)
{ {
...@@ -69,14 +70,15 @@ static int info_exists(struct info_ctx *ctx, struct apk_database *db, ...@@ -69,14 +70,15 @@ static int info_exists(struct info_ctx *ctx, struct apk_database *db,
struct apk_name *name; struct apk_name *name;
struct apk_package *pkg = NULL; struct apk_package *pkg = NULL;
struct apk_dependency dep; struct apk_dependency dep;
int r, i, j, ok = 0; int i, j, ok = 0;
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
r = apk_dep_from_blob(&dep, db, APK_BLOB_STR(argv[i])); apk_blob_t b = APK_BLOB_STR(argv[i]);
if (r != 0) apk_blob_pull_dep(&b, db, &dep);
name = dep.name;
if (name == NULL)
continue; continue;
name = dep.name;
for (j = 0; j < name->pkgs->num; j++) { for (j = 0; j < name->pkgs->num; j++) {
pkg = name->pkgs->item[j]; pkg = name->pkgs->item[j];
if (pkg->ipkg != NULL) if (pkg->ipkg != NULL)
...@@ -309,6 +311,26 @@ static void info_print_triggers(struct apk_package *pkg) ...@@ -309,6 +311,26 @@ static void info_print_triggers(struct apk_package *pkg)
} }
} }
static void info_print_replaces(struct apk_package *pkg)
{
apk_blob_t separator = APK_BLOB_STR(apk_verbosity > 1 ? " " : "\n");
char dep[256];
int i;
if (apk_verbosity == 1)
printf(PKG_VER_FMT " replaces:\n",
PKG_VER_PRINTF(pkg));
if (apk_verbosity > 1)
printf("%s: ", pkg->name->name);
for (i = 0; i < pkg->ipkg->replaces->num; i++) {
apk_blob_t b = APK_BLOB_BUF(dep);
apk_blob_push_dep(&b, &pkg->ipkg->replaces->item[i]);
apk_blob_push_blob(&b, separator);
b = apk_blob_pushed(APK_BLOB_BUF(dep), b);
fwrite(b.ptr, b.len, 1, stdout);
}
}
static void info_subaction(struct info_ctx *ctx, struct apk_package *pkg) static void info_subaction(struct info_ctx *ctx, struct apk_package *pkg)
{ {
typedef void (*subaction_t)(struct apk_package *); typedef void (*subaction_t)(struct apk_package *);
...@@ -322,10 +344,11 @@ static void info_subaction(struct info_ctx *ctx, struct apk_package *pkg) ...@@ -322,10 +344,11 @@ static void info_subaction(struct info_ctx *ctx, struct apk_package *pkg)
info_print_triggers, info_print_triggers,
info_print_install_if, info_print_install_if,
info_print_rinstall_if, info_print_rinstall_if,
info_print_replaces,
}; };
const int requireipkg = const int requireipkg =
APK_INFO_CONTENTS | APK_INFO_TRIGGERS | APK_INFO_RDEPENDS | APK_INFO_CONTENTS | APK_INFO_TRIGGERS | APK_INFO_RDEPENDS |
APK_INFO_RINSTALL_IF; APK_INFO_RINSTALL_IF | APK_INFO_REPLACES;
int i; int i;
for (i = 0; i < ARRAY_SIZE(subactions); i++) { for (i = 0; i < ARRAY_SIZE(subactions); i++) {
...@@ -398,6 +421,9 @@ static int info_parse(void *ctx, struct apk_db_options *dbopts, ...@@ -398,6 +421,9 @@ static int info_parse(void *ctx, struct apk_db_options *dbopts,
case 't': case 't':
ictx->subaction_mask |= APK_INFO_TRIGGERS; ictx->subaction_mask |= APK_INFO_TRIGGERS;
break; break;
case 0x10000:
ictx->subaction_mask |= APK_INFO_REPLACES;
break;
case 'a': case 'a':
ictx->subaction_mask = 0xffffffff; ictx->subaction_mask = 0xffffffff;
break; break;
...@@ -423,6 +449,7 @@ static struct apk_option info_options[] = { ...@@ -423,6 +449,7 @@ static struct apk_option info_options[] = {
{ 'W', "who-owns", "Print the package owning the specified file" }, { 'W', "who-owns", "Print the package owning the specified file" },
{ 'R', "depends", "List packages that the PACKAGE depends on" }, { 'R', "depends", "List packages that the PACKAGE depends on" },
{ 'r', "rdepends", "List all packages depending on PACKAGE" }, { 'r', "rdepends", "List all packages depending on PACKAGE" },
{ 0x10000, "replaces", "List packages whom files PACKAGE might replace" },
{ 'i', "install-if", "List the PACKAGE's install-if rule" }, { 'i', "install-if", "List the PACKAGE's install-if rule" },
{ 'I', "rinstall-if", "List all packages having install-if referencing PACKAGE" }, { 'I', "rinstall-if", "List all packages having install-if referencing PACKAGE" },
{ 'w', "webpage", "Show URL for more information about PACKAGE" }, { 'w', "webpage", "Show URL for more information about PACKAGE" },
......
...@@ -77,6 +77,7 @@ struct apk_installed_package *apk_pkg_install(struct apk_database *db, ...@@ -77,6 +77,7 @@ struct apk_installed_package *apk_pkg_install(struct apk_database *db,
ipkg->pkg = pkg; ipkg->pkg = pkg;
apk_string_array_init(&ipkg->triggers); apk_string_array_init(&ipkg->triggers);
apk_string_array_init(&ipkg->pending_triggers); apk_string_array_init(&ipkg->pending_triggers);
apk_dependency_array_init(&ipkg->replaces);
/* Overlay override information resides in a nameless package */ /* Overlay override information resides in a nameless package */
if (pkg->name != NULL) { if (pkg->name != NULL) {
...@@ -109,6 +110,7 @@ void apk_pkg_uninstall(struct apk_database *db, struct apk_package *pkg) ...@@ -109,6 +110,7 @@ void apk_pkg_uninstall(struct apk_database *db, struct apk_package *pkg)
} }
apk_string_array_free(&ipkg->triggers); apk_string_array_free(&ipkg->triggers);
apk_string_array_free(&ipkg->pending_triggers); apk_string_array_free(&ipkg->pending_triggers);
apk_dependency_array_free(&ipkg->replaces);
for (i = 0; i < APK_SCRIPT_MAX; i++) for (i = 0; i < APK_SCRIPT_MAX; i++)
if (ipkg->script[i].ptr != NULL) if (ipkg->script[i].ptr != NULL)
...@@ -189,26 +191,28 @@ struct parse_depend_ctx { ...@@ -189,26 +191,28 @@ struct parse_depend_ctx {
struct apk_dependency_array **depends; struct apk_dependency_array **depends;
}; };
int apk_dep_from_blob(struct apk_dependency *dep, struct apk_database *db, void apk_blob_pull_dep(apk_blob_t *b, struct apk_database *db, struct apk_dependency *dep)
apk_blob_t blob)
{ {
struct apk_name *name; struct apk_name *name;
apk_blob_t bname, bop, bver = APK_BLOB_NULL; apk_blob_t bname, bop, bver = APK_BLOB_NULL;
int mask = APK_DEPMASK_REQUIRE; int mask = APK_DEPMASK_REQUIRE;
size_t len;
/* [!]name[<,<=,=,>=,>]ver */ /* [!]name[<,<=,=,>=,>]ver */
if (blob.ptr[0] == '!') { if (APK_BLOB_IS_NULL(*b))
goto fail;
if (b->ptr[0] == '!') {
mask = 0; mask = 0;
blob.ptr++; b->ptr++;
blob.len--; b->len--;
} }
if (apk_blob_cspn(blob, "<>=", &bname, &bop)) { if (apk_blob_cspn(*b, "<>= ", &bname, &bop)) {
int i; int i;
if (mask == 0) if (mask == 0)
return -EINVAL; goto fail;
if (!apk_blob_spn(bop, "<>=", &bop, &bver)) if (!apk_blob_spn(bop, "<>=", &bop, &bver))
return -EINVAL; goto fail;
mask = 0; mask = 0;
for (i = 0; i < bop.len; i++) { for (i = 0; i < bop.len; i++) {
switch (bop.ptr[i]) { switch (bop.ptr[i]) {
...@@ -225,21 +229,29 @@ int apk_dep_from_blob(struct apk_dependency *dep, struct apk_database *db, ...@@ -225,21 +229,29 @@ int apk_dep_from_blob(struct apk_dependency *dep, struct apk_database *db,
} }
if ((mask & APK_DEPMASK_CHECKSUM) != APK_DEPMASK_CHECKSUM && if ((mask & APK_DEPMASK_CHECKSUM) != APK_DEPMASK_CHECKSUM &&
!apk_version_validate(bver)) !apk_version_validate(bver))
return -EINVAL; goto fail;
} else {
blob = bname; bname = *b;
bop = APK_BLOB_NULL;
bver = APK_BLOB_NULL;
} }
len = bname.len + bop.len + bver.len;
b->ptr += len;
b->len -= len;
name = apk_db_get_name(db, blob); name = apk_db_get_name(db, bname);
if (name == NULL) if (name == NULL)
return -ENOENT; goto fail;
*dep = (struct apk_dependency){ *dep = (struct apk_dependency){
.name = name, .name = name,
.version = apk_blob_atomize_dup(bver), .version = apk_blob_atomize_dup(bver),
.result_mask = mask, .result_mask = mask,
}; };
return 0; return;
fail:
*dep = (struct apk_dependency){ .name = NULL };
*b = APK_BLOB_NULL;
} }
void apk_dep_from_pkg(struct apk_dependency *dep, struct apk_database *db, void apk_dep_from_pkg(struct apk_dependency *dep, struct apk_database *db,
...@@ -266,7 +278,8 @@ static int parse_depend(void *ctx, apk_blob_t blob) ...@@ -266,7 +278,8 @@ static int parse_depend(void *ctx, apk_blob_t blob)
if (blob.len == 0) if (blob.len == 0)
return 0; return 0;
if (apk_dep_from_blob(&p, pctx->db, blob) < 0) apk_blob_pull_dep(&blob, pctx->db, &p);
if (p.name == NULL || blob.len != 0)
return -1; return -1;
dep = apk_dependency_array_add(pctx->depends); dep = apk_dependency_array_add(pctx->depends);
...@@ -301,16 +314,14 @@ int apk_dep_is_satisfied(struct apk_dependency *dep, struct apk_package *pkg) ...@@ -301,16 +314,14 @@ int apk_dep_is_satisfied(struct apk_dependency *dep, struct apk_package *pkg)
return 0; return 0;
} }
void apk_deps_parse(struct apk_database *db, void apk_blob_pull_deps(apk_blob_t *b, struct apk_database *db, struct apk_dependency_array **deps)
struct apk_dependency_array **depends,
apk_blob_t blob)
{ {
struct parse_depend_ctx ctx = { db, depends }; struct parse_depend_ctx ctx = { db, deps };
if (blob.len > 0 && blob.ptr[blob.len-1] == '\n') if (b->len > 0 && b->ptr[b->len-1] == '\n')
blob.len--; b->len--;
apk_blob_for_each_segment(blob, " ", parse_depend, &ctx); apk_blob_for_each_segment(*b, " ", parse_depend, &ctx);
} }
void apk_blob_push_dep(apk_blob_t *to, struct apk_dependency *dep) void apk_blob_push_dep(apk_blob_t *to, struct apk_dependency *dep)
...@@ -327,6 +338,20 @@ void apk_blob_push_dep(apk_blob_t *to, struct apk_dependency *dep) ...@@ -327,6 +338,20 @@ void apk_blob_push_dep(apk_blob_t *to, struct apk_dependency *dep)
} }
} }
void apk_blob_push_deps(apk_blob_t *to, struct apk_dependency_array *deps)
{
int i;
if (deps == NULL)
return;
for (i = 0; i < deps->num; i++) {
if (i)
apk_blob_push_blob(to, APK_BLOB_PTR_LEN(" ", 1));
apk_blob_push_dep(to, &deps->item[i]);
}
}
int apk_deps_write(struct apk_dependency_array *deps, struct apk_ostream *os) int apk_deps_write(struct apk_dependency_array *deps, struct apk_ostream *os)
{ {
apk_blob_t blob; apk_blob_t blob;
...@@ -657,7 +682,7 @@ int apk_pkg_add_info(struct apk_database *db, struct apk_package *pkg, ...@@ -657,7 +682,7 @@ int apk_pkg_add_info(struct apk_database *db, struct apk_package *pkg,
pkg->arch = apk_blob_atomize_dup(value); pkg->arch = apk_blob_atomize_dup(value);
break; break;
case 'D': case 'D':
apk_deps_parse(db, &pkg->depends, value); apk_blob_pull_deps(&value, db, &pkg->depends);
break; break;
case 'C': case 'C':
apk_blob_pull_csum(&value, &pkg->csum); apk_blob_pull_csum(&value, &pkg->csum);
...@@ -669,7 +694,7 @@ int apk_pkg_add_info(struct apk_database *db, struct apk_package *pkg, ...@@ -669,7 +694,7 @@ int apk_pkg_add_info(struct apk_database *db, struct apk_package *pkg,
pkg->installed_size = apk_blob_pull_uint(&value, 10); pkg->installed_size = apk_blob_pull_uint(&value, 10);
break; break;
case 'i': case 'i':
apk_deps_parse(db, &pkg->install_if, value); apk_blob_pull_deps(&value, db, &pkg->install_if);
break; break;
case 'o': case 'o':
pkg->origin = apk_blob_atomize_dup(value); pkg->origin = apk_blob_atomize_dup(value);
...@@ -683,7 +708,7 @@ int apk_pkg_add_info(struct apk_database *db, struct apk_package *pkg, ...@@ -683,7 +708,7 @@ int apk_pkg_add_info(struct apk_database *db, struct apk_package *pkg,
case 'c': case 'c':
pkg->commit = apk_blob_cstr(value); pkg->commit = apk_blob_cstr(value);
break; break;
case 'F': case 'M': case 'R': case 'Z': case 'F': case 'M': case 'R': case 'Z': case 'r':
/* installed db entries which are handled in database.c */ /* installed db entries which are handled in database.c */
return 1; return 1;
default: default:
......
...@@ -147,6 +147,7 @@ static int test_main(void *pctx, struct apk_database *db, int argc, char **argv) ...@@ -147,6 +147,7 @@ static int test_main(void *pctx, struct apk_database *db, int argc, char **argv)
struct apk_bstream *bs; struct apk_bstream *bs;
struct apk_package_array *solution = NULL; struct apk_package_array *solution = NULL;
struct apk_changeset changeset = {}; struct apk_changeset changeset = {};
apk_blob_t b;
int i, r; int i, r;
if (argc != 1) if (argc != 1)
...@@ -173,7 +174,8 @@ static int test_main(void *pctx, struct apk_database *db, int argc, char **argv) ...@@ -173,7 +174,8 @@ static int test_main(void *pctx, struct apk_database *db, int argc, char **argv)
} }
/* construct new world */ /* construct new world */
apk_deps_parse(db, &db->world, APK_BLOB_STR(argv[0])); b = APK_BLOB_STR(argv[0]);
apk_blob_pull_deps(&b, db, &db->world);
/* run solver */ /* run solver */
r = apk_solver_solve(db, ctx->solver_flags, db->world, &solution, &changeset); r = apk_solver_solve(db, ctx->solver_flags, db->world, &solution, &changeset);
......
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