How To Write RPM Spec

Home » CentOS » How To Write RPM Spec
CentOS 4 Comments

Hi team,

I setup the RPM build server and read some doc to write the spec files. but i did get it clearly. So can you guys please help me to write a new RPM
spec.

or give me a scenario to write

Thanks, Jegadeesh

4 thoughts on - How To Write RPM Spec

  • The easiest way to create a spec file is to look at an existing spec file for something similar to what you’re trying to write. Some spec files are very simple, and some are so elaborate they’re almost impossible to understand.

    A good place to start is here:

    http://www.rpm.org/max-rpm/

  • If you have set up an RPM build server then you should have installed the rpmbuild and rpmdevtools packages. If you have installed the latter then you can use vi (vim/gvim) to automatically create an empty spec template file simply by opening any new file name ending in
    ‘.spec’. It will look like this:

    Name:
    Version:
    Release: 1%{?dist}
    Summary:

    Group:
    License:
    URL:
    Source0:
    BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

    BuildRequires:
    Requires:

    %description

    %prep
    %setup -q

    %build
    %configure make %{?_smp_mflags}

    %install rm -rf %{buildroot}
    make install DESTDIR=%{buildroot}

    %clean rm -rf %{buildroot}

    %files
    %defattr(-,root,root,-)
    %doc

    %changelog
    * Fri Apr 05 2013 James B. Byrne
    – Rebuild for CentOS-6.4
    – This description is an example and is not automatically
    – generated for you.

    Note that the formats for the date and identity in changelog entries are very specific and include the leading ‘*’. You cannot use any other format (to my knowledge) than that given above as an example. Each descriptive line thereafter must be prefaced by’- ‘.

    See:
    https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/Packagers_Guide/sect-Packagers_Guide-Creating_a_Basic_Spec_File.html

  • Rather than relying on vim to do this, you can also use
    ‘rpmdev-newspec’ to create a new spec file, which has options to automatically set up packages for Perl, Python, PHP (etc.) modules, system libraries or a really minimal simple package. Read the man page for ‘rpmdev-newspec’.