Steps towards creating an RPM for a MID application

Submit New Article

Last Modified On :   December 10, 2008 1:56 PM PST
Rate
 



Introduction

Once you’ve got an application that runs on the MID, a next step might be to create a RPM file from it, so that it is easily distributed and installed. This way, the user does not need to build the application from source code. This article is a brief step-through of how to create an RPM package. For more detailed information, you might check out the following .PDF file: http://www.redhat.com/promo/summit/2008/downloads/pdf/Wednesday_130pm_Tom_Callaway_OSS.pdf

To create an RPM, the basic steps you need to do are:

  • Create the RPM Work Tree
  • Create a RPM SPEC file
  • Build the RPM

 


Make a rpmbuild tree in your home directory. Make sure that it is in your home directory. I ran into problems putting it somewhere else:

mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS,tmp}
mkdir -p ~/rpmbuild/RPMS/{i386,i686,noarch}

Create a ~/.rpmmacros file and add the following custom macro to it:

%_topdir %(echo $HOME)/rpmbuild

Create a .tar.gz of your application’s source code, and place it in the SOURCES folder


A SPEC file has six sections to it: Preamble, Setup, Build, Install, Clean, Files. This is the painful part of building an RPM, because the SPEC file must be exactly correct in order to install. A sample spec file is split up into the six different sections, and is show below:

Preamble: defines the packages characteristics

# RPM Spec file for MidPlatformSvc %define _tmppath %{_topdir}/tmp
%define _prefix /usr
%define _dbusdir %{_prefix}/share/dbus-1/services
%define name MidPlatformSvc
%define summary a Platform Information Service for the MID
%define version 1.0
%define release MIDinux
%define license GPLv3
%define group Services
%define source %{name}-%{version}.tar.gz
%define vendor Intel
%define packager Clayne Robison
%define buildroot %{_tmppath}/%{name}-root
#Preamble
Name: %{name}
Version: %{version}
Release: %{release}
Packager: %{packager}
Vendor: %{vendor}
License: %{license}
Summary: %{summary}
Group: %{group}
Source: %{source}
Prefix: %{_prefix}
Buildroot: %{buildroot}
%description
MidPlatformSvc will broadcast (over D-Bus) information involving
a platform's Power, Connection, Display, Input, Location, Processor,
and Storage information

 

Setup: Source tree is genereated, sources unpacked

%prep
%setup –q

 

Build: Instruct how your Binaries are created from the source

%build
echo "build"
./autogen.sh
%configure --enable-gps=no
make

 

Install: Copy all necessary files from the source to the %{buildroot} directory, as if putting them on the filesystem. This command can be as simple as a “make install DESTDIR=%{buildroot}” command

%install
rm -rf %{buildroot}
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_dbusdir}
cp src/MIDPlatformSvc %{buildroot}%{_bindir}
cp data/org.moblin.Platform.service %{buildroot}%{_dbusdir}

 

Clean: Removes the %{buildroot}

%clean
rm –rf %{buildroot}

 

Files: list your packages’ contents

%files
%defattr(-,root,root,-)
%{_bindir}/MIDPlatformSvc
%{_dbusdir}/org.moblin.Platform.service

 


Create a binary and source rpm by pointing rpmbuild to your SPEC file:

rpmbuild -ba SPECS/MidPlatformSvc.spec

 

Once the rpm builds successfully, use the following commands to test the structure of your rpm:

rpm –qpi [RPMfile.rpm]
rpm –qpl [RPMfile.rpm]