RPM Community Forums

Mailing List Message of <rpm-devel>

Extending header extension tag syntax.

From: Jeff Johnson <n3npq@mac.com>
Date: Thu 08 May 2008 - 21:42:43 CEST
Message-Id: <4979A7AB-61FC-4482-9B51-D2CF132A0AA4@mac.com>
A header extension tag is a means to stransorm package metadata.
The simplest example is likely ":date", used by rpm -qi for years
to format RPM_INT32_TYPE into a ctime(3) string.

Over the last couple of months I've had to add a number of
header format extensions, including ":utf8" to use iconv(3),
and ":cdata" to do XML escaping.

One deficiency in the existing (and ancient ;-) --qf header
format extensions is that there's no means to apply
several extensions, like 1st convert to utf8, then escape
for cdata. So far that hasn't been a big issue, as it's pretty
clear that ":cdata" implies ":utf8" for common XML conversion
case.

But this past weekend I found my self creating ":bncdata",
which does (essentially) a basename(3) on a file URI, and
then converts to utf8 and XML escapes.

It's certainly possible to generate ":foobar" and ":barfoo"
extensions to handle both cases of applying ":foo" and ":bar"
application and change nothing wrto header format extensions.

There is a performance cost however, since header extensions are
searched linearly as chained tables. So there is a performance
cost on headerGet() pathways if I continue to populate header
extensions. Sure the "linear" can be turned into logarithmic
with a more intelligent store, but then one has to pay the cost
of setting up a binary/hash store lazily.

The second reason for extending header format extensions is to
support passing a parameter to the routine that implements the
extension. Perhaps the simples case is %d/%x/%o to choose
whether decimal/hexadecimal/octal output is desired.

There's a need (imho) to wire a ":uuid" conversion, which comes
in 5 versions (yes only some are useful for rpm), as well as digests
(used widely by repository markup), that are leading me to consider some
means to pass parameters through --queryformat syntax rather than
by generating all possible combinations of ":foobar" and ":barfoo"  
string
concatenation.

So any ideas about syntax? Off the top of my head, maybe
     :foo(fooarg1,fooarg2):bar(bararg)
L->R (or R->L, it really doesn't matter yet) serial application
of parameterized header extensions.

And perhaps its time to just wire a lua hook into headerSprintf  
extensions,
and remove the buttload of table entries for header tag/format  
extensions
that are currently growing deep inside rpm libraries,

Any other opinions?

73 de Jeff
Received on Thu May 8 21:43:56 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.