[PATCH] List files along with their languages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---

This patch enables one to list contents of an rpm package along with
language tags associated with files. Use the following command

rpm -qp --filelanguages YOUR.rpm

I have tested the patch only by querying rpm files and not the database.

The output format is just a proof of concept.

RFC.

 lib/poptQV.c   |    6 ++++++
 lib/query.c    |    9 +++++++++
 lib/rpmcli.h   |    3 ++-
 lib/rpmfiles.h |    2 +-
 4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/lib/poptQV.c b/lib/poptQV.c
index 3db17b0..0aa1050 100644
--- a/lib/poptQV.c
+++ b/lib/poptQV.c
@@ -21,6 +21,7 @@ struct rpmQVKArguments_s rpmQVKArgs;
 #define POPT_QUERYBYPKGID	-1007
 #define POPT_QUERYBYHDRID	-1008
 #define POPT_QUERYBYTID		-1010
+#define POPT_FILELANGUAGES	-1011
 
 /* ========== Query/Verify/Signature source args */
 static void rpmQVSourceArgCallback( poptContext con,
@@ -121,6 +122,9 @@ static void queryArgCallback(poptContext con,
     case POPT_DUMP: qva->qva_flags |= QUERY_FOR_DUMPFILES | QUERY_FOR_LIST;
 	break;
 
+    case POPT_FILELANGUAGES: qva->qva_flags |= QUERY_FOR_FILELANGS | QUERY_FOR_LIST;
+	break;
+
     case POPT_QUERYFORMAT:
 	rstrcat(&qva->qva_queryFormat, arg);
 	break;
@@ -168,6 +172,8 @@ struct poptOption rpmQueryPoptTable[] = {
 /* FIX: cast? */
  { NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA | POPT_CBFLAG_CONTINUE, 
 	queryArgCallback, 0, NULL, NULL },
+ { "filelanguages", '\0', 0, 0, POPT_FILELANGUAGES,
+	N_("list all files and their languages"), NULL },
  { "configfiles", 'c', 0, 0, 'c',
 	N_("list all configuration files"), NULL },
  { "docfiles", 'd', 0, 0, 'd',
diff --git a/lib/query.c b/lib/query.c
index 896ebe3..2580a99 100644
--- a/lib/query.c
+++ b/lib/query.c
@@ -132,6 +132,8 @@ int showQueryPackage(QVA_t qva, rpmts ts, Header h)
 	const char *fuser = rpmfiFUser(fi);
 	const char *fgroup = rpmfiFGroup(fi);
 	const char *flink = rpmfiFLink(fi);
+	const char *flangs = rpmfiFLangs(fi);
+
 	char *buf = NULL;
 
 	/* If querying only docs, skip non-doc files. */
@@ -202,6 +204,13 @@ int showQueryPackage(QVA_t qva, rpmts ts, Header h)
 	    rpmlog(RPMLOG_NOTICE, "%s%s\n", buf, add);
 	    free(add);
 	} else
+	if (qva->qva_flags & QUERY_FOR_FILELANGS) {
+	    char *lang;
+	    rasprintf(&lang, (flangs && *flangs ? "%%lang(%s) " : ""),
+			    (flangs && *flangs ? flangs : ""));
+	    rpmlog(RPMLOG_NOTICE, "%s%s\n", lang, fn);
+	    free(lang);
+	} else
 	if (!rpmIsVerbose()) {
 	    rpmlog(RPMLOG_NOTICE, "%s%s\n", buf ? buf : "", fn);
 	}
diff --git a/lib/rpmcli.h b/lib/rpmcli.h
index cdb1f8a..f537d50 100644
--- a/lib/rpmcli.h
+++ b/lib/rpmcli.h
@@ -124,7 +124,8 @@ enum rpmQueryFlags_e {
     QUERY_FOR_DOCS	= (1 << 25),	/*!< query:  from --docfiles */
     QUERY_FOR_CONFIG	= (1 << 26),	/*!< query:  from --configfiles */
     QUERY_FOR_DUMPFILES	= (1 << 27),	/*!< query:  from --dump */
-    QUERY_FOR_LICENSE	= (1 << 28)	/*!< query:  from --licensefiles */
+    QUERY_FOR_LICENSE	= (1 << 28),	/*!< query:  from --licensefiles */
+    QUERY_FOR_FILELANGS = (1 << 29),    /*!< query:  from --filelanguages */
 };
 
 typedef rpmFlags rpmQueryFlags;
diff --git a/lib/rpmfiles.h b/lib/rpmfiles.h
index 2d6ce98..46a7ad6 100644
--- a/lib/rpmfiles.h
+++ b/lib/rpmfiles.h
@@ -129,7 +129,7 @@ typedef rpmFlags rpmfiFlags;
      RPMFI_NOFILECOLORS)
 
 #define RPMFI_FLAGS_QUERY \
-    (RPMFI_NOFILECLASS | RPMFI_NOFILEDEPS | RPMFI_NOFILELANGS | \
+    (RPMFI_NOFILECLASS | RPMFI_NOFILEDEPS | \
      RPMFI_NOFILECOLORS | RPMFI_NOFILEVERIFYFLAGS)
 
 typedef enum rpmFileIter_e {
-- 
1.7.9.5

_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list




[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux