How to create rpm from a tarball?
September 26th, 2008Let me try to describe it with an example.
I want to install munin-1.2.6 from its tarball, so I downloaded its tarball version from their official website ( http://downloads.sourceforge.net/munin/munin_1.2.6.tar.gz?modtime=1213233975&big_mirror=0)
Quote:
| [root@saphire ~]# wget http://downloads.sourceforge.net/munin/munin_1.2.6.tar.gz?modtime=1213233975&big_mirror=0 [1] 12029 –04:20:36– http://downloads.sourceforge.net/munin/munin_1.2.6.tar.gz?modtime=1213233975 => `munin_1.2.6.tar.gz?modtime=1213233975′ Resolving downloads.sourceforge.net… 216.34.181.60 Connecting to downloads.sourceforge.net|216.34.181.60|:80… connected. HTTP request sent, awaiting response… 302 Found Location: http://voxel.dl.sourceforge.net/sourceforge/munin/munin_1.2.6.tar.gz [following] –04:20:36– http://voxel.dl.sourceforge.net/sourceforge/munin/munin_1.2.6.tar.gz => `munin_1.2.6.tar.gz’ Resolving voxel.dl.sourceforge.net… 72.26.192.194 Connecting to voxel.dl.sourceforge.net|72.26.192.194|:80… connected. HTTP request sent, awaiting response… 200 OK Length: 360,694 (352K) [application/x-gzip]100%[====================================>] 360,694 506.59K/s04:20:39 (506.05 KB/s) - `munin_1.2.6.tar.gz’ saved [360694/360694] |
We need the spec file to build rpm from the tarballs. If we try to create rpm from the downloaded tarball, we get an error similar to that of the following:
error: Version field must be present in package: (main package)
error: Release field must be present in package: (main package)
error: Summary field must be present in package: (main package)
error: Group field must be present in package: (main package)
error: License field must be present in package: (main package)
The above error message means the tarball is missing a proper spec file. We need to create the spec file manually or search for it in their official website. For easiness, I am downloading it from the web itself:
Quote:
| [root@saphire ~]#wget http://www.sfr-fresh.com/unix/privat/munin_1.2.6.tar.gz:b/munin-1.2.6/dists/redhat/munin.spec.in [root@saphire ~]# tar zxf munin_1.2.6.tar.gz [root@saphire ~]# mv munin.spec.in munin_1.2.6/munin.spec |
Then, open the spec file and make the needed modifications. Initially, I received the error “error: Legacy syntax is unsupported: copyright” while trying to compile which is corrected by replacing the word “copyright” by “License” in the spec file. Also, change the version information to 1.2.6 in the mentioned spec file
Then create the tarball again from the mentioned directory
Quote:
| [root@saphire ~]# tar czf munin-1.2.6.tar.gz munin-1.2.6 |
Then, I was able to compile the source and binary munin rpm via
Quote:
| [root@saphire ~]# rpmbuild -ta munin_1.2.6.tar.gz |
Sometimes , it can show errors like the following while compiling the rpm:
Quote:
| RPM build errors: Installed (but unpackaged) file(s) found: /usr/bin/munindoc /usr/lib/perl5/site_perl/5.8.8/Munin/Plugin.pm /usr/share/munin/VeraMono.ttf |
It can be corrected by adding the following lines in the spec file
Quote:
| %{_docdir}/../munin/VeraMono.ttf %{_bindir}/munindoc %{_libdir}/perl5/*perl/5.*/Munin/Plugin.pm |
