% $Id$
\documentclass[blends,slideColor,colorBG,pdf,ps2pdf]{prosper}
\usepackage[frenchb]{babel}
\usepackage[T1]{fontenc}
%\usepackage{multicol}
\usepackage{moreverb}


\title{RPM and policy for packaging}
\subtitle{Adapt a rpm to a GNU/Linux distribution}
\author{Olivier Thauvin}
\email{olivier.thauvin@aerov.jussieu.fr}
%%\institution{
%%  \includegraphics*[height=0.3\textheight]{gnutux.eps}
%%}

\NoFrenchBabelItemize

\begin{document}
\maketitle

\part{Introduction}

\begin{slide}{Plan}
\bigskip
\begin{itemize}
\item{RPM reminder}
\item{Policy: introduction}
\item{Matter of fact case: Mandriva}
\end{itemize}
\end{slide}

\part{RPM reminder}

\overlays{2}{
\begin{slide}{RPM: Rpm Package Manager}
What is it ?
\begin{itemize}
    \item a set of tools
    \item an archive format (.rpm)
    \item files	in rpm format 
\end{itemize}
\bigskip

\FromSlide{2}
Roles:
\begin{itemize}
\item install
\item list
\item control
%\item make easier software installation 
%\item versioning (evr)
%\item ensure that the environment is compatible with the software
%\item ensure system's integrity
\end{itemize}
\end{slide}
}

\begin{slide}{The package}
An .rpm file containing:
\begin{itemize}
\item{entête} informations about the rpm
    \begin{itemize}
    \item practical informations about the software (name, version, url, \ldots)
    \item to make the rpm
    \item a list of dependances
    \item a list of files provided
    \item history of the package (changelog)
    \end{itemize}
\item an archive containing the files 
\end{itemize}
\end{slide}

\begin{slide}{Making an rpm}
\begin{center}
\includegraphics*[height=1\textheight]{rpm-building-en}
\end{center}
\end{slide}

\begin{slide}{The spec file}
It describes:
\begin{itemize}
\item the rpm(s) produced(s)
\item the compiling of the software
\end{itemize}
\bigskip
There are the following sections:
\begin{itemize}
\item header, \%description
\item \%package
\item \%prep, \%build, \%install, \%check
\item \%files
\item \%verify, \%pre, \%preun, \%post, \%postun, \%posttrans, \ldots
\item \%changelog
\end{itemize}
\end{slide}

\begin{slide}{Specfile: example}
\begin{small}
\verbatiminput{simple.spec}
\bigskip
\begin{verbatim}
$ rpm -ba simple.spec
Write: /home/users/olivier/RPM/SRPMS/simple-1-1.src.rpm
\o/
\end{verbatim}
\end{small}
\end{slide}

\begin{slide}{Macros}
RPM specific variables.

Origine:
\begin{tabular}{|l|l|}
\hline
where&provider\\
\hline
\hline
system macros files&rpm\\
\hline
system macros files&distribution\\
\hline
\verb+~/.rpmmacros+&user\\
\hline
spec file&packager\\
\hline
\end{tabular}

\bigskip
They provide values or functions.
\end{slide}

\part{Policy: introduction}

\overlays{2}{
\begin{slide}{What is a policy}
To define rules.

\FromSlide{2}
\bigskip

Goal:
\bigskip
\begin{itemize}
\item homogeneity
\item work factorisation
\item quality
\item ease the work
\end{itemize}
\bigskip
In brief, that's good (tm)
\bigskip

\end{slide}
}

\overlays{2}{
\begin{slide}{Root is evil}
Do not build as root,\\
Do not build as root,\\
And do not build as root.\\
\FromSlide{2}
\bigskip

Risks :
\begin{itemize}
\item pollute your system
\item skip errors unwillingly
\item compromission, corruption of your system
\item cannot be done on the compile-server
\item it gives buttons
%\item It makes you impotent
\end{itemize}
\end{slide}
}

\begin{slide}{Do not change the config}
The environment provided with rpm adapts the rpms one to each other.

You notably find:
\begin{itemize}
\item default paths
\item dependances generation
\item post-installation
\end{itemize}
\end{slide}

\begin{slide}{Summary of basic rules}
\begin{itemize}
\item document yourself
\item ask people used to making packages for their distribution
\item understand rather than work-around
\item a package well done for a distribution often becomes uncompatible
with others
\item get your package integrated to the distribution
(it's worth doing for other things than rpm)
\end{itemize}
\end{slide}

\part{Matter of fact case: Mandriva}

\overlays{2}{
\begin{slide}{User configuration}
\begin{itemize}
\item define your rpm environment
\item define the packager tag
\end{itemize}

\FromSlide{2}
.rpmmacros:
\bigskip
\begin{small}
\listinginput[5]{1}{rpmmacros}
\end{small}
\end{slide}
}

\begin{slide}{Package naming policy}
\begin{itemize}
\item package name are lowercase (there are some exceptions)
\item package name should match software name
\item language modules have package name prefixed by language name
\end{itemize}

Example:
\begin{itemize}
\item perl
\item rpm
\item perl-POE
\end{itemize}
\end{slide}

\overlays{2}{
\begin{slide}{\%mkrel}
Problems with backport:

\begin{tabular}{|l|l|c|l|}
\hline
&cooker&&stable\\
\hline
\hline
without&1mdv&==&1mdv\\
\hline
with&1mdk&>&0.1.20060mdk\\
&1mdv2007.0&>&1mdv2006.0\\
\hline
\end{tabular}
\bigskip
\FromSlide{2}

Release: 1mdk

becomes:

Release: \%mkrel 1

\end{slide}
}

\begin{slide}{Path for files}
\begin{itemize}
\item Prefix has a specific meaning, do not use it 
\item respect the standard paths
\item prefer macros
\item /usr/local is reserved for softwares installed without rpm
\end{itemize}
\end{slide}

\begin{slide}{Standard path}
\bigskip
\begin{small}
\begin{tabular}{|l|l|l|}
\hline
path&macro&usage\\
\hline
\hline
/usr&\%\_prefix&general path\\
\hline
/etc&\%\_sysconfdir&configuration\\
\hline
/usr/bin&\%\_bindir&application\\
\hline
/usr/sbin&\%\_sbindir&app. for root\\
\hline
/usr/lib&\%\_libdir&libraries\\
/usr/lib64&&\\
\hline
/usr/share&\%\_datadir&data\\
\hline
/usr/share/man&\%\_mandir&man pages\\
\hline
\end{tabular}
\end{small}
\end{slide}

\begin{slide}{Compilation and installation}
Compiling a software:

\begin{itemize}
\item use the appropriate options (\%optflags)
\item take care to paths
\item install files in \%buildroot
\end{itemize}
\bigskip
Simple case with autotools

{\scriptsize\begin{verbatim}
%build
%configure
%make

%install
%makeinstall_std
\end{verbatim}
}
\end{slide}

\begin{slide}{Spec extracts}
Example of a complicated case:

{\tiny\begin{verbatim}
export CFLAGS="%optflags"
./configure \
    --prefix %_prefix \
    --bindir %_bindir \
    --libdir %_libdir
# parallel make do not work
make

%install
make install DEST=%buildroot

#install one file:
cat > %buildroot%_sysconfdir/%name.cfg <<EOF
blabla
EOF
\end{verbatim}%
}

\end{slide}

\overlays{3}{
\begin{slide}{Include the files in the package}
\begin{itemstep}
\item all files must be listed
\item use macros
\item software-specific directories must be included
\end{itemstep}
\end{slide}
}

\overlays{3}{
\begin{slide}{Include the files in the package}
\begin{itemstep}
\item configuration files must not be replaced

{\scriptsize%
\%config(noreplace) \%\_sysconfdir/foo
}

\item documentations are included with \%doc
{\scriptsize%
\%doc README \ldots
}

\item use \%find\_lang for translations

{\scriptsize%
\%install\\
\%find\_lang \%name\\
\ldots\\
\%files -f \%name.lang\\
}

\end{itemstep}
\end{slide}
}

\begin{slide}{Dependances}
For binary packages: usually, nothing to do

For sources:
\begin{itemize}
\item identical for all architectures
\item suficient to build the packages
\item no redundancy
\end{itemize}
\bigskip
Example:
\begin{verbatim}
BuildRequires: libfoo-devel
\end{verbatim}
\end{slide}

\begin{slide}{Libidification}
Goal:
\begin{itemize}
\item have many versions of a library\\
Name packages using major number
\item have many architectures\\
Name package including a prefix
\end{itemize}
\bigskip
{\begin{center}
\scriptsize
\begin{tabular}{|c|c|c|}
\hline
majeur:&0&1\\
\hline
32bits&libfoo0&libfoo1\\
&lib/foo.so.0&lib/foo.so.1\\
\hline
64bits&lib64foo0&lib64foo1\\
&lib64/foo.so.0&lib64/foo.so.1\\
\hline
\end{tabular}
\end{center}
}

\end{slide}

\begin{slide}{Libidification: use case}

\begin{verbatim}
%define major 0
#similar to %_lib%name%major
%define libname %name %major
\end{verbatim}
\ldots
\begin{verbatim}
%package -n %libname
Provide: lib%name = %version-%release
\end{verbatim}
\ldots
\begin{verbatim}
%files -n %libname
%defattr(-, root, root, -)
%_libdir/*.so.*
\end{verbatim}
\end{slide}

\part{Conclusion}

\begin{slide}{rpmlint}
Tool to check packages complies to the policy
\begin{itemize}
\item maintained by the wonderful Michaël Scherer
\item available at \url{http://rpmlint.zarb.org/}
\end{itemize}
\bigskip
{\tiny
\begin{verbatim}
$ rpmlint -i rpm-mandriva-setup-1.24-1mdv2007.0.i586.rpm
E: rpm-mandriva-setup no-binary
The package should be of the noarch architecture because it
doesn't contain any binaries.

E: rpm-mandriva-setup only-non-binary-in-usr-lib
There are only non binary files in /usr/lib so they should
be in /usr/share.

\end{verbatim}
}
\end{slide}

\begin{slide}{The End}
This document is there: {\scriptsize\url{http://forge.ipsl.jussieu.fr/docipsl/}}.

Mandriva's rpmhowto: {\scriptsize\url{http://qa.mandriva.com/twiki/bin/view/Main/RpmHowTo}}.

\bigskip
Thanks:
\begin{itemize}
\item Guillaume Rousse
\item Benoît Audouard
\item Eric Villard
\item CNRS/ISPL for web hosting
\end{itemize}

\bigskip
Questions ?

\end{slide}
\end{document}
