FreeBSD 11.4 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」コマンドは、デフォルトで用意されています。  「portsnap」のコンフィグレーションファイルを編集します。

vi /etc/portsnap.conf
 下記は、「ports」で更新しないグループを指定するものです。  日本語以外の言語を使用しないのであれば、「japanese」を削除して先頭のコメント定義である「#」を削除します。

# REFUSE arabic chinese french german hebrew hungarian japanese
# REFUSE korean polish portuguese russian ukrainian vietnamese
 「fetch」オプションで最新のスナップショットを取得します。

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

portsnap extract
 というオプションを使用して取得した情報を反映します。  これは、少し時間がかかります。

2. portupgrade

 「ports」をメンテナンスするための「ports」、「portupgrade」をインストールします。  「portupgrade」を「make」する前に「make」のコンフィグレーションファイルを、コピーして編集します。  以前は、そのまま編集できたのですが、「FreeBSD 11.4 RELEASE」では、書き込み権限が必要になったようです。

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

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

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

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

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

DEFAULT_VERSIONS+=perl5=5.28
 2020年6月17日時点で「/usr/ports/lang/perl5.32」が、存在します。上記の記述をしない場合、何になるのかは、インストール後に確かめてみます。  インストールしてみたら、「perl5.30.3」でした。

$ perl --version

This is perl 5, version 30, subversion 3 (v5.30.3) 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
 オプションはドキュメントをインストールするかしないかだけですので、どちらでも構いません。  インストールが終わったら、以下のコマンドを再度実行します。

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.53...
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) ... - 24 packages found - done]
autoconf-2.69_1             =  up-to-date with port
autoconf-wrapper-20131203   =  up-to-date with port
automake-1.16.1             =  up-to-date with port
ca_root_nss-3.38            =  up-to-date with port
db5-5.3.28_6                =  up-to-date with port
dialog4ports-0.1.6          =  up-to-date with port
gettext-runtime-0.19.8.1_1  =  up-to-date with port
gettext-tools-0.19.8.1      =  up-to-date with port
gmake-4.2.1_2               =  up-to-date with port
help2man-1.47.6             =  up-to-date with port
indexinfo-0.3.1             =  up-to-date with port
libedit-3.1.20170329_2,1    =  up-to-date with port
libffi-3.2.1_2              =  up-to-date with port
libunwind-20170615          =  up-to-date with port
libyaml-0.1.6_2             =  up-to-date with port
m4-1.4.18,1                 =  up-to-date with port
p5-Locale-gettext-1.07      =  up-to-date with port
perl5-5.26.2                =  up-to-date with port
pkg-1.10.5_1                =  up-to-date with port
pkgconf-1.4.2,1             =  up-to-date with port
portupgrade-2.4.16,2        =  up-to-date with port
ruby-2.4.4,1                =  up-to-date with port
ruby24-bdb-0.6.6_5          =  up-to-date with port
texinfo-6.5,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
 とやれば正常に戻ります。
earthcar(アースカー)