4

I'm trying to build an rpm from source-1.4.3-linux.tgz (that is downloaded so I don't control the name) and the file untars into the directory source-1.4.3-linux. In my source.spec file, I have

Name: source
Version: 1.4.3 

So it is probably quite logical that I am getting an error:

cd: source-1.4.3: No such file or directory.  

I tried tacking -linux onto the version, but rpmbuild wants only a number there. What do I have to do to tell rpmbuild that the source files are untarred into source-1.4.3-linux?

Boyd
  • 351
  • 4
  • 14
  • could you show more contens of you spec file? Probably you need to change the %prep section. The rpmbuild output should tell you in which section the error occured – Chris Maes Sep 12 '18 at 06:07
  • Thank you. This put me on the right track. I found what I had to do in %prep. Will post answer below. – Boyd Sep 13 '18 at 07:47

3 Answers3

6

Just use the setup macro.

setup -n %{name}-%{version}.linux

Aaron D. Marasco
  • 6,506
  • 3
  • 26
  • 39
  • This answer should be accepted. Is does what OP requests: build from an alternate source root in the tarfile. Corresponds with http://ftp.rpm.org/max-rpm/s1-rpm-inside-macros.html. – Edward Oct 01 '20 at 08:14
-1

Here is a simple.spec file that would help you understand the issue. Source tarball contains the following:

$ tar tzf simple-0.tar.gz 
simple-0/
simple-0/simple.txt

Spec file:

Summary: Simple SPEC
Name: simple
Version: 0
Release: 1
License: NONE
Group: NONE
URL: NONE
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root


%description
" This is Simple "

%prep
%setup -q

%build

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/tmp/
install -m 0644 simple.txt %{buildroot}/tmp/simple.txt

%clean
rm -rf $RPM_BUILD_ROOT

%post
echo "In the Post section of Simple"

%files
%defattr(-,root,root,-)
%doc
/tmp/simple.txt


%changelog
* Wed Sep 12 2018  <iamauser@localdomain> - 
- Initial build.
iamauser
  • 11,119
  • 5
  • 34
  • 52
  • As per the question the file name/contents is $ tar tzf simple-0-linux-blah.tar.gz simple-0-linux-blah/ simple-0/simple.txt This unconventional naming is the issue I'm asking about. – Boyd Sep 13 '18 at 07:51
-1

ok I got this working. Maybe a hack but it is working. As per the question my tarball is unconventionally named.

$ tar tzf source-1.4.3-linux-amd64.tar.gz 
source-1.4.3-linux-amd64/
source-1.4.3-linux-amd64/simple.txt

in the specfile %prep section instead of using %setup or %autosetup, I unpacked manually and renamed the untarred directory.

Name:       source
Version:    1.4.3
Release:    0
Source0:    https://example.com/%{name}-%{version}-linux-amd64.tar.bz2

%prep
rm -fr %{name}-%{version}
tar -xjf %{SOURCE0}
mv %{name}-%{version}-linux-amd64 %{name}-%{version}
Boyd
  • 351
  • 4
  • 14