CLOVER🍀

That was when it all began.

Ubuntu Linux 21.04以降でaptにも適用されているPhased Updates

これは、なにをしたくて書いたもの?

Ubuntu Linux 22.04 LTSにしてから、パッケージを更新しようとした時に

$ sudo apt upgrade

以下のようにパッケージの更新が保留されることが増えました。

以下のパッケージは保留されます:
  update-notifier update-notifier-common

これ自体は、個別にapt installすれば解消できるのですが…。

Ubuntu Linuxでapt upgradeで保留されたパッケージがあった場合に、アップデートするには? - CLOVER🍀

どうも頻度が多すぎる気がします。

少し調べてみることにしました。

Phased Updates

調べてみると、Phased Updatesというものが関係しているようです。

PhasedUpdates - Ubuntu Wiki

Phased Updates自体は前からあったようですが、

Ubuntu 16.04 その69 - 段階的にパッケージのアップデートを提供するフェーズドアップデート - kledgeb

aptが対応したのは、Ubuntu Linux 21.04からみたいですね。

Ubuntu 21.04 その10 - APTがフェーズドアップデートに対応・apt/apt-getでもフェーズドアップデートが有効に - kledgeb

Phased updates in APT in 21.04 - Foundations - Ubuntu Community Hub

Phased Updatesというのは、リグレッション対策のためにアップデートの内容を一部のユーザーに提供して、問題がなければ徐々に
対象とするユーザーを増やしていくもののようです。

パーセンテージは最初は10%に設定されていて、そこからリグレッションの確認が6時間ごとに行われ、問題がない場合は10%ずつ
対象とするユーザーを増やしていくようです。最終的には54時間後または2日後に完全に提供されるとか。

The Phased-Update-Percentage is initially set to 10%, and a job is run (every 6 hours) that checks for regressions and if none are found the phased update percentage will be incremented by 10%. So an update will become fully phased after 54 hours or about 2 days.

PhasedUpdates - Ubuntu Wiki

つまり、放っておいてもそのうち適用されるということですね。

とにかく適用する

一時的に保留しないようにするには、-oオプションでAPT::Get::Always-Include-Phased-Updatestrueに指定します。

$ sudo apt -o APT::Get::Always-Include-Phased-Updates=true upgrade

ずっと適用するには、/etc/apt/apt.conf.d配下にオプションを記述するとよいでしょう。

/etc/apt/apt.conf.d/99phased-update

APT::Get::Always-Include-Phased-Updates "true";

確認。

$ apt-config dump | grep -i phased
APT::Get::Always-Include-Phased-Updates "true";

この説明は、apt_preferencesに書かれています。

Ubuntu Manpage: apt_preferences - Preference control file for APT

APT::Get::Always-Include-Phased-Updatestrueにすると、Phased Updatesを考慮しなくなります(パッケージの更新がすぐに
インストールされます)。

set APT::Get::Never-Include-Phased-Updates or APT::Get::Always-Include-Phased-Updates to true such that APT will never/always consider phased updates.

APT::Get::Never-Include-Phased-Updatestrueにすると、Phased Updatesによる段階的導入が済んだ後に更新されたパッケージが
インストールされることになります。

Phased updates in APT in 21.04 - Foundations - Ubuntu Community Hub

また、Phased Updatesの仕組みには乗るものの、マシン間で更新タイミングを合わせたい場合はAPT::Machine-IDに同じUUIDを設定すれば
よいみたいです。

In case you have multiple systems that you want to receive the same set of updates, you can set APT::Machine-ID to a UUID such that they all phase the same

Ubuntu Manpage: apt_preferences - Preference control file for APT

この値をシードのひとつとして、Phased Updatesによる更新タイミングを算出するようなので。