R – How to solve No such file or directory error: Bad exit status from (%prep) while building an RPM

linuxrpmbuild

I am building an rpm please let me know where i am going wrong,

My spec file is rpms.spec and the contents are:

Summary: GNU indent
Name: rpms
Version: 1
Release: 1
Source0: %{name}-%{version}.tar.gz
License: GPL
Group: Development/Tools
%description
The GNU indent program reformats C code to any of a variety of
formatting standards, or you can define your own.
%prep
%setup -q
%build
./configure
make
%install
make install
%files
%defattr(-,root,root)
/usr/local/bin/indent
%doc /usr/local/info/indent.info
%doc %attr(0444,root,root) /usr/local/man/man1/indent.1
%doc COPYING AUTHORS README NEWS

I have copied the tar file to /usr/src/redhat/SOURCES/ also
and then when i do rpmbuild -ba rpms.spec I get the following error

rpmbuild -ba rpms.spec  Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.87218
+ umask 022
+ cd /usr/src/redhat/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /usr/src/redhat/BUILD
+ rm -rf rpms-1
+ /bin/gzip -dc /usr/src/redhat/SOURCES/rpms-1.tar.gz
+ tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd rpms-1 /var/tmp/rpm-tmp.87218: line 35: cd: rpms-1: No such file or directory error: Bad exit status from /var/tmp/rpm-tmp.87218 (%prep)

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

There is no directory as rpms-1.I tried creating the directory in BUILd directory it didnt work.

Best Answer

You have set Name to rpms and version to 1

rpmbuild will therefore assume that unpacking rpms-1.tar.gz results in a directory named rpms-1 in which is should step into to do the build.

if you want to override that, change the %setup to

%setup -n yourdir

where yourdir is whatever directory your sources are packaged in, inside your tar.gz file

Related Topic