[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Create RPM from already compiled and tar.gz file

Posted on 2010-11-16
Medium Priority
Last Modified: 2013-11-13
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
Question by:ruggar
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1

Expert Comment

ID: 34148604
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.
LVL 14

Accepted Solution

Deepak Kosaraju earned 700 total points
ID: 34148623
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


Author Comment

ID: 34148631
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.
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  


Author Comment

ID: 34148636
Thank you kosarajudeepak. I will try that and report back.

Expert Comment

ID: 34148662
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.
LVL 14

Expert Comment

by:Deepak Kosaraju
ID: 34148753
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


Assisted Solution

AbhisekSanyal earned 700 total points
ID: 34154338
   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.

Author Comment

ID: 34157224
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.



Expert Comment

ID: 34161669
  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.

Author Comment

ID: 34168168
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.

Expert Comment

ID: 34170765
Can you run the script with -v to see the command where it runs out of memory ? That will help narrow down the issue.

Author Closing Comment

ID: 34232731
Multiple solutions accepted for multiple ways to accomplish the goal.

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
If you don't know how to downgrade, my instructions below should be helpful.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question