summaryrefslogtreecommitdiff
path: root/src/info.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2011-10-29 05:18:21 +0300
committerTimo Teräs <timo.teras@iki.fi>2011-10-29 05:18:21 +0300
commit500f8d4a7d7b17871647392e79e4c7a17c210534 (patch)
tree47d4b1cd04e374d88e26e352eeac9f51da083451 /src/info.c
parente682e6596c101d634b3780a98773c8433b3baadb (diff)
downloadapk-tools-500f8d4a7d7b17871647392e79e4c7a17c210534.tar.gz
apk-tools-500f8d4a7d7b17871647392e79e4c7a17c210534.tar.bz2
apk-tools-500f8d4a7d7b17871647392e79e4c7a17c210534.tar.xz
apk-tools-500f8d4a7d7b17871647392e79e4c7a17c210534.zip
solver, db: implement repository pinning
Improves /etc/apk/repositories format so you can say: http://nl.alpinelinux.org/alpine/v2.3/main @edge http://nl.alpinelinux.org/alpine/edge/main @testing http://nl.alpinelinux.org/alpine/edge/testing After which you can pin dependencies to these tags using: apk add stableapp newapp@edge bleedingapp@testing Apk will now by default only use the untagged repositories, but adding a tag to specific dependency: 1. will prefer that tag for the name 2. allowing pulling in dependencies from that tag (though, it prefers untagged packages to satisfy deps if possible) fixes #575
Diffstat (limited to 'src/info.c')
-rw-r--r--src/info.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/info.c b/src/info.c
index b45eba5..b90fa1a 100644
--- a/src/info.c
+++ b/src/info.c
@@ -18,6 +18,7 @@
#include "apk_print.h"
struct info_ctx {
+ struct apk_database *db;
int (*action)(struct info_ctx *ctx, struct apk_database *db,
int argc, char **argv);
int subaction_mask;
@@ -130,7 +131,7 @@ static int info_who_owns(struct info_ctx *ctx, struct apk_database *db,
struct apk_ostream *os;
os = apk_ostream_to_fd(STDOUT_FILENO);
- apk_deps_write(deps, os);
+ apk_deps_write(db, deps, os);
os->write(os, "\n", 1);
os->close(os);
}
@@ -139,7 +140,7 @@ static int info_who_owns(struct info_ctx *ctx, struct apk_database *db,
return r;
}
-static void info_print_description(struct apk_package *pkg)
+static void info_print_description(struct apk_database *db, struct apk_package *pkg)
{
if (apk_verbosity > 1)
printf("%s: %s", pkg->name->name, pkg->description);
@@ -149,7 +150,7 @@ static void info_print_description(struct apk_package *pkg)
pkg->description);
}
-static void info_print_url(struct apk_package *pkg)
+static void info_print_url(struct apk_database *db, struct apk_package *pkg)
{
if (apk_verbosity > 1)
printf("%s: %s", pkg->name->name, pkg->url);
@@ -159,7 +160,7 @@ static void info_print_url(struct apk_package *pkg)
pkg->url);
}
-static void info_print_size(struct apk_package *pkg)
+static void info_print_size(struct apk_database *db, struct apk_package *pkg)
{
if (apk_verbosity > 1)
printf("%s: %zu", pkg->name->name, pkg->installed_size);
@@ -169,7 +170,7 @@ static void info_print_size(struct apk_package *pkg)
pkg->installed_size);
}
-static void info_print_depends(struct apk_package *pkg)
+static void info_print_depends(struct apk_database *db, struct apk_package *pkg)
{
apk_blob_t separator = APK_BLOB_STR(apk_verbosity > 1 ? " " : "\n");
char dep[256];
@@ -182,14 +183,14 @@ static void info_print_depends(struct apk_package *pkg)
printf("%s: ", pkg->name->name);
for (i = 0; i < pkg->depends->num; i++) {
apk_blob_t b = APK_BLOB_BUF(dep);
- apk_blob_push_dep(&b, &pkg->depends->item[i]);
+ apk_blob_push_dep(&b, db, &pkg->depends->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_print_required_by(struct apk_package *pkg)
+static void info_print_required_by(struct apk_database *db, struct apk_package *pkg)
{
int i, j, k;
char *separator = apk_verbosity > 1 ? " " : "\n";
@@ -221,7 +222,7 @@ static void info_print_required_by(struct apk_package *pkg)
}
}
-static void info_print_install_if(struct apk_package *pkg)
+static void info_print_install_if(struct apk_database *db, struct apk_package *pkg)
{
apk_blob_t separator = APK_BLOB_STR(apk_verbosity > 1 ? " " : "\n");
char dep[256];
@@ -234,14 +235,14 @@ static void info_print_install_if(struct apk_package *pkg)
printf("%s: ", pkg->name->name);
for (i = 0; i < pkg->install_if->num; i++) {
apk_blob_t b = APK_BLOB_BUF(dep);
- apk_blob_push_dep(&b, &pkg->install_if->item[i]);
+ apk_blob_push_dep(&b, db, &pkg->install_if->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_print_rinstall_if(struct apk_package *pkg)
+static void info_print_rinstall_if(struct apk_database *db, struct apk_package *pkg)
{
int i, j, k;
char *separator = apk_verbosity > 1 ? " " : "\n";
@@ -273,7 +274,7 @@ static void info_print_rinstall_if(struct apk_package *pkg)
}
}
-static void info_print_contents(struct apk_package *pkg)
+static void info_print_contents(struct apk_database *db, struct apk_package *pkg)
{
struct apk_installed_package *ipkg = pkg->ipkg;
struct apk_db_dir_instance *diri;
@@ -295,7 +296,7 @@ static void info_print_contents(struct apk_package *pkg)
}
}
-static void info_print_triggers(struct apk_package *pkg)
+static void info_print_triggers(struct apk_database *db, struct apk_package *pkg)
{
struct apk_installed_package *ipkg = pkg->ipkg;
int i;
@@ -311,7 +312,7 @@ static void info_print_triggers(struct apk_package *pkg)
}
}
-static void info_print_replaces(struct apk_package *pkg)
+static void info_print_replaces(struct apk_database *db, struct apk_package *pkg)
{
apk_blob_t separator = APK_BLOB_STR(apk_verbosity > 1 ? " " : "\n");
char dep[256];
@@ -324,7 +325,7 @@ static void info_print_replaces(struct apk_package *pkg)
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_dep(&b, db, &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);
@@ -333,7 +334,7 @@ static void info_print_replaces(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_database *, struct apk_package *);
static subaction_t subactions[] = {
info_print_description,
info_print_url,
@@ -358,7 +359,7 @@ static void info_subaction(struct info_ctx *ctx, struct apk_package *pkg)
if (pkg->ipkg == NULL && (BIT(i) & requireipkg))
continue;
- subactions[i](pkg);
+ subactions[i](ctx->db, pkg);
puts("");
}
}
@@ -437,6 +438,7 @@ static int info_main(void *ctx, struct apk_database *db, int argc, char **argv)
{
struct info_ctx *ictx = (struct info_ctx *) ctx;
+ ictx->db = db;
if (ictx->action != NULL)
return ictx->action(ictx, db, argc, argv);