前に、yum/rpmコマンドでファイルがどのパッケージに含まれるか、逆にパッケージを指定してどのようなファイルが展開されるかについて書いたので、今回はapt/dpkgコマンドで同様のことをする方法について残しておく。
1.指定したファイル名がどのパッケージに含まれるかを調べる
指定したファイル名がどのパッケージに含まれるか(yumでいうprovides)を調べる場合、aptで行う場合はそのものズバリな機能はないため、apt-fileという別のプログラムを利用する必要があるようだ。
以下のコマンドでインストールできる。
sudo apt install apt-file sudo apt-file update
インストール後、以下のようにapt-fileを実行することで指定したファイルを提供しているパッケージを検索できる。
apt-file search ファイル名
blacknon@bs-pub-ubuntu-03:~$ apt-file search Rscript mapdamage: /usr/lib/python2.7/dist-packages/mapdamage/Rscripts/lengths.R mapdamage: /usr/lib/python2.7/dist-packages/mapdamage/Rscripts/mapDamage.R mapdamage: /usr/lib/python2.7/dist-packages/mapdamage/Rscripts/stats/checkLibraries.R mapdamage: /usr/lib/python2.7/dist-packages/mapdamage/Rscripts/stats/data.R mapdamage: /usr/lib/python2.7/dist-packages/mapdamage/Rscripts/stats/function.R mapdamage: /usr/lib/python2.7/dist-packages/mapdamage/Rscripts/stats/main.R mapdamage: /usr/lib/python2.7/dist-packages/mapdamage/Rscripts/stats/postConditonal.R mapdamage: /usr/lib/python2.7/dist-packages/mapdamage/Rscripts/stats/priorPropose.R mapdamage: /usr/lib/python2.7/dist-packages/mapdamage/Rscripts/stats/runGeneral.R mapdamage: /usr/lib/python2.7/dist-packages/mapdamage/Rscripts/stats/start.R r-base-core: /usr/bin/Rscript r-base-core: /usr/lib/R/bin/Rscript r-base-core: /usr/share/man/man1/Rscript.1.gz transdecoder: /usr/lib/transdecoder/util/PWM/make_seqLogo.Rscript transdecoder: /usr/lib/transdecoder/util/PWM/plot_ROC.Rscript transdecoder: /usr/lib/transdecoder/util/misc/rpart_scores.Rscript trinityrnaseq: /usr/lib/trinityrnaseq/Analysis/DifferentialExpression/GOplot.Rscript trinityrnaseq: /usr/lib/trinityrnaseq/Analysis/DifferentialExpression/Glimma.Trinity.Rscript trinityrnaseq: /usr/lib/trinityrnaseq/Analysis/DifferentialExpression/plot_all_DE_MAplots.Rscript trinityrnaseq: /usr/lib/trinityrnaseq/Analysis/DifferentialExpression/plot_all_DE_volcanos.Rscript trinityrnaseq: /usr/lib/trinityrnaseq/Analysis/DifferentialExpression/validate_UP_subset.Rscript trinityrnaseq: /usr/lib/trinityrnaseq/util/misc/plot_ExN50_statistic.Rscript trinityrnaseq: /usr/lib/trinityrnaseq/util/misc/plot_strand_specificity_dist_by_quantile.Rscript
インストール済のパッケージから調べる場合は、以下のようにdpkgコマンドから調べることができる。
パッケージ名やディレクトリ名からも検索してしまうので、ちゃんとPATHを指定しないとノイズが多いので注意。
dpkg -S ファイル名
blacknon@bs-pub-ubuntu-03:~$ dpkg -S $(which ls) coreutils: /bin/ls
2.指定したパッケージにどのようなファイルが含まれているかを調べる
先ほどとは逆に、指定したパッケージにどのようなファイルが含まれているかリストにして出力する場合。
aptで調べる場合、やはり先程と同じようにapt-fileで調べることになる。
apt-file list パッケージ名
blacknon@bs-pub-ubuntu-03:~$ apt-file list coreutils coreutils: /bin/cat coreutils: /bin/chgrp coreutils: /bin/chmod coreutils: /bin/chown coreutils: /bin/cp coreutils: /bin/date coreutils: /bin/dd coreutils: /bin/df coreutils: /bin/dir coreutils: /bin/echo coreutils: /bin/false coreutils: /bin/ln coreutils: /bin/ls ...
インストール済のパッケージから提供しているファイルの一覧を取得する場合は、以下のようにdpkgコマンドを実行する。
dpkg -L パッケージ名
blacknon@bs-pub-ubuntu-03:~$ dpkg -L coreutils /. /bin /bin/cat /bin/chgrp /bin/chmod /bin/chown /bin/cp /bin/date /bin/dd /bin/df /bin/dir ...
