LoginSignup
2
3

More than 5 years have passed since last update.

apt備忘録: バージョン指定でパッケージを削除/導入するとき

Last updated at Posted at 2019-04-10

経緯

公式・非公式リポジトリを併用しているUbuntu 16.04 でRubyのビルドを行う際、

ことがありました。
これはその際に行った作業の簡単なメモです。

dpkg -l

まずはインストール済のパッケージを確認。
openssl 関連のパッケージを一通りチェックします。

$ dpkg -l | grep ssl
ii  libgnutls-openssl27:amd64          3.4.10-4ubuntu1.4                          amd64        GNU TLS library - OpenSSL wrapper
ii  libssl-dev:amd64                   1.0.2g-1ubuntu4.15                         amd64        Secure Sockets Layer toolkit - development files
ii  libssl-doc                         1.0.2g-1ubuntu4.15                         all          Secure Sockets Layer toolkit - development documentation
ii  libssl1.0.0:amd64                  1.0.2g-1ubuntu4.15                         amd64        Secure Sockets Layer toolkit - shared libraries
ii  openssl                            1.1.0h-2.0+ubuntu16.04.1+deb.sury.org+1                         amd64        Secure Sockets Layer toolkit - cryptographic utility

apt show

続いてパッケージ情報の確認。

$ apt show openssl
Package: openssl
Version: 1.1.0h-2.0+ubuntu16.04.1+deb.sury.org+1
Priority: optional
Section: utils
Maintainer: Debian OpenSSL Team <pkg-openssl-devel@lists.alioth.debian.org>
Installed-Size: 1,255 kB
...(中略)...

出力の最後に以下のメッセージが出る場合は同名パッケージが複数あります。

...(中略)...

N: There are 2 additional records. Please use the '-a' switch to see them.

-a オプションをつけると、残りの同名パッケージもまとめて確認できます。

$ apt show -a openssl

apt remove

インストール済のパッケージをまず削除。
--purge オプションで *.deb パッケージも含めた完全削除としました。

$ sudo apt remove --purge libssl-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  libssl-dev*
0 upgraded, 0 newly installed, 1 to remove and 62 not upgraded.
After this operation, 8,142 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 69775 files and directories currently installed.)
Removing libssl-dev:amd64 (1.1.1b-1+ubuntu16.04.1+deb.sury.org+1) ...

apt install

apt show で調べた Version 文字列を指定して、特定バージョンのパッケージを導入。
今回は

Version: 1.0.2g-1ubuntu4.15

を導入したいので、

$ apt install openssl=1.0.2g-1ubuntu4.15

終わりに

なるべくなら Ubuntu 18.04 LTS つかおうね!!!

参考文献

2
3
0

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
2
3