「pkg」の版間の差分
提供: FreeBSD入門
(ページの作成:「<!-- vim: fileencoding=utf-8 filetype=mediawiki --> ;pkg:ぴーけーじー __TOC__ == 概要 == pkgは、次世代パッケージ管理システムとその...」) |
|||
行1: | 行1: | ||
<!-- vim: fileencoding=utf-8 filetype=mediawiki | <!-- vim: fileencoding=utf-8 filetype=mediawiki | ||
--> | --> | ||
+ | [[pkg]]は、次世代パッケージ管理システムとそのコマンドです。 | ||
+ | [[FreeBSD]] 10-CURRENT から採用されました。 | ||
+ | |||
+ | '''読み方''' | ||
;[[pkg]]:ぴーけーじー | ;[[pkg]]:ぴーけーじー | ||
__TOC__ | __TOC__ | ||
行8: | 行12: | ||
[[pkg]]は、次世代パッケージ管理システムとそのコマンドです。 | [[pkg]]は、次世代パッケージ管理システムとそのコマンドです。 | ||
[[FreeBSD]] 10-CURRENT から採用されました。 | [[FreeBSD]] 10-CURRENT から採用されました。 | ||
+ | [[FreeBSD]] 9.1-RELEASE で利用できます。 | ||
[[ports|Ports Collection]]をベースに1-2週間ごとにパッケージが更新されます。 | [[ports|Ports Collection]]をベースに1-2週間ごとにパッケージが更新されます。 | ||
最新のコレクションをバイナリでインストール・アップグレードできます。 | 最新のコレクションをバイナリでインストール・アップグレードできます。 | ||
+ | |||
+ | == 設定 == | ||
+ | |||
+ | === 設定ファイル === | ||
+ | |||
+ | * /usr/local/etc/pkg.conf | ||
+ | |||
+ | === make.conf === | ||
+ | |||
+ | [[FreeBSD]] 10.x 未満の場合は、下記設定を /etc/make.conf にします。 | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | WITH_PKGNG= yes | ||
+ | </syntaxhighlight> | ||
== 使い方 == | == 使い方 == | ||
+ | |||
+ | === pkg コマンドのオプション === | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | % pkg help | ||
+ | usage: pkg [-v] [-d] [-j <jail name or id>|-c <chroot path>] <command> [<args>] | ||
+ | |||
+ | Global options supported: | ||
+ | -d Increment debug level | ||
+ | -j Execute pkg(1) inside a jail(8) | ||
+ | -c Execute pkg(1) inside a chroot(8) | ||
+ | -v Display pkg(1) version | ||
+ | |||
+ | Commands supported: | ||
+ | add Registers a package and installs it on the system | ||
+ | audit Reports vulnerable packages | ||
+ | autoremove Removes orphan packages | ||
+ | backup Backs-up and restores the local package database | ||
+ | check Checks for missing dependencies and database consistency | ||
+ | clean Cleans old packages from the cache | ||
+ | create Creates software package distributions | ||
+ | delete Deletes packages from the database and the system | ||
+ | fetch Fetches packages from a remote repository | ||
+ | help Displays help information | ||
+ | info Displays information about installed packages | ||
+ | install Installs packages from remote package repositories | ||
+ | query Queries information about installed packages | ||
+ | register Registers a package into the local database | ||
+ | remove Deletes packages from the database and the system | ||
+ | repo Creates a package repository catalogue | ||
+ | rquery Queries information in repository catalogues | ||
+ | search Performs a search of package repository catalogues | ||
+ | set Modifies information about packages in the local database | ||
+ | shell Opens a debug shell | ||
+ | shlib Displays which packages link against a specific shared library | ||
+ | stats Displays package database statistics | ||
+ | update Updates package repository catalogues | ||
+ | updating Displays UPDATING information for a package | ||
+ | upgrade Performs upgrades of packaged software distributions | ||
+ | version Displays the versions of installed packages | ||
+ | which Displays which package installed a specific file | ||
+ | |||
+ | For more information on the different commands see 'pkg help <command>'. | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === はじめて起動するとき === | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | % sudo /usr/sbin/pkg | ||
+ | The package management tool is not yet installed on your system. | ||
+ | Do you want to fetch and install it now? [y/N]: | ||
+ | Bootstrapping pkg please wait | ||
+ | Installing pkg-1.0.11... done | ||
+ | If you are upgrading from the old package format, first run: | ||
+ | |||
+ | # pkg2ng | ||
+ | usage: pkg [-v] [-d] [-j <jail name or id>|-c <chroot path>] <command> [<args>] | ||
+ | |||
+ | Global options supported: | ||
+ | -d Increment debug level | ||
+ | -j Execute pkg(1) inside a jail(8) | ||
+ | -c Execute pkg(1) inside a chroot(8) | ||
+ | -v Display pkg(1) version | ||
+ | |||
+ | Commands supported: | ||
+ | add Registers a package and installs it on the system | ||
+ | audit Reports vulnerable packages | ||
+ | autoremove Removes orphan packages | ||
+ | backup Backs-up and restores the local package database | ||
+ | check Checks for missing dependencies and database consistency | ||
+ | clean Cleans old packages from the cache | ||
+ | create Creates software package distributions | ||
+ | delete Deletes packages from the database and the system | ||
+ | fetch Fetches packages from a remote repository | ||
+ | help Displays help information | ||
+ | info Displays information about installed packages | ||
+ | install Installs packages from remote package repositories | ||
+ | query Queries information about installed packages | ||
+ | register Registers a package into the local database | ||
+ | remove Deletes packages from the database and the system | ||
+ | repo Creates a package repository catalogue | ||
+ | rquery Queries information in repository catalogues | ||
+ | search Performs a search of package repository catalogues | ||
+ | set Modifies information about packages in the local database | ||
+ | shell Opens a debug shell | ||
+ | shlib Displays which packages link against a specific shared li brary | ||
+ | stats Displays package database statistics | ||
+ | update Updates package repository catalogues | ||
+ | updating Displays UPDATING information for a package | ||
+ | upgrade Performs upgrades of packaged software distributions | ||
+ | version Displays the versions of installed packages | ||
+ | which Displays which package installed a specific file | ||
+ | |||
+ | For more information on the different commands see 'pkg help <command>'. | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === すでのサードパーティ製ソフトウェアがインストールされている場合 === | ||
+ | |||
+ | [[FreeBSD]] に [[ports]] などでソフトウェアがインストールされている場合は、データベースを新しいフォーマットへ変換する必要があります。 | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | sudo /usr/local/sbin/pkg2ng | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | % sudo /usr/local/sbin/pkg2ng | ||
+ | |||
+ | 省略 | ||
+ | |||
+ | Moved old package database to /var/db/pkg.bak. | ||
+ | Conversion has been successfully finished | ||
+ | Your old packages database has been moved to: /var/db/pkg.bak. | ||
+ | % ls /var/db/pkg | ||
+ | local.sqlite repo.sqlite | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === パッケージをインストールする === | ||
パッケージのインストールの例。 | パッケージのインストールの例。 | ||
行18: | 行154: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
pkg install tmux | pkg install tmux | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === バージョンチェック === | ||
+ | |||
+ | アップデートできるパッケージがないか調べます。 | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | pkg version | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | % pkg version | ||
+ | ImageMagick-6.8.0.7 < | ||
+ | ORBit2-2.14.19 = | ||
+ | R-2.15.3 = | ||
+ | adns-1.4_1 = | ||
+ | amap-5.2 = | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === データベースのダウンロード === | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | % sudo pkg update -f | ||
+ | Updating repository catalogue | ||
+ | repo.txz 100% 1832 1.8KB/s 1.8KB/s 00:00 | ||
+ | </syntaxhighlight> | ||
+ | === バージョンアップ === | ||
+ | |||
+ | 新しいバージョンのパッケージにアップグレードします。 | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | sudo pkg upgrade | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ドライラン(Dry run)します。 | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | sudo pkg upgrade -n | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === パッケージの検証 === | ||
+ | |||
+ | 脆弱性のあるソフトウェアがインストールされていないか、検証できます。 | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | pkg audit -F | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | % sudo pkg audit -F | ||
+ | auditfile.tbz 100% 87KB 86.8KB/s 86.8KB/s 00:01 | ||
+ | ca_root_nss-3.14 is vulnerable: | ||
+ | mozilla -- multiple vulnerabilities | ||
+ | |||
+ | WWW: http://portaudit.FreeBSD.org/a4ed6632-5aa9-11e2-8fcb-c8600054b392.html | ||
+ | |||
+ | 省略 | ||
+ | |||
+ | 10 problem(s) in your installed packages found. | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === パッケージの情報をする === | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | % pkg info tmux | ||
+ | tmux-1.8 A Terminal Multiplexer | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | インストールされているファイルの一覧を表示する。 | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | % pkg info -l tmux | ||
+ | tmux-1.8 owns the following files: | ||
+ | /usr/local/bin/tmux | ||
+ | /usr/local/etc/bash_completion.d/tmux | ||
+ | /usr/local/man/man1/tmux.1.gz | ||
+ | /usr/local/share/doc/tmux/CHANGES | ||
+ | /usr/local/share/doc/tmux/FAQ | ||
+ | /usr/local/share/doc/tmux/README | ||
+ | /usr/local/share/doc/tmux/TODO | ||
+ | /usr/local/share/examples/tmux/bash_completion_tmux.sh | ||
+ | /usr/local/share/examples/tmux/h-boetes.conf | ||
+ | /usr/local/share/examples/tmux/n-marriott.conf | ||
+ | /usr/local/share/examples/tmux/screen-keys.conf | ||
+ | /usr/local/share/examples/tmux/t-williams.conf | ||
+ | /usr/local/share/examples/tmux/tmux.vim | ||
+ | /usr/local/share/examples/tmux/tmux_backup.sh | ||
+ | /usr/local/share/examples/tmux/vim-keys.conf | ||
+ | /usr/local/share/licenses/tmux-1.8/BSD | ||
+ | /usr/local/share/licenses/tmux-1.8/LICENSE | ||
+ | /usr/local/share/licenses/tmux-1.8/catalog.mk | ||
</syntaxhighlight> | </syntaxhighlight> | ||
行23: | 行246: | ||
* [[ports]] | * [[ports]] | ||
+ | * [[ソフトウェアの管理]] |
2013年5月18日 (土) 21:30時点における版
pkgは、次世代パッケージ管理システムとそのコマンドです。 FreeBSD 10-CURRENT から採用されました。
読み方
- pkg
- ぴーけーじー
目次
概要
pkgは、次世代パッケージ管理システムとそのコマンドです。 FreeBSD 10-CURRENT から採用されました。 FreeBSD 9.1-RELEASE で利用できます。
Ports Collectionをベースに1-2週間ごとにパッケージが更新されます。 最新のコレクションをバイナリでインストール・アップグレードできます。
設定
設定ファイル
- /usr/local/etc/pkg.conf
make.conf
FreeBSD 10.x 未満の場合は、下記設定を /etc/make.conf にします。
WITH_PKGNG= yes
使い方
pkg コマンドのオプション
% pkg help usage: pkg [-v] [-d] [-j <jail name or id>|-c <chroot path>] <command> [<args>] Global options supported: -d Increment debug level -j Execute pkg(1) inside a jail(8) -c Execute pkg(1) inside a chroot(8) -v Display pkg(1) version Commands supported: add Registers a package and installs it on the system audit Reports vulnerable packages autoremove Removes orphan packages backup Backs-up and restores the local package database check Checks for missing dependencies and database consistency clean Cleans old packages from the cache create Creates software package distributions delete Deletes packages from the database and the system fetch Fetches packages from a remote repository help Displays help information info Displays information about installed packages install Installs packages from remote package repositories query Queries information about installed packages register Registers a package into the local database remove Deletes packages from the database and the system repo Creates a package repository catalogue rquery Queries information in repository catalogues search Performs a search of package repository catalogues set Modifies information about packages in the local database shell Opens a debug shell shlib Displays which packages link against a specific shared library stats Displays package database statistics update Updates package repository catalogues updating Displays UPDATING information for a package upgrade Performs upgrades of packaged software distributions version Displays the versions of installed packages which Displays which package installed a specific file For more information on the different commands see 'pkg help <command>'.
はじめて起動するとき
% sudo /usr/sbin/pkg The package management tool is not yet installed on your system. Do you want to fetch and install it now? [y/N]: Bootstrapping pkg please wait Installing pkg-1.0.11... done If you are upgrading from the old package format, first run: # pkg2ng usage: pkg [-v] [-d] [-j <jail name or id>|-c <chroot path>] <command> [<args>] Global options supported: -d Increment debug level -j Execute pkg(1) inside a jail(8) -c Execute pkg(1) inside a chroot(8) -v Display pkg(1) version Commands supported: add Registers a package and installs it on the system audit Reports vulnerable packages autoremove Removes orphan packages backup Backs-up and restores the local package database check Checks for missing dependencies and database consistency clean Cleans old packages from the cache create Creates software package distributions delete Deletes packages from the database and the system fetch Fetches packages from a remote repository help Displays help information info Displays information about installed packages install Installs packages from remote package repositories query Queries information about installed packages register Registers a package into the local database remove Deletes packages from the database and the system repo Creates a package repository catalogue rquery Queries information in repository catalogues search Performs a search of package repository catalogues set Modifies information about packages in the local database shell Opens a debug shell shlib Displays which packages link against a specific shared li brary stats Displays package database statistics update Updates package repository catalogues updating Displays UPDATING information for a package upgrade Performs upgrades of packaged software distributions version Displays the versions of installed packages which Displays which package installed a specific file For more information on the different commands see 'pkg help <command>'.
すでのサードパーティ製ソフトウェアがインストールされている場合
FreeBSD に ports などでソフトウェアがインストールされている場合は、データベースを新しいフォーマットへ変換する必要があります。
sudo /usr/local/sbin/pkg2ng
% sudo /usr/local/sbin/pkg2ng 省略 Moved old package database to /var/db/pkg.bak. Conversion has been successfully finished Your old packages database has been moved to: /var/db/pkg.bak. % ls /var/db/pkg local.sqlite repo.sqlite
パッケージをインストールする
パッケージのインストールの例。
pkg install tmux
バージョンチェック
アップデートできるパッケージがないか調べます。
pkg version
% pkg version ImageMagick-6.8.0.7 < ORBit2-2.14.19 = R-2.15.3 = adns-1.4_1 = amap-5.2 =
データベースのダウンロード
% sudo pkg update -f Updating repository catalogue repo.txz 100% 1832 1.8KB/s 1.8KB/s 00:00
バージョンアップ
新しいバージョンのパッケージにアップグレードします。
sudo pkg upgrade
ドライラン(Dry run)します。
sudo pkg upgrade -n
パッケージの検証
脆弱性のあるソフトウェアがインストールされていないか、検証できます。
pkg audit -F
% sudo pkg audit -F auditfile.tbz 100% 87KB 86.8KB/s 86.8KB/s 00:01 ca_root_nss-3.14 is vulnerable: mozilla -- multiple vulnerabilities WWW: http://portaudit.FreeBSD.org/a4ed6632-5aa9-11e2-8fcb-c8600054b392.html 省略 10 problem(s) in your installed packages found.
パッケージの情報をする
% pkg info tmux tmux-1.8 A Terminal Multiplexer
インストールされているファイルの一覧を表示する。
% pkg info -l tmux tmux-1.8 owns the following files: /usr/local/bin/tmux /usr/local/etc/bash_completion.d/tmux /usr/local/man/man1/tmux.1.gz /usr/local/share/doc/tmux/CHANGES /usr/local/share/doc/tmux/FAQ /usr/local/share/doc/tmux/README /usr/local/share/doc/tmux/TODO /usr/local/share/examples/tmux/bash_completion_tmux.sh /usr/local/share/examples/tmux/h-boetes.conf /usr/local/share/examples/tmux/n-marriott.conf /usr/local/share/examples/tmux/screen-keys.conf /usr/local/share/examples/tmux/t-williams.conf /usr/local/share/examples/tmux/tmux.vim /usr/local/share/examples/tmux/tmux_backup.sh /usr/local/share/examples/tmux/vim-keys.conf /usr/local/share/licenses/tmux-1.8/BSD /usr/local/share/licenses/tmux-1.8/LICENSE /usr/local/share/licenses/tmux-1.8/catalog.mk