RPM Community Forums

Mailing List Message of <rpm-devel>

Permitting tag tuples with --queryformat

From: Jeff Johnson <n3npq@mac.com>
Date: Fri 27 Jun 2008 - 16:04:30 CEST
Message-id: <C7728FA2-B435-472D-B8E9-D977F1B84237@mac.com>
Increasingly, I'm finding myself having to make a choice between
implementing some spewage functionality as a header tag or
a header format extension.

My choice is largely decided by the arguments passed.

In rpm-5.0/rpm-4.5, a header tag extension is prototyped as

     /** \ingroup header
      * HEADER_EXT_FORMAT format function prototype.
      * This is allowed to fail, which indicates the tag doesn't exist.
      *
      * @param h             header
      * @retval he           tag container
      * @return              0 on success
      */
     typedef int (*headerTagTagFunction) (Header h, HE_t he)
         /*@modifies he @*/;

while a header format extension is prototyped as

     /** \ingroup header
      * HEADER_EXT_TAG format function prototype.
      *
      * @param he            tag container
      * @param av            parameter array (or NULL)
      * @return              formatted string
      */
     typedef /*only@*/ char * (*headerTagFormatFunction) (HE_t he, / 
*@null@*/ const char ** av)
         /*@modifies he @*/;

So my criteria for choosing between a header extension tag or format  
implementation is

1) Are multiple tags needed?
     ==> Use a header extension tag because a Header is passed.

2) Are parameters needed?
     ==> Use a header extension format with parameters passed in  
ARGV_t av.

While I could just pass headers to extension formats and figger some  
syntax
to pass parameters to header extension tags, that change just  
obliterates the distinction
between "tags", which are basically items to be processed, and  
"formats", which
are transforms to be applied to items.

The distinction between "items" and "transforms" seems (to me  
anyways) worth preserving.

What I will attempt instead is to permit a tuple array into a HE_t  
container.

Since all of the above likely makes no sense to anyone, here's a  
concrete example:

The current queryformat used by the --requires popt alias is

     rpm     alias --requires        --qf \
       "[%{REQUIRENAME}%{REQUIREFLAGS:depflags}%{REQUIREVERSION}\n]" \
             --POPTdesc=$"list capabilities required by package(s)"

Instead, the usual {N,EVR,F} dependency tuple could/should be passed  
to a formatter method
with a RPM <-> DEB format selector parameter:

     rpm     alias --requires        --qf \
       "[%{REQUIRENAME,REQUIREFLAGS,REQUIREVERSION:depformat(RPM)}\n]" \
             --POPTdesc=$"list capabilities required by package(s)"

Changing a tag item into a tag tuple is almost certainly gonna break  
something. Caveat emptor.

73 de Jeff
Received on Fri Jun 27 16:04:47 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.