2

Resources on Internet are all about how to build a rpm files from source code.

But I have already got compiled binary tarball of software. But I don't want to directly extract it to / , because it is difficult to maintain. How can I build a rpm package from binary tarball.

There is a series famous software which provided the binary package in a tarball which have a clearly tree structure which is same as the tree structure in root dir.

And so on.

A lot of software provider release universal tarball to make the software universal in different Linux distribution.

Is there a essential way?

1

1 Answer 1

5

UPD Thanks to @msuchy who has corrected me.

Assume that you've already created a 'rpmbuild' directory skeleton in your home directory: SPECS, BUILD, SOURCES... Copy the tarball into the SOURCE directory and write simple spec-file, skipping the sections: %prep, %build.

Little example:

Tarball:

[yurij@centos7 SOURCES]$ ls -lah total 4.0K drwxrwxr-x. 2 user user 33 Mar 12 12:22 . drwxrwxr-x. 8 user user 89 Dec 8 15:54 .. -rw-rw-r-- 1 user user 231 Mar 12 12:14 binarius-0.1.tar.gz [yurij@centos7 SOURCES]$ tar -tvf binarius-0.1.tar.gz drwxrwxr-x user/user 0 2018-03-12 12:11 ./binarius-0.1/ drwxrwxr-x user/user 0 2018-03-12 12:11 ./binarius-0.1/usr/ drwxrwxr-x user/user 0 2018-03-12 12:11 ./binarius-0.1/usr/local/ drwxrwxr-x user/user 0 2018-03-12 12:12 ./binarius-0.1/usr/local/bin/ -rwxr-xr-x user/user 30 2018-03-12 12:12 ./binarius-0.1/usr/local/bin/binarius 

Spec-file:

Name: binarius Version: 0.1 Release: 1%{?dist} Summary: Binarius package Group: System Environment/Base License: GPLv3+ Source0: binarius-0.1.tar.gz %description Testing package. %prep %setup -q #unpack tarball %build %install cp -rfa * %{buildroot} %files /* 
5
  • It is better to have %prep\n %setup -q \n\n %install \n cp -rfa * %{buildroot}. Rest of the answer is correct. Commented Mar 13, 2018 at 20:30
  • In Centos 7.4, macro '%setup -q' force trying './configure' step. Therefore, I omit it. Commented Mar 13, 2018 at 20:36
  • Yurij - definitely not true. See ftp.rpm.org/max-rpm/s1-rpm-inside-macros.html Commented Mar 14, 2018 at 20:43
  • I've tested spec with '%prep', '%setup'. You are right. I knew that macros '%prep', '%setup' must not to do configure step. '%configure' macro exists for that. But, when I was writing and testing spec for this example, configure step was executing after any changes in spec file. When I've commented all macros except '%install', I've got package. It's hard to assume what happed, but now it's work. Maybe I was not so close. Thanks for correction! I've edit answer. Commented Mar 14, 2018 at 21:25
  • Usually, if I'm not sure about macro, then I read 'rpmbuild --showrc' output. In my answer I've forgotten to do this. Commented Mar 14, 2018 at 21:32

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.