Presentation is loading. Please wait.

Presentation is loading. Please wait.

RPM Packaging for Sysadmins

Similar presentations


Presentation on theme: "RPM Packaging for Sysadmins"— Presentation transcript:

1 RPM Packaging for Sysadmins
David Nalley @ke4qqq on twitter/identi.ca New presentation available at: The non-code portions of this presentation are licensed under a Creative Commons, Attribution, Share Alike 3.0, unported license. Why are you here?? I have given this presentation to people inherently interested in distributions, but not to sysadmins What breakup of distributions/OS Solaris?? Deb? RPM??

2 # whoami Recovering sysadmin F/LOSS community guy Packager for Fedora
Work for an ISV who packages software

3 Schedule Spend first hour or so getting through slides
This is designed to be interactive – please don't bore others by making them listen only to me – ask questions!, interact! Break – OM NOMs Spend 15 or so minutes getting access to VMs in 'the cloud' Spend the rest of the class doing some hands on work with packages.

4 OS-specific or distro-specific installable container for software
define: package OS-specific or distro-specific installable container for software

5 Why should sysadmins care?
SO WHAT?

6 Why should sysadmins care?
Automation – packaging makes decisions ahead of time

7 Why should sysadmins care?
Automation – packaging makes decisions ahead of time Anyone still doing: tar -zxvf foo.tar.gz cd foo ./configure make make install

8 Why should sysadmins care
Repeatability Using packages means that you will get the same behavior and files in the same location on subsequent installs

9 Why should sysadmins care?
Documentation: Packages are documentation – provided you keep the original work. Building a package is far better than maintaining installation instructions.

10 Why should sysadmins care?
Easier customization Need to deploy a package with different compiler options? Need to patch the source for some cool new option?

11 Why should sysadmins care?
Security: No compilers on hosts Running your own package repository means you can ensure that every host with a given package will get updates.

12 Why should sysadmins care
Single source of truth for software (think Ruby gems, Python PyPi, Perl CPAN, PHP Pear)

13 Sysadmins should package F/LOSS for: fame peer review experience
Packaging for F/LOSS Sysadmins should package F/LOSS for: fame peer review experience

14 Packaging is really a snapshot of being a sysadmin
Automating Configuration Documenting Doing things right the first time

15 Examples Learning by reading a book/website takes days or weeks
Hopefully learning by seeing examples from someone else will be faster Longum iter est per preaecepta, breve et efficax per exempla!

16 Red Hat Package Manager Used by RHEL, SLES, Fedora, and a few others
RPM Red Hat Package Manager Used by RHEL, SLES, Fedora, and a few others

17 Resources Maximum RPM: http://www.rpm.org/max-rpm/
Build Service at openSuSE: IBM DeveloperWorks – good generic docs

18 Setting up your environment
Fedora: yum install fedora-packager SLES/openSuSE: yast -i osc RHEL: yum install rpmbuild (or rpm-build) Even within RPM changes there are some rather large differences. For instance, openSuSE handles changelog differently, and places it in a separate file. Fedora now uses sha-256, while RHEL uses MD5.

19 Setting up your environment
/usr/lib/rpm/macros rpmdev-tree mkdir -p ~/rpmbuild/SRPMS ~rpmbuild/RPMS \ ~/rpmbuild/SPECS ~rpmbuild/SOURCE \ ~/rpmbuild/BUILD ~/rpmbuild/BUILDROOT

20 spec files – heart of rpm building
spec files are the instruction manual for the build process.

21 rpmbuild rpmlint mock koji Novell's Open Build Service
Tools rpmbuild rpmlint mock koji Novell's Open Build Service mock – creates chroot, installs requirements and builds koji – uses mock to build, but does it for mulitple environments (EL4, EL5, F11, F12, etc). Fedora makes a build server available – must have a fedora account. OBS – provides multiple distro and arch build service – last I checked multiarch support limited.

22 More tools (imperfect)
cpan2rpm rust.sourceforge.net pear make-rpm-spec Foo.tgz gem2rpm python setup.py bdist_rpm –spec-only

23 Contents of a spec file headers – information about the package
scripts – the real work files – identifying ownership and permissions changelog – who changed what when Novell has started moving changelogs out of spec files.

24 spec file framework Name: Version: Release: 1%{?dist} Summary: Group:
License: URL: Source0: BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}- XXXXXX) BuildRequires: Requires: %description

25 spec file framework %prep %setup -q %build %configure
make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT %clean %files %defattr(-,root,root,-) %doc %changelog

26 Building the spec file %{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} Name: zapplet Version: Release: %{dist} Summary: Zenoss Tray Applet Group: Applications/Communications License: GPLv2+ URL: Source0: %{version}.tar.gz Source1: BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root- %(%{__id_u} -n) BuildRequires: python python-setuptools-devel desktop-file-utils Requires: pygtk2 BuildArch: noarch %description Zapplet is a tray applet for monitoring aspects of Zenoss from the desktop.

27 Building the spec file %prep %setup -q -n zapplet-%{version}
cp %{SOURCE1} ./README.fedora %build CFLAGS="%{optflags}" %{__python} setup.py build %install rm -rf %{buildroot} %{__python} setup.py install -O1 --skip-build --root %{buildroot} desktop-file-install --add-category="Network" -- dir=%{buildroot}%{_datadir}/applications zapplet.desktop rm -rf %{buildroot}%{_sysconfdir}/xdg/autostart/zapplet.desktop

28 Building the spec file %clean rm -rf %{buildroot} %files
%defattr(-,root,root,-) %{python_sitelib}/* %{_bindir}/%{name} %{_datadir}/applications/zapplet.desktop %doc README.fedora %changelog * Mon Jan David Nalley 0.1-4 - Made changes suggested by ianweller to fix cvs issues * Sun Dec David Nalley 0.1-3 - Made changes suggested by Brian Pepple * Sat Dec David Nalley 0.1-2 - Making corrections suggested by Fabian Affolter * Sun Dec David Nalley 0.1-1 - Initial packaging efforts

29 rpmbuild -ba /path/to/zapplet.spec
Building rpmbuild -ba /path/to/zapplet.spec

30 rpmlint and other checks
rpmlint /path/to/zapplet.spec rpmlint /path/to/zapplet src.rpm rpmlint /path/to/zapplet noarch.rpm And you are going to install and test it first, right?

31 Example 1 - php-gettext Simple No real compilation
Places files in correct place Heavily commented

32 Example 2 - sheepdog Requires compilation
Relatively heavy dependencies

33 Example 3 - rubygem-logging
Simple – created by external tool Requires registration with additional 'package' manager Similiar things needed for CPAN, Pear, etc.

34 Questions and contacts reminders
IRC: ke4qqq on irc.freenode.net Blog:


Download ppt "RPM Packaging for Sysadmins"

Similar presentations


Ads by Google