FreeBSD で各種アプリケーションのインストール(ポーツ・ツリー を使用)

FreeBSD に各種ソフトウェアを ポーツ・コレクション(Ports Collection) からソースビルドしてインストールする手順を記述している.ビルドオプションを変更する必要がない場合は,バイナリパッケージ(pkg)を用いる方が短時間で導入できる.

関連する外部ページ】:

FreeBSD ハンドブック 「アプリケーションのインストール - packages と ports」

FreshPorts(ports/packages の検索)

前準備

システムの更新

コマンドプロンプト(端末)を管理者権限(root)で開き,次のコマンドを実行する.システムのセキュリティパッチを適用する.

freebsd-update fetch
freebsd-update install

コマンドプロンプト(端末)を管理者権限(root)で開き,次のコマンドを実行する.インストール済みパッケージを更新する.

pkg update
pkg upgrade

ポーツ・ツリーの取得と更新

ポーツ・ツリーの配布は Git で行われる.portsnap は廃止されている.

コマンドプロンプト(端末)を管理者権限(root)で開き,次のコマンドを実行する.Git をインストールする.

pkg install -y devel/git

コマンドプロンプト(端末)を管理者権限(root)で開き,次のコマンドを実行する.ポーツ・ツリーを /usr/ports に取得する(初回のみ).

git clone --depth 1 https://git.FreeBSD.org/ports.git /usr/ports

コマンドプロンプト(端末)を管理者権限(root)で開き,次のコマンドを実行する.ポーツ・ツリーを最新の状態に更新する.

git -C /usr/ports pull --depth 1

ビルドに用いるツール

個々の ports は,そのディレクトリで make install clean を実行することでビルドおよびインストールできる.インストール済み ports の一括更新には次のツールがある.

コマンドプロンプト(端末)を管理者権限(root)で開き,次のコマンドを実行する.これらのツールをインストールする.

pkg install -y ports-mgmt/portmaster ports-mgmt/poudriere

ビルドオプションの設定と解除は,各 ports のディレクトリで次のコマンドを実行して行う.

make -C /usr/ports/www/firefox config
make -C /usr/ports/www/firefox rmconfig

Linux バイナリ互換機能(Linuxulator)の設定

  1. /etc/rc.conf に「linux_enable="YES"」の 1 行を追加する
    linux_enable="YES"
    
  2. コマンドプロンプト(端末)を管理者権限(root)で開き,次のコマンドを実行する.Linuxulator のサービスを開始する.このサービスは,カーネルモジュール linux64.ko の読み込みと,linprocfslinsysfs,devfs の /compat/linux 以下へのマウントをまとめて行う./etc/fstab への手動での記述は不要である.
    service linux start
    
  3. コマンドプロンプト(端末)を管理者権限(root)で開き,次のコマンドを実行する.カーネルモジュールが読み込まれていることを確認する.
    kldstat | grep linux
    
  4. コマンドプロンプト(端末)を管理者権限(root)で開き,次のコマンドを実行する.Linux ユーザランド(linux_base-rl9,Rocky Linux 9 ベース)をビルドしてインストールする.
    make -C /usr/ports/emulators/linux_base-rl9 install clean BATCH=yes
    
  5. コマンドプロンプト(端末)を管理者権限(root)で開き,次のコマンドを実行する.マウント状況を確認する.
    mount | grep compat
    

アプリケーション等のインストール

以下に,用途別の ports を示す.

コマンドプロンプト(端末)を管理者権限(root)で開き,次のスクリプトを実行する.上記の ports をまとめてビルドしてインストールする.BATCH=yes は,オプション選択ダイアログを表示せず既定値を用いる指定である.不要な項目は削除して使用する.

#!/bin/sh
set -e

PORTS="
multimedia/libdvdcss
textproc/libxml2
textproc/libxml++26
devel/libgsf
devel/qt6-base
print/freetype2
multimedia/ffmpeg

www/firefox
www/firefox-i18n
www/chromium
mail/evolution
mail/thunderbird
mail/thunderbird-i18n
net-im/pidgin
net-im/telegram-desktop

editors/libreoffice
japanese/libreoffice
editors/abiword
math/gnumeric

graphics/evince
graphics/zathura
graphics/zathura-pdf-mupdf
graphics/xpdf
print/gv
print/ghostscript10
print/gsfonts
print/psutils

multimedia/vlc
multimedia/mpv
multimedia/smplayer
multimedia/totem
multimedia/totem-pl-parser
multimedia/kdenlive
multimedia/shotcut
audio/rhythmbox
audio/amarok
multimedia/audacious
multimedia/audacious-plugins
audio/audacity

multimedia/handbrake
sysutils/brasero
sysutils/k3b
sysutils/cdrtools
sysutils/dvd+rw-tools

graphics/shotwell
graphics/digikam
graphics/gwenview
graphics/gthumb
graphics/geeqie
multimedia/ffmpegthumbnailer

graphics/gimp
graphics/gimp-data-extras
misc/gimp-help-en
graphics/krita
graphics/ImageMagick7
graphics/GraphicsMagick
graphics/rubygem-rmagick
games/tuxpaint
games/tuxpaint-config
games/tuxpaint-fonts
games/tuxpaint-stamps

graphics/inkscape
graphics/dia
graphics/drawio
graphics/tgif
math/gnuplot
math/octave
math/py-numpy
math/py-matplotlib

deskutils/gnome-calendar
deskutils/korganizer
editors/vim
editors/neovim
editors/emacs
japanese/yatex
editors/gedit
editors/nano
deskutils/gnote
editors/hexedit

misc/mc
sysutils/fd
sysutils/ranger
archivers/zip
archivers/unzip
archivers/7-zip
archivers/lha
archivers/zstd

textproc/hunspell
textproc/en-hunspell
textproc/aspell
misc/lv
textproc/bat
japanese/nkf
japanese/qkc
converters/dos2unix
converters/libiconv
textproc/catdoc
textproc/xlhtml
japanese/a2ps
graphics/poppler-utils
textproc/wkhtmltopdf
print/detex

net/remmina
net/rsync
ftp/wget
ftp/curl
ftp/filezilla

japanese/font-std
japanese/font-ipa
japanese/font-ipaex
japanese/font-ipa-uigothic
japanese/font-vlgothic
japanese/font-sazanami
japanese/font-kochi
x11-fonts/noto-jp
x11-fonts/noto-basic
x11-fonts/urwfonts-ttf
x11-fonts/intlfonts

textproc/ibus
japanese/ibus-mozc

x11/xfce4
x11/lxde-meta
x11-wm/lxsession
x11-wm/fvwm3
graphics/scrot
graphics/flameshot

security/clamav
security/clamtk
www/e2guardian
security/nmap
sysutils/htop

astro/stellarium
games/gcompris-qt
"

for p in ${PORTS}; do
    if [ -d "/usr/ports/${p}" ]; then
        make -C "/usr/ports/${p}" install clean BATCH=yes
    else
        echo "skip: ${p} は現在のポーツ・ツリーに存在しない"
    fi
done

インストール後の設定

フォントの設定

現在の X 環境では,フォントの管理は fontconfig が行う.xorg.conf への FontPath の記述は不要である.ports でインストールしたフォントは /usr/local/share/fonts 以下に配置され,自動的に認識される.

コマンドプロンプト(端末)を管理者権限(root)で開き,次のコマンドを実行する.フォントキャッシュを再構築する.

fc-cache -f -v

コマンドプロンプト(端末)を開き,次のコマンドを実行する.日本語フォントが認識されていることを確認する.

fc-list :lang=ja

日本語入力(Mozc)の設定

ホームディレクトリの ~/.xprofile に次の内容を記述する.この作業は,root ではなく一般ユーザで行う.

export GTK_IM_MODULE=ibus
export QT_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
ibus-daemon -drx

.emacs の設定例

ホームディレクトリの ~/.emacs を設定する.この作業は,root ではなく一般ユーザで行う.

;; フォントロックの有効化
(when (fboundp 'global-font-lock-mode)
  (global-font-lock-mode t))

;; フレームタイトル
(setq frame-title-format (concat "%b - emacs@" (system-name)))

;; フォント
(when window-system
  (set-frame-font "Noto Sans Mono CJK JP-12" t t)
  (mouse-wheel-mode 1))

;; 表示の設定
(setq next-line-add-newlines nil)
(setq line-number-mode t)
(column-number-mode 1)
(display-time)
(setq inhibit-startup-message t)
(setq initial-scratch-message nil)

;; テキストモードでの自動折り返し
(add-hook 'text-mode-hook (lambda () (auto-fill-mode 1)))

;; cc-mode
(add-hook 'c-mode-common-hook
          (lambda () (c-set-style "gnu")))

;; 日本語環境,文字コードは UTF-8
(set-language-environment "Japanese")
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(setq default-file-name-coding-system 'utf-8)