Bug 28514 - urpmi fails to install buildrequires from local .spec file while parsing sources (for a cople packages)
Summary: urpmi fails to install buildrequires from local .spec file while parsing sour...
Status: NEW
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 8
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Mageia tools maintainers
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-03 15:14 CET by Florian Hubold
Modified: 2021-06-05 16:47 CEST (History)
5 users (show)

See Also:
Source RPM: urpmi-8.125-1.mga8.src.rpm
CVE:
Status comment:


Attachments

Description Florian Hubold 2021-03-03 15:14:58 CET
Seems urpmi behaviour changed regarding --buildrequires when trying to install them from a .spec file, or the parsing for .spec has changed. Seems urpmi is trying to parse/stat all the Sources instead of just installing all BuildRequires.

Also not sure why it tries to look in ~/rpmbuild/SOURCES/ for those Sources ...


As an example, from a local checkout of grub2:


[doktor5000@Mageia8]─[15:11:41]─[~/MGA/8/grub2] LC_ALL=C sudo urpmi --debug --buildrequires SPECS/grub2.spec 
getting lock on urpmi
parsing: /etc/urpmi/mediacfg.d/Official-8-x86_64

[snip]

error: Unable to open /home/doktor5000/rpmbuild/SOURCES/grub.macros: No such file or directory
unable to parse spec file SPECS/grub2.spec [No such file or directory]
error registering local packages
unlocking urpmi database
EXITING (pid=17123)

[✗]─[doktor5000@Mageia8]─[15:11:48]─[~/MGA/8/grub2] ls -al SPECS/grub2.spec
-rw-r--r-- 1 doktor5000 doktor5000 16275 Mär  3 14:17 SPECS/grub2.spec

[doktor5000@Mageia8]─[15:12:09]─[~/MGA/8/grub2] grep grub.macros SPECS/grub2.spec
Source1:        grub.macros
[doktor5000@Mageia8]─[15:12:28]─[~/MGA/8/grub2]
Florian Hubold 2021-03-03 15:15:29 CET

CC: (none) => doktor5000, thierry.vignaud

Comment 1 Lewis Smith 2021-03-03 20:28:57 CET
Thank you for the report.
Unsure where to assign it. Start with mageiaTools; could it be rpmstack?

Assignee: bugsquad => mageiatools

Comment 2 Thomas Backlund 2021-03-03 20:39:30 CET
I "think" this only happens with grub2 spec because of it's uggly packaging layout
Comment 3 Thomas Backlund 2021-03-03 20:41:03 CET
because of this:

Source111:      mageia.macros
%include %{SOURCE111}
Comment 4 Thomas Backlund 2021-03-03 20:44:55 CET
I meant:
Source1:        grub.macros
%include %{SOURCE1}


but all those %include and their contents will screw spec parsing
Comment 5 Pascal Terjan 2021-03-03 20:48:56 CET
Yes, the problem is that urpmi has no idea where those files are.
It expects them in _sourcedir which would be /root/rpmbuild/SOURCES.

Tools like bm  will redefine _topdir so that rpm finds everything but I can't think of a clean way to achieve it with urpmi.

A workaround is to to bm -s --nodeps + urpmi SRPMS/*

CC: (none) => pterjan

Comment 6 Alex Kotov 2021-03-04 09:32:49 CET
(In reply to Florian Hubold from comment #0)
> Seems urpmi behaviour changed regarding --buildrequires when trying to
> install them from a .spec file, or the parsing for .spec has changed. Seems
> urpmi is trying to parse/stat all the Sources instead of just installing all
> BuildRequires. ...

Hello, Florian Hubold.
A long time ago, I wrote a script to make it easier to install "BuildRequires" directly from *.spec, who "understands" the "Provides". In addition to Mageia, the script understands *.spec's from Fedora, which is useful for migrating packages. If the Administration allows it, I will leave a link here just in case, since the topic is about this. Florian, perhaps it will be an addition to your collection of scripts.

https://github.com/AKotov-dev/deps

Sincerely,
Alex

CC: (none) => alex_q_2000

Comment 7 Florian Hubold 2021-03-04 23:12:38 CET
Thanks Alex, this is not about how to install buildrequires, I can easily install them via the src.rpm or manually by simply looking for all BuildRequires.
Comment 8 Thomas Backlund 2021-03-04 23:55:55 CET
(In reply to Pascal Terjan from comment #5)
> Yes, the problem is that urpmi has no idea where those files are.
> It expects them in _sourcedir which would be /root/rpmbuild/SOURCES.
> 
> Tools like bm  will redefine _topdir so that rpm finds everything but I
> can't think of a clean way to achieve it with urpmi.

one way could be to parse pwd of spec file, if it is "SPECS", check if it has a SOURCES at same level and set _topdir accordingly...

but otoh I think only grub2 is (ab)using the %include, so it would be easier to fix that spec and drop all the useless cruft in it...
Comment 9 Thierry Vignaud 2021-03-05 22:29:31 CET
I disagree.
First that's not the only package to use %include
Second, %include is a standard feature of modern rpm, we've to live with it.
So we can patch urpmi to handle that case…
Comment 10 Florian Hubold 2021-03-07 17:51:55 CET
@tv:

For completeness sake, Neal mentioned to me that this works just fine with dnf via

sudo dnf builddep -D "_topdir %(pwd)" SPECS/grub2.spec

Maybe some of the spec parsing logic can be adapted and fixed in urpmi ?
Comment 11 Pascal Terjan 2021-03-07 17:59:34 CET
There is no specific logic in dnf, defining _topdir is what is needed, but it is not very user friendly to require the user to do so...

One suggestion in comment #8 was to try to detect if it is the parent directory of the one holding the .spec file and set it.
Comment 12 Neal Gompa 2021-03-08 01:28:00 CET
(In reply to Pascal Terjan from comment #11)
> There is no specific logic in dnf, defining _topdir is what is needed, but
> it is not very user friendly to require the user to do so...
> 
> One suggestion in comment #8 was to try to detect if it is the parent
> directory of the one holding the .spec file and set it.

It is deliberately *not* part of DNF because it's *very* dangerous to allow mutations for RPM settings from the CLI like that in a global context. The builddep subcommand is a plugin that implements a very constrained way to mutate RPM settings to *just* handle spec parsing and revert it before passing on the result to libdnf to set up the transaction to install the packages without those mutations affecting librpm.

CC: (none) => ngompa13

Thierry Vignaud 2021-06-05 16:47:47 CEST

Summary: urpmi fails to install buildrequires from local .spec file while parsing sources => urpmi fails to install buildrequires from local .spec file while parsing sources (for a cople packages)


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