When installing an RPM on CentOS, I receive the following error message:

/var/tmp/rpm-tmp.44492: line 578: [: too many arguments

The trouble I'm having is that /var/tmp/rpm-tmp.xxxxx file is always deleted after a RPM install and I want to see the line number it's having trouble with. What is the best way to preserve this file when installing so that debugging problems with the rpm are easier? So far, I placed this in the %pre section of my rpm spec file to deal with this issue:

cp -vf /var/tmp/rpm-tmp* /tmp/%module_name-rpm-tmp-copy

By copying /var/tmp/rpm-tmp* to /tmp, I was able to look at look at line 578 and fix the syntax error in my code easily. Is there a way to reference the rpm-tmp file that RPM is using during the install? Something from env that I can use in my spec file to copy the correct rpm-tmp instead of a blanket cp (copy /var/tmp/rpm-tmp* files) statement?

  • What is this RPM? It sounds like it has a typo in the post hook that runs at the end. This would be evident if you had the .spec file that was used to create it. You can also get more details of what it's doing with the -v switch to rpm. – slm Aug 28 '14 at 17:09
  • This RPM performs some OS related modifications. If successful with the edits in the %pre section, the rpm will post a Provides: that other product RPMs look at in order for installation to proceed. The line number in the error message doesn't line up with the correct line number in the spec file because rpm-tmp.xxxxx file doesn't contain any comments. After examining the rpm-tmp file for the problem I'm having above, I found I had a malformed if statement that needed correcting. – GoinOff Aug 28 '14 at 17:29
  • 1
    In my post, I explained that I gained access to the rpm-tmp file by putting a cp command in the %pre section that copied /var/tmp/rpm-tmp* to /tmp which preserves any rpm-tmp file before it is deleted by rpm. I'll modify my original post and add more detail. Thx for unclosing the question. – GoinOff Aug 28 '14 at 20:12
  • No problem. Sorry again about that, I'm truly sorry for missing this! I've added an A to your Q, hopefully that's what you were looking for when you asked this. – slm Aug 28 '14 at 20:13
  • I edited the original post to clear things up a bit (I hope). – GoinOff Aug 28 '14 at 20:27

I have also come across this problem today in SLES 11SP4 (RPM verion there is neither a --noclean nor the rewrite the %clean tag suggested solution prevents the deletion of the /var/tmp/rpm-tmp.* script.

I could solve the problem though by adding a succinct exit -1 at the end of the phase I was debugging: rpmbuilder exits with a

error: Bad exit status from /var/tmp/rpm-tmp.00000 (%install)

and the file persists to be debugged.

With rpmbuild you have 2 options.

1. --noclean

You can instruct rpmbuild to not remove these files with this switch when you are --rebuild'ing a package.

$ rpmbuild --rebuild --noclean ....

NOTE: This is available in most versions that I have access to.

$ rpmbuild --help |& grep clean
      --clean                    remove build tree when done
      --noclean                  do not execute %clean stage of the build
Fedora 20
$ rpmbuild --version
RPM version 4.11.2
CentOS 5.x
$ rpmbuild --version
RPM version

2. rpmbuild doesn't support --noclean

If you're using rpmbuild --rebuild to build a package using your own .spec file. and it doesn't support this option, you can add your own routine to the %clean phase of that .spec file.

%if "%{noclean}" == ""
   rm -rf $RPM_BUILD_ROOT


  • My problem occurs when rpm -U xxxxxxx.rpm is executed to install a RPM. Using rpmbuild in this case does'nt help... – GoinOff Aug 29 '14 at 16:22
  • Just curious, do you know why my post from yesterday also shows up here: howproblemsolution.com/fix/… – GoinOff Aug 29 '14 at 19:34
  • Yeah there are sites that crawl SE sites and repost. – slm Aug 29 '14 at 19:40

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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