diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-09-03 14:56:24 +0400 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-09-03 14:56:24 +0400 |
commit | 58e771303c95f9d97d009602516b509866c3fb5a (patch) | |
tree | 9cf8ce0d4608d4531850177549cb70670544fbb4 /src/ver.c | |
parent | 7829f1191f1812f30c763a685dff1b61393f7491 (diff) | |
download | apk-tools-58e771303c95f9d97d009602516b509866c3fb5a.tar.gz apk-tools-58e771303c95f9d97d009602516b509866c3fb5a.tar.bz2 apk-tools-58e771303c95f9d97d009602516b509866c3fb5a.tar.xz apk-tools-58e771303c95f9d97d009602516b509866c3fb5a.zip |
index, version: support for repository descriptions (fixes #141)
ability embed description information to repository indexes
(e.g. repository name and version) and show it via "apk version -I".
Diffstat (limited to 'src/ver.c')
-rw-r--r-- | src/ver.c | 32 |
1 files changed, 28 insertions, 4 deletions
@@ -16,11 +16,31 @@ #include "apk_version.h" struct ver_ctx { - int (*action)(int argc, char **argv); + int (*action)(struct apk_database *db, int argc, char **argv); const char *limchars; }; -static int ver_test(int argc, char **argv) +static int ver_indexes(struct apk_database *db, int argc, char **argv) +{ + struct apk_repository *repo; + int i; + + for (i = 0; i < db->num_repos; i++) { + repo = &db->repos[i]; + + if (APK_BLOB_IS_NULL(repo->description)) + continue; + + apk_message("%.*s [%s]", + repo->description.len, + repo->description.ptr, + db->repos[i].url); + } + + return 0; +} + +static int ver_test(struct apk_database *db, int argc, char **argv) { int r; @@ -32,7 +52,7 @@ static int ver_test(int argc, char **argv) return 0; } -static int ver_validate(int argc, char **argv) +static int ver_validate(struct apk_database *db, int argc, char **argv) { int i, r = 0; for (i = 0; i < argc; i++) { @@ -50,6 +70,9 @@ static int ver_parse(void *ctx, struct apk_db_options *dbopts, { struct ver_ctx *ictx = (struct ver_ctx *) ctx; switch (opt) { + case 'I': + ictx->action = ver_indexes; + break; case 't': ictx->action = ver_test; break; @@ -99,7 +122,7 @@ static int ver_main(void *ctx, struct apk_database *db, int argc, char **argv) if (ictx->action != NULL) - return ictx->action(argc, argv); + return ictx->action(db, argc, argv); if (apk_verbosity > 0) printf("%-42sAvailable:\n", "Installed:"); @@ -131,6 +154,7 @@ ver_exit: } static struct apk_option ver_options[] = { + { 'I', "indexes", "Print description and versions of indexes" }, { 't', "test", "Compare two given versions" }, { 'c', "check", "Check if the given version string is valid" }, { 'l', "limit", "Limit output to packages whos status matches LIMCHAR", |