Presentation is loading. Please wait.

Presentation is loading. Please wait.

Getting Started in RPM Packaging Izhar Firdaus / KageSenshi Contributor Fedora Project

Similar presentations


Presentation on theme: "Getting Started in RPM Packaging Izhar Firdaus / KageSenshi Contributor Fedora Project"— Presentation transcript:

1 Getting Started in RPM Packaging Izhar Firdaus / KageSenshi Contributor Fedora Project http://blog.kagesenshi.org/ izhar@fedoraproject.org

2 WARNING Geek Stuff Alert!!

3 Whats covered, and whats not Stuff covered Basic concept of RPM packaging How to write a simple SPEC for a simple package Stuff not covered Stuff from Fedora Packaging Guidelines Advanced tricks around RPM packaging Whatever off-topic

4 Presentation Outline Getting Started Quick into to RPM How RPMs are packaged RPM Packaging Basics The toolset The SPEC file Writing a SPEC file Building your package Moving Forward Best Practises Contributing to Fedora Packaging Project

5 9/29/20165 Getting Started : A quick intro to RPM RPM Package Manager Used widely in Fedora and Fedora based distros. Also used in OpenSuSE Mandriva, and other distros with lineage from RHL YUM Update Manager Dependency resolution tool which manage RPM packages. YUM != RPM

6 9/29/20166 Getting Started : How RPMs are packaged Creating a RPM package is easy Equivalent to writing a script for automatically compile and install a particular source code package With some extra rules to follow Straightforward, write a SPEC, put the source tarball and the SPEC in the correct place, run rpmbuild, wait, fun, profit!.

7 9/29/20167 RPM Packaging Basics : The Toolset RPMBuild Obviously, used for building RPM yum install rpmdevtools This is the primary tool needed for building RPM. rpmbuild -ba mypackage.spec rpmbuild --rebuild mypackage.src.rpm rpmbuild -ta mypackage.tar.bz2

8 9/29/20168 RPM Packaging Basics : The Toolset GCC and friends Without these you can't build anything In Fedora, best to have "Development Tools" group installed yum groupinstall "Development Tools" Others nice-to-have python-devel – if ure doing python packages openjdk-devel – if ure trying to package a Java stuff etc

9 9/29/20169 RPM Packaging Basics : The SPEC file Look at it as the specification config for a RPM package Generally consist of several parts Headers Source preparation script (%prep) Build script (%build) Install script (%install) Post-installation cleanup script (%clean) Installed files listing (%files) SPEC changelog (%changelog)

10 9/29/201610 RPM Packaging Basics : The SPEC file Case Study : Nitrogen Nitrogen is a tool for setting up different background on different screens on a multi-monitor machine running GNOME Straightforward package Should cover the basics of RPM packaging

11 9/29/201611 RPM Packaging Basics : The SPEC file Headers Metadata configuration about the package Define the name, description, version, build dependencies, etc.

12 9/29/201612 RPM Packaging Basics : The SPEC file Name: nitrogen Version: 1.4 Release: 1%{?dist} Summary: Background browser and setter for X windows. Group: User Interface/Desktop License: GPLv2+ URL: http://projects.l3ib.org/nitrogen/ Source0: http://projects.l3ib.org/nitrogen/files/nitrogen-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: gtkmm24-devel gtk2-devel glib-devel glib2-devel xorg-x11-proto-devel BuildRequires: intltool gettext %description Nitrogen is a background browser and setter for X windows. It is written in C++ using the gtkmm toolkit. It can be used in two modes: browser and recall. Nitrogen has been in development for over 2 years, due to real life and laziness. For more info, check out http://projects.l3ib.org/nitrogen/

13 9/29/201613 RPM Packaging Basics : The SPEC file Package information Name: nitrogen Version: 1.4 Release: 1%{?dist} Summary: Background browser and setter for X windows. Group: User Interface/Desktop License: GPLv2+ URL: http://projects.l3ib.org/nitrogen/

14 9/29/201614 RPM Packaging Basics : The SPEC file Source information Define the location and filename of the source tarball, patches, etc. Build dependencies Define the packages that required to be installed first before compiling. Source0: http://projects.l3ib.org/nitrogen/files/nitrogen-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: gtkmm24-devel gtk2-devel BuildRequires: glib-devel glib2-devel xorg-x11-proto-devel BuildRequires: intltool gettext

15 9/29/201615 RPM Packaging Basics : The SPEC file %prep section Section for script to prepare the package source code before compiling Usually where scripts to extract the tarball, apply patches, copy/move files are defined. The script style is similar to a sh script, with some additional RPM helper macros to aid on stuff. Common simplest example: %prep %setup -q ** %setup macro will extract the source0 tarball and chdir into it.

16 9/29/201616 RPM Packaging Basics : The SPEC file %build section Section for scripts which configure and compile the source code../configure && make - kind of scripts Commonly used macro for configure - %configure Set the proper autoconf values for RPM building Eg: %build %configure make %{?_smp_mflags}

17 9/29/201617 RPM Packaging Basics : The SPEC file %install section Where the script to install the files into the RPM system root make install Can also use the cp command to install or other way to install files Eg: %install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT

18 9/29/201618 RPM Packaging Basics : The SPEC file %clean section Clean everything, usually, just rm -rf the extracted source. %clean rm -rf $RPM_BUILD_ROOT

19 9/29/201619 RPM Packaging Basics : The SPEC file %files section Listing of files installed by the package %files %defattr(-,root,root,-) %doc README COPYING INSTALL AUTHORS %{_bindir}/nitrogen %{_datadir}/icons/hicolor/*/apps/nitrogen.png %{_datadir}/icons/hicolor/*/actions/wallpaper-tiled.png %{_datadir}/icons/hicolor/*/actions/wallpaper-centered.png %{_datadir}/icons/hicolor/*/actions/wallpaper-scaled.png %{_datadir}/icons/hicolor/*/actions/wallpaper-zoomed.png %{_datadir}/icons/hicolor/*/devices/video-display.png %{_datadir}/icons/hicolor/*/mimetypes/image-x-generic.png %{_mandir}/man1/nitrogen.1.gz

20 9/29/201620 RPM Packaging Basics : Writing a SPEC file General steps Define the package information Figure out the dependencies required for building the package and define in the spec Write the prepare script Write the build script Write the install script Define files included in the package

21 9/29/201621 RPM Packaging Basics : Building the RPM package After writing the specfile, the tarball, and related files need to be put in correct rpmbuild location. To create a RPM build tree skeleton rpmdev-setuptree This will create a tree in ~/rpmbuild containing: BUILD – folder for temporary build files BUILDROOT – folder for temporary install files RPMS – generated RPMs are saved here SOURCES – where you should put your source tarballs SPECS – where you should pun your specfile

22 9/29/201622 RPM Packaging Basics : Building the RPM package Save the specfile in the SPEC folder Copy the source tarballs to the SOURCES folder Chdir to the SPEC folder, and build!!! rpmbuild -ba yourspecfile.spec The build process will run, if theres no problem with your spec, after successful build, Source RPM will be saved in SRPMS folder, and binary RPM will be saved in RPMS folder. Test install, debug if have problem, then, Profit!!!

23 9/29/201623 Moving Forward : Best Practices Try to use built in helper macro if possible Keep It Simple S***** Dependencies should not be bundled together Spec should be reproduceable repetitively across different system

24 9/29/201624 Moving Forward : Contributing to Fedora Packaging Project Start writing your own RPM package!! Contribute to Fedora Project, Grab some softwares which are not packaged in Fedora Repository, package them, and submit for review Be A Fedora Packager http://join.fedoraproject.orghttp://join.fedoraproject.org !!


Download ppt "Getting Started in RPM Packaging Izhar Firdaus / KageSenshi Contributor Fedora Project"

Similar presentations


Ads by Google