Subject: [alpine-devel] apk list repository contents

From: Cameron Banta <[email-masked]>
Date: Thu, 5 Mar 2009 21:37:08 -0600

Hello,

Here's a patch, if interested, for the new apk to allow listing the contents
of the repositories.

"apk list -o" or "apk -v list -o"

Thanks,
Cameron
From 984c9cbaf52187f72f52acdd9d3506c817613753 Mon Sep 17 00:00:00 2001
From: Cameron Banta <[email-masked]>
Date: Fri, 6 Mar 2009 03:29:56 +0000
Subject: [PATCH] Added -o option to apk info to list repository packages

---
 src/info.c |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/src/info.c b/src/info.c
index 7bfc6b7..9414738 100644
--- a/src/info.c
+++ b/src/info.c
@@ -35,6 +35,30 @@ static int info_list(struct apk_database *db, int argc, char **argv)
 	return 0;
 }
 
+static int info_repo_pkgs_print(apk_hash_item item, void *ctx)
+{
+	struct apk_database *db = (struct apk_database *) ctx;
+	struct apk_package *pkg = (struct apk_package *) item;
+
+	printf("%s", pkg->name->name);
+	if (apk_verbosity > 0)
+		printf("-%s", pkg->version);
+	if (apk_verbosity > 1) {
+		printf("\n\t%s", db->repos[pkg->repos].url);
+		printf("\n\t%s", pkg->description);
+	}
+	printf("\n");
+
+	return 0;
+}
+
+static int info_repo_pkgs(struct apk_database *db, int argc, char **argv)
+{
+	apk_hash_foreach(&db->available.packages, info_repo_pkgs_print, db);
+
+	return 0;
+}
+
 static int info_exists(struct apk_database *db, int argc, char **argv)
 {
 	struct apk_name *name;
@@ -183,6 +207,9 @@ static int info_parse(void *ctx, int optch, int optindex, const char *optarg)
 	case 'R':
 		ictx->action = info_depends;
 		break;
+	case 'o':
+		ictx->action = info_repo_pkgs;
+		break;
 	default:
 		return -1;
 	}
@@ -212,11 +239,12 @@ static struct option info_options[] = {
 	{ "installed",	no_argument,		NULL, 'e' },
 	{ "who-owns",	no_argument,		NULL, 'W' },
 	{ "depends",	no_argument,		NULL, 'R' },
+	{ "repo-pkgs",	no_argument,		NULL, 'o' },
 };
 
 static struct apk_applet apk_info = {
 	.name = "info",
-	.usage = "",
+	.usage = "[--repo-pkgs|-o]",
 	.context_size = sizeof(struct info_ctx),
 	.num_options = ARRAY_SIZE(info_options),
 	.options = info_options,
-- 
1.6.1.3

---

From: Timo Teräs <[email-masked]>
Date: Fri, 06 Mar 2009 08:11:14 +0200

> "apk list -o" or "apk -v list -o"

Thanks.

We might want the output format to be a bit different, but not sure yet.
So applied as is.

- Timo

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Natanael Copa <[email-masked]>
Date: Fri, 06 Mar 2009 16:05:52 +0100

> We might want the output format to be a bit different, but not sure yet.

I wonder if we might want have this in a separate applet. ie. 'apk info'
is for querying installed packages and maybe 'apk search' for whats in
repository.

apk search without options could list all packages in repositories. then
we could search based on comment, match pkgname, dependencies etc.

I'm just throwing out some ideas...

-nc

---

---

From: Cameron Banta <[email-masked]>
Date: Fri, 6 Mar 2009 11:53:42 -0600

> > We might want the output format to be a bit different, but not sure yet.

What kind of output would you like?

> I'm just throwing out some ideas...

That's a good idea. I'll can start working up a search applet, if you want.

-Cameron

---

From: Natanael Copa <[email-masked]>
Date: Fri, 06 Mar 2009 19:17:42 +0100

On Fri, 2009-03-06 at 11:53 -0600, Cameron Banta wrote:
> On Fri, Mar 6, 2009 at 9:05 AM, Natanael Copa 
>         

I think that would be very nice. Its different from what we have in
apk-tools-0.15 (its nice to be somewhat compatible) but on the other
hand, we had alot less info in the index then so it didnt make any sense
at that time.

I say go for apk search.

---

---

From: Cameron Banta <[email-masked]>
Date: Fri, 6 Mar 2009 19:41:32 -0600

> hand, we had alot less info in the index then so it didnt make any sense

Done. Please review and commit.

-Cameron

---

From: Timo Teräs <[email-masked]>
Date: Sat, 07 Mar 2009 11:35:41 +0200

> Done. Please review and commit.

Fixed From, and applied with --whitespace=fix (there was some whitespace
issues).

Thanks!

As side note, we might want to use fnmatch() instead of strstr() or similar.

- Timo

---