Solved

Create RPM from already compiled and tar.gz file

Posted on 2010-11-16
12
3,626 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
[X]
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
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

726 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