Commit 972bec32 authored by Timo Teräs's avatar Timo Teräs
Browse files

various: use 'atoms' for certain package field and misc fixes

 - implement a hash table for commonly shared fields such as
   license, version and architecture
 - use macroes to print blobs or pkgname-pkgver strings
 - fix some old cruft
parent fca1c30b
...@@ -78,7 +78,7 @@ static int add_main(void *ctx, struct apk_database *db, int argc, char **argv) ...@@ -78,7 +78,7 @@ static int add_main(void *ctx, struct apk_database *db, int argc, char **argv)
virtpkg->name = apk_db_get_name(db, APK_BLOB_STR(actx->virtpkg)); virtpkg->name = apk_db_get_name(db, APK_BLOB_STR(actx->virtpkg));
apk_blob_checksum(APK_BLOB_STR(virtpkg->name->name), apk_blob_checksum(APK_BLOB_STR(virtpkg->name->name),
apk_checksum_default(), &virtpkg->csum); apk_checksum_default(), &virtpkg->csum);
virtpkg->version = strdup("0"); virtpkg->version = apk_blob_atomize(APK_BLOB_STR("0"));
virtpkg->description = strdup("virtual meta package"); virtpkg->description = strdup("virtual meta package");
apk_dep_from_pkg(&virtdep, db, virtpkg); apk_dep_from_pkg(&virtdep, db, virtpkg);
virtdep.name->flags |= APK_NAME_TOPLEVEL; virtdep.name->flags |= APK_NAME_TOPLEVEL;
......
...@@ -247,6 +247,7 @@ int main(int argc, char **argv) ...@@ -247,6 +247,7 @@ int main(int argc, char **argv)
memset(&dbopts, 0, sizeof(dbopts)); memset(&dbopts, 0, sizeof(dbopts));
list_init(&dbopts.repository_list); list_init(&dbopts.repository_list);
apk_atom_init();
umask(0); umask(0);
applet = deduce_applet(argc, argv); applet = deduce_applet(argc, argv);
......
...@@ -24,6 +24,9 @@ struct apk_blob { ...@@ -24,6 +24,9 @@ struct apk_blob {
typedef struct apk_blob apk_blob_t; typedef struct apk_blob apk_blob_t;
typedef int (*apk_blob_cb)(void *ctx, apk_blob_t blob); typedef int (*apk_blob_cb)(void *ctx, apk_blob_t blob);
#define BLOB_FMT "%.*s"
#define BLOB_PRINTF(b) (int)(b).len, (b).ptr
#define APK_CHECKSUM_NONE 0 #define APK_CHECKSUM_NONE 0
#define APK_CHECKSUM_MD5 16 #define APK_CHECKSUM_MD5 16
#define APK_CHECKSUM_SHA1 20 #define APK_CHECKSUM_SHA1 20
...@@ -114,4 +117,8 @@ struct apk_indent { ...@@ -114,4 +117,8 @@ struct apk_indent {
void apk_print_indented_words(struct apk_indent *i, const char *text); void apk_print_indented_words(struct apk_indent *i, const char *text);
int apk_print_indented(struct apk_indent *i, apk_blob_t blob); int apk_print_indented(struct apk_indent *i, apk_blob_t blob);
void apk_atom_init(void);
apk_blob_t *apk_blob_atomize(apk_blob_t blob);
apk_blob_t *apk_blob_atomize_dup(apk_blob_t blob);
#endif #endif
...@@ -103,7 +103,8 @@ struct apk_database { ...@@ -103,7 +103,8 @@ struct apk_database {
char *root; char *root;
int root_fd, lock_fd, cache_fd, cachetmp_fd, keys_fd; int root_fd, lock_fd, cache_fd, cachetmp_fd, keys_fd;
unsigned name_id, num_repos; unsigned name_id, num_repos;
const char *cache_dir, *arch; const char *cache_dir;
apk_blob_t *arch;
int permanent; int permanent;
unsigned int local_repos; unsigned int local_repos;
......
...@@ -63,8 +63,8 @@ struct apk_sign_ctx { ...@@ -63,8 +63,8 @@ struct apk_sign_ctx {
struct apk_dependency { struct apk_dependency {
struct apk_name *name; struct apk_name *name;
apk_blob_t *version;
int result_mask; int result_mask;
char *version;
}; };
APK_ARRAY(apk_dependency_array, struct apk_dependency); APK_ARRAY(apk_dependency_array, struct apk_dependency);
...@@ -83,18 +83,21 @@ struct apk_installed_package { ...@@ -83,18 +83,21 @@ struct apk_installed_package {
struct apk_package { struct apk_package {
apk_hash_node hash_node; apk_hash_node hash_node;
unsigned repos;
struct apk_name *name; struct apk_name *name;
char *version, *arch; struct apk_installed_package *ipkg;
char *url, *description, *license; apk_blob_t *version, *arch, *license;
char *url, *description;
char *filename;
struct apk_dependency_array *depends; struct apk_dependency_array *depends;
size_t installed_size, size; size_t installed_size, size;
char *filename; unsigned repos;
struct apk_checksum csum; struct apk_checksum csum;
struct apk_installed_package *ipkg;
}; };
APK_ARRAY(apk_package_array, struct apk_package *); APK_ARRAY(apk_package_array, struct apk_package *);
#define PKG_VER_FMT "%s-" BLOB_FMT
#define PKG_VER_PRINTF(pkg) pkg->name->name, BLOB_PRINTF(*pkg->version)
extern const char *apk_script_types[]; extern const char *apk_script_types[];
void apk_sign_ctx_init(struct apk_sign_ctx *ctx, int action, void apk_sign_ctx_init(struct apk_sign_ctx *ctx, int action,
......
...@@ -11,8 +11,15 @@ ...@@ -11,8 +11,15 @@
#include <malloc.h> #include <malloc.h>
#include <string.h> #include <string.h>
#include <printf.h>
#include "apk_blob.h" #include "apk_blob.h"
#include "apk_hash.h"
struct apk_blob_atom {
struct hlist_node hash_node;
apk_blob_t blob;
};
char *apk_blob_cstr(apk_blob_t blob) char *apk_blob_cstr(apk_blob_t blob)
{ {
...@@ -432,3 +439,63 @@ void apk_blob_pull_base64(apk_blob_t *b, apk_blob_t to) ...@@ -432,3 +439,63 @@ void apk_blob_pull_base64(apk_blob_t *b, apk_blob_t to)
b->ptr += needed; b->ptr += needed;
b->len -= needed; b->len -= needed;
} }
static apk_blob_t atom_hash_get_key(apk_hash_item item)
{
return ((struct apk_blob_atom *) item)->blob;
}
static struct apk_hash atom_hash;
static struct apk_hash_ops atom_ops = {
.node_offset = offsetof(struct apk_blob_atom, hash_node),
.get_key = atom_hash_get_key,
.hash_key = apk_blob_hash,
.compare = apk_blob_compare,
.delete_item = (apk_hash_delete_f) free,
};
static apk_blob_t null_blob = {0,0};
void apk_atom_init(void)
{
apk_hash_init(&atom_hash, &atom_ops, 2048);
}
apk_blob_t *apk_blob_atomize(apk_blob_t blob)
{
struct apk_blob_atom *atom;
unsigned long hash = apk_hash_from_key(&atom_hash, blob);
if (blob.len < 0 || blob.ptr == NULL)
return &null_blob;
atom = (struct apk_blob_atom *) apk_hash_get_hashed(&atom_hash, blob, hash);
if (atom != NULL)
return &atom->blob;
atom = malloc(sizeof(*atom));
atom->blob = blob;
apk_hash_insert_hashed(&atom_hash, atom, hash);
return &atom->blob;
}
apk_blob_t *apk_blob_atomize_dup(apk_blob_t blob)
{
struct apk_blob_atom *atom;
unsigned long hash = apk_hash_from_key(&atom_hash, blob);
char *ptr;
if (blob.len < 0 || blob.ptr == NULL)
return &null_blob;
atom = (struct apk_blob_atom *) apk_hash_get_hashed(&atom_hash, blob, hash);
if (atom != NULL)
return &atom->blob;
atom = malloc(sizeof(*atom) + blob.len);
ptr = (char*) (atom + 1);
memcpy(ptr, blob.ptr, blob.len);
atom->blob = APK_BLOB_PTR_LEN(ptr, blob.len);
apk_hash_insert_hashed(&atom_hash, atom, hash);
return &atom->blob;
}
...@@ -453,9 +453,9 @@ int apk_cache_download(struct apk_database *db, const char *url, ...@@ -453,9 +453,9 @@ int apk_cache_download(struct apk_database *db, const char *url,
char fullurl[PATH_MAX]; char fullurl[PATH_MAX];
int r; int r;
snprintf(fullurl, sizeof(fullurl), "%s%s%s/%s", snprintf(fullurl, sizeof(fullurl), "%s%s" BLOB_FMT "/%s",
url, url[strlen(url)-1] == '/' ? "" : "/", url, url[strlen(url)-1] == '/' ? "" : "/",
db->arch, item); BLOB_PRINTF(*db->arch), item);
apk_message("fetch %s", fullurl); apk_message("fetch %s", fullurl);
if (apk_flags & APK_SIMULATE) if (apk_flags & APK_SIMULATE)
...@@ -738,7 +738,7 @@ static int apk_db_scriptdb_write(struct apk_database *db, struct apk_ostream *os ...@@ -738,7 +738,7 @@ static int apk_db_scriptdb_write(struct apk_database *db, struct apk_ostream *os
bfn = APK_BLOB_BUF(filename); bfn = APK_BLOB_BUF(filename);
apk_blob_push_blob(&bfn, APK_BLOB_STR(pkg->name->name)); apk_blob_push_blob(&bfn, APK_BLOB_STR(pkg->name->name));
apk_blob_push_blob(&bfn, APK_BLOB_STR("-")); apk_blob_push_blob(&bfn, APK_BLOB_STR("-"));
apk_blob_push_blob(&bfn, APK_BLOB_STR(pkg->version)); apk_blob_push_blob(&bfn, *pkg->version);
apk_blob_push_blob(&bfn, APK_BLOB_STR(".")); apk_blob_push_blob(&bfn, APK_BLOB_STR("."));
apk_blob_push_csum(&bfn, &pkg->csum); apk_blob_push_csum(&bfn, &pkg->csum);
apk_blob_push_blob(&bfn, APK_BLOB_STR(".")); apk_blob_push_blob(&bfn, APK_BLOB_STR("."));
...@@ -1122,8 +1122,7 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts) ...@@ -1122,8 +1122,7 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
blob = APK_BLOB_STR("etc:*etc/init.d"); blob = APK_BLOB_STR("etc:*etc/init.d");
apk_blob_for_each_segment(blob, ":", add_protected_path, db); apk_blob_for_each_segment(blob, ":", add_protected_path, db);
db->arch = apk_arch; db->arch = apk_blob_atomize(APK_BLOB_STR(apk_arch));
db->cache_fd = openat(db->root_fd, db->cache_dir, O_RDONLY | O_CLOEXEC); db->cache_fd = openat(db->root_fd, db->cache_dir, O_RDONLY | O_CLOEXEC);
mkdirat(db->cache_fd, "tmp", 0644); mkdirat(db->cache_fd, "tmp", 0644);
db->cachetmp_fd = openat(db->cache_fd, "tmp", O_RDONLY | O_CLOEXEC); db->cachetmp_fd = openat(db->cache_fd, "tmp", O_RDONLY | O_CLOEXEC);
...@@ -1401,15 +1400,15 @@ static int apk_repo_is_remote(struct apk_repository *repo) ...@@ -1401,15 +1400,15 @@ static int apk_repo_is_remote(struct apk_repository *repo)
} }
static struct apk_bstream *apk_repo_file_open(struct apk_repository *repo, static struct apk_bstream *apk_repo_file_open(struct apk_repository *repo,
const char *arch, apk_blob_t arch,
const char *file, const char *file,
char *buf, int buflen) char *buf, int buflen)
{ {
const char *url = repo->url; const char *url = repo->url;
snprintf(buf, buflen, "%s%s%s/%s", snprintf(buf, buflen, "%s%s" BLOB_FMT "/%s",
url, url[strlen(url)-1] == '/' ? "" : "/", url, url[strlen(url)-1] == '/' ? "" : "/",
arch, file); BLOB_PRINTF(arch), file);
if ((apk_flags & APK_NO_NETWORK) && apk_repo_is_remote(repo)) if ((apk_flags & APK_NO_NETWORK) && apk_repo_is_remote(repo))
return NULL; return NULL;
...@@ -1577,7 +1576,7 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t repository) ...@@ -1577,7 +1576,7 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t repository)
bs = apk_bstream_from_file(db->cache_fd, buf); bs = apk_bstream_from_file(db->cache_fd, buf);
} else { } else {
db->local_repos |= BIT(r); db->local_repos |= BIT(r);
bs = apk_repo_file_open(repo, db->arch, apkindex_tar_gz, buf, sizeof(buf)); bs = apk_repo_file_open(repo, *db->arch, apkindex_tar_gz, buf, sizeof(buf));
} }
if (bs == NULL) { if (bs == NULL) {
apk_warning("Failed to open index for %s", repo->url); apk_warning("Failed to open index for %s", repo->url);
...@@ -1675,7 +1674,6 @@ static int apk_db_install_archive_entry(void *_ctx, ...@@ -1675,7 +1674,6 @@ static int apk_db_install_archive_entry(void *_ctx,
apk_blob_t name = APK_BLOB_STR(ae->name), bdir, bfile; apk_blob_t name = APK_BLOB_STR(ae->name), bdir, bfile;
struct apk_db_dir_instance *diri = ctx->diri; struct apk_db_dir_instance *diri = ctx->diri;
struct apk_db_file *file; struct apk_db_file *file;
const char *p;
int r = 0, type = APK_SCRIPT_INVALID; int r = 0, type = APK_SCRIPT_INVALID;
if (apk_sign_ctx_process_file(&ctx->sctx, ae, is) == 0) if (apk_sign_ctx_process_file(&ctx->sctx, ae, is) == 0)
...@@ -1693,19 +1691,6 @@ static int apk_db_install_archive_entry(void *_ctx, ...@@ -1693,19 +1691,6 @@ static int apk_db_install_archive_entry(void *_ctx,
type = apk_script_type(&ae->name[1]); type = apk_script_type(&ae->name[1]);
if (type == APK_SCRIPT_INVALID) if (type == APK_SCRIPT_INVALID)
return 0; return 0;
} else if (strncmp(ae->name, "var/db/apk/", 11) == 0) {
/* APK 1.0 format */
p = &ae->name[11];
if (strncmp(p, pkg->name->name, strlen(pkg->name->name)) != 0)
return 0;
p += strlen(pkg->name->name) + 1;
if (strncmp(p, pkg->version, strlen(pkg->version)) != 0)
return 0;
p += strlen(pkg->version) + 1;
type = apk_script_type(p);
if (type == APK_SCRIPT_INVALID)
return 0;
} }
/* Handle script */ /* Handle script */
...@@ -2001,7 +1986,7 @@ static int apk_db_unpack_pkg(struct apk_database *db, ...@@ -2001,7 +1986,7 @@ static int apk_db_unpack_pkg(struct apk_database *db,
if (bs == NULL) { if (bs == NULL) {
apk_pkg_format_plain(pkg, APK_BLOB_BUF(item)); apk_pkg_format_plain(pkg, APK_BLOB_BUF(item));
bs = apk_repo_file_open(repo, pkg->arch ?: db->arch, item, file, sizeof(file)); bs = apk_repo_file_open(repo, *(pkg->arch ?: db->arch), item, file, sizeof(file));
if (apk_repo_is_remote(repo)) if (apk_repo_is_remote(repo))
need_copy = TRUE; need_copy = TRUE;
} }
...@@ -2076,14 +2061,14 @@ int apk_db_install_pkg(struct apk_database *db, ...@@ -2076,14 +2061,14 @@ int apk_db_install_pkg(struct apk_database *db,
{ {
char *script_args[] = { NULL, NULL, NULL, NULL }; char *script_args[] = { NULL, NULL, NULL, NULL };
struct apk_installed_package *ipkg; struct apk_installed_package *ipkg;
int r; int r = 0;
/* Upgrade script gets two args: <new-pkg> <old-pkg> */ /* Upgrade script gets two args: <new-pkg> <old-pkg> */
if (oldpkg != NULL && newpkg != NULL) { if (oldpkg != NULL && newpkg != NULL) {
script_args[1] = newpkg->version; script_args[1] = apk_blob_cstr(*newpkg->version);
script_args[2] = oldpkg->version; script_args[2] = apk_blob_cstr(*oldpkg->version);
} else { } else {
script_args[1] = oldpkg ? oldpkg->version : newpkg->version; script_args[1] = apk_blob_cstr(*(oldpkg ? oldpkg->version : newpkg->version));
} }
/* Just purging? */ /* Just purging? */
...@@ -2091,19 +2076,18 @@ int apk_db_install_pkg(struct apk_database *db, ...@@ -2091,19 +2076,18 @@ int apk_db_install_pkg(struct apk_database *db,
ipkg = oldpkg->ipkg; ipkg = oldpkg->ipkg;
if (ipkg == NULL) if (ipkg == NULL)
return 0; goto ret_r;
r = apk_ipkg_run_script(ipkg, db, r = apk_ipkg_run_script(ipkg, db,
APK_SCRIPT_PRE_DEINSTALL, script_args); APK_SCRIPT_PRE_DEINSTALL, script_args);
if (r != 0) if (r != 0)
return r; goto ret_r;
apk_db_purge_pkg(db, ipkg, NULL); apk_db_purge_pkg(db, ipkg, NULL);
r = apk_ipkg_run_script(ipkg, db, r = apk_ipkg_run_script(ipkg, db,
APK_SCRIPT_POST_DEINSTALL, script_args); APK_SCRIPT_POST_DEINSTALL, script_args);
apk_pkg_uninstall(db, oldpkg); apk_pkg_uninstall(db, oldpkg);
goto ret_r;
return r;
} }
/* Install the new stuff */ /* Install the new stuff */
...@@ -2121,7 +2105,7 @@ int apk_db_install_pkg(struct apk_database *db, ...@@ -2121,7 +2105,7 @@ int apk_db_install_pkg(struct apk_database *db,
script_args); script_args);
if (r != 0) { if (r != 0) {
apk_pkg_uninstall(db, newpkg); apk_pkg_uninstall(db, newpkg);
return r; goto ret_r;
} }
} }
...@@ -2138,5 +2122,8 @@ int apk_db_install_pkg(struct apk_database *db, ...@@ -2138,5 +2122,8 @@ int apk_db_install_pkg(struct apk_database *db,
apk_error("%s-%s: Failed to execute post-install/upgrade script", apk_error("%s-%s: Failed to execute post-install/upgrade script",
newpkg->name->name, newpkg->version); newpkg->name->name, newpkg->version);
} }
ret_r:
free(script_args[1]);
free(script_args[2]);
return r; return r;
} }
...@@ -145,7 +145,7 @@ static int index_main(void *ctx, struct apk_database *db, int argc, char **argv) ...@@ -145,7 +145,7 @@ static int index_main(void *ctx, struct apk_database *db, int argc, char **argv)
for (j = 0; j < name->pkgs->num; j++) { for (j = 0; j < name->pkgs->num; j++) {
struct apk_package *pkg = name->pkgs->item[j]; struct apk_package *pkg = name->pkgs->item[j];
if (apk_blob_compare(bver, APK_BLOB_STR(pkg->version)) != 0) if (apk_blob_compare(bver, *pkg->version) != 0)
continue; continue;
if (pkg->size != fi.size) if (pkg->size != fi.size)
continue; continue;
......
...@@ -45,7 +45,7 @@ static void verbose_print_pkg(struct apk_package *pkg, int minimal_verbosity) ...@@ -45,7 +45,7 @@ static void verbose_print_pkg(struct apk_package *pkg, int minimal_verbosity)
printf("%s", pkg->name->name); printf("%s", pkg->name->name);
if (apk_verbosity > 1) if (apk_verbosity > 1)
printf("-%s", pkg->version); printf("-" BLOB_FMT, BLOB_PRINTF(*pkg->version));
if (apk_verbosity > 2) if (apk_verbosity > 2)
printf(" - %s", pkg->description); printf(" - %s", pkg->description);
printf("\n"); printf("\n");
...@@ -84,7 +84,7 @@ static int info_exists(struct info_ctx *ctx, struct apk_database *db, ...@@ -84,7 +84,7 @@ static int info_exists(struct info_ctx *ctx, struct apk_database *db,
if (j >= name->pkgs->num) if (j >= name->pkgs->num)
continue; continue;
if (!(apk_version_compare(pkg->version, dep.version) if (!(apk_version_compare_blob(*pkg->version, *dep.version)
& dep.result_mask)) & dep.result_mask))
continue; continue;
...@@ -116,8 +116,8 @@ static int info_who_owns(struct info_ctx *ctx, struct apk_database *db, ...@@ -116,8 +116,8 @@ static int info_who_owns(struct info_ctx *ctx, struct apk_database *db,
}; };
apk_deps_add(&deps, &dep); apk_deps_add(&deps, &dep);
} else { } else {
printf("%s is owned by %s-%s\n", argv[i], printf("%s is owned by " PKG_VER_FMT "\n",
pkg->name->name, pkg->version); argv[i], PKG_VER_PRINTF(pkg));
} }
} }
if (apk_verbosity < 1 && deps->num != 0) { if (apk_verbosity < 1 && deps->num != 0) {
...@@ -138,8 +138,9 @@ static void info_print_description(struct apk_package *pkg) ...@@ -138,8 +138,9 @@ static void info_print_description(struct apk_package *pkg)
if (apk_verbosity > 1) if (apk_verbosity > 1)
printf("%s: %s", pkg->name->name, pkg->description); printf("%s: %s", pkg->name->name, pkg->description);
else else
printf("%s-%s description:\n%s\n", pkg->name->name, printf(PKG_VER_FMT " description:\n%s\n",
pkg->version, pkg->description); PKG_VER_PRINTF(pkg),
pkg->description);
} }
static void info_print_url(struct apk_package *pkg) static void info_print_url(struct apk_package *pkg)
...@@ -147,7 +148,8 @@ static void info_print_url(struct apk_package *pkg) ...@@ -147,7 +148,8 @@ static void info_print_url(struct apk_package *pkg)
if (apk_verbosity > 1) if (apk_verbosity > 1)
printf("%s: %s", pkg->name->name, pkg->url); printf("%s: %s", pkg->name->name, pkg->url);
else else
printf("%s-%s webpage:\n%s\n", pkg->name->name, pkg->version, printf(PKG_VER_FMT " webpage:\n%s\n",
PKG_VER_PRINTF(pkg),
pkg->url); pkg->url);
} }
...@@ -156,7 +158,8 @@ static void info_print_size(struct apk_package *pkg) ...@@ -156,7 +158,8 @@ static void info_print_size(struct apk_package *pkg)
if (apk_verbosity > 1) if (apk_verbosity > 1)
printf("%s: %zu", pkg->name->name, pkg->installed_size); printf("%s: %zu", pkg->name->name, pkg->installed_size);
else else
printf("%s-%s installed size:\n%zu\n", pkg->name->name, pkg->version, printf(PKG_VER_FMT " installed size:\n%zu\n",
PKG_VER_PRINTF(pkg),
pkg->installed_size); pkg->installed_size);
} }
...@@ -165,7 +168,8 @@ static void info_print_depends(struct apk_package *pkg) ...@@ -165,7 +168,8 @@ static void info_print_depends(struct apk_package *pkg)
int i; int i;
char *separator = apk_verbosity > 1 ? " " : "\n"; char *separator = apk_verbosity > 1 ? " " : "\n";
if (apk_verbosity == 1) if (apk_verbosity == 1)
printf("%s-%s depends on:\n", pkg->name->name, pkg->version); printf(PKG_VER_FMT " depends on:\n",
PKG_VER_PRINTF(pkg));
if (apk_verbosity > 1) if (apk_verbosity > 1)
printf("%s: ", pkg->name->name); printf("%s: ", pkg->name->name);
for (i = 0; i < pkg->depends->num; i++) for (i = 0; i < pkg->depends->num; i++)
...@@ -178,7 +182,8 @@ static void info_print_required_by(struct apk_package *pkg) ...@@ -178,7 +182,8 @@ static void info_print_required_by(struct apk_package *pkg)
char *separator = apk_verbosity > 1 ? " " : "\n"; char *separator = apk_verbosity > 1 ? " " : "\n";
if (apk_verbosity == 1) if (apk_verbosity == 1)
printf("%s-%s is required by:\n", pkg->name->name, pkg->version); printf(PKG_VER_FMT " is required by:\n",
PKG_VER_PRINTF(pkg));
if (apk_verbosity > 1) if (apk_verbosity > 1)
printf("%s: ", pkg->name->name); printf("%s: ", pkg->name->name);
for (i = 0; i < pkg->name->rdepends->num; i++) { for (i = 0; i < pkg->name->rdepends->num; i++) {
...@@ -194,8 +199,9 @@ static void info_print_required_by(struct apk_package *pkg) ...@@ -194,8 +199,9 @@ static void info_print_required_by(struct apk_package *pkg)
for (k = 0; k < pkg0->depends->num; k++) { for (k = 0; k < pkg0->depends->num; k++) {
if (pkg0->depends->item[k].name != pkg->name) if (pkg0->depends->item[k].name != pkg->name)
continue; continue;
printf("%s-%s%s", pkg0->name->name, printf(PKG_VER_FMT "%s",
pkg0->version, separator); PKG_VER_PRINTF(pkg0),
separator);
break; break;
} }
} }
...@@ -210,7 +216,8 @@ static void info_print_contents(struct apk_package *pkg) ...@@ -210,7 +216,8 @@ static void info_print_contents(struct apk_package *pkg)
struct hlist_node *dc, *dn, *fc, *fn; struct hlist_node *dc, *dn, *fc, *fn;
if (apk_verbosity == 1) if (apk_verbosity == 1)
printf("%s-%s contains:\n", pkg->name->name, pkg->version); printf(PKG_VER_FMT " contains:\n",
PKG_VER_PRINTF(pkg));
hlist_for_each_entry_safe(diri, dc, dn, &ipkg->owned_dirs, hlist_for_each_entry_safe(diri, dc, dn, &ipkg->owned_dirs,
pkg_dirs_list) { pkg_dirs_list) {
...@@ -229,7 +236,8 @@ static void info_print_triggers(struct apk_package *pkg) ...@@ -229,7 +236,8 @@ static void info_print_triggers(struct apk_package *pkg)
int i; int i;
if (apk_verbosity == 1) if (apk_verbosity == 1)
printf("%s-%s triggers:\n", pkg->name->name, pkg->version); printf(PKG_VER_FMT " triggers:\n",
PKG_VER_PRINTF(pkg));