\section{DPKG (Debian Package)}
\begin{frame}
   {DPKG Essentials}

   \begin{itemize}

      \item Used in all \textbf{Debian}-based \textbf{Linux}
      distributions, including \textbf{Ubuntu} and
      \textbf{Linux Mint}

      \item Like \textbf{rpm}, the \textbf{dpkg} utility does
      not retrieve packages or remedy dependency failures.

      \item Package files have a \texttt{.deb} suffix

      \item \textbf{DPKG} database resides
      \filelink{/var/lib/dpkg}
   \end{itemize}

\end{frame}

\cprotect\note{

   \textbf{DPKG} (\textbf{Debian Package}) is the packaging
   system used to install, remove, and manage software
   packages under \textbf{Debian Linux} and other
   distributions derived from it.  Like \textbf{RPM} it is
   not designed to directly retrieve packages in day to day
   use, but to install and remove them locally.

   Package files have a \texttt{.deb} suffix and the
   \textbf{DPKG} database resides in the
   \filelink{/var/lib/dpkg} directory.

   Like \textbf{rpm}, the \textbf{dpkg} program has only a
   partial view of the universe: it knows only what is
   installed on the system, and whatever it is given on the
   command line, but knows nothing of the other available
   packages whether they are in some other directory on the
   system or out on the Internet.  As such it will also
   fail if a dependency is not met, or if one tries to
   remove a package other installed packages need.

}
\section{Package File Names and Source}
\begin{frame}
   {Package File Names and Source}
   \begin{itemize}

      \item
      Standard naming format for a binary package:
      \begin{kcode}
<name>_<version>-<revision_number>_<architecture>.deb
      \end{kcode}
      as in:
      \begin{kcode}
logrotate_3.14.0-4_amd64.deb
logrotate_3.14.0-4ubuntu3_amd64.deb
      \end{kcode}

      \item Source package consists of at least 3 files:
      \begin{itemize}
         \item An \textbf{upstream tarball} (ending in
         \verb?.tar.gz?)
         \item A \textbf{description file} (ending with
         \verb?.dsc?)
         \item A second tarball (ending in \verb?.diff.gz?
         or \verb?.debian.tar.gz?)
         containing any patches to the upstream source, and
         additional files created for the package
      \end{itemize}
   \end{itemize}

\end{frame}

\cprotect\note {

   \textbf{Debian} package file names are based on fields
   that represent specific information.

   For historical reasons, the 64-bit \textbf{x86} platform
   is called \textbf{amd64} rather than \textbf{x86\_64},
   and distributors such as \textbf{Ubuntu} manage to
   insert their name in the package name.

   On an \textbf{Ubuntu} system one can download a source
   package and then see
   what files are downloaded or created as in:

   \begin{figure}[H]
      \includegraphics[width=6.5in]{IMAGES/aptsource}
      \caption{Getting Source Packages on Ubuntu}
   \end{figure}

}

\section{DPKG Queries}
\begin{frame}
   {DPKG Queries}
   \begin{itemize}
      \item List all packages installed:
      \begin{cmd}
$ dpkg -l
      \end{cmd}
      \item List files in the \texttt{wget} package:
      \begin{cmd}
$ dpkg -L wget
      \end{cmd}
      \item Show info about an installed package, and a package file:
      \begin{cmd}
$ dpkg -s wget
$ dpkg -I webfs_1.21+ds1-8_amd64.deb
      \end{cmd}
      \item List files in a package file:
      \begin{cmd}
$ dpkg -c  webfs_1.21+ds1-8_amd64.deb
      \end{cmd}
      \item Show what package owns
      \filelink{/etc/init/networking.conf}:
      \begin{cmd}
$ dpkg -S /etc/init/networking.conf
      \end{cmd}
      \item Verify the installed package integrity
      \begin{cmd}
$ dpkg -V package
      \end{cmd}
   \end{itemize}

\end{frame}

\cprotect\note{

   Only versions of \textbf{dpkg} greater than 1.17 support the
   \texttt{-V} option. Without arguments this will verify all
   packages on the system.  See the \textbf{man} page to
   interpret the output.

}

\section{Installing/Upgrading/Uninstalling}
\begin{frame}
   {Installing/Upgrading/Uninstalling}

   \begin{itemize}

      \item
      Install or upgrade the \textbf{foobar} package:
      \begin{cmd}
$ sudo dpkg -i foobar.deb
      \end{cmd}

      \item Remove all of an installed package except for its
      configuration files:
      \begin{cmd}
$ sudo dpkg -r package
      \end{cmd}

      \item Remove all of an installed package including
      its configuration files.
      \begin{cmd}
$ sudo dpkg -P package
      \end{cmd}
   \end{itemize}

\end{frame}

\cprotect\note {

   When using the \texttt{-i} option (for install):
   \begin{itemize}
      \item
      If the package is not currently installed, then it
      will be installed.
      \item
      If the package is newer than the one currently
      installed then it will be upgraded.
   \end{itemize}

   Note the \texttt{-P} option stands for \textbf{purge}.

}




