設定ファイル内のaptオプション

設定ファイル内のaptオプション

以下のように実行していますapt-get:

rm -rf /var/lib/apt/lists/*'
apt-get clean
apt-get --option Acquire::Check-Valid-Until=false update
DEBIAN_FRONTEND=noninteractive apt-get --yes --option Dpkg::Options::="--force-confdef" --option Dpkg::Options::="--force-confold" upgrade
DEBIAN_FRONTEND=noninteractive apt-get --yes --option Dpkg::Options::="--force-confdef" --option Dpkg::Options::="--force-confold" dist-upgrade
apt-get autoremove --yes --force-yes
apt-get clean

構成ファイルからオプションを削除して、/etc/apt/apt.conf.d/これらのオプションを指定せずにコマンドを実行できるようにし、オプションが尊重されるようにしたいと思います。具体的には、次のものを削除します。

  1. --option Acquire::Check-Valid-Until=falseからapt-get update
  2. DEBIAN_FRONTEND=noninteractiveそして--yes --option Dpkg::Options::="--force-confdef" --option Dpkg::Options::="--force-confold"からapt-get upgradeそしてapt-get dist-upgrade
  3. --yes --force-yesからapt-get autoremove

そして私はマニュアルページ、どうすれば正しく実行できるかわかりませんでした。

どのようにすればそれが実現できるか、詳しく説明していただければ幸いです。

必要になった場合に備えて、私のシステムに関する情報を以下に示します。

$ cat /etc/*release* | grep -i dist
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.1 LTS"

$ dpkg -l | grep -i apt | head -n 1
ii  apt  1.2.15ubuntu0.2  amd64  commandline package manager

答え1

ファイルに--option次の部分を追加できます:=

Acquire::Check-Valid-Until "false";
Dpkg::Options:: "--force-confdef";
Dpkg::Options:: "--force-confold";

--yesおよびに関しては--force-yesapt-getマニュアルページ言う:

-y, --yes, --assume-yes
   Automatic yes to prompts; assume "yes" as answer to all prompts and
   run non-interactively. If an undesirable situation, such as
   changing a held package, trying to install a unauthenticated
   package or removing an essential package occurs then apt-get will
   abort. Configuration Item: APT::Get::Assume-Yes.

--force-yes
   Force yes; this is a dangerous option that will cause apt to
   continue without prompting if it is doing something potentially
   harmful. It should not be used except in very special situations.
   Using force-yes can potentially destroy your system! Configuration
   Item: APT::Get::force-yes. This is deprecated and replaced by
   --allow-downgrades, --allow-remove-essential,
   --allow-change-held-packages in 1.1.

それで:

APT::Get::Assume-Yes "true";
APT::Get::force-yes "true";

APT::Get::allow-downgrades2 行目は、、の 1 つ以上をAPT::Get::allow-remove-essentialtrueAPT::Get::allow-change-held-packagesに設定する行に置き換える必要があります。

DEBIAN_FRONTEND=noninteractiveはdebconf設定であり、で設定する必要がありますdebconf.confマニュアルページ例があります。

これらを設定ファイルで設定するのではなく、スクリプトを作成することを強くお勧めします。また、upgradeの前にを実行しても意味がありませんdist-upgrade。 だけdist-upgradeで十分です。

関連情報