% on the following slides, include icon in the left sidebar
\def\lximg{/usr/share/lx/icons/fueller.png}

\input{configpres}

\title{Debian Package Management}
\maketitle

% stop displaying 'fueller.png' on the following slides
\def\lximg{none}

\subsection{Debian Package Management}

\subsubsection{Introduction}
\begin{frame}
\frametitle{Package Management}
\begin{itemize}
\item Dependencies
\item Updates
\item Licensing
\item Managing Repositories
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Debian Package Management}
\begin{itemize}
\item Binary packages (.deb)
\item dpkg is the base software of the Debian Package Management System
\end{itemize}
\end{frame}

\subsubsection{dpkg}
\begin{frame}[fragile]
\frametitle{Using dpkg}
\begin{verbatim}
# Install a package
dpkg -i packagename.deb
# Get a list of the installed packages
dpkg -l
# Get a list of the installed packages
# which match a specific pattern
dpkg -l zlib*
# remove a package
dpkg -r packagename
# remove a package
# (and it's configuration files)
dpkg -P packagename
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Using dpkg}
\begin{verbatim}
# Figure out to which package a
# file belongs do
dpkg -S /bin/df
# Get a list of files
# which will be installed
# with a package
dpkg -L coreutils
# Get some information about an archive
dpkg -I packagename.deb
# Reconfigure a package
dpkg-reconfigure packagename
\end{verbatim}
\end{frame}

\subsubsection{APT}
\begin{frame}
\frametitle{The \textbf{A}dvanced \textbf{P}ackaging \textbf{T}oolkit}
\begin{itemize}
\item DPKG is the mechanism to install the package itself. APT will keep track of
the dependencies and so on...
\item The \textbf{apt} command has several sub-commands:
 \begin{itemize}
 \item search - search in package descriptions
 \item install/remove - install/remove packages
 \item update - update list of available packages
 \item upgrade - upgrade the system by installing/upgrading packages
 \end{itemize}
\item old-style: various apt-commands
 \begin{itemize}
 \item apt-cache update
 \item apt-get upgrade
 \item apt-get install ...
 \end{itemize}
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{The \textbf{A}dvanced \textbf{P}ackaging \textbf{T}oolkit}
Repository list is kept in:
\begin{verbatim}
/etc/apt/sources.list
\end{verbatim}
The repository list looks like:
\begin{verbatim}
deb http://debian.tu-bs.de/debian stretch \
      main contrib non-free
deb-src http://debian.tu-bs.de/debian stretch \
      main contrib non-free
[...]
\end{verbatim}
\end{frame}


\begin{frame}[fragile]
\frametitle{The \textbf{A}dvanced \textbf{P}ackaging \textbf{T}oolkit}
There are several frontends for APT. The most important ones are:
\begin{itemize}
\item aptitude
\item synaptic
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Update and Upgrade}
\begin{verbatim}
# Update the package list
apt update

# Upgrade all packages on your system
apt upgrade

# Upgrade packages on your system AND
# and resolves any new dependencies
apt dist-upgrade
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Install and Remove}
\begin{verbatim}
# Install a package
apt install <packagename>

# Remove a package
apt remove <packagename>

# Remove auto-installed packages, which are
# no longer required by other packages.
apt autoremove

# Remove a package
# including its configuration files
apt purge <packagename>

# Clean the local apt cache
apt clean
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Search and Dependencies}
\begin{verbatim}
# Looking for a package
apt search minicom

# Show dependencies
apt depends minicom

# Show a user readable record
apt show minicom
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{apt behind a proxy}
/etc/apt/apt.conf.d/02proxy:
\begin{verbatim}
Acquire::http::Proxy "http://proxy:8080";
\end{verbatim}
with user:
\begin{verbatim}
Acquire::http::Proxy \
   "http://user@proxy:8080";
\end{verbatim}
with user and password:
\begin{verbatim}
Acquire::http::Proxy \
   "http://user:pass@proxy:8080";
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{aptitude}
Aptitude has an \textbf{advanced dependency handling} and a graphical front-end. The
syntax is quite similar to apt:
\begin{verbatim}
# alternative to: apt install minicom
aptitude install minicom

# alternative to: apt search minicom
aptitude search minicom
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{apt vs. aptitude (I)}
aptitude supports extended search patterns
\begin{verbatim}
# search only in installed packages (long and short version)
$ aptitude search "?installed(linux-image)"
$ aptitude search ~ilinux-image
i A linux-image-4.19.0-1-amd64  - Linux 4.19 for 64-bit PCs
i   linux-image-amd64           - Linux for 64-bit PCs

# search packages, which are no longer present in repository
aptitude search "?obsolete(openjdk)"
aptitude search ~oopenjdk
i A openjdk-10-jre              - OpenJDK Java runtime, ...
i A openjdk-10-jre-headless     - OpenJDK Java runtime, ...
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{apt vs. aptitude (II)}
apt has super cow powers, aptitude does not!! ;-)
\begin{verbatim}
$ aptitude moo
There are no Easter Eggs in this program.

$ apt moo
         (__) 
         (oo) 
   /------\/ 
  / |    ||   
 *  /\---/\ 
    ~~   ~~   
...."Have you mooed today?"...
\end{verbatim}
\end{frame}

\subsubsection{deb packages}
\begin{frame}
\frametitle{The .deb file format}
A Debian archive contains three files:
\begin{itemize}
\item debian-binary: Version of the archive formate
\item control.tar.gz: GZIPPed Tarball containing the archive's control files
\item data.tar.gz: GZIPPed Tarball containing the archives data files
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Creating .deb packages}
Directory structure:
\begin{verbatim}
hello_pkt/
  debian/
    changelog
    control
    copyright
    ...
  bin/
    hello
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Creating .deb packages}
\begin{verbatim}
# hello_pkt/debian/control
Package: hello
Version: 0.0.1
Section: misc
Priority: optional
Architecture: i386
Depends: libc6 (>= 2.2.4-4)
Maintainer: Max Mustermann <m@mustermail.de>
Description: Simple hello world program
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Creating .deb packages}
\begin{verbatim}
# Building the package
dpkg-deb -b hello_pkt
# dpkg -I hello_pkt.deb
[...]
 Version: 0.0.1
 Section: misc
 Priority: optional
 Architecture: i386
 Depends: libc6 (>= 2.2.4-4)
 Maintainer: Max Mustermann <m@mustermail.de>
 Description: Simple hello world program
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Creating .deb packages}
\begin{verbatim}
$ ar -tv hello_pkt.deb
rw-r--r-- 0/0  [...] 2011 debian-binary
rw-r--r-- 0/0  [...] 2011 control.tar.gz
rw-r--r-- 0/0  [...] 2011 data.tar.gz
\end{verbatim}
\end{frame}

\subsubsection{debhelper}
\begin{frame}[fragile]
\frametitle{dh\_make}
dh\_make is a helper to create skeletons for the contents in the DEBIAN/
directory:
\begin{verbatim}
$ mkdir hello-0.0.1
$ cd hello-0.0.1
$ dh_make -c gpl2 -n -s -e m@mustermann.de
\end{verbatim}
\end{frame}

\begin{frame}
\begin{thebibliography}{1}
\bibitem{debian} http://www.debian.org
\end{thebibliography} 
\end{frame}

\input{tailpres}
