% $Header: /cvsroot/latex-beamer/latex-beamer/solutions/generic-talks/generic-ornate-15min-45min.en.tex,v 1.5 2007/01/28 20:48:23 tantau Exp $

\documentclass[hyperref={pdfpagelabels=false}]{beamer}

% This file is a solution template for:

% - Giving a talk on some subject.
% - The talk is between 15min and 45min long.
% - Style is ornate.



% Copyright 2004 by Till Tantau <tantau@users.sourceforge.net>.
%
% In principle, this file can be redistributed and/or modified under
% the terms of the GNU Public License, version 2.
%
% However, this file is supposed to be a template to be modified
% for your own needs. For this reason, if you use this file as a
% template and not specifically distribute it as part of a another
% package/program, I grant the extra permission to freely copy and
% modify this file as you see fit and even to delete this copyright
% notice. 


\mode<presentation>
{
  \usetheme{Warsaw}
  % or ...

  \setbeamercovered{transparent}
  % or whatever (possibly just delete it)
}


\usepackage[english]{babel}
% or whatever

\usepackage[utf8]{inputenc}
% or whatever

\usepackage{times}
\usepackage[T1]{fontenc}
% Or whatever. Note that the encoding and the font should match. If T1
% does not look nice, try deleting the line with the fontenc.


\title[CDBS]{The Common Debian Build System}
\subtitle{(CDBS)}
\author{Peter~Eisentraut}
\date{FOSDEM 2009}

\subject{Talks}
% This is only inserted into the PDF information catalog. Can be left
% out. 



% Delete this, if you do not want the table of contents to pop up at
% the beginning of each subsection:
\AtBeginSubsection[]
{
  \begin{frame}<beamer>{Outline}
    \tableofcontents[currentsection,currentsubsection]
  \end{frame}
}


% If you wish to uncover everything in a step-wise fashion, uncomment
% the following command: 

%\beamerdefaultoverlayspecification{<+->}


\begin{document}

\begin{frame}
  \titlepage
\end{frame}


\begin{frame}{What is CDBS?}
  \begin{itemize}
    \item A set of makefile fragments to include into \texttt{debian/rules}
    \item Makes packaging complex packages easier.
    \item Makes packaging simple packages harder.
    \item Initiates you to a secret subculture of Debian packagers.
    \item Causes you to lose all your not-CDBS-using friends.
  \end{itemize}
\end{frame}


\begin{frame}[fragile]{Simple Example}
\begin{verbatim}
#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk
\end{verbatim}
\pause
\begin{verbatim}
DEB_CONFIGURE_EXTRA_FLAGS = --enable-funnybiz
DEB_INSTALL_DOCS_ALL = readme.txt
LDFLAGS += -Wl,--as-needed
\end{verbatim}
\pause
\begin{verbatim}
binary-install/mypackage-tools::
        chmod a+x debian/mypackage-tools/\
            usr/lib/mypackage/*
\end{verbatim}
\end{frame}


\begin{frame}{Background}
  \begin{itemize}
    \item First published in 2003 by Colin Walters
    \item Co-maintained 2003-2005 by Colin Walters and Jeff Bailey
    \item Hijacked in 2006 by me after a period of no maintenance
    \item Currently 2 or 3 maintainers plus Ubuntu feedback
  \end{itemize}
\end{frame}


\begin{frame}[fragile]{Package Parameters}
\begin{scriptsize}
\begin{verbatim}
Source: cdbs
Section: devel
Priority: optional
Maintainer:
 CDBS Hackers <build-common-hackers@lists.alioth.debian.org>
Build-Depends-Indep: debhelper (>= 5), graphviz, realpath, fakeroot,
 python-dev, python2.4-dev, python2.5-dev, libxml2-utils, xsltproc,
 docbook-xml, docbook-xsl, dblatex, ant, kaffe, sharutils, gs-common,
 texlive-extra-utils
Uploaders: Jonas Smedegaard <dr@jones.dk>,
 Marc Dequènes (Duck) <Duck@DuckCorp.org>,
 Peter Eisentraut <petere@debian.org>
Standards-Version: 3.7.3
Vcs-Browser: http://svn.debian.org/wsvn/build-common/
Vcs-Svn: svn://svn.debian.org/build-common/
\end{verbatim}

Bugs: 1 I, 31 N, 7 M, 33 W

Last upload: 01 Apr 2008
\end{scriptsize}
\end{frame}


\begin{frame}{Statistics}
  \begin{itemize}
    \item Currently 13077 source packages in unstable
    \item 3185 use CDBS (24.4\%)
    \item Appears to be increasing by 0.2\% or so per month
    \item Archive takeover completed by 2020 :-)
  \end{itemize}
\end{frame}


\begin{frame}{Architecture}
  \begin{itemize}
    \item Yes, there is one:
    \begin{itemize}
      \item \emph{Classes} contain the logic for the package's upstream build system: make, autotools, MakeMaker, distutils, cmake, etc.
      \item \emph{Rules} contain additional rules of various utility: debhelper, tarball-in-tarball, patch tools
      \item Classes use inheritance (a.k.a. makefile inclusion): autotools inherits make, gnome inherits autotools, etc.
    \end{itemize}

    \item In practice, this is arcane, so just remember:
    \begin{itemize}
      \item Exactly one class per \texttt{debian/rules}
      \item Zero or more rules per \texttt{debian/rules}
      \item Usually, you want at least the debhelper rules set
      \item Deviations are possible, but rarely useful
    \end{itemize}

  \end{itemize}
\end{frame}


\begin{frame}[fragile]{Advantages}

  Technical advantages:

  \begin{itemize}
    \item Writing \texttt{debian/rules} becomes quick and easy (usually)
    \item You get the details right for free:
      \begin{itemize}
        \item \texttt{dh\_*} sequencing
        \item \verb|configure --build/--host| (see autotools-dev README)
        \item \texttt{DEB\_BUILD\_OPTIONS}: noopt, nostrip
        \item \texttt{CFLAGS}, \texttt{CXXFLAGS}, etc. (try passing them to cmake or qmake correctly)
        \item parallel make
        \item Java packaging policy
      \end{itemize}
    \item You follow policy evolvement for free:
      \begin{itemize}
        \item Python policy
        \item \texttt{patch}, \texttt{unpatch} targets
        \item KDE 4 packaging practices
      \end{itemize}
  \end{itemize}
\end{frame}


\begin{frame}[fragile]{Advantages}

  Conceptual advantages:

  \begin{itemize}
    \item \texttt{debian/rules} highlights the nonstandard packaging steps, rather than hiding them in boilerplate.
    \item Avoids propagation of mistakes through copy-and-paste or \texttt{dh\_make}.
    \item Avoids home-brewed and half-baked alternative \texttt{debian/rules} makefile fragments packages.
  \end{itemize}
\end{frame}


\begin{frame}{Disadvantages}
  \begin{itemize}
    \item If your package has an unusual build system, CDBS might be in your way.
    \item If you are a control-freak, CDBS will be in your way.
    \item If GNU make syntax confuses you, CDBS will confuse you.
    \item CDBS is not good for learning Debian packaging.
  \end{itemize}
\end{frame}


\begin{frame}[fragile]{Makefile Class}
\begin{verbatim}
include /usr/share/cdbs/1/class/makefile.mk

DEB_MAKE_BUILD_TARGET = all
DEB_MAKE_INSTALL_TARGET = install DESTDIR=$(CURDIR)/debian/tmp
DEB_MAKE_CLEAN_TARGET = clean
\end{verbatim}

\begin{itemize}
 \item Sets \texttt{CFLAGS} etc. according to policy
 \item Observes \texttt{DEB\_BUILD\_OPTIONS}
\end{itemize}
\end{frame}


\begin{frame}[fragile]{Autotools Class}
\begin{verbatim}
include /usr/share/cdbs/1/class/autotools.mk

DEB_CONFIGURE_EXTRA_FLAGS = --enable-funnybiz
\end{verbatim}

\begin{itemize}
 \item ``Inherits'' makefile class
 \item Calls configure with proper options (host tuple, installation paths)
 \item Calls \texttt{make distclean} instead of \texttt{make clean}
 \item Handles \texttt{config.guess}, \texttt{config.sub} updates
 \item Supports \texttt{autoreconf}, \texttt{libtoolize} before build (dubious)
\end{itemize}
\end{frame}


\begin{frame}[fragile]{Perl Class}
\begin{verbatim}
include /usr/share/cdbs/1/class/perlmodule.mk

DEB_MAKEMAKER_USER_FLAGS = --with-foo
\end{verbatim}

\begin{itemize}
 \item ``Inherits'' makefile class
 \item Calls MakeMaker with proper options and paths
\end{itemize}
\end{frame}


\begin{frame}[fragile]{Python Class}
\begin{verbatim}
include /usr/share/cdbs/1/class/python-distutils.mk

# mandatory
DEB_PYTHON_SYSTEM = pycentral | pysupport
\end{verbatim}

\begin{itemize}
 \item ``Inherits'' makefile class
 \item Figures out all the Python policy details :-)
 \item Documentation needs updates :-(
\end{itemize}
\end{frame}


\begin{frame}[fragile]{KDE Class}
\begin{verbatim}
include /usr/share/cdbs/1/class/kde.mk
\end{verbatim}

(for KDE <= 3.5)

\begin{itemize}
 \item ``Inherits'' autotools class
 \item Sets proper \texttt{configure} flags, additional installation paths
 \item Documentation installation
 \item Used for all major KDE packages
\end{itemize}

KDE 4 class will be based on CMake.
\end{frame}


\begin{frame}[fragile]{Ant Class}
\begin{tiny}
\begin{verbatim}
include /usr/share/cdbs/1/class/ant.mk

JAVA_HOME = /usr/lib/kaffe
DEB_JARS = junit
DEB_ANT_BUILD_TARGET = jars
DEB_ANT_COMPILER = jikes

install/libjline-java:: DEB_FINALDIR=$(CURDIR)/debian/libjline-java
install/libjline-java::
        install -m 644 -D release/jline-0_9_5.jar \
            $(DEB_FINALDIR)/usr/share/java/jline-$(DEB_UPSTREAM_VERSION).jar
        dh_link /usr/share/java/jline-$(DEB_UPSTREAM_VERSION).jar \
            /usr/share/java/jline.jar
\end{verbatim}
\end{tiny}

\begin{itemize}
 \item Most Java library packags are built this way.
 \item Tuned to Java packaging policy (at some point in time).
\end{itemize}
\end{frame}


\begin{frame}{Other classes}
  \begin{itemize}
    \item CMake
    \item GNOME
    \item Haskell
    \item QMake
    \item OCaml (external)
    \item PEAR (external)
  \end{itemize}
\end{frame}


\begin{frame}[fragile]{Debhelper Rules}
\begin{verbatim}
include /usr/share/cdbs/1/rules/debhelper.mk
\end{verbatim}

\begin{itemize}
 \item Usually put this first in every \texttt{debian/rules}
 \item Takes care of proper sequencing and sequence points
 \item Arguments for every command can be overridden on a per-package basis, e.g.,
\begin{verbatim}DEB_INSTALL_EXAMPLES_libjline-java-doc = \
   release/jline-demo.jar\end{verbatim}
 \item Easy and automatic debug package support
\end{itemize}
\end{frame}


\begin{frame}{Patch Systems Support}
  \texttt{include /usr/share/cdbs/1/rules/}\ldots

  \begin{description}
    \item[dpatch.mk] DPatch rules
    \item[patchsys-quilt.mk] Quilt rules (contained in \texttt{quilt} package)
    \item[simple-patchsys.mk] Home-grown ``simple'' patch system (TANSTAA``S''PS)
  \end{description}
\end{frame}


\begin{frame}{What CDBS Is Not}
  \begin{itemize}
    \item No support for un-Common build systems
    \item Not a dumping ground for rejected debhelper features.
    \item Not a workaround for missing dpkg functionality.
    \item Not a way to enforce packaging behavior (but to enable or encourage it).
    \item Individual teams sometimes create a local subclass to enforce local policy.
  \end{itemize}
\end{frame}


\begin{frame}{Comparisons and Contrasts}
  \begin{description}
    \item[vs. Debhelper only] Debhelper is only the steps, CDBS puts them together.
    \item[vs. dh (Debhelper 7)] Does not allow for customization, only suitable for dead-simple packages.
    \item[vs. BSD ports] Very similar setup.  Difference: Variables at the top, include \texttt{bsd.port.mk} at the bottom.
    \item[vs. Automake] Same declarative approach; details about actual make rules are hidden.
  \end{description}
\end{frame}


\begin{frame}{Problems}
  \begin{itemize}
    \item Patching the clean rule of a makefile (or equivalent) is broken
    \item Feature creep/unbounded user requests
    \item Certain old features/behaviors are not documented or understood
    \item CDBS maintainer must know all subpolicies in Debian ;-)
  \end{itemize}
\end{frame}


\begin{frame}{Plans: CDBS 2}
  \begin{itemize}
    \item Original idea: replace \texttt{/usr/share/cdbs/1/rules/foo.mk} by \texttt{/usr/share/cdbs/2/rules/foo.mk}
    \item Upcoming idea: similar to Debhelper compat levels, e.g., \texttt{CDBS\_COMPAT = 2}
    \item Throw out some obsolete features
    \item Synchronize default values with Debhelper 7
    \item Maybe move the include to the bottom
    \item Need a better/useful version numbering system
  \end{itemize}
\end{frame}


\begin{frame}{How to Help}
  \begin{itemize}
    \item Bugs, patches, ideas welcome.
    \item Join bug discussions.
    \item Enhance the test suite.
    \item Drive the right features into \texttt{debhelper} and \texttt{dpkg}.
  \end{itemize}
\end{frame}


\begin{frame}{Summary}
  \begin{itemize}
    \item Include CDBS rules rather than writing \texttt{debian/rules} by hand.
    \item Takes care of details and policy requirements automatically.
    \item Particularly useful for packages with uniform build processes.
    \item Not suitable for all packages and packagers.
  \end{itemize}
\end{frame}

\end{document}
