aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2012-01-12 11:33:04 +0200
committerTimo Teräs <timo.teras@iki.fi>2012-01-12 11:33:04 +0200
commit30965aa86735f7d2dcd544bae0b788195c51f336 (patch)
tree028bb08c90f425796dbb5dbf1cfb89bf1a0214d0
parentf1de353b8162b6f41c36c01fd54599d446203a68 (diff)
downloadapk-tools-30965aa86735f7d2dcd544bae0b788195c51f336.tar.gz
apk-tools-30965aa86735f7d2dcd544bae0b788195c51f336.tar.bz2
apk-tools-30965aa86735f7d2dcd544bae0b788195c51f336.tar.xz
solver: print repository tag when committing package changes
-rw-r--r--src/apk_database.h1
-rw-r--r--src/database.c11
-rw-r--r--src/solver.c31
3 files changed, 34 insertions, 9 deletions
diff --git a/src/apk_database.h b/src/apk_database.h
index 929f262..c72a946 100644
--- a/src/apk_database.h
+++ b/src/apk_database.h
@@ -167,6 +167,7 @@ typedef union apk_database_or_void {
struct apk_name *apk_db_get_name(struct apk_database *db, apk_blob_t name);
struct apk_name *apk_db_query_name(struct apk_database *db, apk_blob_t name);
int apk_db_get_tag_id(struct apk_database *db, apk_blob_t tag);
+int apk_db_get_tag_id_by_repos(struct apk_database *db, unsigned int repos);
struct apk_db_dir *apk_db_dir_query(struct apk_database *db,
apk_blob_t name);
struct apk_db_file *apk_db_file_query(struct apk_database *db,
diff --git a/src/database.c b/src/database.c
index dd3f4b5..e3c10c5 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1475,6 +1475,17 @@ int apk_db_get_tag_id(struct apk_database *db, apk_blob_t tag)
return -1;
}
+int apk_db_get_tag_id_by_repos(struct apk_database *db, unsigned int repos)
+{
+ int i;
+
+ for (i = 0; i < db->num_repo_tags; i++) {
+ if (db->repo_tags[i].allowed_repos & repos)
+ return i;
+ }
+ return -1;
+}
+
static int fire_triggers(apk_hash_item item, void *ctx)
{
struct apk_database *db = (struct apk_database *) ctx;
diff --git a/src/solver.c b/src/solver.c
index 1ebadcc..074df6b 100644
--- a/src/solver.c
+++ b/src/solver.c
@@ -1061,24 +1061,37 @@ static void print_change(struct apk_database *db,
struct apk_package *oldpkg = change->oldpkg;
struct apk_package *newpkg = change->newpkg;
const char *msg = NULL;
- char status[64];
- int r;
+ char status[32], n[512], *nameptr;
+ int r, tag;
snprintf(status, sizeof(status), "(%i/%i)", cur+1, total);
- status[sizeof(status) - 1] = '\0';
+ status[sizeof(status) - 1] = 0;
- if (oldpkg != NULL)
- name = oldpkg->name;
- else
+ if (newpkg != NULL) {
name = newpkg->name;
+ tag = apk_db_get_tag_id_by_repos(db, newpkg->repos);
+ } else {
+ name = oldpkg->name;
+ tag = apk_db_get_tag_id_by_repos(db, oldpkg->repos);
+ }
+
+ if (tag > 0) {
+ snprintf(n, sizeof(n), "%s@" BLOB_FMT,
+ name->name,
+ BLOB_PRINTF(*db->repo_tags[tag].name));
+ n[sizeof(n) - 1] = 0;
+ nameptr = n;
+ } else {
+ nameptr = name->name;
+ }
if (oldpkg == NULL) {
apk_message("%s Installing %s (" BLOB_FMT ")",
- status, name->name,
+ status, nameptr,
BLOB_PRINTF(*newpkg->version));
} else if (newpkg == NULL) {
apk_message("%s Purging %s (" BLOB_FMT ")",
- status, name->name,
+ status, nameptr,
BLOB_PRINTF(*oldpkg->version));
} else {
r = apk_pkg_version_compare(newpkg, oldpkg);
@@ -1097,7 +1110,7 @@ static void print_change(struct apk_database *db,
break;
}
apk_message("%s %s %s (" BLOB_FMT " -> " BLOB_FMT ")",
- status, msg, name->name,
+ status, msg, nameptr,
BLOB_PRINTF(*oldpkg->version),
BLOB_PRINTF(*newpkg->version));
}