RPM Community Forums

Mailing List Message of <rpm-devel>

Re: Another strange request

From: Jeff Johnson <n3npq@mac.com>
Date: Fri 14 Dec 2007 - 14:00:08 CET
Message-Id: <416343D9-2EDA-4E3B-9114-A9A899A0E3FF@mac.com>

On Dec 14, 2007, at 7:00 AM, Ralf S. Engelschall wrote:

> I'm currently trying to figure out whether the following would be
> possible to easily support VCS-less package modifications for end  
> users:
>
> 1. Someone unpacks a *.src.rpm to the local filesystem
> 2. He changes some files (usually via svs(1) which automatically
>    generates the *.orig files for him, etc) according to his needs.
> 3. He then packs a new *.src.rpm from the changed source files.
>
> And here the request comes: could it be achieved that for each already
> existing "SourceX: foo" and "PatchX: bar" lines in the *.spec file,
> an RPM macro hack automatically generates additional "Source1000X:
> foo.orig" and "Patch1000X: bar.orig" lines in order to include those
> files into the new *.src.rpm?
>
> The question is not whether the Source1000X tags can be generated.
> That's clear, it can be done similar to what I did yesterday for
> the Environment tag. The question is how I can figure out in the
> generation-macro which *.orig files exists. For this I first have  
> to...
>
> 1. reliably locate the *.spec file.
>    How can this be done?
>    A "rpm --eval '%{_specdir}'" doesn't work as it still might contain
>    %{name} which depends on the current package.
>

There's a chicken <-> egg problem here that was (but is borken on HEAD)
solved by using a per-macro context that included %{name} in %{_topdir}
so that other (but not %{_specdir}) macros might include %{name}.

If you _REALLY_ need %{_specdir} to include %{_name} before opening
and parsing foo.spec,  it will be a hard and/or hacky implementation.  
The
only approach is something like how %{_target_cpu} is set in  
boostrapping
rpm configuration.

Including %{name} in other macros is still on my todo. I'm currently  
renaming
'%{name} => whatever after doing rpm -ivh foo*.src.rpm.

> 2. query all its SourceX and PatchX header.
>    How can this be done?
>    A "rpm -q --specfile *.spec --qf '%{SOURCE0}' didn't worked.
>

%{SOURCE0} is a macro, not a queryformat specifier.

Try
     $ rpm -qp --qf '[%{source}\n]' time*.src.rpm
     time-1.7.tar.gz
     $ rpm -qp --qf '[%{patch}\n]' time*.src.rpm
     time-1.7-destdir.patch

The issue with --specfile is listed in the TODO. Basically source/patch
needs to be added to srpm header earlier so that source/patch can be  
queried
with --specfile.

Note that the fix is not quite as simple as just reverting the patch  
bcause of how
Icon: is now wired. But its not much harder than reverting the patch.

73 de Jeff
Received on Fri Dec 14 14:01:06 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.