pkg 1.5登場
先日、
# pkg --version 1.5.0 #
FreeBSDシステムの管理という面で見れば、
Linuxディストリビューションや*BSDではそれぞれが個々にパッケージ管理システムを持っています。そうしたパッケージ管理システムの中で、
パッケージ管理システムpkgの主な特徴は次のとおりです。
- pkg(8)コマンドでパッケージ管理に必要になる操作をすべて実施できる
- 完全性の高いアップグレード作業を実施できる
- Ports Collectionとシームレスに結びついている
- パッケージのビルドは水曜日に開始され、
日本時間ではだいたい週末ごとに最新のパッケージへアップグレードできるようになる - セキュリティ脆弱性が存在するソフトウェアをチェックする機能がある
- 改変されたバイナリを検出する機能がある
- あるソフトウェアのアンインストールなどによって使われることのなくなったソフトウェアを自動的に削除する機能がある
週に1回のペースで最新のパッケージが公開されていますので、
ただし、
pkgはPorts Collectionともシームレスに連動しています。緊急のセキュリティ脆弱性に対応するには、
pkg(8)コマンドの代表的な使い方
今回はとくにpkg(8)コマンドの代表的な使い方を紹介します。
updateサブコマンド
ソフトウェアをインストールする時はupdateサブコマンドを指定してまずメタデータやリポジトリのアップデートを実施します。
# pkg update Updating FreeBSD repository catalogue... [jail1.ongs.co.jp] Fetching meta.txz: 100% 944 B 0.9kB/s 00:01 Processing entries: 100% FreeBSD repository update completed. 23938 packages processed #
searchサブコマンド
ソフトウェアの検索にはsearchサブコマンドを使います。
# pkg search vim ja-jvim-3.0.j2.1b_1 p5-Shell-EnvImporter-1.07_1 p5-Text-VimColor-0.25 p5-Vimana-2010.09303_3 vim-7.4.691 vim-lite-7.4.691 vimb-gtk2-2.9 vimb-gtk3-2.9 vimpager-1.8.9 xpi-vimperator-3.5 #
どういったソフトウェアかより詳しく知りたい場合にはsearchサブコマンドに-fオプションを指定します。
# pkg search -f vim-lite vim-lite-7.4.691 Name : vim-lite Version : 7.4.691 Origin : editors/vim-lite Architecture : freebsd:10:x86:64 Prefix : /usr/local Repository : FreeBSD [pkg+http://pkg.FreeBSD.org/FreeBSD:10:amd64/latest] Categories : editors Licenses : Maintainer : sunpoet@FreeBSD.org WWW : http://www.vim.org/ Comment : Improved version of the vi editor (lite package) Options : DEFAULT_VIMRC : on Annotations : cpe : cpe:2.3:a:vim:vim:7.4:::::freebsd10:x64 Flat size : 20.4MiB Pkg size : 4.71MiB Description : Vim is a highly configurable text editor built to enable efficient text editing. It is an improved version of the vi editor distributed with most UNIX systems. Vim is often called a "programmer's editor," and so useful for programming that many consider it an entire IDE. It's not just for programmers, though. Vim is perfect for all kinds of text editing, from composing email to editing configuration files. Despite what the above comic suggests, Vim can be configured to work in a very simple (Notepad-like) way, called evim or Easy Vim. WWW: http://www.vim.org/ #
installサブコマンド
ソフトウェアのインストールにはinstallサブコマンドを使います。installサブコマンドを指定すると依存関係含めてソフトウェアパッケージのインストールが実施されます。
# pkg install vim-lite Updating FreeBSD repository catalogue... FreeBSD repository is up-to-date. All repositories are up-to-date. The following 1 packages will be affected (of 0 checked): New packages to be INSTALLED: vim-lite: 7.4.691 The process will require 20 MiB more space. 5 MiB to be downloaded. Proceed with this action? [y/N]: y [jail1.ongs.co.jp] [1/1] Extracting vim-lite-7.4.691: 100% #
infoサブコマンド
システムにインストールされたパッケージの一覧表示にはinfoサブコマンドを使います。
# pkg info apr-1.5.1.1.5.4 Apache Portability Library db5-5.3.28_2 The Oracle Berkeley DB, revision 5.3 expat-2.1.0_2 XML 1.0 parser written in C gdbm-1.11_2 GNU database manager gettext-runtime-0.19.4 GNU gettext runtime libraries and programs indexinfo-0.2.3 Utility to regenerate the GNU info page index serf-1.3.8 Serf HTTP client library sqlite3-3.8.9_1 SQL database engine in a C library subversion-1.8.13 Version control system vim-lite-7.4.691 Improved version of the vi editor (lite package) zsh-5.0.7_3 The Z shell #
updateサブコマンドおよびupgradeサブコマンド
システムにインストールされているパッケージのアップデートはupdateサブコマンドおよびupgradeサブコマンドを使います。次のようにupdateサブコマンドでメタデータとリポジトリをアップデートし、
# pkg update Updating FreeBSD repository catalogue... Fetching meta.txz: 100% 944 B 0.9kB/s 00:01 Fetching packagesite.txz: 100% 5 MiB 280.2kB/s 00:19 Processing entries: 100% FreeBSD repository update completed. 23938 packages processed. # pkg upgrade Updating FreeBSD repository catalogue... FreeBSD repository is up-to-date. All repositories are up-to-date. Checking for upgrades (62 candidates): 100% Processing candidates (62 candidates): 100% The following 37 package(s) will be affected (of 0 checked): Installed packages to be UPGRADED: xproto: 7.0.26 -> 7.0.27 xcb-util-renderutil: 0.3.9 -> 0.3.9_1 xcb-util: 0.4.0,1 -> 0.4.0_1,1 ...略... font-util: 1.3.0_2 -> 1.3.1 curl: 7.41.0 -> 7.42.0 ca_root_nss: 3.18 -> 3.18.1 Installed packages to be REINSTALLED: cups-client-1.7.3_4 (needed shared library changed) The process will require 11 MiB more space. 39 MiB to be downloaded. Proceed with this action? [y/N]: y Fetching xproto-7.0.27.txz: 100% 58 KiB 59.7kB/s 00:01 Fetching xcb-util-renderutil-0.3.9_1.txz: 100% 8 KiB 8.2kB/s 00:01 Fetching xcb-util-0.4.0_1,1.txz: 100% 12 KiB 12.3kB/s 00:01 ...略... Fetching curl-7.42.0.txz: 100% 1 MiB 351.9kB/s 00:04 Fetching cups-client-1.7.3_4.txz: 100% 828 KiB 169.5kB/s 00:05 Fetching ca_root_nss-3.18.1.txz: 100% 336 KiB 344.5kB/s 00:01 Checking integrity... done (0 conflicting) [1/37] Extracting xproto-7.0.27: 100% [2/37] Extracting libXdmcp-1.1.2: 100% [3/37] Extracting libXau-1.0.8_3: 100% ...略... [34/37] Extracting harfbuzz-0.9.40_1: 100% [36/37] Extracting font-util-1.3.1: 100% ==> You should manually remove the "cups" user. ===> Creating users and/or groups. Using existing group 'cups'. Using existing user 'cups'. [37/37] Extracting cups-client-1.7.3_4: 100% #
deleteサブコマンド
インストールしたソフトウェアのアンインストールにはdeleteサブコマンドを使います。
# pkg delete vim-lite Checking integrity... done (0 conflicting) Deinstallation has been requested for the following 1 packages (of 0 packages in the universe): Installed packages to be REMOVED: vim-lite-7.4.691 The operation will free 20 MiB. Proceed with deinstalling packages? [y/N]: y [jail1.ongs.co.jp] [1/1] Deleting files for vim-lite-7.4.691: 100% #
autoremoveサブコマンド
インストールやアンインストールを繰り返すと、
# pkg autoremove Checking integrity... done (0 conflicting) Deinstallation has been requested for the following 8 packages: Installed packages to be REMOVED: serf-1.3.8 apr-1.5.1.1.5.4 db5-5.3.28_2 expat-2.1.0_2 gdbm-1.11_2 gettext-runtime-0.19.4 indexinfo-0.2.3 sqlite3-3.8.9_1 The operation will free 56 MiB. Proceed with deinstalling packages? [y/N]: y [jail1.ongs.co.jp] [1/8] Deleting files for serf-1.3.8: 100% [jail1.ongs.co.jp] [2/8] Deleting files for apr-1.5.1.1.5.4: 100% [jail1.ongs.co.jp] [3/8] Deleting files for gdbm-1.11_2: 100% [jail1.ongs.co.jp] [4/8] Deleting files for gettext-runtime-0.19.4: 100% [jail1.ongs.co.jp] [5/8] Deleting files for db5-5.3.28_2: 100% [jail1.ongs.co.jp] [6/8] Deleting files for expat-2.1.0_2: 100% [jail1.ongs.co.jp] [7/8] Deleting files for indexinfo-0.2.3: 100% [jail1.ongs.co.jp] [8/8] Deleting files for sqlite3-3.8.9_1: 100% #
whichサブコマンド
もう1つ、
# pkg which /usr/local/bin/geoiplookup /usr/local/bin/geoiplookup was installed by package GeoIP-1.6.5 #
おわりに
このあたりのサブコマンドを押えておけば、
pkgではすべてのソフトウェアを常に最新版にすることを前提にしているため、