Poudriere (FreeBSD) 覚書

2025-05-06

● 前置き

2025年4月3日頃..

日課の portupgrade しようとすると、glib20 と gobject-introspection なるものが衝突して、失敗した。


〜
pkg-static: glib-2.82.4,2 conflicts with gobject-introspection-1.78.1_2,1 (installs files into the same place).  Problematic file: /usr/local/lib/girepository-1.0/GLib-2.0.typelib
〜
** Listing the failed packages (-:ignored / *:skipped / !:failed)
	! devel/glib20 (glib-2.80.5_1,2)	(install error)
	* devel/gobject-introspection (gobject-introspection-1.78.1_2,1)
	* devel/appstream-qt (AppStreamQt6-1.0.4)
	* sysutils/plasma6-discover (plasma6-discover-6.3.3)
	* x11/kf6-frameworkintegration (kf6-frameworkintegration-6.12.0)

しょうがないので、pkg delete gobject-introspection (依存パッケージも含めて) した。

依存パッケージの emacs も消えてしまったので、まずはこれを portinstall し直そうとした。 (wanderlust の依存関係で emacs をインストールする)

ところが.. それもうまくいかない。


〜
===>  Script "configure" failed unexpectedly.
Please report the problem to desktop@FreeBSD.org [maintainer] and attach the
"/usr/ports/devel/gobject-introspection/work-default/gobject-introspection-1.82.0/_build/meson-logs/meson-log.txt"
including the output of the failure of your make command. Also, it might be
a good idea to provide an overview of all packages installed on your system
(e.g. a /usr/local/sbin/pkg-static info -g -Ea).
*** Error code 1

Stop.
make[12]: stopped in /usr/ports/devel/gobject-introspection
*** Error code 1

Stop.
〜
make: stopped in /usr/ports/mail/wanderlust
--->  [Executing a command as root: sudo /usr/local/sbin/pkgdb -aFOQ]
** Listing the failed packages (-:ignored / *:skipped / !:failed)
	! mail/wanderlust	(dependent ports)

どうしようもなくなって、emacs は ソースからのコンパイルをあきらめて、pkg install emacs してしのいだりしていた。

その他の依存関係で消えたパッケージは portinstall でソースからコンパイルし直したりした。

それでも、portupgrade しようとすると、glib20 と gobject-introspection が衝突して失敗する現象は変わらない。

ていうか、色々やっているうちに、emacs が起動しなくなった。


blue% emacs
ld-elf.so.1: Shared object "libtree-sitter.so.0.24" not found, required by "emacs"

実は、/usr/ports/UPDATING を見てみると..

20250402:
  AFFECTS: users of devel/glib20 and devel/gobject-introspection building outside of Poudriere
  AUTHOR: arrowd@FreeBSD.org

  New versions of glib started to require gobject-introspection as a build
  dependency, while gobject-introspection requires glib to build. This forms a
  dependency cycle that is dealt with by introducing the @bootstrap flavor for
  mentioned ports. This solution is suggested by the upstream as well, see
  https://discourse.gnome.org/t/dealing-with-glib-and-gobject-introspection-circular-dependency/18701

  When building devel/glib20 in Poudriere no manual intervention is required.
  〜

glib と gobject-introspection の依存関係が循環参照している (それも upstream で) というのも何だが..

Poudriere なるものを使うと、no manual intervention is required なのだという。
Poudriere を使わない方法も、その下に書いてある(?) ようなのだが、少なくとも筆者の所では portupgrade ではうまくいっていない。

Poudriere というのは、ports-mgmt/poudriere らしい。 そこで、これを導入してみることにする。

● Poudriere でやってみる

◎ 準備

以下を参考。

https://github.com/freebsd/poudriere
https://github.com/freebsd/poudriere/wiki

portinstall -s poudriere でインストール。

/usr/local/etc/poudriered.conf を編集。
/usr/local/etc/poudriered.conf.sample も存在しており、初期状態では同じファイル。


blue% md5 poudriere.conf*
MD5 (poudriere.conf) = dfbf9d515cbcedecf785f1f47c4b4f92
MD5 (poudriere.conf.sample) = dfbf9d515cbcedecf785f1f47c4b4f92

blue% sudoedit poudriere.conf

ZFS を使用。

筆者の環境では、ZPOOL を「zfsnv」としたいので、以下のように設定。


ZPOOL=zfsnv

以下のようになっているが..


FREEBSD_HOST=_PROTO_://_CHANGE_THIS_
その上の Suggested: 通りに設定。

FREEBSD_HOST=https://download.FreeBSD.org

以下は、そのまま使う。


RESOLV_CONF=/etc/resolv.conf

以下も、そのまま使う。


DISTFILES_CACHE=/usr/ports/distfiles

以下のようになっているが..


#BUILDER_HOSTNAME=pkg.FreeBSD.org

よく分からないが、以下のように設定する (筆者の環境の場合)。


BUILDER_HOSTNAME=pkg.nsmrtks.jp

以下のようになっているが..


#URL_BASE=http://yourdomain.com/poudriere/

これもよく分からないが、以下のように設定する (筆者の環境の場合)。


URL_BASE=https://nsmrtks.jp/poudriere/

以上までのように poudriere.conf を変更して、diff で示すと以下のようになった。


blue% diff -u poudriere.conf.sample poudriere.conf
--- poudriere.conf.sample	2025-04-05 10:07:55.683107000 +0900
+++ poudriere.conf	2025-04-05 10:42:53.560854000 +0900
@@ -9,7 +9,7 @@
 # You need at least 7GB of free space in this pool to have a working
 # poudriere.
 #
-#ZPOOL=zroot
+ZPOOL=zfsnv
 
 ### NO ZFS
 # To not use ZFS, define NO_ZFS=yes
@@ -27,7 +27,7 @@
 # Also note that all protocols supported by fetch(1) are supported here, even
 # file:///
 # Suggested: https://download.FreeBSD.org
-FREEBSD_HOST=_PROTO_://_CHANGE_THIS_
+FREEBSD_HOST=https://download.FreeBSD.org
 
 # By default the jails have no /etc/resolv.conf, you will need to set
 # RESOLV_CONF to a file on your hosts system that will be copied to
@@ -277,7 +277,7 @@
 # Define the building jail hostname to be used when building the packages
 # Some port/packages hardcode the hostname of the host during build time
 # This is a necessary setup for reproducible builds.
-#BUILDER_HOSTNAME=pkg.FreeBSD.org
+BUILDER_HOSTNAME=pkg.nsmrtks.jp
 
 # Define to get a predictable timestamp on the ports tree
 # This is a necessary setup for reproducible builds.
@@ -345,7 +345,7 @@
 # URL where your POUDRIERE_DATA/logs are hosted
 # This will be used for giving URL hints to the HTML output when
 # scheduling and starting builds
-#URL_BASE=http://yourdomain.com/poudriere/
+URL_BASE=https://nsmrtks.jp/poudriere/
 
 # Set to hosted to use the /data directory instead of inline style HTML
 # Default: inline

前述の https://github.com/freebsd/poudriere がいう通り、poudriere(8) の EXAMPLES に従う。
Bulk build of specific binary packages に従う。

まず poudriere jail コマンドを実行。 (やはりというか root 権限なしだと失敗したので sudo を付けてやり直している)
しかし、ここで -v に指定した文字列が..


blue% sudo poudriere jail -c -v 14.2-RELEASE-p2 -a amd64 -j 142p2amd64
[00:00:00] Creating 142p2amd64 fs at /usr/local/poudriere/jails/142p2amd64... done
[00:00:00] Fetching MANIFEST for FreeBSD 14.2-RELEASE-p2 amd64
fetch: https://download.FreeBSD.org/releases/amd64/amd64/14.2-RELEASE-p2/MANIFEST: Not Found
fetch: https://download.FreeBSD.org/releases/amd64/amd64/14.2-RELEASE-p2/MANIFEST: Not Found
[00:00:02] Error: Failed to fetch from https://download.FreeBSD.org/releases/amd64/amd64/14.2-RELEASE-p2/MANIFEST
[00:00:02] Error while creating jail, cleaning up.
[00:00:02] Removing 142p2amd64 jail... done
[00:00:02] Cleaning 142p2amd64 data... done

14.2-RELEASE-p2 という指定はダメだったか。
実際、https://download.FreeBSD.org/releases/amd64/amd64/ を見てみたが、14.2-RELEASE はあっても 14.2-RELEASE-p2 なんてものは無かった。

Error while creating jail, cleaning up. とある通り、/usr/local/poudriere/jails/ には何も無かった。


blue% ls -a /usr/local/poudriere/jails/
./      ../

-v に 14.2-RELEASE を指定してやり直す。


blue% sudo poudriere jail -c -v 14.2-RELEASE -a amd64 -j 142amd64
[00:00:00] Creating 142amd64 fs at /usr/local/poudriere/jails/142amd64... done
[00:00:01] Using pre-distributed MANIFEST for FreeBSD 14.2-RELEASE amd64
[00:00:01] Fetching base for FreeBSD 14.2-RELEASE amd64
base.txz                                               196 MB   19 MBps    10s
[00:00:12] Extracting base... done
[00:00:23] Fetching src for FreeBSD 14.2-RELEASE amd64
src.txz                                                204 MB   24 MBps    08s
[00:00:33] Extracting src... done
[00:00:45] Fetching lib32 for FreeBSD 14.2-RELEASE amd64
lib32.txz                                               59 MB   12 MBps    05s
[00:00:51] Extracting lib32... done
[00:00:54] Cleaning up... done
[00:00:54] Recording filesystem state for clean... done
[00:00:54] Upgrading using http
Looking up update.FreeBSD.org mirrors... 3 mirrors found.
Fetching public key from update1.freebsd.org... done.
Fetching metadata signature for 14.2-RELEASE from update1.freebsd.org... done.
Fetching metadata index... done.
Fetching 2 metadata files... done.
Inspecting system... done.
Preparing to download files... done.
Fetching 48 patches.....10....20....30....40.... done.
Applying patches... done.
The following files will be updated as part of updating to
14.2-RELEASE-p2:
/bin/freebsd-version
〜
Installing updates...Scanning /usr/local/poudriere/jails/142amd64/usr/share/certs/untrusted for certificates...
Scanning /usr/local/poudriere/jails/142amd64/usr/share/certs/trusted for certificates...
 done.
14.2-RELEASE-p2
[00:01:08] Recording filesystem state for clean... done
[00:01:08] Jail 142amd64 14.2-RELEASE-p2 amd64 is ready to be used

おお、ちゃんと freebsd-update してくれるんや。

続いて、poudriere ports コマンドを実行。 (やはり root 権限が必要で、sudo を付けてやり直している。)


blue% sudo poudriere ports -c
パスワード: 
[00:00:00] Creating default fs at /usr/local/poudriere/ports/default... done
[00:00:00] Cloning the ports tree... done

◎ ビルド

さて、ここでは emacs をビルドする。

以下の内容の pkglist.txt というファイルを作成。


editors/emacs

poudriere bulk コマンドを実行。 (やっぱり root 権限が必要で、sudo を付けてやり直している。)


blue% sudo poudriere bulk -f ~/pkglist.txt -j 142amd64

しばらくビルドが続くが、それにしても 8-core 16-thread (AMD Ryzen 7) なのに、全然フルに使ってくれなくて、時間がかかる..

あまりにも遅いので、Ctrl-c で止めて、poudriere.conf の以下も設定してみた。


PARALLEL_JOBS=12

そうして、さっきと同じコマンドライン (poudriere bulk) で再開させた。
しかし変わらないようだ。 (そのため、この設定は、後で元に戻しておいた。 (# PARALLEL_JOBS=1 というものがコメントアウトされた状態))

画面が全く進まなくなったので、フリーズしたのかと思い、以下を探し当てた所、


blue% ls -ltrA /usr/local/poudriere/data/logs/bulk/142amd64-default/latest/logs/ 
total 1147
drwxr-xr-x  2 root wheel        2  4月  5 13:56 errors/
-rw-r--r--  3 root wheel  3687907  4月  5 16:17 rust-1.85.1.log
-rw-r--r--  3 root wheel 11000928  4月  5 16:17 gcc13-13.3.0_2.log

一応コンパイルは進行中のようだった。

よく見ると Hit CTRL+t at any time to see build progress and stats とも書いてあり、Ctrl-t を押すと、それなりに表示される。

しばらくして、最後まで完了した。

我々の例だと以下に、ビルドされたパッケージがあった。

/usr/local/poudriere/data/packages/142amd64-default/All/

● 利用

sudo pkg delete emacs して、cd /usr/local/poudriere/data/packages/142amd64-default/All/ して sudo pkg add emacs-30.1_3,3.pkg すると、無事に emacs がインストールされた。
emacs を起動することも出来た。

◎ その後

しかしその後、portupgrade したら、別のパッケージで、やはり glib20 と gobject-introspection 周りで、うまくいかなかった。


〜
Installing glib-2.82.4_1,2...
pkg-static: glib-2.82.4_1,2 conflicts with gobject-introspection-1.78.1_2,1 (installs files into the same place).  Problematic file: /usr/local/lib/girepository-1.0/GLib-2.0.typelib
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/devel/glib20
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/devel/glib20
*** Error code 1

Stop.
make: stopped in /usr/ports/devel/glib20

Pourdriere でコンパイルした方には、glib-2.82.4_1,2 や gobject-introspection-1.82.0_1,1 がある。


blue% ls -ld glib-* gobject-introspection-*
-rw-r--r--  1 nobody wheel 10932061  4月  5 11:24 glib-2.82.4_1,2.pkg
-rw-r--r--  1 nobody wheel  2941691  4月  5 11:19 glib-bootstrap-2.82.4_1,2.pkg
-rw-r--r--  1 nobody wheel   657127  4月  5 11:24 gobject-introspection-1.82.0_1,1.pkg
-rw-r--r--  1 nobody wheel   656681  4月  5 11:19 gobject-introspection-bootstrap-1.82.0_1,1.pkg

強引だが、現状インストールされている gobject-introspection を pkg delete する。 そうすると、依存関係で emacs も削除される (他の大量のパッケージも)。
その状態でさっきの pkg add emacs-30.1_3,3.pkg をいまいちどやり直した。

その状態で portupgrade すると、今度は glib-2.82.4_1,2 がコンパイルされインストールされた。

その状態で、依存関係で削除されたパッケージを portinstall し直した。 (強引だな..)

firefox / kde / libreoffice / chromium

● 別バージョンでも

さっきのは FreeBSD 14.2 環境だったが、別環境の FreeBSD 13.5 も、同じ状況 (emacs が起動しない) になったので、こちらのためにも同様の作業を行った。

こちらについて、FreeBSD 13.5 環境上で pourdriere を行うのではなく、先ほどと同じ FreeBSD 14.2 環境で流用して行う。

まず poudriere jail コマンドを実行。


blue% sudo poudriere jail -c -v 13.5-RELEASE -a amd64 -j 135amd64
[00:00:00] Creating 135amd64 fs at /usr/local/poudriere/jails/135amd64... done
[00:00:00] Using pre-distributed MANIFEST for FreeBSD 13.5-RELEASE amd64
[00:00:00] Fetching base for FreeBSD 13.5-RELEASE amd64
base.txz                                               212 MB   19 MBps    11s
[00:00:13] Extracting base... done
[00:00:25] Fetching src for FreeBSD 13.5-RELEASE amd64
src.txz                                                200 MB   16 MBps    12s
[00:00:38] Extracting src... done
[00:00:50] Fetching lib32 for FreeBSD 13.5-RELEASE amd64
lib32.txz                                               70 MB   16 MBps    04s
[00:00:56] Extracting lib32... done
[00:00:59] Cleaning up... done
[00:00:59] Recording filesystem state for clean... done
[00:01:00] Upgrading using http
Looking up update.FreeBSD.org mirrors... 3 mirrors found.
Fetching public key from update1.freebsd.org... done.
Fetching metadata signature for 13.5-RELEASE from update1.freebsd.org... done.
Fetching metadata index... done.
Fetching 1 metadata files... done.
Inspecting system... done.
Preparing to download files... done.

No updates needed to update system to 13.5-RELEASE-p0.
13.5-RELEASE
[00:01:02] Recording filesystem state for clean... done
[00:01:02] Jail 135amd64 13.5-RELEASE amd64 is ready to be used

続いて、poudriere ports コマンドを実行.. ところが。


blue% sudo poudriere ports -c
[00:00:00] Error: The ports tree, default, already exists

以前のままでいけるんだろうか?

ここでも emacs をビルドするが、以前作成した、以下の内容の pkglist.txt というファイルをそのまま利用。


editors/emacs

poudriere bulk コマンドを実行。


blue% sudo poudriere bulk -f ~/pkglist.txt -j 135amd64

ports ツリーを更新したように見えなかったのだが..

数分進んだ所で、poudriere ports -u で ports ツリーを更新するものなのだと、poudriere-ports(8) で知った。

Ctrl-c でコンパイルを止め、poudriere ports -u を実行。


blue% sudo poudriere ports -u
[00:00:00] Updating portstree "default" with git+https... done

ん? 数秒で終わってしまったのだが、これで合っていたのだろうか。

git log を見てみると (git log にも sudo を付けないと上手くいかなかった)、


blue% cd /usr/local/poudriere/ports/default/

blue% sudo git log --name-status

前回 4月5日よりも明らかに新しい、4月9日の更新が見えたので (タイムゾーンが日本と違ったりしたが 4日経過していることに比べれば誤差)、ports ツリーは更新されているようだ。

あらためて poudriere bulk コマンドを実行。


blue% cd

blue% sudo poudriere bulk -f ~/pkglist.txt -j 135amd64

しばらくして、最後まで完了した。

以下に、ビルドされたパッケージがあった。

/usr/local/poudriere/data/packages/135amd64-default/All/

それらのファイルを FreeBSD 13.5 の環境にコピーして、色々 pkg add などした。

以上


index