LoginSignup
16
6

More than 1 year has passed since last update.

aptコマンドで指定のパッケージのみアップグレードする

Last updated at Posted at 2022-07-05

毎度、ググっても出てこない小ネタを取り扱っております。
本記事は個人的な見解であり、筆者の所属するいかなる団体にも関係ございません。

0. apt のアップグレードで指定のパッケージのみアップグレードしたい!

apt updateして、アップグレードできるパッケージをapt list --upgradableで確認しました。

(下記一例)

$ apt list --upgradable
Listing... Done
linux-aws/jammy-updates 5.15.0.1014.14 amd64 [upgradable from: 5.15.0.1013.13]
linux-headers-aws/jammy-updates 5.15.0.1014.14 amd64 [upgradable from: 5.15.0.1013.13]
linux-image-aws/jammy-updates 5.15.0.1014.14 amd64 [upgradable from: 5.15.0.1013.13]
mesa-va-drivers/jammy-updates 22.0.1-1ubuntu2.1 amd64 [upgradable from: 22.0.1-1ubuntu2]
mesa-vdpau-drivers/jammy-updates 22.0.1-1ubuntu2.1 amd64 [upgradable from: 22.0.1-1ubuntu2]
mesa-vulkan-drivers/jammy-updates 22.0.1-1ubuntu2.1 amd64 [upgradable from: 22.0.1-1ubuntu2]
nginx/stable 1.22.0-1~jammy amd64 [upgradable from: 1.20.2-1~jammy]
php7.4-apcu/jammy 5.1.21+4.0.11-8+ubuntu22.04.1+deb.sury.org+1 amd64 [upgradable from: 5.1.21+4.0.11-7+ubuntu22.04.1+deb.sury.org+1]
php7.4-cli/jammy 1:7.4.30-3+ubuntu22.04.1+deb.sury.org+1 amd64 [upgradable from: 1:7.4.29-2+ubuntu22.04.1+deb.sury.org+1]
php7.4-common/jammy 1:7.4.30-3+ubuntu22.04.1+deb.sury.org+1 amd64 [upgradable from: 1:7.4.29-2+ubuntu22.04.1+deb.sury.org+1]
php7.4-json/jammy 1:7.4.30-3+ubuntu22.04.1+deb.sury.org+1 amd64 [upgradable from: 1:7.4.29-2+ubuntu22.04.1+deb.sury.org+1]
php7.4-opcache/jammy 1:7.4.30-3+ubuntu22.04.1+deb.sury.org+1 amd64 [upgradable from: 1:7.4.29-2+ubuntu22.04.1+deb.sury.org+1]
php7.4-phpdbg/jammy 1:7.4.30-3+ubuntu22.04.1+deb.sury.org+1 amd64 [upgradable from: 1:7.4.29-2+ubuntu22.04.1+deb.sury.org+1]
php7.4-readline/jammy 1:7.4.30-3+ubuntu22.04.1+deb.sury.org+1 amd64 [upgradable from: 1:7.4.29-2+ubuntu22.04.1+deb.sury.org+1]

この中で、nginxやphp7.4だけアップデートして他のはアップデートしたくないということがあります。

Redhat EL系であれば、yum update php7.4* といったワイルドカードでの特定のパッケージのみアップデートすることが可能です。
しかし、apt コマンドの場合は、apt upgrade php7.4*という指定をすることができません。

そこで、やり方を調べました。

1. aptコマンドで指定のパッケージのみアップグレードする方法

以下のように指定する

sudo apt install --only-upgrade php7.4*

2. 参考

How to upgrade a single package using apt-get? - Ask Ubuntu
https://askubuntu.com/questions/44122/how-to-upgrade-a-single-package-using-apt-get

16
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
6