Create RPM Package On Ubuntu

Table of Contents

1 What is RPM

RPM is a package management system, The name RPM variously refers to the .rpm file fromat. RPM was intended primarily for GNU/Linux distributions, ex: Fedora, Meego and openSUSE.

2 How to create RPM package on ubuntu

2.1 Prepare

  • install apm on ubuntu:
#aptitude install rpm
  • make rpmbuild directory:
#mkdir -p ~/rpmbuild/SOURCES ~/rpmbuild/SPECS
  • enter into SOURCES directory:
#cd ~/rpmbuild/SOURCES
  • get hello word souce code:
#wget http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz

2.2 Write hello-2.8.spec file for the rpm package, and saved into SPECS

Summary: The "Hello World" program from GNU
Name: hello
Version: 2.8
Release: 1%{?dist}
Source0: %{name}-%{version}.tar.gz
License: GPLv3+
Group: Development/Tools

Requires(post): info
Requires(preun): info

%description 
The "Hello World" program, done with all bells and whistles of a proper FOSS 
project, including configuration, build, internationalization, help files, etc.

%prep
%setup -q

%build
%configure
make %{?_smp_mflags}

%install
%make_install
%find_lang %{name}
rm -f %{buildroot}/%{_infodir}/dir

%post
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || :

%preun
if [ $1 = 0] ; then
/sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir || :
fi

%files -f %{name}.lang
%doc AUTHORS ChangeLog COPYING NEWS README THANKS TODO
%{_mandir}/man1/hello.1.gz
%{_infodir}/%{name}.info.gz
%{_bindir}/hello

%changelog
* Tue Sep 06 2011 The Coon of Ty <Ty@coon.org> 2.8-1
- Initial version of the package
ORG-LIST-END-MARKER

Date: 2012-08-05 日

Author: yannik.li

Org version 7.8.11 with Emacs version 24

Validate XHTML 1.0