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?


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 tarball in SOURCE and write simple spec-file with skipped sections: %prep, %build.

Little example:


[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


Name:       binarius
Version:    0.1
Release:    1%{?dist}
Summary:    Binarius package

Group:      System Environment/Base
License:    GPLv3+
Source0:    binarius-0.1.tar.gz

Testing package.

%setup -q #unpack tarball


cp -rfa * %{buildroot}

| improve this answer | |
  • It is better to have %prep\n %setup -q \n\n %install \n cp -rfa * %{buildroot}. Rest of the answer is correct. – msuchy Mar 13 '18 at 20:30
  • In Centos 7.4, macro '%setup -q' force trying './configure' step. Therefore, I omit it. – Yurij Goncharuk Mar 13 '18 at 20:36
  • Yurij - definitely not true. See ftp.rpm.org/max-rpm/s1-rpm-inside-macros.html – msuchy Mar 14 '18 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. – Yurij Goncharuk Mar 14 '18 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. – Yurij Goncharuk Mar 14 '18 at 21:32

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.