\section{Advanced Usage}

CUDF-based solvers come with the built-in ability to specify a
set of user preferences for selecting the kind of changes one accepts
on the system to satisfy the installation request. Compared with
\aptget, this gives the user a greater flexibility to define
``optimal'' solutions for a specific installation problem (ex:
minimize the number of new packages or minimize the total installation
size the packages to upgrade).

\subsection{Choosing your own optimization criteria}

Each CUDF solver implements a base optimization language, and some of
them implement extensions to this basic language to respond to
specific optimization requirements. \aptcudf, that is the bridge from
\aptget and the CUDF solver, associates to each \aptget command an
optimization strategy that can be either configured at each invocation
using one \aptget configuration option or by using the configuration
file (\texttt{/etc/apt-cudf.conf} ) of \aptcudf.

\begin{verbatim}
solver: *
upgrade: -new,-removed,-notuptodate
dist-upgrade: -notuptodate,-new
install: -removed,-changed
remove: -removed,-changed
trendy: -removed,-notuptodate,-unsat_recommends,-new
paranoid: -removed,-changed
\end{verbatim}

The field \texttt{solver} define the (comma-separated) list of solvers
to which this stanza applies. The symbol ``*'' denotes that this
stanza applies to all solver that do not have a specific stanza.

Each field of the stanza defines the default optimization criteria.
If one field name coincides with a standard apt-get action, like
install, remove, upgrade or dist-upgrade, the corresponding criterion
will be applied by the external solver. Otherwise the field is
interpreted as a short-cut definition that can be used on the \aptget
command line.

Using the configuration option of \aptget
\texttt{APT::Solver::aspcud::Preferences}, the user can pass a
specific optimization criteria on the command line overwriting the
default. For example :


\begin{verbatim}

 apt-get -s --solver aspcud install totem -o "APT::Solver::aspcud::Preferences=trendy"

\end{verbatim}


\subsection{Relaxing Pinning}

When a package is available in more than one version, \aptget uses a mechanism
known as pinning to decide which version should be installed. However,
since this mechanism defines from the beginning which package versions
must be consider and consequently which package version should be
ignored, it has also the consequence of considerably limiting the
search space, leading to unsatisfiable solutions even if one might
exists if all packages are considered.

To circumvent this restriction and to allow the underlying solver to
explore the entire search space, \aptget can be configured to let the
CUDF solver ignore the pinning annotation.

The option \texttt{APT::Solver::Strict-Pinning} when used in
conjunction with an external solver, tells \aptget to ignore pinning
information when solving dependencies possibly leading to a solution
that was not considered by the \aptget internal solver.

Anther consequence of such strict pinning policy of \aptget is that
if a package is specified on the command line with version or suite
annotations, overwriting the pinning strategy for this package, but
not for its dependencies, the underlying solver might not be able to
find a possible solution because not all packages are available 

Because of the way that pinning information are encoded, \aptcudf + a
CUDF solver is effectively unable to do better then \aptget because
important information were lost on the way.
In order to overcome this limitation, \aptcudf has the ability to 
reconstruct the user request and to use this information to provide a
possible solution. To this end, \aptcudf reads an environment variable,
named \texttt{APT\_GET\_CUDF\_CMDLINE}, that the user can pass along
containing the invocation of \aptget.

To make it straightforward for the user, a very simple script called
\texttt{apt-cudf-get} is provided by the \aptcudf package.

\begin{verbatim}
#!/bin/sh
export APT_GET_CUDF_CMDLINE="apt-get $* -o APT::Solver::Strict-Pinning=\"false\""
apt-get $* -o APT::Solver::Strict-Pinning="false"
\end{verbatim}

The wrapper is be invoked using the same commands as \aptget :

\begin{verbatim}
apt-cudf-get -s --solver aspcud install totem \
    -o "APT::Solver::aspcud::Preferences=-new,-changed"
\end{verbatim}
