Creating a RPM package can be simply
interpreted as a process that builds a package and puts specific content to
that package, and when users need that RPM package, they just restore the package
content back to the system by using the command “rpm -i”. In general, there are
three steps to complete the process of building the RPM package. First,
building the package, which builds from the SPEC file; second, testing the
package uses Mock utility; last, using Koji performs cross-platform package
testing. Below is the first step to perform the SPEC file building. This is the
link documentation from fedora
http://fedoraproject.org/wiki/How_to_create_an_RPM_package?rd=PackageMaintainers/CreatingPackageHowTo#Introduction
http://fedoraproject.org/wiki/How_to_create_an_RPM_package?rd=PackageMaintainers/CreatingPackageHowTo#Introduction
1) First, in order to create the package, we need to build the
environment, so some packages need to be installed
- yum groupinstall "Fedora Packager"
- yum install rpmlint yum-utils
2) Run this command under command line interface
“rpmdev-setuptree”
- This command creates the ~/rpmbuild directory and
~/.rpmmacros file, and these are the essential element to build a raw RPM
package.
3) Under
~/rpmbuild directory, there are a few sub-directory exist, and they represent
different meaning by itself. Our building processes take place under the SPEC
directory.
- ~/rpmbuild/SPECS: RPM specifications (.spec) files
- ~/rpmbuild/SOURCES: Pristine source package
(e.g. tarballs) and patches
- ~/rpmbuild/BUILD: Source files are unpacked and
compiled in a subdirectory underneath this.
- ~/rpmbuild/BUILDROOT: Files are installed under here
during the %install stage.
- ~/rpmbuild/RPMS: Binary RPMs are created and
stored under here.
- ~/rpmbuild/SRPMS: Source RPMs are created and
stored here.
4) Under
the SPEC directory, run this command “rpmdev-newspec nameOfPackage”. In my case, I build the package
named combine, so my command will be “rpmdev-newspec combine”.
- This command will generate the file of “combine.spec”,
and this is the package that needs to be editing.
5) Edit the file of
combine.spec to specify the content under each Macro (this is the link for explaining
Macro https://fedoraproject.org/wiki/How_to_create_an_RPM_package?rd=PackageMaintainers/CreatingPackageHowTo#Macros)
below is the content of my SPEC file:
below is the content of my SPEC file:
Name: combine
Version: 0.3.4
Release: 1%{?dist}
Summary: combine files or data stream tool
License: GPLv2+
URL:
http://savannah.gnu.org/projects/combine/
#BuildRequires:
#Requires:
%description
combine matches 0, 1, or
many files to one file or data streamm to generate ouput files or data streams
based on the match.
%prep
%setup -q
%build
%configure
make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
%make_install
%files
/usr/bin/combine
/usr/share/guile/date/calendar.scm
/usr/share/guile/date/parse.scm
/usr/share/info/combine.info.gz
/usr/share/info/dir
/usr/share/locale/de/LC_MESSAGES/combine.mo
%changelog
* Sun Oct 10 2012 Max Ou
<maximumou@fedoraproject.org> - 0.3.4
- Initial packaging
6) Use command “rpmbuild -ba nameOfPackage.spec” to
build the file of combine.spec. In my case, I need to
run the command of “rpmbuild -ba combine.spec”. When the build is successful, the binary RPMs will be placed
in
~/rpmbuild/RPMS
and the source RPM will be placed in ~/rpmbuild/SRPMS/
- -ba
refers to build all
7) Using rpmlint
utility to examine the package after finishes building the SPEC file.
Below is my output, and it contains a few errors and warnings that need to be fixed
Below is my output, and it contains a few errors and warnings that need to be fixed
[root@localhost x86_64]#
rpmlint combine-0.3.4-1.fc17.x86_64.rpm
combine.x86_64: W:
summary-not-capitalized C combine files or data stream tool
combine.x86_64: W:
name-repeated-in-summary C combine
combine.x86_64: W:
spelling-error %description -l en_US streamm -> stream, streams, stream m
combine.x86_64: W:
spelling-error %description -l en_US ouput -> output, putout, out
combine.x86_64: E:
description-line-too-long C combine matches 0, 1, or many files to one file or
data streamm to generate ouput files or data streams based on the match.
combine.x86_64: W:
incoherent-version-in-changelog 0.3.4 ['0.3.4-1.fc17', '0.3.4-1']
combine.x86_64: E:
info-files-without-install-info-postin /usr/share/info/combine.info.gz
combine.x86_64: E:
info-files-without-install-info-postun /usr/share/info/combine.info.gz
combine.x86_64: E:
info-dir-file /usr/share/info/dir
combine.x86_64: E:
info-files-without-install-info-postin /usr/share/info/dir
combine.x86_64: E:
info-files-without-install-info-postun /usr/share/info/dir
combine.x86_64: E:
incorrect-fsf-address /usr/share/guile/date/calendar.scm
combine.x86_64: W:
no-manual-page-for-binary combine
combine.x86_64: E:
unknown-key (MD5
combine.x86_64: W:
file-not-in-%lang /usr/share/locale/de/LC_MESSAGES/combine.mo
1 packages and 0
specfiles checked; 8 errors, 7 warnings.
8)All the relative files can be downloading from
this link: