FreeBSD 12.2 RELEASE - ports・pkg - ports

 クラウディア
 2021年4月以降、「ports」のリポジトリが「Subversion」から「Git」へ移行しました。  それに伴い、「ports」の更新方法も変わりましたので、詳細は「「メンテナンス・トラブルシュート - pkg・ports - Subversion から Git へ」」をご参照ください。
1. portsnap
2. portupgrade
3. データベースの更新
4. ports の状態を参照する
5. ports のアップグレード
6. portmaster
7. INDEXが壊れている場合の対処

1. portsnap

 「portsnap」を使用して、「ports」の状態を最新にします。  以前のバージョンでは、「portsnap」自体を「ports」でインストールする必要がありましたが、「FreeBSD 12.2」では、デフォルトでインストールされています。  以下、本ページはすべて「root」ユーザで  「portsnap」 のコンフィグレーションファイルを編集します。

vi /etc/portsnap.conf
 です。これを編集します。

# REFUSE arabic chinese french german hebrew hungarian japanese
# REFUSE korean polish portuguese russian ukrainian vietnamese
 「ports」の更新をかけないグループを指定するもので、日本語以外の他言語を使用しないのであれば、上記より「japanese」を削除して、先頭のコメント定義である「#」を削除します。  「fetch」オプションで最新のスナップショットを取得します。

portsnap fetch
 「fetch」が終了したら、

portsnap extract
 で、取得した情報を反映します。

2. portupgrade

 「ports」をメンテナンスするための「ports」、「portupgrade」をインストールします。  「portupgrade」を「make」する前に、「make」のコンフィグレーションファイルを、コピーして編集します。

cp /usr/share/examples/etc/make.conf /etc/make.conf
chmod 644 /etc/make.conf
vi  /etc/make.conf
 「X11」を使用しない場合、以下の行を追加します。

OPTIONS_UNSET+=X11
WITHOUT_GUI=yes
NO_X=true
 後で「PHP」をインストールし、かつ、日本語を使用するのであれば、あらかじめ以下の行を追加しておきます。

OPTIONS_SET+=MBSTRING
 2020年10月現在、「python」は、2.7 と 3.7 の系列があります。  「python2.7」の系列をメインに使用する場合は、以下のように記述します。

DEFAULT_VERSIONS+=python=2.7 python2=2.7
 「python3.6」の系列をメインに使用する場合は、以下のように記述します。

DEFAULT_VERSIONS+=python=3.7 python3=3.7
 「perl5」に関してデフォルトのバージョンと違うものをインストールするのであれば、例えば「perl5.28」であれば

DEFAULT_VERSIONS+=perl5=5.28
 上記の記述をしない場合、何になるのかは、インストール後に確かめてみます。  インストールしてみたら、「perl5.32」でした。

$ perl --version

This is perl 5, version 32, subversion 0 (v5.32.0) built for amd64-freebsd-thread-multi

Copyright 1987-2020, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
 「/etc/make.conf」を編集したら、「portupgrade」を以下の手順でインストールします。

cd /usr/ports/ports-mgmt/portupgrade
make
make install
 オプションはドキュメントをインストールするかしないかだけですので、どちらでも構いません。  以前のバージョンで、「make」の途中で、「help2man」のインストールでこけたりしましたが、今回のバージョンでは、そのまますんなりインストールできました。  インストールが終わったら、以下のコマンドを再度実行します。

portsnap fetch
portsnap extract
 ここまで終われば、これ以降、ports 参照の更新は

portsnap fetch
portsnap update
 となります。

3. データベースの更新

 データベースの更新を行う際にルート証明書が必要になります。  ルート証明書の仕組みも「ports」で提供されていて、これを更新しておかないと証明書のエラーとなることがあるのでインストールしておきます。

cd /usr/ports/security/ca_root_nss
make
make install
 オプションはデフォルトで進めます。  インストール時のメッセージ

Installing ca_root_nss-3.58...
FreeBSD does not, and can not warrant that the certification authorities
whose certificates are included in this package have in any way been
audited for trustworthiness or RFC 3647 compliance.

Assessment and verification of trust is the complete responsibility of the
system administrator.


This package installs symlinks to support root certificates discovery by
default for software that uses OpenSSL.

This enables SSL Certificate Verification by client software without manual
intervention.

If you prefer to do this manually, replace the following symlinks with
either an empty file or your site-local certificate bundle.

  * /etc/ssl/cert.pem
  * /usr/local/etc/ssl/cert.pem
  * /usr/local/openssl/cert.pem
 「ports」データベースの更新を

portsdb -Fu
 で行います。  この「 -F」オプションは、サーバからインデックスファイルを取得してきますが、そのときにルート証明書が必要になります。  先ほどの「ca_root_nss」のインストールは、このために必要だったのでした。

4. ports の状態を参照する

 データベースの状態を参照するには

portversion -v
 とします。  結果として以下のような表示になります。(あくまでも一例です)

[Reading data from pkg(8) ... - 31 packages found - done]
autoconf-2.69_3             =  up-to-date with port
autoconf-wrapper-20131203   =  up-to-date with port
automake-1.16.2             =  up-to-date with port
ca_root_nss-3.58            =  up-to-date with port
db5-5.3.28_7                =  up-to-date with port
dialog4ports-0.1.6          =  up-to-date with port
gettext-runtime-0.21        =  up-to-date with port
gettext-tools-0.21          =  up-to-date with port
gmake-4.3_2                 =  up-to-date with port
help2man-1.47.16            =  up-to-date with port
indexinfo-0.3.1             =  up-to-date with port
libedit-3.1.20191231,1      =  up-to-date with port
libffi-3.3_1                =  up-to-date with port
libiconv-1.16               =  up-to-date with port
libtextstyle-0.21           =  up-to-date with port
libunwind-20200331_1        =  up-to-date with port
libyaml-0.2.5               =  up-to-date with port
m4-1.4.18_1,1               =  up-to-date with port
p5-Locale-gettext-1.07      =  up-to-date with port
p5-Locale-libintl-1.31      =  up-to-date with port
p5-Text-Unidecode-1.30      =  up-to-date with port
p5-Unicode-EastAsianWidth-12.0  =  up-to-date with port
perl5-5.32.0                =  up-to-date with port
pkg-1.15.10                 =  up-to-date with port
pkgconf-1.7.3,1             =  up-to-date with port
portupgrade-2.4.16,2        =  up-to-date with port
ruby-2.6.6_2,1              =  up-to-date with port
ruby26-bdb-0.6.6_8          =  up-to-date with port
ruby26-gems-3.0.8           =  up-to-date with port
rubygem-rdoc-6.2.1          =  up-to-date with port
texinfo-6.7_4,1             =  up-to-date with port
「=」マークがついていれば、最新版がインストールされている 「<」マークがついていれば、「ports」に新しい版が存在する(更新すべきかも)  ということになります。  次項で述べる「pkg」コマンドで

pkg version -vl "<"
 というコマンドを使えば

gmake-3.81_4                <  needs updating (port has 3.82)
help2man-1.38.4             <  needs updating (port has 1.40.4)
ja-freebsd-doc-20110110     <  needs updating (port has 20110828)
libtool-2.20                <  needs updating (port has 2.3)
m4-1.4.15,1                 <  needs updating (port has 1.4.16,1)
perl-5.10.1_3               <  needs updating (port has 5.10.1_4)
portupgrade-2.3.8_1,2       <  needs updating (port has 2.3.9.3,2)
ruby-1.8.7.302,1            <  needs updating (port has 1.8.7.352_2,1)
ruby18-bdb-0.6.5_1          <  needs updating (port has 0.6.6)
 というように新しい版が存在するものを一覧表示できます。  ここまでの一連の動作を、「crontab」に記述して定期的に「ports」を更新する方法もあります。  が、バックグラウンドでやってしまうと見落とすことがありますので、例えば適当なディレクトリに下記のような「Makefile」を作成しておいて、明示的に「make」する方法もあります。

ports	:
	portsnap fetch
	portsnap update
	portsdb -Fu
	portversion -v

5. ports のアップグレード

 「portversion」で確認した結果、新しいバージョンが出ている「ports」を更新するには、

portupgrade [-オプション] ports名
 というコマンドを使用します。  わたしは以下のオプションを使用しています。
オプション   意味  
v 冗長な出力を行う(細かい動きまで見ることができるということです)
R 対象の「ports」が依存している「ports」を同時に更新する
r 対象の「ports」に依存している「ports」を同時に更新する


6. portmaster

 「ports」でインストールしているアプリケーションの、マイナーバージョンでなくメジャーバージョンの方が変わった、あるいは変えたいとき・・・。  例えば

$ pkg version -vl "<"
ruby-2.1.8,1                       <   needs updating (index has 2.2.4,1)
 となっているとき、「portupgrade」では、バージョンアップしてくれないときがあります。  これを解決するには 「portmaster」を使用します。  インストールは

cd /usr/ports/ports-mgmt/portmaster
make
make install
 すぐに終わります。  インストールしておいて

portmaster -o lang/ruby24 ruby23
 でアップグレードすることになります。  途中で、進行をきかれることがあります。  たいていの場合な y Enter でうまく進行していきます。

7. INDEXが壊れている場合の対処

 「portsnap」の途中で失敗して「INDEX」が壊れいると、「portsnap」のコマンド途中にエラーになります。  そういう場合は、

rm /var/db/portsnap/INDEX
 でダウンロードに失敗した INDEX を削除後

portsnap fetch
portsnap extract
portsnap update
 とやれば正常に戻ります。
ハイスピードプランPoint anytime健康サポート特集【usus ウズウズ】