RPM Community Forums

Mailing List Message of <rpm-users>

Re: determine package arch without/before building package?

From: Jeffrey Johnson <n3npq@me.com>
Date: Wed 11 Jul 2012 - 20:35:54 CEST
Message-id: <C8AC973A-374B-432D-837B-B7C0D10CBD46@me.com>

On Jul 11, 2012, at 12:13 PM, Tim Mooney wrote:

> Given a spec file foo.spec, is there a way use rpmbuild or rpm to
> determine what the package architecture will be without (or before)
> actually building the package?
> I know I could use sed or grep on the spec file looking for BuildArch,
> but I'm wondering if there's a way to essentially run the equivalent of
> a macro --eval query against a spec file.

The "recommended" way is this

	./rpm -q --qf '%{arch}\n' --specsrpm rpm.spec

Yes: SRPM's have a RPMTAG_ARCH associated.
And yes sed/grep/awk can all be used if the *.spec file isn't
all b00gered up with macro magic.

The functionality is kinda tweaky and backward because ultimately the
arch is determined by configuration and how rpm is invoked which
are all mostly known a priori (noarch being the important exception,
cross-building and multilib builds have never been directly supported
by rpmbuild itself meaningfully).

It wouldn't be too hard to add some sugary automatic syntax to all of the above
to hide the gory details. All that stops the implementation is consensus on the option
(technically the popt alias) name to be used and supported.

I'm not going to hold my breath waiting for consensus to appear wrto rpmbuild however.


73 de Jeff
Received on Wed Jul 11 21:36:00 2012
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.