web-dev-qa-db-fra.com

Faire apt-get (ou aptitude) exécuté avec -y mais pas Demander de remplacer les fichiers de configuration?

Lors de l'exécution de apt-get -y install <packages ...> sur Ubuntu 10.04, j'aimerais apt-get (ou aptitude si cela le rend plus facile) pour ne pas me demander lors de l'installation de dépendances supplémentaires (comportement de -y tel que je le comprends) et mais pas Me demander de remplacer fichiers de configuration, supposons au contraire que les fichiers existants soient conservés (ce qui est généralement la valeur par défaut). Malheureusement, --trivial-only semble être l'inverse de -y et n'affecte pas l'invite affichée, conformément à la page man.

En particulier, les paquets tels que samba, nullmailer, localepurge et lighttpd m'ont obligé à interagir avec le terminal, même si la procédure entière était scriptée et supposée être non interactive.

69
0xC0000022L

Vous pouvez utiliser:

Sudo apt-get update
Sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade

Pour des packages spécifiques uniquement, par exemple mypackage1 mypackage2:

Sudo apt-get update
Sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install mypackage1 mypackage2

Source: http://raphaelhertzog.com/2010/09/21/debian-conffile-configuration-file-managed-by-dpkg/

Avoiding the conffile Prompt

Every time that dpkg must install a new conffile that you have modified
(and a removed file is only a particular case of a modified file in dpkg’s eyes),
it will stop the upgrade and wait your answer. This can be particularly annoying for
major upgrades. That’s why you can give predefined answers to dpkg with the help
of multiple --force-conf* options:

    --force-confold: do not modify the current configuration file, the new version
is installed with a .dpkg-dist suffix. With this option alone, even configuration
files that you have not modified are left untouched. You need to combine it with
--force-confdef to let dpkg overwrite configuration files that you have not modified.
    --force-confnew: always install the new version of the configuration file, the
current version is kept in a file with the .dpkg-old suffix.
    --force-confdef: ask dpkg to decide alone when it can and Prompt otherwise. This
is the default behavior of dpkg and this option is mainly useful in combination with
--force-confold.
    --force-confmiss: ask dpkg to install the configuration file if it’s currently
missing (for example because you have removed the file by mistake).

If you use Apt, you can pass options to dpkg with a command-line like this:

$ apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade

You can also make those options permanent by creating /etc/apt/apt.conf.d/local:

Dpkg::Options {
   "--force-confdef";
   "--force-confold";
}

Vous pouvez trouver plus d'informations et plus d'options dans le manuel de dpkg à l'adresse http://manpages.ubuntu.com/manpages/xenial/fr/man1/dpkg.1.html ou man dpkg et c.-à-d. cherchez "confdef".

96
Savvas Radevic