4

When I use rpmbuild I get, No such file or directory.

# rpmbuild -ba ./SPECS/myFoo.spec
error: File /root/rpmbuild/SOURCES/myFoo.tar.gz: No such file or directory

It seems to be reading from my home directory despite running the rpmbuild command from an entirely different user's home directory. However that doesn't change if I use --root (which is documented as "Use the file system tree rooted at DIRECTORY for all operations.")

# rpmbuild -ba ./SPECS/myFoo.spec --root /home/centos/myFoo/
error: File /root/rpmbuild/SOURCES/myFoo.tar.gz: No such file or directory

What' the solution to getting this to look in the right place.

6
  • Why are you running rpmbuild as root? Commented Nov 20, 2019 at 14:27
  • I get No such file or directory when I run it as non-root too. error: File /home/centos/rpmbuild/SOURCES/myFOO_rc1.tar.gz: No such file or directory Commented Nov 20, 2019 at 14:40
  • I’m not asking if it works any better when running as a user; I’m asking why you’re running rpmbuild as root. Commented Nov 20, 2019 at 14:57
  • 1
    (I’m being curious, really; trying to understand what suggests that running rpmbuild is either needed or a potentially good idea.) Commented Nov 20, 2019 at 15:04
  • Because we develop as root. And because it didn't work as a regular user. But I don't see how that's relevant here, but feel free to ask more questions so long as they're related to this problem. Commented Nov 20, 2019 at 15:14

3 Answers 3

8

One method to do this, is

rpmbuild --define "_topdir `pwd`" -ba ./SPECS/myFoo.spec

No idea if that's the right method.

5

rpmbuild doesn’t particularly care about the current directory, except to find the files given to it as arguments. Everything else is based on the value of the _topdir macro. rpmbuild also really expects you to do all your building with a single directory structure.

You can define the root of rpmbuild’s directory structure permanently for any particular user by storing the appropriate value in ~/.rpmmacros:

%_topdir /path/to/your/data

Or, as you determined, override _topdir every time you run rpmbuild with the -D option.

1
  • Let's say I have foo/SPECS/foo.spec, bar/SPECS/bar.spec, baz/SPECS/baz.spec. Is it possible to set %_topdir properly for foo/bar/baz? Or should I continue with my solution? Or am I doing something majorly wrong? Commented Nov 20, 2019 at 18:02
4

I have the same problem, and I have used the follow solution.

Open the file ~/.rpmmacros

and change the line:

%_topdir %(echo $HOME)/rpmbuild

for:

%_topdir %(pwd)

Now:

rpmbuild -ba ./SPECS/myFoo.spec

will work as excepted.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.