• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4561
  • Last Modified:

Create RPM from already compiled and tar.gz file

I have been tasked with taking a suite of software tools we develop in-house that is provided to me pre-compiled and as a .tar.gz file and creating a simple binary RPM installer. The software has no external dependancies. Our typical install procedures is to untar the tar directories to a location. It is all stand alone with no external dependancies.  

Is this even possible? I don't have access to the source since I am not on the development team. I have the tar file and can untar the directory structure to get the precompiled toolset directory structure. But they basically want a binary RPM file to function like an un-tar so the end user just has to double click the RPM file and BOOM all our software is in the proper place.

Example directory structure
  • 5
  • 3
  • 2
  • +1
2 Solutions
RPM is a very flexible format and will certainly let you just extract the tarball without having to compile anything.

I'd read this as an introduction: http://www.ibm.com/developerworks/library/l-rpm1/

In your case, you can just leave the %build and %install sections blank.
Deepak KosarajuDevOps EngineerCommented:
you have to create a spec file and then load the spec file into tar.gz and then use following command to create rpm pkg
rpmbuild -ta packagename.tgz
rpmbuild -ta packagename.tar.gz

rpmbuild -ba packagename.spec

You require rpmbuild to be installed on your system before start building rpm from source package as u said no deps associated for your package you can avoid depes steps on spec file.
Basic spec file consist of

# Example spec file for cdplayer app...
Summary: A CD player app that rocks!
Name: cdplayer
Version: 1.0
Release: 1
Copyright: GPL
Group: Applications/Sound
Source: ftp://ftp.gnomovision.com/pub/cdplayer/cdplayer-1.0.tgz
URL: http://www.gnomovision.com/cdplayer/cdplayer.html
Distribution: WSS Linux
Vendor: White Socks Software, Inc.
Packager: Santa Claus <sclaus@northpole.com>

It slices!  It dices!  It's a CD player app that
can't be beat.  By using the resonant frequency
of the CD itself, it is able to simulate 20X
oversampling.  This leads to sound quality that
cannot be equaled with more mundane software...

Open in new window

ruggarAuthor Commented:
Just to clarify, the .tar.gz file I get DOES NOT contain source. It is the result of the source already having been compiled. I just need an RPM that can be clicked on and extract or copy files to a specific directory. Much like you would do with the original .tar.gz file anyway.
Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

ruggarAuthor Commented:
Thank you kosarajudeepak. I will try that and report back.
ruggar, we understand the structure of your tarball. Like I mentioned above, you can just have the RPM extract the files when double-clicked and exit.
Deepak KosarajuDevOps EngineerCommented:
RPM nature is to extract and push to specific location - like if u see the package below my package just pushes the files to specific location.
So when I install (or) double click this RPM the files are copied to the location define inside the rpm pkg.

To make things simple I attached sample spec file which does exactly you might be looking for.
[root@pro01 ~]# rpm -qpl nagios-3.0.3-1.fc4.test.i386.rpm 

[root@pro01 nsca-2.7.2]# cat nsca.spec 
%define name nsca
%define version 2.7.2
%define release 1

# Macro that print mesages to syslog at package (un)install time
%define nnmmsg logger -t %{name}/rpm

Summary: Host/service/network monitoring agent for Nagios
URL: http://www.nagios.org
Name: %{name}
Version: %{version}
Release: %{release}
License: GPL
Group: Application/System
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-buildroot

This program is designed to accept passive service check results from 
clients that use the send_nsca utility and pass them along to the 
Nagios process by using the external command 

%setup -q
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
install -b -D -m 0644 sample-config/nsca.cfg ${RPM_BUILD_ROOT}/etc/nagios/nsca.cfg
install -b -D -m 0644 sample-config/send_nsca.cfg ${RPM_BUILD_ROOT}/etc/nagios/send_nsca.cfg
install -b -D -m 0755 src/nsca ${RPM_BUILD_ROOT}/usr/sbin/nsca
install -b -D -m 0755 src/send_nsca ${RPM_BUILD_ROOT}/usr/bin/send_nsca


%files send
%config(noreplace) /etc/nagios/send_nsca.cfg

Open in new window

   Since you say that you already have the tar file which has the directory structure to get the precompiled toolset directory structure and you basically need to just create an RPM out of it, I suggest that you take a look at "myrpm" available at http://code.google.com/p/myrpm/.
   I have used this script earlier to create rpm out of an existing tar file. It requires basic configuration to be able to create a RPM which will include information like Description, Author, Version and Revision.
   Check the User Guide kept at http://code.google.com/p/myrpm/wiki/UserGuide which will give you a good idea on how to achieve that.
ruggarAuthor Commented:
Could you provide me an example of using a tar.gz file with myrpm? When I try to run it I get an error:

I ran this command:
myrpm -v -a /myrpm/testtoolset.tar.gz -N Toolset -V 10 -R 2 -S Toolset -b

I get this error:
Could not create filehandle for '%(echo /home/ruggar)/Toolset10.1/SOURCES/Toolset-10.tar.gz': No such file or directory! at /usr/bin/myrpm line 456

Which is odd because the directory exists and the file does too. I copied the tar file to there and tried it and still no dice. All the paths are correct. I dunno.


  I am assuming that you were running this as the user "ruggar".
  You will need to create a ".rpmmacros" file for this script to work ( I was unable to locate the howto which said that )

   Contents of "/home/ruggar/.rpmmacros" (There is a dot before the file name)
%_topdir        /tmp/toolset
%packager       Abhisek Sanyal<abhisek.sanyal@gmail.com>
%vendor         My Vendor Name
%vendor_url     Website of my Vendor
%distribution   Distribution name
%_arch          i686
%dist_tag       .1
%_tmppath       /var/tmp
%_signature     gpg
%_gpg_name      Abhisek Sanyal

In the above macros file, "/tmp/toolset" is the directory where everything will be present (rpm, srpm, spec file, tar file and the build area).
You need to create the following directories before running the script

You can always change "/tmp/toolset" and point it to some where else. You will need to update the ".rpmmacros" file and create the SOURCES and SPECS directory in it.

Now it should work.
ruggarAuthor Commented:
Is there a size limit on RPMs? When I use the myrpm tool I eventually get an "Out of memory!" error. My Toolset is 4 gigabyets large with 35k+ files.
Can you run the script with -v to see the command where it runs out of memory ? That will help narrow down the issue.
ruggarAuthor Commented:
Multiple solutions accepted for multiple ways to accomplish the goal.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now