0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Arch小ネタ】依存パッケージをすべて表示

Last updated at Posted at 2025-04-18

結論

$ pactree -l (パッケージ名) | sort | uniq

$ pactree -l sh | sort | uniq
filesystem
gcc-libs
glibc
glibc>=2.27
iana-etc
libncursesw.so=6-64
libreadline.so=8-64
linux-api-headers>=4.10
ncurses
readline
sh
tzdata

解説

pactreeはpacman-contribパッケージをインストールすると使用できるようになるコマンドで、ツリー状に依存関係を表示することができる。

$ pactree sh
bash provides sh
├─readline
│ ├─glibc
│ │ ├─linux-api-headers>=4.10
│ │ ├─tzdata
│ │ └─filesystem
│ │   └─iana-etc
│ ├─ncurses
│ │ ├─glibc
│ │ └─gcc-libs
│ │   └─glibc>=2.27
│ └─ncurses provides libncursesw.so=6-64
├─readline provides libreadline.so=8-64
├─glibc
└─ncurses

-l オプションをつけることで、ツリー状の表示から、依存パッケージを列挙する形式の表示に変更できる。

$ pactree -l sh
sh
readline
glibc
linux-api-headers>=4.10
tzdata
filesystem
iana-etc
ncurses
glibc
gcc-libs
glibc>=2.27
libncursesw.so=6-64
libreadline.so=8-64
glibc
ncurses

この出力結果を、sortコマンドで並べ替え、uniqコマンドで重複した行を削除すれば、目的の依存パッケージのリストが得られる。

おまけ

これとcommを組み合わせれば、依存関係の差異も表示できる。
試しに、shとbashの依存関係の差異を表示してみる。

$ comm <(pactree -l sh | sort | uniq) <(pactree -l bash | sort | uniq)
	bash
		filesystem
		gcc-libs
		glibc
		glibc>=2.27
		iana-etc
		libncursesw.so=6-64
		libreadline.so=8-64
		linux-api-headers>=4.10
		ncurses
		readline
sh
		tzdata

1列目がshのみ必要とするもの、2列目がbashのみ必要とするもの、3列目が共通で必要となるものである。
たとえば、bashのみ必要なもののみ表示したい場合は次のようにする:

$ comm -13 <(pactree -l sh | sort | uniq) <(pactree -l bash | sort | uniq)
bash

-13オプションで、1列目と3列目を非表示にした。
同様の方法で、左側のパッケージのみ必要とする依存関係や、共通して必要とする依存関係なども、それに限った出力ができる。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?