ParagNemade/PackagingNotes

= My Packaging Notes =

Author: [Parag Nemade

Revision: 0.9

Initial Draft: Thursday Jun 29, 2006

Last Revised: Saturday Jul 22, 2006

NOTE: I am still reorganizing and reformatting following page. This not yet compelete page.

PackagingNotes
To create correct package that satisfies Fedora Package Guidelines, three things need to be considered.

1)Source tarball/Source Files

2)SPEC file

3)Source and Binary RPM testing

Source Tarball
1)Sorce tarball name must be in foo-{version}-{release}.tar.gz/foo-{version}-{release}.bz2/foo-{version}-{release}.zip format

2)Don't forget to include License file in tarball.

3)If you are only packager for upstream tarball and not able to alter it, then its ok for not to change tarball and include any such license.

Source Files
1)If package contains only number of files and not having any compressed tarball/zip file then care should be taken to add all files as number of Source tags for each file to be packaged.

Source0: file1.sh

Source1: file2.init

2)Don't forget to include License file in package also as separate file say

Source2: GPL

SPEC file Writing Guidelines
1) Before starting to write SPEC file, make sure that you have installed fedora-rpmdevtools rpm package.

2) Once you got it installed just execute fedora-newrpmspec. This will create newpackage.spec file.

3) newpackage.spec is Fedora spec file template.

4) Its not mandatory to use fedora-newrpmspec for writing SPEC file. You can start writing on your own SPEC file.

5) Now you need to check wiki pages while writing SPEC file

http://fedoraproject.org/wiki/Packaging/NamingGuidelines This is used for package name, its version, release, dist tag check ups.

http://fedoraproject.org/wiki/PackagingGuidelines This is used to make sure final SPEC file contains name, version, release, summary, group, license, BuildRrequires, requires, description, build, install, clean, changelog, files section that satisfies Fedora Packaging Guidelines.

http://www.fedoraproject.org/wiki/Extras/RPMMacros This contains macros to be used instead of writing hard coded direcotry names

5) From the Paul Howarth's feedback to this page Any change to the upstream release, no matter how small, should have a new version number. There should never be two different versions of a tarball with different contents and the same version number as it only causes confusion. Similarly from the packager's viewpoint, any changes to the package (spec, patches, etc.) should result in an new release number for the package, for the same reasons.

Sample SPEC file for Simple GUI application
-

Here i am giving sample SPEC file foo.spec. This is spec file for GUI application foo-1.0.1.tar.gz that contains its version number as 1.0.1 and its going to install binary file foo and foo.desktop and it contains documentation files COPYING,README in tarball.

Name:          foo Version:       1.0.1 Release:       1%{?dist} Summary:       Write the summary for your package

Group:         Find apropriate group for your package under /usr/share/doc/rpm-{version}/GROUPS License:       Find allowed Licenses on http://fedoraproject.org/wiki/Packaging/Guidelines URL:           This URL contains online documentation for software being packaged. Source0:       This must be working upstream source tarball download link. BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires: Any -devel package dependency should be added here. Requires:      Any package dependency should be added here.

%description Add lines of description here that should not cross limit of 80 characters per line.

%prep %setup -q

%build %configure make %{?_smp_mflags}

%install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT desktop-file-install --vendor fedora   \ --dir %{buildroot}%{_datadir}/applications     \ --add-category X-Fedora        \ --delete-original      \ %{buildroot}%{_datadir}/applications/%{name}.desktop

%clean rm -rf $RPM_BUILD_ROOT

%files %defattr(-,root,root,-) %doc COPYING README %{_bindir}/%{name} %{_datadir}/applications/fedora-%{name}.desktop

%changelog - Inital Release
 * Wed Jun 28 2006 Parag Nemade  - 1.0.1-1

Sample SPEC file for Application that contains Subpackage -devel
-

Suppose if above foo-1.0.1 tarball contains some header files, .so library files, then that should go into -devel subpackage for main base package.

Name:          foo Version:       1.0.1 Release:       1%{?dist} Summary:       Write the summary for your package

Group:         Find apropriate group for your package under /usr/share/doc/rpm-{version}/GROUPS License:       Find allowed Licenses http://fedoraproject.org/wiki/Packaging/Guidelines URL:           This URL contains online documentation for software being packaged. Source0:       This must be working upstream source tarball download link. BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires: Any -devel package dependency should be added here. Requires:      Any package dependency should be added here.

%description Add lines of description here that should not cross limit of 80 characters per line.

%package      devel Summary:      Summary for devel package. Group:        Development/Libraries Requires:     %{name} = %{version}-%{release}

%description  devel This package contains headers and libraries required to build base application

%prep %setup -q

%prep %setup -q

%build %configure make %{?_smp_mflags}

%install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT desktop-file-install --vendor fedora   \ --dir %{buildroot}%{_datadir}/applications     \ --add-category X-Fedora        \ --delete-original      \ %{buildroot}%{_datadir}/applications/%{name}.desktop

%clean rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig %postun -p /sbin/ldconfig

%files %defattr(-,root,root,-) %doc COPYING README %{_bindir}/%{name} %{_datadir}/applications/fedora-%{name}.desktop

%files devel %defattr(-,root,root,-) %{_includedir}/foo*.h %{_libdir}/libfoo*.so %{_libdir}/pkgconfig/%{name}.pc

%changelog - Inital Release
 * Wed Jun 28 2006 Parag Nemade  - 1.0.1-1

Source and Binary RPM testing
Once you created SPEC file. Use following 5 steps to check for any errors in source RPM as well as Binary RPM.

Step 1: Create src.rpm using rpmbuild -bs foo.spec

Step 2: Use rpmlint on src.rpm as rpmlint -i foo-1.0.1-1.src.rpm if you got some warnings/errors. Try to solve it first.

More on rpmlint can be found at http://www.fedoraproject.org/wiki/Packaging/CommonRpmlintIssues

Step 3: Once all errors are removed then use mock command to build binary rpm in mock environment. To setup mock environment,check following pages

http://www.fedoraproject.org/wiki/Projects/Mock

http://www.fedoraproject.org/wiki/Extras/MockTricks

http://www.fedoraproject.org/wiki/Legacy/Mock

Mock setup used by me can be found at http://www.fedoraproject.org/wiki/ParagNemade/MockSetupUsingLocalMirror

Step 4: In case you got any problems in mock package build like command not found then check for required package to be added under Requires/BuildRequires. After doing that follow steps from step 1 again else skip to step5

Step 5: Now as you did successfull Mock build of you package, use rpmlint on Binary built RPM also for any missings in a package

rpmlint -i foo-1.0.1-1.fc6.i386.rpm

Solve all warning/error messages.

Thus you have got now successfully Package built according to Fedora Extras Packaging Guidlines.