Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Having failures to build RPM using some spec file which works great for other users, I found out that it for some reason changes the current directory to rpmbuild/BUILD:

+ umask 022
+ cd /home/dev1/rpmbuild/BUILD
+ export LANG
+ unset DISPLAY

For other users on same machine exactly, it stays in the directory it was launched, and able to find the required files, so it works fine.

I double checked my .rpmmacros, and the only entry is the topdir pointing to rpmbuild directory.

The SPEC file is:

Summary: core package
Name: core
Version: 2
Release: 1
Group: Applications
License: Commercial
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

Core package



mkdir -p $RPM_BUILD_ROOT/Core
mkdir -p $RPM_BUILD_ROOT/Core/etc
install -m 755 dist/Core.jar $RPM_BUILD_ROOT/Core/
install -m 755 dist/    $RPM_BUILD_ROOT/Core/
install -m 755 dist/etc/configuration.conf $RPM_BUILD_ROOT/Core/etc/


%config(noreplace) /Core/etc/configuration.conf

mv /Core/etc/configuration.conf /Core/etc/configuration.conf.bak

rm -f /Core/Core.jar
rm -f /Core/

Any idea, what can be causing rpmbuild to switch the current directory?


share|improve this question
Can you provide the full paths involved? What does rpmbuild --showrc print? – Mikel Dec 17 '10 at 4:46
What paths you exactly mean? And what portion of rpmbuild --showrc? – SyRenity Dec 17 '10 at 5:40
So what is the actual error you get when the build fails ? – topdog Dec 17 '10 at 6:21
[rpm] + install -m 755 dist/daemon.jar /var/tmp/core-root-dev/Daemon [rpm] install: cannot stat `dist/daemon.jar': No such file or directory [rpm] error: Bad exit status from /var/tmp/rpm-tmp.802 (%install) [rpm] Bad exit status from /var/tmp/rpm-tmp.802 (%install) [rpm] '/usr/bin/rpmbuild' failed with exit code 1 – SyRenity Dec 20 '10 at 10:00
Which naturally happens because the rpmbuild can't find the JAR files. – SyRenity Dec 20 '10 at 10:01
up vote 1 down vote accepted

topdir in .rpmmacros indicates where your software should be built, rpmbuild recommends to build your programs in a separate dir to avoid crossing streams with live files, which is normally a good behaviour.

If you wanna remove this behaviour just remove topdir from .rpmmacros although I don't recommend this.

It could easily be that the SPEC file depends on some enviroment variable that is not set in your user but set on the others, you should compare and see if that's the case, if it's so add this env variable to the SPEC file.

So in one word, I think the SPEC is to blame for somehow missing this, if you paste the SPEC around here I can have a look and try to find the issue for you

share|improve this answer
I pasted the SPEC in description above, thanks. – SyRenity Feb 10 '11 at 18:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.