Solved

Create RPM from already compiled and tar.gz file

Posted on 2010-11-16
12
3,443 Views
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
/local/Tools/lib
/local/Tools/bin
/local/Tools/scripts
/local/Tools/resources
0
Comment
Question by:ruggar
  • 5
  • 3
  • 2
  • +1
12 Comments
 
LVL 3

Expert Comment

by:poison5151
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.
0
 
LVL 14

Accepted Solution

by:
Deepak Kosaraju earned 175 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
(or)
rpmbuild -ta packagename.tar.gz

(or)
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

Reference:
http://docs.redhat.com/docs/en-US/Red_Hat_Network_Satellite/5.3/html/Deployment_Guide/satops-rpm-building.html
http://www.rpm.org/max-rpm/s1-rpm-build-creating-spec-file.html
https://pmc.ucsc.edu/~dmk/notes/RPMs/Creating_RPMs.html
#

# 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>



%description

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

0
 

Author Comment

by:ruggar
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.
0
 

Author Comment

by:ruggar
ID: 34148636
Thank you kosarajudeepak. I will try that and report back.
0
 
LVL 3

Expert Comment

by:poison5151
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.
0
 
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 

/etc/init.d/nagios

/etc/nagios

/etc/nagios/cgi.cfg

/etc/nagios/contacts.cfg

/etc/nagios/nagios.cfg

/etc/nagios/resource.cfg

/etc/nagios/timeperiods.cfg

/usr/lib/nagios/eventhandlers

/usr/lib/nagios/eventhandlers/disable_active_service_checks

/usr/lib/nagios/eventhandlers/disable_notifications

/usr/lib/nagios/eventhandlers/enable_active_service_checks

/usr/lib/nagios/eventhandlers/enable_notifications

/usr/lib/nagios/eventhandlers/submit_check_result

/usr/sbin/convertcfg

/usr/sbin/mini_epn

/usr/sbin/nagios

/usr/sbin/nagiostats

/usr/sbin/new_mini_epn

/usr/share/doc/nagios-3.0.3

/usr/share/doc/nagios-3.0.3/Changelog

/usr/share/doc/nagios-3.0.3/INSTALLING

/usr/share/doc/nagios-3.0.3/LICENSE

/usr/share/doc/nagios-3.0.3/README

/usr/share/doc/nagios-3.0.3/UPGRADING

/var/log/nagios

/var/log/nagios/archives

/var/spool/nagios





[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



%description

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 

interface.



%setup -q

%install

[ "$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



%clean

rm -rf $RPM_BUILD_ROOT



%files send

%defattr(755,root,root)

/usr/bin/send_nsca

%defattr(644,root,root)

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

%defattr(755,%{nsusr},%{nsgrp})

Open in new window

0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 4

Assisted Solution

by:AbhisekSanyal
AbhisekSanyal earned 175 total points
ID: 34154338
Hi,
   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.
0
 

Author Comment

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

 

0
 
LVL 4

Expert Comment

by:AbhisekSanyal
ID: 34161669
Hi,
  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
/tmp/toolset/SOURCES
/tmp/toolset/SPECS

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.
0
 

Author Comment

by:ruggar
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.
0
 
LVL 4

Expert Comment

by:AbhisekSanyal
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.
0
 

Author Closing Comment

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

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

762 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now