pkg

提供: FreeBSD入門
2014年2月4日 (火) 00:07時点におけるDaemon (トーク | 投稿記録)による版 (すでのサードパーティ製ソフトウェアがインストールされている場合)

移動: 案内検索
スポンサーリンク

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>'.

すでにサードパーティ製ソフトウェアがインストールされている場合

FreeBSDports などでソフトウェアがインストールされている場合は、データベースを新しいフォーマットへ変換する必要があります。

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

関連項目




スポンサーリンク