Bug 1404281 - dnf builddep --spec fails to recognize legitimate spec file
Summary: dnf builddep --spec fails to recognize legitimate spec file
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf-plugins-core
Version: 25
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: rpm-software-management
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 1366411
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-12-13 14:21 UTC by Nikos Mavrogiannopoulos
Modified: 2016-12-19 12:36 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-12-19 12:36:08 UTC
Type: Bug


Attachments (Terms of Use)

Description Nikos Mavrogiannopoulos 2016-12-13 14:21:05 UTC
Description of problem:
dnf builddep fails to create dependencies from a spec file.



How reproducible:
1. fedpkg clone -a openconnect
2. dnf builddep -y --spec openconnect/openconnect.spec



Actual results:
Last metadata expiration check: 0:49:13 ago on Tue Dec 13 14:29:59 2016.
Failed to open: 'openconnect/openconnect.spec', not a valid spec file.
Error: Some packages could not be found.

Comment 1 Nikos Mavrogiannopoulos 2016-12-13 14:21:45 UTC
I am actually trying to work around #1402784

Comment 2 Panu Matilainen 2016-12-14 06:28:07 UTC
Here's the problem:

[pmatilai@sopuli dist]$ rpmspec -q --buildrequires openconnect/openconnect.spec 
warning: Macro expanded in comment on line 12: %make_install macro

error: Unable to open /home/pmatilai/rpmbuild/SOURCES/macros.gpg: No such file or directory
error: query of specfile openconnect/openconnect.spec failed, can't parse
[pmatilai@sopuli dist]$ 

I was about to say this is an rpm bug, it's supposed to ignore missing sources in spec parse, but the problem here is this:
%include %SOURCE3

Rpm tries to include it from %_sourcedir, but that defaults to ~/rpmbuild/SOURCES and since SOURCE3 (macros.gpg) is not there it fails. The difference here is that an average source is not relevant for parsing the spec, but an %include is, so it cannot be ignored like other sources.

If you tell what the source dir is, it works:
[pmatilai@sopuli dist]$ rpmspec --define "_sourcedir openconnect" -q --buildrequires openconnect/openconnect.spec
warning: Macro expanded in comment on line 12: %make_install macro

Found source: openconnect/openconnect-7.08.tar.gz
Found source: openconnect/openconnect-7.08.tar.gz.asc
Found keyring: openconnect/gpgkey-BE07D9FD54809AB2C4B0FF5F63762CDA67E2F359.asc
Found source: openconnect/macros.gpg
No common key yet
Using first found keyring file: openconnect/gpgkey-BE07D9FD54809AB2C4B0FF5F63762CDA67E2F359.asc
------------
autoconf
automake
gettext
gnupg2
krb5-devel
libtool
pkgconfig(gnutls)
pkgconfig(liblz4)
pkgconfig(libpcsclite)
pkgconfig(libproxy-1.0)
pkgconfig(libpskc)
pkgconfig(libxml-2.0)
pkgconfig(socket_wrapper)
pkgconfig(stoken)
pkgconfig(uid_wrapper)
python
trousers-devel
[pmatilai@sopuli dist]$

Only there's no way to do that with dnf builddep.

It's one of those cases where everything is behaving correctly but somehow it ends up not working :) %include in spec is problematic from parsing POV, because generally a spec can be parsed as an independent entity but %include introduces local paths into the picture.

Comment 3 Panu Matilainen 2016-12-14 06:44:27 UTC
In this particular case, the %include is only needed during build (%prep) but and the issue could be avoided by writing the spec differently, eg something like:

%if 0%{?gitcount} > 0
%include %SOURCE3
%gpg_verify
%endif

But that's just an exception, the expected use of %include is to construct parts of the spec so it can't be just ignored.

Comment 4 David Woodhouse 2016-12-15 14:23:03 UTC
Hm, I thought that's how we were supposed to use this until it landed in the default macros. Tibbs?

Comment 5 Panu Matilainen 2016-12-16 06:43:44 UTC
Actually my "workaround" only works because it disables the whole thing so not the most thought-out workaround ever, sorry about that. The bottom line is %include is somewhat problematic, and in this case the whole thing would be better off written as a shell-script because it's only supposed to be executed during %prep.

Comment 6 Igor Gnatenko 2016-12-19 12:36:08 UTC
We have introduced printing rpm error if spec parsing fails, so it should be improved UX.

Unfortunately dnf can't do more about this.


Note You need to log in before you can comment on or make changes to this bug.