RPM: Packaging python client

Package Management Systems take care of everything from installation, upgrading, configuring to removing software packages. They are the original “Application Stores”. RPM is one such package manager used in various distributions like Fedora, CentOS, openSUSE, Mandriva etc.

Packages, in addition to the software and data, also have some meta data with them, such as the version number, license and dependencies.

To create an RPM package, you need the source files and a spec file that has information about your package.

A specification file looks like this:

Name:      popcorn
Version:   0.1
Release:   0
Summary:   Client for popularity contest for RPMs
License:   MIT
Url:       http://github.com/opensuse/popcorn
Group:     System/Packages
Source:    %{name}.tar.gz
Requires:  cron, python, rpm-python
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch

Popcorn tracks the collection of packages and repositories that users have installed.

%setup -q -c -n %{name}


install -Dm755 popcorn-client %{buildroot}%{_bindir}/popcorn
install -Dm644 popcorn.conf   %{buildroot}%{_sysconfdir}/popcorn.conf
install -Dm755 popcorn.cron   %{buildroot}%{_sysconfdir}/cron.monthly/popcorn
install -Dm644 popcorn.log %{buildroot}%{_localstatedir}/log/popcorn.log

rm -rf %{buildroot}

%defattr(-, root, root, -)
%config(noreplace) %{_sysconfdir}/popcorn.conf
%config(noreplace) %{_sysconfdir}/cron.monthly/popcorn
%ghost %{_localstatedir}/log/popcorn.log


Keep your spec file in ~/rpmbuild/SPECS directory, and source files in ~/rpmbuild/SOURCES directory.

Common tags used in SPEC file:

Use rpmbuild -ba NAME.spec to build the pacakage.

rpmbuild reads the SPEC file and perform the following operations:

RPMs are created in %_rpmdir directory, ~/rpmbuild/RPMS/noarch/ in this case. Use rpmlint to check common problems in RPM package.

Files included in packaged Popcorn[2] client:

  1. popcorn: the client python script that collects anonymous package usage data and sends to popcorn server.
  2. popcorn.conf: configuration file having basic settings for popcorn.
  3. popcorn.log: log file for data sent to server.

Popcorn is an openSUSE project[3] that tracks usage of linux packages.

Useful links:

[1] Reference: Fedora’s Guide for creating an RPM package

[2] My GSoC ‘12 Proposal for the project. Thanks Ionuț Arțăriși for mentoring :)

[3] https://github.com/opensuse/popcorn