ALT Linux Team development discussions
 help / color / mirror / Atom feed
* [devel] [PATCH] Verbose QueryTags prints whether tag is an extension
@ 2020-04-10 23:19 Vladimir D. Seleznev
  2020-04-11 10:46 ` Andrey Savchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Vladimir D. Seleznev @ 2020-04-10 23:19 UTC (permalink / raw)
  To: devel; +Cc: vseleznv

Verbose QueryTags prints four field: tagname, tagvalue, tagtype and whether
it is an extension. To make it possible QueryTags uses new function
rpmTagIsExtension() that return 0 if tag is real, 1 if tag is an extension
or 2 if tag is not found.

* lib/query.c(rpmDisplayQueryTags): Print whether tag is an extension.
* lib/rpmtag.h(rpmTagIsExtension): New definition.
* lib/tagname.c(rpmTagIsExtension): New function.
---
 lib/query.c   |  5 +++++
 lib/rpmtag.h  |  7 +++++++
 lib/tagname.c | 14 ++++++++++++++
 3 files changed, 26 insertions(+)

diff --git a/lib/query.c b/lib/query.c
index 60d3a0269..5f0216bdc 100644
--- a/lib/query.c
+++ b/lib/query.c
@@ -253,9 +253,14 @@ void rpmDisplayQueryTags(FILE * fp)
 	if (rpmIsVerbose()) {
 	    rpmTagVal tag = rpmTagGetValue(sname);
 	    rpmTagType type = rpmTagGetTagType(tag);
+	    int ext = rpmTagIsExtension(tag);
 	    fprintf(fp, "%-20s %6d", sname, tag);
 	    if (type > RPM_NULL_TYPE && type <= RPM_MAX_TYPE)
 		fprintf(fp, " %s", tagTypeNames[type]);
+	    else if (ext)
+		fprintf(fp, " -");
+	    if (ext)
+		fprintf(fp, " ext");
 	} else {
 	    fprintf(fp, "%s", sname);
 	}
diff --git a/lib/rpmtag.h b/lib/rpmtag.h
index f74b451dc..8e860f927 100644
--- a/lib/rpmtag.h
+++ b/lib/rpmtag.h
@@ -519,6 +519,13 @@ rpmTagType rpmTagGetTagType(rpmTagVal tag);
  */
 rpmTagReturnType rpmTagGetReturnType(rpmTagVal tag);
 
+/** \ingroup rpmtag
+ * Return 0 if tag is real, 1 if tag is an extension, 2 on not found
+ * @param tag		tag value
+ * @return		0 if tag is real, 1 if tag is an extension, 2 on not found
+ */
+int rpmTagIsExtension(rpmTagVal tag);
+
 /** \ingroup rpmtag
  * Return tag data class from value.
  * @param tag		tag value
diff --git a/lib/tagname.c b/lib/tagname.c
index 532437740..791b38ade 100644
--- a/lib/tagname.c
+++ b/lib/tagname.c
@@ -197,6 +197,20 @@ rpmTagReturnType rpmTagGetReturnType(rpmTagVal tag)
     return (rpmTagGetType(tag) & RPM_MASK_RETURN_TYPE);
 }
 
+int rpmTagIsExtension(rpmTagVal tag)
+{
+    const struct headerTagTableEntry_s *t;
+
+    pthread_once(&tagsLoaded, loadTags);
+
+    t = entryByTag(tag);
+
+    if (t)
+	return t->extension;
+    else
+	return 2;
+}
+
 rpmTagClass rpmTagTypeGetClass(rpmTagType type)
 {
     rpmTagClass tclass;
-- 
2.25.2



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [devel] [PATCH] Verbose QueryTags prints whether tag is an extension
  2020-04-10 23:19 [devel] [PATCH] Verbose QueryTags prints whether tag is an extension Vladimir D. Seleznev
@ 2020-04-11 10:46 ` Andrey Savchenko
  2020-04-12  3:02   ` Vladimir D. Seleznev
  0 siblings, 1 reply; 7+ messages in thread
From: Andrey Savchenko @ 2020-04-11 10:46 UTC (permalink / raw)
  To: ALT Linux Team development discussions

[-- Attachment #1: Type: text/plain, Size: 1138 bytes --]

On Sat, 11 Apr 2020 02:19:17 +0300 Vladimir D. Seleznev wrote:
> Verbose QueryTags prints four field: tagname, tagvalue, tagtype and whether
> it is an extension. To make it possible QueryTags uses new function
> rpmTagIsExtension() that return 0 if tag is real, 1 if tag is an extension
> or 2 if tag is not found.
[...]
> diff --git a/lib/rpmtag.h b/lib/rpmtag.h
> index f74b451dc..8e860f927 100644
> --- a/lib/rpmtag.h
> +++ b/lib/rpmtag.h
> @@ -519,6 +519,13 @@ rpmTagType rpmTagGetTagType(rpmTagVal tag);
>   */
>  rpmTagReturnType rpmTagGetReturnType(rpmTagVal tag);
>  
> +/** \ingroup rpmtag
> + * Return 0 if tag is real, 1 if tag is an extension, 2 on not found
> + * @param tag		tag value
> + * @return		0 if tag is real, 1 if tag is an extension, 2 on not found

I prpopose to change the return code semantics: rpmTagIsExtension
is designed to return 3 possible values: yes, no or error.
1 is a good choise for yes, so it is OK
0 is a good choise for no, so it is OK
But for the error — not found — it is better to use -1 to comply
with commonly used semantics.

Best regards,
Andrew Savchenko

[-- Attachment #2: Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [devel] [PATCH] Verbose QueryTags prints whether tag is an extension
  2020-04-11 10:46 ` Andrey Savchenko
@ 2020-04-12  3:02   ` Vladimir D. Seleznev
  2020-04-13 18:04     ` Dmitry V. Levin
  0 siblings, 1 reply; 7+ messages in thread
From: Vladimir D. Seleznev @ 2020-04-12  3:02 UTC (permalink / raw)
  To: devel; +Cc: vseleznv

Verbose QueryTags prints four field: tagname, tagvalue, tagtype and whether
it is an extension. To make it possible QueryTags uses new function
rpmTagIsExtension() that returns 0 if tag is real, 1 if tag is an extension
or -1 if tag is not found.

* lib/query.c(rpmDisplayQueryTags): Print whether tag is an extension.
* lib/rpmtag.h(rpmTagIsExtension): New definition.
* lib/tagname.c(rpmTagIsExtension): New function.
---
 lib/query.c   |  5 +++++
 lib/rpmtag.h  |  7 +++++++
 lib/tagname.c | 14 ++++++++++++++
 3 files changed, 26 insertions(+)

diff --git a/lib/query.c b/lib/query.c
index 60d3a0269..f27b15a7c 100644
--- a/lib/query.c
+++ b/lib/query.c
@@ -253,9 +253,14 @@ void rpmDisplayQueryTags(FILE * fp)
 	if (rpmIsVerbose()) {
 	    rpmTagVal tag = rpmTagGetValue(sname);
 	    rpmTagType type = rpmTagGetTagType(tag);
+	    int ext = rpmTagIsExtension(tag);
 	    fprintf(fp, "%-20s %6d", sname, tag);
 	    if (type > RPM_NULL_TYPE && type <= RPM_MAX_TYPE)
 		fprintf(fp, " %s", tagTypeNames[type]);
+	    else if (ext == 1)
+		fprintf(fp, " -");
+	    if (ext == 1)
+		fprintf(fp, " ext");
 	} else {
 	    fprintf(fp, "%s", sname);
 	}
diff --git a/lib/rpmtag.h b/lib/rpmtag.h
index f74b451dc..501fd7b2f 100644
--- a/lib/rpmtag.h
+++ b/lib/rpmtag.h
@@ -519,6 +519,13 @@ rpmTagType rpmTagGetTagType(rpmTagVal tag);
  */
 rpmTagReturnType rpmTagGetReturnType(rpmTagVal tag);
 
+/** \ingroup rpmtag
+ * Return 0 if tag is real, 1 if tag is an extension, -1 on not found
+ * @param tag		tag value
+ * @return		0 if tag is real, 1 if tag is an extension, -1 on not found
+ */
+int rpmTagIsExtension(rpmTagVal tag);
+
 /** \ingroup rpmtag
  * Return tag data class from value.
  * @param tag		tag value
diff --git a/lib/tagname.c b/lib/tagname.c
index 532437740..405dd8aa4 100644
--- a/lib/tagname.c
+++ b/lib/tagname.c
@@ -197,6 +197,20 @@ rpmTagReturnType rpmTagGetReturnType(rpmTagVal tag)
     return (rpmTagGetType(tag) & RPM_MASK_RETURN_TYPE);
 }
 
+int rpmTagIsExtension(rpmTagVal tag)
+{
+    const struct headerTagTableEntry_s *t;
+
+    pthread_once(&tagsLoaded, loadTags);
+
+    t = entryByTag(tag);
+
+    if (t)
+	return t->extension;
+    else
+	return -1;
+}
+
 rpmTagClass rpmTagTypeGetClass(rpmTagType type)
 {
     rpmTagClass tclass;
-- 
2.25.2



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [devel] [PATCH] Verbose QueryTags prints whether tag is an extension
  2020-04-12  3:02   ` Vladimir D. Seleznev
@ 2020-04-13 18:04     ` Dmitry V. Levin
  2020-04-13 18:20       ` Vladimir D. Seleznev
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry V. Levin @ 2020-04-13 18:04 UTC (permalink / raw)
  To: Vladimir D. Seleznev; +Cc: ALT Devel discussion list

On Sun, Apr 12, 2020 at 06:02:26AM +0300, Vladimir D. Seleznev wrote:
> Verbose QueryTags prints four field: tagname, tagvalue, tagtype and whether
> it is an extension. To make it possible QueryTags uses new function
> rpmTagIsExtension() that returns 0 if tag is real, 1 if tag is an extension
> or -1 if tag is not found.
> 
> * lib/query.c(rpmDisplayQueryTags): Print whether tag is an extension.
> * lib/rpmtag.h(rpmTagIsExtension): New definition.
> * lib/tagname.c(rpmTagIsExtension): New function.
> ---
>  lib/query.c   |  5 +++++
>  lib/rpmtag.h  |  7 +++++++
>  lib/tagname.c | 14 ++++++++++++++
>  3 files changed, 26 insertions(+)
> 
> diff --git a/lib/query.c b/lib/query.c
> index 60d3a0269..f27b15a7c 100644
> --- a/lib/query.c
> +++ b/lib/query.c
> @@ -253,9 +253,14 @@ void rpmDisplayQueryTags(FILE * fp)
>  	if (rpmIsVerbose()) {
>  	    rpmTagVal tag = rpmTagGetValue(sname);
>  	    rpmTagType type = rpmTagGetTagType(tag);
> +	    int ext = rpmTagIsExtension(tag);
>  	    fprintf(fp, "%-20s %6d", sname, tag);
>  	    if (type > RPM_NULL_TYPE && type <= RPM_MAX_TYPE)
>  		fprintf(fp, " %s", tagTypeNames[type]);
> +	    else if (ext == 1)
> +		fprintf(fp, " -");
> +	    if (ext == 1)
> +		fprintf(fp, " ext");
>  	} else {
>  	    fprintf(fp, "%s", sname);
>  	}

This changes rpmDisplayQueryTags output in an incompatible way.


-- 
ldv


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [devel] [PATCH] Verbose QueryTags prints whether tag is an extension
  2020-04-13 18:04     ` Dmitry V. Levin
@ 2020-04-13 18:20       ` Vladimir D. Seleznev
  2020-04-13 18:42         ` Dmitry V. Levin
  0 siblings, 1 reply; 7+ messages in thread
From: Vladimir D. Seleznev @ 2020-04-13 18:20 UTC (permalink / raw)
  To: ALT Linux Team development discussions

On Mon, Apr 13, 2020 at 09:04:37PM +0300, Dmitry V. Levin wrote:
> On Sun, Apr 12, 2020 at 06:02:26AM +0300, Vladimir D. Seleznev wrote:
> > Verbose QueryTags prints four field: tagname, tagvalue, tagtype and whether
> > it is an extension. To make it possible QueryTags uses new function
> > rpmTagIsExtension() that returns 0 if tag is real, 1 if tag is an extension
> > or -1 if tag is not found.
> > 
> > * lib/query.c(rpmDisplayQueryTags): Print whether tag is an extension.
> > * lib/rpmtag.h(rpmTagIsExtension): New definition.
> > * lib/tagname.c(rpmTagIsExtension): New function.
> > ---
> >  lib/query.c   |  5 +++++
> >  lib/rpmtag.h  |  7 +++++++
> >  lib/tagname.c | 14 ++++++++++++++
> >  3 files changed, 26 insertions(+)
> > 
> > diff --git a/lib/query.c b/lib/query.c
> > index 60d3a0269..f27b15a7c 100644
> > --- a/lib/query.c
> > +++ b/lib/query.c
> > @@ -253,9 +253,14 @@ void rpmDisplayQueryTags(FILE * fp)
> >  	if (rpmIsVerbose()) {
> >  	    rpmTagVal tag = rpmTagGetValue(sname);
> >  	    rpmTagType type = rpmTagGetTagType(tag);
> > +	    int ext = rpmTagIsExtension(tag);
> >  	    fprintf(fp, "%-20s %6d", sname, tag);
> >  	    if (type > RPM_NULL_TYPE && type <= RPM_MAX_TYPE)
> >  		fprintf(fp, " %s", tagTypeNames[type]);
> > +	    else if (ext == 1)
> > +		fprintf(fp, " -");
> > +	    if (ext == 1)
> > +		fprintf(fp, " ext");
> >  	} else {
> >  	    fprintf(fp, "%s", sname);
> >  	}
> 
> This changes rpmDisplayQueryTags output in an incompatible way.

rpm --verbose --querytags is missing in rpm 4.0.4, and is undocumented
feature of modern rpm. Should we care about compatibility in this
particular case?

-- 
   WBR,
   Vladimir D. Seleznev


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [devel] [PATCH] Verbose QueryTags prints whether tag is an extension
  2020-04-13 18:20       ` Vladimir D. Seleznev
@ 2020-04-13 18:42         ` Dmitry V. Levin
  2020-04-14 16:21           ` Vladimir D. Seleznev
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry V. Levin @ 2020-04-13 18:42 UTC (permalink / raw)
  To: Vladimir D. Seleznev; +Cc: ALT Linux Team development discussions

On Mon, Apr 13, 2020 at 09:20:21PM +0300, Vladimir D. Seleznev wrote:
> On Mon, Apr 13, 2020 at 09:04:37PM +0300, Dmitry V. Levin wrote:
> > On Sun, Apr 12, 2020 at 06:02:26AM +0300, Vladimir D. Seleznev wrote:
> > > Verbose QueryTags prints four field: tagname, tagvalue, tagtype and whether
> > > it is an extension. To make it possible QueryTags uses new function
> > > rpmTagIsExtension() that returns 0 if tag is real, 1 if tag is an extension
> > > or -1 if tag is not found.
> > > 
> > > * lib/query.c(rpmDisplayQueryTags): Print whether tag is an extension.
> > > * lib/rpmtag.h(rpmTagIsExtension): New definition.
> > > * lib/tagname.c(rpmTagIsExtension): New function.
> > > ---
> > >  lib/query.c   |  5 +++++
> > >  lib/rpmtag.h  |  7 +++++++
> > >  lib/tagname.c | 14 ++++++++++++++
> > >  3 files changed, 26 insertions(+)
> > > 
> > > diff --git a/lib/query.c b/lib/query.c
> > > index 60d3a0269..f27b15a7c 100644
> > > --- a/lib/query.c
> > > +++ b/lib/query.c
> > > @@ -253,9 +253,14 @@ void rpmDisplayQueryTags(FILE * fp)
> > >  	if (rpmIsVerbose()) {
> > >  	    rpmTagVal tag = rpmTagGetValue(sname);
> > >  	    rpmTagType type = rpmTagGetTagType(tag);
> > > +	    int ext = rpmTagIsExtension(tag);
> > >  	    fprintf(fp, "%-20s %6d", sname, tag);
> > >  	    if (type > RPM_NULL_TYPE && type <= RPM_MAX_TYPE)
> > >  		fprintf(fp, " %s", tagTypeNames[type]);
> > > +	    else if (ext == 1)
> > > +		fprintf(fp, " -");
> > > +	    if (ext == 1)
> > > +		fprintf(fp, " ext");
> > >  	} else {
> > >  	    fprintf(fp, "%s", sname);
> > >  	}
> > 
> > This changes rpmDisplayQueryTags output in an incompatible way.
> 
> rpm --verbose --querytags is missing in rpm 4.0.4, and is undocumented
> feature of modern rpm. Should we care about compatibility in this
> particular case?

Can we rely on any particular output format of this undocumented feature?


-- 
ldv


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [devel] [PATCH] Verbose QueryTags prints whether tag is an extension
  2020-04-13 18:42         ` Dmitry V. Levin
@ 2020-04-14 16:21           ` Vladimir D. Seleznev
  0 siblings, 0 replies; 7+ messages in thread
From: Vladimir D. Seleznev @ 2020-04-14 16:21 UTC (permalink / raw)
  To: ALT Linux Team development discussions

On Mon, Apr 13, 2020 at 09:42:18PM +0300, Dmitry V. Levin wrote:
> On Mon, Apr 13, 2020 at 09:20:21PM +0300, Vladimir D. Seleznev wrote:
> > On Mon, Apr 13, 2020 at 09:04:37PM +0300, Dmitry V. Levin wrote:
> > > On Sun, Apr 12, 2020 at 06:02:26AM +0300, Vladimir D. Seleznev wrote:
> > > > Verbose QueryTags prints four field: tagname, tagvalue, tagtype and whether
> > > > it is an extension. To make it possible QueryTags uses new function
> > > > rpmTagIsExtension() that returns 0 if tag is real, 1 if tag is an extension
> > > > or -1 if tag is not found.
> > > > 
> > > > * lib/query.c(rpmDisplayQueryTags): Print whether tag is an extension.
> > > > * lib/rpmtag.h(rpmTagIsExtension): New definition.
> > > > * lib/tagname.c(rpmTagIsExtension): New function.
> > > > ---
> > > >  lib/query.c   |  5 +++++
> > > >  lib/rpmtag.h  |  7 +++++++
> > > >  lib/tagname.c | 14 ++++++++++++++
> > > >  3 files changed, 26 insertions(+)
> > > > 
> > > > diff --git a/lib/query.c b/lib/query.c
> > > > index 60d3a0269..f27b15a7c 100644
> > > > --- a/lib/query.c
> > > > +++ b/lib/query.c
> > > > @@ -253,9 +253,14 @@ void rpmDisplayQueryTags(FILE * fp)
> > > >  	if (rpmIsVerbose()) {
> > > >  	    rpmTagVal tag = rpmTagGetValue(sname);
> > > >  	    rpmTagType type = rpmTagGetTagType(tag);
> > > > +	    int ext = rpmTagIsExtension(tag);
> > > >  	    fprintf(fp, "%-20s %6d", sname, tag);
> > > >  	    if (type > RPM_NULL_TYPE && type <= RPM_MAX_TYPE)
> > > >  		fprintf(fp, " %s", tagTypeNames[type]);
> > > > +	    else if (ext == 1)
> > > > +		fprintf(fp, " -");
> > > > +	    if (ext == 1)
> > > > +		fprintf(fp, " ext");
> > > >  	} else {
> > > >  	    fprintf(fp, "%s", sname);
> > > >  	}
> > > 
> > > This changes rpmDisplayQueryTags output in an incompatible way.
> > 
> > rpm --verbose --querytags is missing in rpm 4.0.4, and is undocumented
> > feature of modern rpm. Should we care about compatibility in this
> > particular case?
> 
> Can we rely on any particular output format of this undocumented feature?

I think we can while we maintain this or if we specify the format.

-- 
   WBR,
   Vladimir D. Seleznev


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-04-14 16:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-10 23:19 [devel] [PATCH] Verbose QueryTags prints whether tag is an extension Vladimir D. Seleznev
2020-04-11 10:46 ` Andrey Savchenko
2020-04-12  3:02   ` Vladimir D. Seleznev
2020-04-13 18:04     ` Dmitry V. Levin
2020-04-13 18:20       ` Vladimir D. Seleznev
2020-04-13 18:42         ` Dmitry V. Levin
2020-04-14 16:21           ` Vladimir D. Seleznev

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git