build create a one single file rpm package

| 0 Comments | 0 TrackBacks
Let's create an rpm package that contains a single file. This was so annoying for me to figure out that I don't want to ever remember or research how to do it again so here it is documented. All I want is to package the file /usr/bin/flashplayerdebugger into an RPM. This is a single binary file and my server installation on the cloud is forcing me to install it using rpm.

RPM seems to have a lot of predefined expectations that is tedious to find and learn. My starting point was this short article by IBM. http://www.ibm.com/developerworks/library/l-rpm1/

That article goes through a build, configure and make steps to build a binary and finally package that binary. In my case I already have the binary and just want to build the rpm right away. After many facing many errors and searching around, these are the steps I had to do to successfully create the rpm.

Create the following 5 directories:

my home is /home/fsaberi.
I created /home/fsaberi/flashplayerdebugger01

then the following 5 directories under /home/fsaberi/flashplayerdebugger01

BUILD/  RPMS/  SOURCES/  SPECS/  SRPMS/


the binary flashplayerdebugger01 is packaged under the SOURCES directory in this way, in a tar ball, so that it would work with the spec file shown further below:

[fsaberi@farm2-zcon-01-v1 flashplayerdebugger01]$ tar -tvf SOURCES/flashplayerdebugger01.tar
drwxr-xr-x f/u     0 20.. 15:30:27 flashplayerdebugger-01/
drwxr-xr-x f/u     0 20.. 15:30:27 flashplayerdebugger-01/usr/
drwxr-xr-x f/u     0 20.. 15:30:46 flashplayerdebugger-01/usr/bin/
-rwxr-xr-x f/u 16816172 201.. 15:30:46 flashplayerdebugger-01/usr/bin/flashplayerdebugger01


The spec file SPECS/flashplayerdebugger.spec would then look like this:

[fsaberi@farm2-zcon-01-v1 flashplayerdebugger01]$ cat SPECS/flashplayerdebugger.spec

%define _topdir         /home/fsaberi/flashplayerdebugger01
%define name        flashplayerdebugger
%define release        1
%define version     01
%define buildroot %{_topdir}/BUILD/%{name}-%{version}

BuildRoot:    %{buildroot}
Summary:         flash player debugger for blah2 server
License:         GPL
Name:             %{name}
Version:         %{version}
Release:         %{release}
Source:         %{name}%{version}.tar
Prefix:         /usr/bin
Group:             blah2

AutoReqProv: no

%description
flash player debugger file for blah2 server. Contains one binary file.

%prep
%setup -q

%build

%install
cp %{buildroot}/usr/bin/%{name}%{version} /usr/bin

%files
%defattr(-,root,root)
/usr/bin/flashplayerdebugger01
[fsaberi@farm2-zcon-01-v1 flashplayerdebugger01]$


A few things I learned is that %setup -q will go into the SOURCES directory and will expect to find a tar file or else it will error out. When the untar occurs it then expect to find a directory that will be %{name}-%{version}. If the hyphen is not there then it complains. It untars %{name}%{version}.tar under the BUILD directory and goes on to the %build and then the %install sections.

I'm packaging a single binary file so I left %build empty. %install will actually install the binary locally on the system before heading to the %files section. In the %files i specify the only binary I wanted to package.

The command to build the rpm is

To make this work, I had used:

   sudo rpmbuild  -vv -bb --clean  SPECS/flashplayerdebugger.spec

But then I got this error:

error: Installed (but unpackaged) file(s) found:
   /debugfiles.list
   /debuglinks.list
   /debugsources.list

Searching a bit more, meant that I had to create a ~/.rpmmacros file with this line in it:

%debug_package          %{nil}

Then everything worked and the RPM is created under the directory RPMS.

To package and copy just one file using rpmbuild, you will most likely want to disable the dependency check or your package won't install without requiring a lot of other packages. So add the tag AutoReqProv: no as shown in the above spec file. There are also AutoReq and AutoProv tags you can look into. But the AutoReqProv deals with both.

So much trouble just to rpm package one single file.

No TrackBacks

TrackBack URL: http://www.farhadsaberi.com/cgi-bin/mt/mt-tb.cgi/23

Leave a comment

About this Entry

This page contains a single entry by Farhad Saberi published on February 10, 2013 1:25 PM.

Parallel processing fork exit vfork _exit was the previous entry in this blog.

Find recent content on the main index or look in the archives to find all content.