Newbie rpmbuild error

Gary picture Gary · Nov 23, 2010 · Viewed 7.1k times · Source

I'm trying to build my first RPM, but getting an error. My .rpmmarcos files looks like this:

%packager Your Name  
%_topdir /home/snort/test  
%_tmppath /home/snort/test/tmp  
%_smp_mflags  -j3  
%__arch_install_post   /usr/lib/rpm/check-rpaths   /usr/lib/rpm/check-buildroot  

When I run: "rpmbuild -v -bb SPECS/test.spec" I receive this error:
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd test-1 /home/snort/test/tmp/rpm-tmp.55712: line 36: cd: test-1: No such file or directory
error: Bad exit status from /home/snort/test/tmp/rpm-tmp.55712 (%prep)

File rpm-tmp.55712 ends with this:

cd '/home/snort/test/BUILD'
rm -rf 'test-1'  
/bin/gzip -dc '/home/snort/test/SOURCES/test-1.c55.tar.gz' | tar -xvvf -  
STATUS=$?
if [ $STATUS -ne 0 ]; then
  exit $STATUS
fi  
cd 'test-1'

I'm guessing rpmbuild does the "rm -rf 'test-1'" to remove any old/un-needed directories, then it untar's the test-1.c55.tar.gz file, then tries to "cd test-1" but the untar command doesn't make the directory so the scripts errors out. I'm not sure what to do now.

My spec file: more SPECS/test.spec

Name:           test  
Version:        1  
Release:        .c55  
Summary:        Just a Test  

Group:          MyJunk  
License:        GPL  
URL:            http://www.somesite.com  
Source0:        test-1.c55.tar.gz  
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)  

%description  
This is just a test  
<br>
%prep  
%setup BUILD     


%build<br>
%configure<br>
make %{?_smp_mflags}<br>


%install<br>
rm -rf $RPM_BUILD_ROOT<br>
make install DESTDIR=$RPM_BUILD_ROOT
<br>

%clean<br>
rm -rf $RPM_BUILD_ROOT<br>


%files  
%defattr(-,root,root,-)  
%doc  

%changelog  

Any ideas?
Thanks for the Help
Gary

Answer

m1tk4 picture m1tk4 · Dec 4, 2010

RPM (or, to be exact, %setup macro) expects your source tarbal test-1.c55.... to contain the directory test-1.

If the directory there is different, you can fix that by using

%setup -n yourdir

See http://www.rpm.org/max-rpm/s1-rpm-inside-macros.html for more details.