I am trying to build an RPM but when I use this command to build it:

[root@vmdb SPEC]# rpmbuild -v -bb SPEC/supportScripts.spec

I always get this error:

Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.gG9C7Y
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd /root/rpmbuild/BUILD
+ rm -rf supportScripts-1
+ /usr/bin/gzip -dc /root/rpmbuild/SOURCES/supportScripts-1.tar.gz
+ /bin/tar -xf -
+ '[' 0 -ne 0 ']'
+ cd supportScripts-1
/var/tmp/rpm-tmp.gG9C7Y: line 34: cd: supportScripts-1: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.gG9C7Y (%prep)

RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.gG9C7Y (%prep)

I have looked on the internet as to why this error might occur and it is due to a bad argument with the macro I am using in %prep/%setup. I am not sure what I need in replacement to fix it and it is getting frustrating. This is what my spec file looks like:

Name:           supportScripts
Version:        1
Release:        1
Summary:        All the support scripts bundled into an RPM.
BuildArch:      noarch

Group:          Development/Tools
License:        GPL
URL:            http://localhost
Source0:        supportScripts-1.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

These are all the support tools we need for new Hardware Agent builds. This will package all the scripts support uses for new builds.

%setup -q

mkdir -p "$RPM_BUILD_ROOT/opt"
cp -R * "$RPM_BUILD_ROOT/opt"



chown -R support:support /opt/*
chmod -R 775 /opt/

UPDATE: What is weird is that I have found the rpm completely built in /root/rpmbuild/RPMS/noarch. I have ran command:

rpm -ivh supportScripts-1-1.noarch.rpm

to unpack all the scripts, and miraculously its there! My next question is: Should I be concerned of any mishaps with the rpmbuild command I have done?


RPM is expecting your package to follow the standard packaging guidelines for Unix software. The GNU release guidelines are typical, but a lot of non-GNU software follows these rules, too.

Specifically here, you have a package called supportScripts, version 1, so the tarball is expected to be called supportScripts-1.tar.gz, and it is expected to unpack into a directory called supportScripts-1.

While there may be ways to arm-twist RPM into coping with a nonstandard scheme, it's simplest to just follow the one it expects.

| improve this answer | |
  • I am not sure how to make the spec file conform to what it expects there to be. Like I mentioned, surprisingly I see the RPM already built and when I unwrraped it, all my scripts were there. Can I just use that RPM or would that produce future problems? I will be using that RPM on to unwrap our scripts at my job for when I build future servers. – ryekayo Sep 12 '14 at 19:14
  • I'm not telling you to change the spec file. I'm telling you to change how you build that tarball, so that it is called supportScripts-1.tar.gz, and so that it unpacks into a directory called supportScripts-1. The error is saying that it is trying to cd into that directory, and is failing because it is not there. – Warren Young Sep 12 '14 at 19:20
  • How should I build the tarball so that it conforms to everything else then? – ryekayo Sep 12 '14 at 19:27
  • Elementary: mkdir supportScripts-1 ; cp $STUFF supportScripts-1 ; tar cvzf supportScripts-1.tar.gz supportScripts-1 – Warren Young Sep 12 '14 at 19:42
  • 1
    You probably didn't copy the new tarball into SOURCES. – Warren Young Sep 12 '14 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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