RPM Build - Permission Denied

4.8k views Asked by At

I have a Python-based SVN pre-commit script that generates an rpmbuild .spec file and runs rpmbuild -bb my.spec via subprocess. The current state is:

1) When doing an SVN commit (SVN over SSH) remotely the rpmbuild fails with...

error: failed to create directory %{_topdir}: /rpmbuild: Permission denied

2) When I rpmbuild -bb my.spec (local on the SVN server) it completes successfully

I have ~/.rpmmacros...

%_topdir /tmp/rpmbuild

When doing #2 (above) rpmbuild will create BUILD, BUILDROOT, RPMS, SOURCES, SPECS, and SRPMS under /tmp/rpmbuild and an RPM is created in RPMS.

From the command line, if I rpm --showrc the dirs are as I expect (and should be which is why the process completes successfully).

But I have different results from the process running via pre-commit...

Command line... -14: _topdir /tmp/rpmbuild

Pre-commit... -14: _topdir %{getenv:HOME}/rpmbuild

I suspect this is the problem and I do not know how to correct this. I also tried:

1) To set the path in my.spec... %define _topdir /tmp/rpmbuild which gave the same permission denied error.

2) To set the path in the rpmbuild command... rpmbuild --define='_topdir /tmp/rpmbuild' which resulted in error: Macro % has illegal name (%define).

Your expertise in resolving this appreciated; thanks very much!

2

There are 2 answers

0
user1801810 On BEST ANSWER

The missing piece is the file...

/etc/rpm/macros

I created /etc/rpm and the file macros populated with my needed %_topdir.... After doing so _topdir is available to rpmbuild and my process completes successfully. This was discovered by running rpmbuild through strace.

0
Etan Reisner On

That error means $HOME is unset when pre-commit runs (so your .rpmmacros file isn't being used and ${getenv:HOME} is evaluating to the empty string).

I don't know why that would be (perhaps an svn change) but that seems to be the issue.