Procedure 2.2. Creating an example package: eject
rpmdev-newspec command, run the following commands:
cd ~/rpmbuild/SPECS rpmdev-newspec eject eject.spec in the ~/rpmbuild/SPECS directory.
/etc/rpmdevtools/ directory, which includes spec file templates called spectemplate-type.spec. For example, to create a new spec file for a Python module, run the following commands:
cd ~/rpmbuild/SPECS rpmdev-newspec python-antigravity rpmdev-newspec, run the rpmdev-newspec --help command.
cd ~/rpmbuild/SPECS vi eject.spec Name: eject Version: Release: 1%{?dist} Summary: Group: License: URL: Source0: BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: Requires: %description %prep %setup -q %build %configure make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) %doc %changelog
The Group and BuildRoot tags are deprecated
Group and BuildRoot tags are included in the spec file templates, RPM in Fedora 18 does not require the presence of these tags in the spec file and ignores them.
The %clean and %defattr directives are deprecated
%clean and %defattr directives are included in the spec file templates, RPM in Fedora 18 does not require the presence of these directives in the spec file and ignores them.
Release tag to set the release value of the package. For example, set the value to 1%{?dist} if you are creating the initial release of the package:
Release: 1%{?dist}
{?dist} tag is used to mark the distribution revision of a package.
Version: 2.1.5 Release: 1%{?dist} Summary: A program that ejects removable media using software control
License tag, fill in the appropriate license for the software. In this case, eject uses the GNU General Public License v2.0 or later. The short name for this license is GPLv2+:
License: GPLv2+
URL tag:
URL: http://www.pobox.com/~tranter
Source tag, fill in the URL of the source archive for the package:
Source0: http://www.ibiblio.org/pub/Linux/utils/disk-management/%{name}-%{version}.tar.gz
BuildRequires tag with requirements that are needed to build the package. BuildRequires can contain either a list of required packages or files. For example, the eject package requires the gettext and libtool packages:
BuildRequires: gettext BuildRequires: libtool
Requires tag. Requires can contain either a list of required packages or files.
Requires tag, so do not include the tag in the spec file.
%description should be at most 79 characters long:
%description The eject program allows the user to eject removable media (typically CD-ROMs, floppy disks or Iomega Jaz or Zip disks) using software control. Eject can also control some multi-disk CD changers and even some devices' auto-eject features. Install eject if you'd like to eject removable media using software control.
%check section between the sections %build and %install in the spec file. The %check section typically contains the make test or make check command that runs any self-tests distributed with the software:
%check make check
%install section by adding the following installation instructions that are specific to eject the to the spec file:
install -m 755 -d $RPM_BUILD_ROOT/%{_sbindir}
ln -s ../bin/eject $RPM_BUILD_ROOT/%{_sbindir}%find_lang, which will locate all of the translation files that belong to the package, and put this list in a file called %{name}.lang.
%find_lang macro, add the following to the %install section:
%find_lang %{name}
%{name}.lang file with a list of translation files, add the file name with the -f option to %files:
%files -f %{name}.lang
%doc directive:
%doc README TODO COPYING ChangeLog
%changelog to describe the last change you have made to the package. Fill it in with the date, your name and email address, the version and release of the package, and a short description of what has changed in the package in the following format:
* date Packager's Name <packager's_email> version-revision - Summary of changes
rpmdev-bumpspec --comment=summary of changes --userstring=Packager's Name <packager's_email> spec file rpmdev-bumpspec command with the following options:
rpmdev-bumpspec --comment="Initial RPM release" --userstring="John Doe <jdoe@example.com>" eject.spec %changelog * Wed Oct 20 2011 John Doe <jdoe@example.com> 2.1.5-0.1 - Initial RPM release
Name: eject Version: 2.1.5 Release: 1%{?dist} Summary: A program that ejects removable media using software control License: GPLv2+ URL: http://www.pobox.com/~tranter Source0: http://www.ibiblio.org/pub/Linux/utils/disk-management/%{name}-%{version}.tar.gz BuildRequires: gettext BuildRequires: libtool %description The eject program allows the user to eject removable media (typically CD-ROMs, floppy disks or Iomega Jaz or Zip disks) using software control. Eject can also control some multi-disk CD changers and even some devices' auto-eject features. Install eject if you'd like to eject removable media using software control. %prep %setup -q -n %build %configure make %{?_smp_mflags} %check make check %install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT install -m 755 -d $RPM_BUILD_ROOT/%{_sbindir} ln -s ../bin/eject $RPM_BUILD_ROOT/%{_sbindir} %find_lang %{name} %files -f %{name}.lang %doc README TODO COPYING ChangeLog %{_bindir}/* %{_sbindir}/* %{_mandir}/man1/* %changelog * Wed Oct 20 2011 John Doe <jdoe@example.com> 0.8.18.1-0.1 - Initial RPM release