summaryrefslogtreecommitdiff
path: root/src/info.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2012-02-29 08:59:26 +0200
committerTimo Teräs <timo.teras@iki.fi>2012-02-29 08:59:26 +0200
commit15adb0475f49d461b21f4826f9f0e1a1b8562205 (patch)
treef2db2307be7b7ad55e8ba1c63a82b51abbc3ddde /src/info.c
parentf27f194d92c952da337205c0176f68a13f0cba7c (diff)
downloadapk-tools-15adb0475f49d461b21f4826f9f0e1a1b8562205.tar.gz
apk-tools-15adb0475f49d461b21f4826f9f0e1a1b8562205.tar.bz2
apk-tools-15adb0475f49d461b21f4826f9f0e1a1b8562205.tar.xz
apk-tools-15adb0475f49d461b21f4826f9f0e1a1b8562205.zip
info: support displaying provides
Diffstat (limited to 'src/info.c')
-rw-r--r--src/info.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/info.c b/src/info.c
index 94a3047..ef7bf9b 100644
--- a/src/info.c
+++ b/src/info.c
@@ -30,12 +30,13 @@ struct info_ctx {
#define APK_INFO_URL 0x02
#define APK_INFO_SIZE 0x04
#define APK_INFO_DEPENDS 0x08
-#define APK_INFO_RDEPENDS 0x10
-#define APK_INFO_CONTENTS 0x20
-#define APK_INFO_TRIGGERS 0x40
-#define APK_INFO_INSTALL_IF 0x80
-#define APK_INFO_RINSTALL_IF 0x100
-#define APK_INFO_REPLACES 0x200
+#define APK_INFO_PROVIDES 0x10
+#define APK_INFO_RDEPENDS 0x20
+#define APK_INFO_CONTENTS 0x40
+#define APK_INFO_TRIGGERS 0x80
+#define APK_INFO_INSTALL_IF 0x100
+#define APK_INFO_RINSTALL_IF 0x200
+#define APK_INFO_REPLACES 0x400
static void verbose_print_pkg(struct apk_package *pkg, int minimal_verbosity)
{
@@ -189,6 +190,26 @@ static void info_print_depends(struct apk_database *db, struct apk_package *pkg)
}
}
+static void info_print_provides(struct apk_database *db, struct apk_package *pkg)
+{
+ apk_blob_t separator = APK_BLOB_STR(apk_verbosity > 1 ? " " : "\n");
+ char dep[256];
+ int i;
+
+ if (apk_verbosity == 1)
+ printf(PKG_VER_FMT " provides:\n",
+ PKG_VER_PRINTF(pkg));
+ if (apk_verbosity > 1)
+ printf("%s: ", pkg->name->name);
+ for (i = 0; i < pkg->provides->num; i++) {
+ apk_blob_t b = APK_BLOB_BUF(dep);
+ apk_blob_push_dep(&b, db, &pkg->provides->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_database *db, struct apk_package *pkg)
{
int i, j;
@@ -339,6 +360,7 @@ static void info_subaction(struct info_ctx *ctx, struct apk_package *pkg)
info_print_url,
info_print_size,
info_print_depends,
+ info_print_provides,
info_print_required_by,
info_print_contents,
info_print_triggers,
@@ -402,6 +424,9 @@ static int info_parse(void *ctx, struct apk_db_options *dbopts,
case 'R':
ictx->subaction_mask |= APK_INFO_DEPENDS;
break;
+ case 'p':
+ ictx->subaction_mask |= APK_INFO_PROVIDES;
+ break;
case 'r':
ictx->subaction_mask |= APK_INFO_RDEPENDS;
break;
@@ -461,6 +486,7 @@ static struct apk_option info_options[] = {
{ 'e', "installed", "Check if PACKAGE is installed" },
{ 'W', "who-owns", "Print the package owning the specified file" },
{ 'R', "depends", "List packages that the PACKAGE depends on" },
+ { 'p', "provides", "List virtual packages provided by PACKAGE" },
{ 'r', "rdepends", "List all packages depending on PACKAGE" },
{ 0x10000, "replaces", "List packages whom files PACKAGE might replace" },
{ 'i', "install-if", "List the PACKAGE's install-if rule" },