RPM Community Forums

Mailing List Message of <rpm-devel>

More --queryformat design fiddles

From: Jeff Johnson <n3npq@mac.com>
Date: Tue 28 Oct 2008 - 16:13:08 CET
Message-id: <EABAE9D0-2E12-4D75-BBB7-9ACECA5AFADD@mac.com>
I find myself wrestling --queryformat limitations Yet Again.

I'm trying to write a rude & crude scriptlet classifier, essentially
using
	rpm -qa --scripts
input to a post processor that will change paths to class identifiers.

All I'm saying is that I'm trying to do, e.g.
	rpm -qa --scripts | sed -e 's,/sbin/ldconfig,SCRITLETCLASS_LDCONFIG,'

(aside)
The first problem I find is easily solved, but illustrates a  
fundamental design
flaw with rpm queries. As originally conceived, rpm --query output was  
destined
for humans, with all the usual semantic and i18n & --help wrappings to  
try to make the
spewage intelligible:
	$ rpm -q --scripts popt
	postinstall program: /sbin/ldconfig
	postuninstall program: /sbin/ldconfig
However, options like --scripts have evolved over time, and its input to
other programs, with a need for simple/regular/predicatble ouput, that  
is
increasingly important:
	$ rpm -q --scripts:yaml popt
	Postin(/sbin/ldconfig): (none)
	Postun(/sbin/ldconfig): (none)
Because YAML is mostly readable by humans, and potentially has a well  
defined
encoding, I will likely increasingly adapth existing popt aliases to  
generate
YAML instead. But I digress ...

The problem that leads to wrestling with --queryformat is that I'd like
the install program to be displayed using #! syntax prefixing the  
scriptlet body.
But --queryformat is per-tag, not per-tag set, and so the ":yaml"  
format extension
cannot include the interpreter because its a different tag.

I had started extending the queryformat mechanism (but not the syntax,  
a different
problem) from, say,

	rpm     alias --scripts:yaml --qf '\
	%|PREINPROG?{Prein(%{PREINPROG}):\
	 %{PREIN:yaml}|\
	\n}|\

to a "tag set" generalization with syntax like

	rpm     alias --scripts:yaml --qf '\
	%|PREINPROG?{Prein:\
	 %{PREINPROG,PREIN:yaml}|\
	\n}|\

Note that syntax scoping of ":yaml" is ambiguous. Should it apply to  
the tag
or the tuple? The easier implementation to achieve is to mandate the  
scoping
to apply to the "tag set", not the tag, in which case the ":yaml" format
extension applies to all, not the last, member of the tag set. OTOH,  
the more
natural and powerful generalization would be to permit per-item rather  
than
per-set application. But that will need a more powerful --queryformat  
syntax
parser than what currently exists in rpm, and I'm still not ready to  
commit
to a --queryformat set.

All of the above is a wordy/windy rationale for hackery I'm gonna  
check-in soonishly.
Basically ":yaml" applied to a "tag set" that will be initially  
instantiated as
(note the reversal of tags in set for argv[0] usage compatibility)

	rpm     alias --scripts:yaml --qf '\
	%|PREINPROG?{Prein:\
	 %{PREIN,PREINPROG:yaml}|\
	\n}|\

so that I can pass multiple tags in order to add the scriptlet  
interpreter using "#!" syntax
within the ":yaml" format extension so that a rude & crude scriptlet  
classification using
YAML spewage can be more easily written.

I'm very likely to change my mind as I implement too ...

73 de Jeff 
Received on Tue Oct 28 16:13:27 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.