SDカードイメージを作成するテスト
Posted:
背景
新しいバージョンを試したい。 調べてみると、 Build.Dist このツールを使うと自分でSDカードのイメージを作成できるらしい。 更に設定で自分好みのイメージが作れるらしい、凄い。
下記はエラーに対する試行錯誤、そのメモです。
ネットワークのトラブル、pingで疎通ができない。名前解決はできないのだがdigだと名前解決ができる
名前解決にdnssecを利用するようになった。
/etc/resolv.conf の内容
nameserver 127.0.0.53
options edns0 trust-ad
search .
edns0: EDNS(Extension mechanisms for DNS)のバージョン0を使用することを示す。 EDNSは、DNSプロトコルを拡張し、より大きなペイロード、改善されたセキュリティ(DNSSEC)、その他の機能をサポート。
trust-ad: DNSSECのAuthenticated Data(AD)フラグを信頼することを示す。 これは、DNSSECにより検証された応答を信頼し、使用することを意味。
DNSSECはサーバ側の時刻を利用する。 ラズパイを長いこと起動していなかったためか、あるいはchronyd, ntpdをインストールして設定が変わったからか、DNSSECが動作しなくなった。
ラズパイの時刻がずれていたので強制的に時刻を合わせる。
dig time.google.com で、googleのNTPサーバのIPアドレスを確認し、nptpdateで合わせる。
sudo systemctl stop ntpd
sudo ntpdate 216.239.35.4
今では systemd-timesyncd, chronydで時刻合わせを設定するようなので、知識をアップデートしたい。
scripts/binfmt.sh でエラーが出る
下記の箇所でエラーが出る。 qemuが必要。
if [ "${cpu}" != "arm" ] ; then
if [[ ! -e /proc/sys/fs/binfmt_misc/arm ]]; then
echo ":arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xf
f\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm:F" >> /proc/sys/fs/binfmt_misc/register
fi
fi
下記のコマンドでqemuをインストールした。
QEMU_SOFTMMU_TARGETS="arm" が必要。このオプションでarm向けのqemuが追加される。
sudo QEMU_SOFTMMU_TARGETS="aarch64 arm" USE="static-libs" emerge --changed-use --ask --quiet app-emulation/qemu
コンパイルすると /usr/bin/qemu-system-arm ができる。
コマンドのパスが異なるので下記を修正した。
if [ "${cpu}" != "arm" ] ; then
if [[ ! -e /proc/sys/fs/binfmt_misc/arm ]]; then
echo ":arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xf
f\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-system-arm:F" >> /proc/sys/fs/binfmt_misc/register
fi
fi
参考 binfmt_misc - Linuxの備忘録とか・・・(目次へ)
sudo sh build.sh を実行するとエラーが出る
1つ目 localeでエラーが出てる
下記のエラーが出ている。
running jobs [(<Popen: returncode: None args: ['/mnt/nfs/home/exampleuser/workspace/git...>, 'locale')]
+ source /mnt/nfs/home/exampleuser/workspace/git/github.com/GenPi64/Build.Dist/scripts/functions.sh
+ echo 'Running eselect locale set en_US.utf8'
Running eselect locale set en_US.utf8
+ trap finish EXIT
+ cat
見ると eselect locale に失敗している?
eselect locale set en_US.utf8
そしてリターンコードが
returncode: None args
parsers/includejson/includejson の下記の部分、 running jobs でエラー?
def checkjob(jobs):
print("running jobs", jobs)
onefinished = False
name = None
while not onefinished and jobs:
for job in jobs:
job[0].poll()
if job[0].returncode is not None:
onefinished = True
if job[0].returncode == 0:
print("jobdone", job[1])
completed.append(job[1])
writecompleted(job[1])
jobs.remove(job)
name = job[1]
else:
print(f"FATAL: JOB {job[1]} FAILED with exit code {job[0].returncode}")
jobs.remove(job)
while jobs:
build.shで出力されている設定は下記の内容だった。
[
{'name': 'locale', 'deps': ['etc'], 'parser': 'rawcommand', 'args': ['eselect locale set en_US.utf8']},
{'name': 'update_portage', 'deps': ['locale'], 'parser': 'emerge', 'args': ['--verbose --oneshot --jobs --tree --ignore-default-opts sys-apps/por
tage']},
{'name': 'install_ccache', 'deps': ['update_portage'], 'parser': 'emerge', 'args': ['--verbose --jobs --tree --ignore-default-opts --binpkg-respe
ct-use=y --binpkg-changed-deps=y --usepkg=y ccache']},
{'name': 'update_world', 'deps': ['install_ccache'], 'parser': 'emerge', 'args': ['--verbose --update @world']},
{'name': 'depclean_update_world', 'deps': ['update_world'], 'parser': 'emerge', 'args': ['--verbose --depclean']},
{'name': 'rebuild_system', 'deps': ['depclean_update_world'], 'parser': 'emerge', 'args': ['--verbose --emptytree @system']},
{'name': 'rebuild_world', 'deps': ['rebuild_system'], 'parser': 'emerge', 'args': ['--verbose --emptytree @world']},
{'name': 'depclean_rebuild_world', 'deps': ['rebuild_world'], 'parser': 'emerge', 'args': ['--verbose --depclean']},
{'name': 'set_profile', 'deps': ['depclean_rebuild_world'], 'parser': 'setprofile', 'args': ['']},
{'name': 'emerge_new_profile', 'deps': ['set_profile'], 'parser': 'emerge', 'args': ['--verbose --update @world']},
{'name': 'add_sets', 'deps': ['emerge_new_profile'], 'parser': 'addsets', 'args': ['']},
{'name': 'emerge_new_sets', 'deps': ['add_sets'], 'parser': 'emerge', 'args': ['--verbose --update @world']},
{'name': 'ccache_stats', 'deps': ['emerge_new_sets'], 'parser': 'rawcommand', 'args': ['ccache -d /var/tmp/ccache --show-stats']},
{'name': 'unmerge_ccache', 'deps': ['ccache_stats'], 'parser': 'emerge', 'args': ['--unmerge ccache']},
{'name': 'depclean_new_profile', 'deps': ['unmerge_ccache'], 'parser': 'emerge', 'args': ['--verbose --depclean']},
{'name': 'eclean-pkg', 'deps': ['depclean_new_profile'], 'parser': 'rawcommand', 'args': ['eclean-pkg --time-limit=1m']},
{'name': 'eclean-dist', 'deps': ['eclean-pkg'], 'parser': 'rawcommand', 'args': ['eclean-dist --time-limit=1m']},
{'name': 'users', 'deps': ['eclean-dist'], 'parser': 'users', 'args': ['']},
{'name': 'setup_services', 'deps': ['users'], 'parser': 'setupservices', 'args': ['']},
{'name': 'news', 'deps': ['setup_services'], 'parser': 'rawcommand', 'args': ['eselect news read &>/dev/null']},
{'name': 'set_root_password', 'deps': ['news'], 'parser': 'password', 'args': ['']}
]
2つ目 em-**** でエラー
em-1876 の数字部分は都度変わる。
running jobs [(<Popen: returncode: None args: ['/mnt/nfs/home/exampleuser/workspace/git...>, 'locale')]
+ source /mnt/nfs/home/exampleuser/workspace/git/github.com/GenPi64/Build.Dist/scripts/functions.sh
+ echo 'Running eselect locale set en_US.utf8'
Running eselect locale set en_US.utf8
+ trap finish EXIT
+ cat
+ chmod +x /mnt/nfs/home/exampleuser/workspace/git/github.com/GenPi64/Build.Dist/build/GenPi64OpenRC/chroot/em-1876
+ /mnt/nfs/home/exampleuser/workspace/git/github.com/GenPi64/Build.Dist/scripts/chroot.py /em-1876
%p1%d`pychroot succeeded%p1%d`pychroot succeededTraceback (most recent call last):
File "/usr/lib/python3.10/site-packages/pychroot/scripts/pychroot.py", line 130, in main
File "/usr/lib/python3.10/subprocess.py", line 501, in run
File "/usr/lib/python3.10/subprocess.py", line 969, in __init__
File "/usr/lib/python3.10/subprocess.py", line 1845, in _execute_child
OSError: [Errno 8] Exec format error: '/em-1876'
+ finish
+ ret=1
+ rm -f /mnt/nfs/home/exampleuser/workspace/git/github.com/GenPi64/Build.Dist/build/GenPi64OpenRC/chroot/em-1876
+ exit 1
FATAL: JOB locale FAILED with exit code 1
FATAL: JOB gentoo-base FAILED with exit code 1
after PARSERS
run complete.
下記の場所でエラーが出ている
/usr/lib/python3.10/site-packages/pychroot/scripts/pychroot.py
@argparser.bind_main_func
def main(options, out, err):
try:
chroot = Chroot(
options.path, mountpoints=options.mountpoints,
hostname=options.hostname, skip_chdir=options.skip_chdir)
with chroot:
p = subprocess.run(options.command) # <- ここでエラー。オプションとしては /em-1876 が渡っている
raise SystemExit(p.returncode)
except FileNotFoundError as e:
cmd = options.command[0]
argparser.error(f'failed to run command {cmd!r}: {e}', status=1)
except ChrootError as e:
argparser.error(str(e), status=1)
return chroot.exit_status
上記のスクリプトは /mnt/nfs/home/exampleuser/workspace/git/github.com/GenPi64/Build.Dist/scripts/chroot.py から呼ばれている。
# Retain old behavior
if 'CHROOT_CMD' in os.environ:
chroot_cmd = os.environ.get('CHROOT_CMD')
if chroot_cmd == 'pychroot':
os.execvpe('pychroot',
['pychroot',
'-B', f'{os.environ["CCACHE_DIR"]}:/var/tmp/ccache',
'-B', f'{os.environ["BINPKGS_DIR"]}:/var/cache/binpkgs',
'-B', f'{os.environ["DISTFILES_DIR"]}:/var/cache/distfiles',
os.environ['CHROOT_DIR'],
*sys.argv[1:]], os.environ)
elif chroot_cmd == 'systemd-nspawn':
os.execvpe('systemd-nspawn',
['systemd-nspawn',
f'--machine={uuid.uuid4()}',
f'--directory={os.environ["CHROOT_DIR"]}',
f'--bind={os.environ["CCACHE_DIR"]}:/var/tmp/ccache',
f'--bind={os.environ["BINPKGS_DIR"]}:/var/cache/binpkgs',
f'--bind={os.environ["DISTFILES_DIR"]}:/var/cache/distfiles',
*sys.argv[1:]],
os.environ | { "SYSTEMD_SUPPRESS_SYNC" : "1" })
parsers/includejson/includejson が処理している、その中でエラーが起きていたのでプルリクした
様々なジョブがあるが、parsers/配下に様々な処理を行うスクリプトがある。 (いろいろな処理を自動化していて凄い…)
{'name': 'locale', 'deps': ['etc'], 'parser': 'rawcommand', 'args': ['eselect locale set en_US.utf8']},
上記の処理を行うパーサーは parsers/rawcommand/rawcommand になる。
#!/bin/bash -ex
source "$BASEDIR/scripts/functions.sh"
echo "Running $@"
function finish
{
ret=$?
rm -f "${PROJECT_DIR}/chroot/em-$$"
exit $ret
}
trap finish EXIT
cat <<- EOF > "${PROJECT_DIR}/chroot/em-$$"
#!/usr/bin/env bash
set -evx
source /etc/profile
$@
EOF
chmod +x "${PROJECT_DIR}/chroot/em-$$"
"${SCRIPTS}/chroot.py" /em-$$
エラーの Running eselect locale set en_US.utf8 は、このスプリクトが出しているようだ。
OSError: [Errno 8] Exec format error: '/em-1876'
em-???? の中身は下記になる。
#!/usr/bin/env bash
set -evx
source /etc/profile
$@
これ… #! の前に空白があるのはマズそう。 空白を除外したら動いた。
タブなのか空白なのか確認する。
https://raw.githubusercontent.com/GenPi64/Build.Dist/master/parsers/rawcommand/rawcommand 空白かもしれない。タブの方が良い。
下記のコミットで入った模様 https://github.com/GenPi64/Build.Dist/commit/cb0d1350503827f5099c5998e24edd65f341121f
Jul 22, 2022 2022/07/22 から。
gitで core.whitespace の設定が入っていないだろうか?
issueで挙がってないか確認
- 2022/02/07 scripts/chroot.py does not forward error code from subcommand · Issue #166 · GenPi64/Build.Dist
- 2023/01/05 Error Handling Which Preserves Possible Problem File? · Issue #180 · GenPi64/Build.Dist
- このイシューが近い
- 2023/01/05 Build Fails 1/4/2023 · Issue #179 · GenPi64/Build.Dist
- 内容を調査する
You seem to be hitting a snag with qemu as Exec format error entails wrong architecture binary is trying to be ran.- qemuのエラーと見ているけど、シバンの前に空白が入っているからかも
- このissueも同様な問題かも
- `I also have a strong feeling that only part of the issue is pychroot which we have had issues with in the past and systemd-nspawn at least is not
recommended to even try on openrc as it will screw up things.`
- systemd-nspawn だと上手くいくらしい。別のフローに入るのだろうか?
- いや、parsers/rawcommand は基本的な処理だと思うが。
フォークして
タブを消したプルリクを作成
issueに上げてみる
自分のタブと空白の見かたが間違っている可能性があるので、再度、git cloneする
エラー対応
update_worldでエラーが出た
FATAL: JOB update_world FAILED with exit code 1
FATAL: JOB gentoo-base FAILED with exit code 1
{'name': 'update_world', 'deps': ['install_ccache'], 'parser': 'emerge', 'args': ['--verbose --update @world']},
下記のエラーが出ていた。 dhcpcdのビルドに失敗しているからだろうか? dhcpcdが無いのは痛い。 本家のコードのタイミングの問題かもしれない。
* Messages for package net-misc/dhcpcd-9.4.1:
* ERROR: net-misc/dhcpcd-9.4.1::gentoo failed (compile phase):
* emake failed
*
* If you need support, post the output of `emerge --info '=net-misc/dhcpcd-9.4.1::gentoo'`,
* the complete build log and the output of `emerge -pqv '=net-misc/dhcpcd-9.4.1::gentoo'`.
* The complete build log is located at '/var/tmp/portage/net-misc/dhcpcd-9.4.1/temp/build.log.gz'.
* The ebuild environment file is located at '/var/tmp/portage/net-misc/dhcpcd-9.4.1/temp/environment'.
* Working directory: '/var/tmp/portage/net-misc/dhcpcd-9.4.1/work/dhcpcd-9.4.1'
* S: '/var/tmp/portage/net-misc/dhcpcd-9.4.1/work/dhcpcd-9.4.1'
下記が実行される。空白ではなく、ここではタブだった。
#!/usr/bin/env bash
set -evx
source /etc/profile
export SHELL="/bin/bash"
export TERM="linux"
export MAKEOPTS="-j$(nproc) -l$(nproc)"
${USE}
${EXTRA_EMERGE_ENV}
emerge $1
再度、 sudo sh build.sh とすると途中から再開した。
惜しいエラー、 acct-group/spi-0-r1 がマスクされている
2つアプローチがありえるように思う。
- マスクを外す
- sys-apps/rpi-spi-1.0.0-r2 へのアップデートをしないようにしてみる
gawklibpath_append () {
[ -z "$AWKLIBPATH" ] && \
AWKLIBPATH=`gawk 'BEGIN {print ENVIRON["AWKLIBPATH"]}'`
export AWKLIBPATH="$AWKLIBPATH:$*"
}
unset sh
++ unset sh
export SHELL="/bin/bash"
+ export SHELL=/bin/bash
+ SHELL=/bin/bash
export TERM="linux"
+ export TERM=linux
+ TERM=linux
export MAKEOPTS="-j4 -l4"
+ export 'MAKEOPTS=-j4 -l4'
+ MAKEOPTS='-j4 -l4'
emerge --verbose --update @world
+ emerge --verbose --update @world
* IMPORTANT: 1 news items need reading for repository 'genpi64'.
* IMPORTANT: 10 news items need reading for repository 'gentoo'.
* Use eselect news read to view new items.
These are the packages that would be merged:
Calculating dependencies ... .... done!
Dependency resolution took 23.07 s.
!!! All ebuilds that could satisfy "acct-group/spi" have been masked.
!!! One of the following masked packages is required to complete your request:
- acct-group/spi-0-r1::gentoo (masked by: package.mask)
/var/db/repos/gentoo/profiles/package.mask:
# Florian Schmaus <flow@gentoo.org> (2023-07-17)
# Obsolete acct-* packages which became leaf packages.
# Removal on 2023-08-17.
(dependency required by "sys-apps/rpi-spi-1.0.0-r2::genpi64" [ebuild])
(dependency required by "@profile" [set])
(dependency required by "@world" [argument])
For more information, see the MASKED PACKAGES section in the emerge
man page or refer to the Gentoo Handbook.
+ finish
+ ret=1
+ rm -f /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/build/GenPi64Systemd/chroot/em-27262
+ exit 1
FATAL: JOB emerge_new_profile FAILED with exit code 1
FATAL: JOB gentoo-base FAILED with exit code 1
run complete.
正しいアプローチとしてはマスクを外す設定を行い、emerge –sync でマスクの情報を更新する方法だと思うが、このイメージを作成するツールでemerge –syncの処理を差し込む方法が不明なので、一旦、システムのファイルをコメントアウトする。
sudo vi build/GenPi64Systemd/chroot/var/db/repos/gentoo/profiles/package.mask
2つをunmaskする必要があった。
# acct-group/spi
# acct-group/gpio
Invalid binary package のエラーが出る
build.shを実行している際に次のエラーが出た。
Error reading binpkg '/var/cache/binpkgs/dev-libs/libical/libical-3.0.16-1.gpkg.t
ar': [Errno 22] Invalid argument!!! Invalid binary package: '/var/cache/binpkgs/d
ev-libs/libical/libical-3.0.16-1.gpkg.tar', Error reading binpkg '/var/cache/binp
kgs/dev-libs/libical/libical-3.0.16-1.gpkg.tar': [Errno 22] Invalid argument
chroot環境配下の build/GenPi64Systemd/chroot/var/cache/binpkgs は空で、下記のディレクトリ配下のファイルを消す必要があった。
rm build/GenPi64Systemd/packages/dev-libs/libical/libical-3.0.16-1.gpkg.tar
Build.Dist環境で net-misc/dhcpcd がemergeできない
下記のエラーにだいぶ悩んだ。状況としては
- コンパイルは始まるが途中でmakeのエラーが出る
- “No rule to make target ‘フルパス/Build.Dist/scripts’, needed by ‘all’. Stop.“というエラー
- Makefile中にはallのターゲットはある.が、Build.Dist/scriptsを対象にmakeが走る理由が分からない
- 通常は srcディレクトリ( /var/tmp/portage/net-misc/dhcpcd-9.5.1/work/dhcpcd-9.5.1/src )配下でmakeが走る認識なので。
- (なぜかsrc配下以外を参照しているので )Build.Dist環境のみで発生すると思われる。
- 通常は srcディレクトリ( /var/tmp/portage/net-misc/dhcpcd-9.5.1/work/dhcpcd-9.5.1/src )配下でmakeが走る認識なので。
aarch64-unknown-linux-gnu-gcc -march=armv8-a+crc -mtune=cortex-a72 -ftree-vectorize -O2 -pipe -march=native -O2 -pipe -std=c99 -DHAVE_CONFIG_H -DNDEBUG -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DINET -DARP -DARPING -DIPV4LL -DINET6 -DDHCP6 -DAUTH -DPLUGIN_DEV -I.. -I../src -I./crypt -c ../compat/rb.c -o ../compat/rb.o
make[1]: *** No rule to make target '/mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/scripts', needed by 'all'. Stop.
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/var/tmp/portage/net-misc/dhcpcd-9.5.1/work/dhcpcd-9.5.1/src'
make: *** [Makefile:24: all] Error 2
* ERROR: net-misc/dhcpcd-9.5.1::gentoo failed (compile phase):
* emake failed
*
* If you need support, post the output of `emerge --info '=net-misc/dhcpcd-9.5.1::gentoo'`,
* the complete build log and the output of `emerge -pqv '=net-misc/dhcpcd-9.5.1::gentoo'`.
* The complete build log is located at '/var/tmp/portage/net-misc/dhcpcd-9.5.1/temp/build.log.gz'.
* The ebuild environment file is located at '/var/tmp/portage/net-misc/dhcpcd-9.5.1/temp/environment'.
* Working directory: '/var/tmp/portage/net-misc/dhcpcd-9.5.1/work/dhcpcd-9.5.1'
* S: '/var/tmp/portage/net-misc/dhcpcd-9.5.1/work/dhcpcd-9.5.1'
* Messages for package net-misc/dhcpcd-9.5.1:
* ERROR: net-misc/dhcpcd-9.5.1::gentoo failed (compile phase):
* emake failed
*
* If you need support, post the output of `emerge --info '=net-misc/dhcpcd-9.5.1::gentoo'`,
* the complete build log and the output of `emerge -pqv '=net-misc/dhcpcd-9.5.1::gentoo'`.
* The complete build log is located at '/var/tmp/portage/net-misc/dhcpcd-9.5.1/temp/build.log.gz'.
* The ebuild environment file is located at '/var/tmp/portage/net-misc/dhcpcd-9.5.1/temp/environment'.
* Working directory: '/var/tmp/portage/net-misc/dhcpcd-9.5.1/work/dhcpcd-9.5.1'
* S: '/var/tmp/portage/net-misc/dhcpcd-9.5.1/work/dhcpcd-9.5.1'
+ finish
+ ret=1
+ rm -f /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/build/GenPi64Systemd/chroot/em-16688
+ exit 1
FATAL: JOB emerge_new_profile FAILED with exit code 1
FATAL: JOB gentoo-base FAILED with exit code 1
run complete.
対応
バイナリパッケージを作るフェーズなので、別マシンで目的のパッケージを作成、Build.Distのパッケージ用ディレクトリ配下に設置した。 設置後は次のフェーズに進行した。
手順
別のマシンでパッケージの作成。
emerge --buildpkgonly <パッケージ名>
今回はdhcpcdだったので、インストールずみの他サーバで下記のようにパッケージを作成した。 (buildpkgonlyを使う場合、既に対象パッケージがインストールされている必要がある)
emerge --buildpkgonly net-misc/dhcpcd
binpkgは /var/cache/binpkgs 配下に保存される。これをBuild.Dist配下のpackagesディレクトリにコピーする
sudo mkdir -p build/GenPi64Systemd/packages/net-misc/dhcpcd/
sudo cp /var/cache/binpkgs/net-misc/dhcpcd/dhcpcd-9.5.1-1.xpak build/GenPi64Systemd/packages/net-misc/dhcpcd/
エラー iniparse を要求される
実行環境に dev-python/iniparse が必要。追加する.
emerge dev-python/iniparse
その時のエラーログ
running jobs [(<Popen: returncode: None args: ['/mnt/nfs/home/exampleuser/workspace/git...>, 'add_kernel8')]
Traceback (most recent call last):
File "/mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/scripts/crudini", line 20, in <module>
import iniparse
ModuleNotFoundError: No module named 'iniparse'
Iniparse failed to be imported
System hostname: k3s-stg-agent-e
Traceback:
FATAL: JOB add_kernel8 FAILED with exit code 223
FATAL: JOB genpi64-lite-finalize FAILED with exit code 1
run complete.
btrfsコマンドが見つからないエラーが出る
Build.Dist/parsers/shrink-image/shrink-image でエラーが発生している。
私のコマンドラインで “/usr/bin/env btrfs device usage -b image” を実行するとエラーは起きない。 btrfsコマンドは/sbin配下に存在する。 /usr/bin/envが btrfs コマンドを見つけられないのが原因かもしれない。
[{'name': 'shrink-image', 'deps': ['strip'], 'parser': 'shrink-image', 'args': ['']}, {'name': 'unmount-image', 'deps': ['shrink-image'], 'parser': 'unmount', 'args': ['']}, {'name': 'compress-image', 'deps': ['unmount-image'], 'parser': 'compress-image', 'args': ['']}]
checking shrink-image
checking unmount-image
checking compress-image
completed= ['', 'makeimage', 'mountimage', 'unpackstage4', 'sudoers', 'fstab', 'cmdline', 'genpi-releaser', 'strip']
manifest= [{'name': 'shrink-image', 'deps': [], 'parser': 'shrink-image', 'args': ['']}, {'name': 'unmount-image', 'deps': ['shrink-image'], 'parser': 'unmount', 'args': ['']}, {'name': 'compress-image', 'deps': ['unmount-image'], 'parser': 'compress-image', 'args': ['']}]
checking shrink-image deps []
all deps satisfied for shrink-image
executing shrink-image deps []
checking compress-image deps ['unmount-image']
running jobs [(<Popen: returncode: None args: ['/mnt/nfs/home/exampleuser/workspace/git...>, 'shrink-image')]
/usr/bin/env: ‘btrfs’: No such file or directory
Traceback (most recent call last):
File "/mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/parsers/shrink-image/shrink-image", line 22, in <module>
check(p)
File "/mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/parsers/shrink-image/shrink-image", line 19, in check
raise RuntimeError(f"{p} exited non-zero: {p.poll()}")
RuntimeError: <Popen: returncode: 127 args: ['/usr/bin/env', 'btrfs', 'device', 'usage', '...> exited non-zero: 127
FATAL: JOB shrink-image FAILED with exit code 1
FATAL: JOB packgenpi FAILED with exit code 1
FATAL: JOB genpi64-lite-finalize FAILED with exit code 1
run complete.
下記のようにshとしてから実行するので、一旦、shと実行してexportして環境変数PATHを確認するが、/sbinが含まれている。 どこかでコマンドサーチパスを変えている可能性がある。
sh build.sh
改善するアプローチとしてはpythonスクリプトの改修で2つ考えられた。
- フルパス(/sbin/btrfs)で実行する
- コマンドサーチパスに/sbinを追加する
1の場合、btrfsが/usr/sbin配下にインストールされるようなディストリビューションで実行できなくなるので、できれば避けたい。 2であれば1の問題点を回避できる。
また
- lsblkも使うので/bin
- truncate が /usr/bin 配下にあるので追加が必要な事が分かった。
pythonスクリプト中で$PATHを出力してみる必要がある。
Build.Dist/parsers/shrink-image/shrink-image に下記を追加。
path_value = os.environ.get('PATH', '')
path_value += ':/bin:/usr/bin:/sbin'
os.environ['PATH'] = path_value
上記を追加すると次のステップに進むが、次のエラーが出る。
checking shrink-image deps []
all deps satisfied for shrink-image
executing shrink-image deps []
checking compress-image deps ['unmount-image']
running jobs [(<Popen: returncode: None args: ['/mnt/nfs/home/exampleuser/workspace/git...>, 'shrink-image')]
30 1073741824
ERROR: failed to parse size 0K
ERROR: unable to resize 'image': Invalid argument
Traceback (most recent call last):
File "/mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/parsers/shrink-image/shrink-image", line 37, in <module>
check(p)
File "/mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/parsers/shrink-image/shrink-image", line 23, in check
raise RuntimeError(f"{p} exited non-zero: {p.poll()}")
RuntimeError: <Popen: returncode: 1 args: ['/usr/bin/env', 'btrfs', 'filesystem', 'resize'...> exited non-zero: 1
FATAL: JOB shrink-image FAILED with exit code 1
FATAL: JOB packgenpi FAILED with exit code 1
FATAL: JOB genpi64-lite-finalize FAILED with exit code 1
run complete.
resizeに失敗している。
現在のマウント状況としては、HDDイメージファイルをloopbackマウントしている。
# losetup -a
/dev/loop0: [0047]:226363202 (/mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/build/GenPi64Systemd/GenPi64
dfをすると
/dev/loop0p2 4579328 2639660 1422724 65% /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/build/GenPi64Systemd/image
/dev/loop0p1 260824 148284 112540 57% /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/build/GenPi64Systemd/image/boot
/etc/mtabで確認すると/ が btrfs、bootがvfatでマウントされている。 この/を縮小する意図と思われる。
/dev/loop0p2 /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/build/GenPi64Systemd/image btrfs rw,relatime,ssd,space_cache=v2,subvolid=5,subvol=/ 0 0
/dev/loop0p1 /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/build/GenPi64Systemd/image/boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro 0 0
pythonスクリプトの下記でエラーが出ている。
p = subprocess.Popen(['/usr/bin/env', 'btrfs', 'filesystem', 'resize', f'-{unused // 1024 - 1024*1024}K', 'image'])
イメージファイルは現状8GBだった。
-rw-r--r-- 1 root root 8.0G 7月 23 21:13 build/GenPi64Systemd/GenPi64Systemd.img
現在の使用量を見ると確かに8GB使っていない。
btrfs filesystem df build/GenPi64Systemd/image
Data, single: total=2.35GiB, used=1.99GiB
System, DUP: total=8.00MiB, used=16.00KiB
Metadata, DUP: total=512.00MiB, used=263.48MiB
GlobalReserve, single: total=15.17MiB, used=0.00B
スクリプト中のunusedを出力してみると 1073741824 だった。
unused // 1024 - 1024*1024 を計算してみると、
unused // 1024 = 1048576 1024*1024 = 1048576
引き算するとゼロになってしまう… この unused は意図したものだろうか?調べた。
pythonのコードを見ると
p = subprocess.Popen(['/usr/bin/env', 'btrfs', 'device', 'usage', '-b', 'image'], stdout=subprocess.PIPE)
check(p)
p.stdout.readline()
filesystemsize = int(p.stdout.readline().decode('utf-8').split(':',1)[1])
for i in range(4):
p.stdout.readline()
unused = int(p.stdout.readline().decode('utf-8').split(':',1)[1])
print(30, unused)
cd Build.Dist/build/GenPi64Systemd
sudo btrfs device usage -b image
/dev/loop0p2, ID: 1
Device size: 8321499136
Device slack: 3632267264
Data,single: 2524971008
Metadata,DUP: 1073741824
System,DUP: 16777216
Unallocated: 1073741824
Unallocated は未使用領域(約1GB)なので、この領域は縮めることができる。
pythonのコードに戻ると、
p = subprocess.Popen(['/usr/bin/env', 'btrfs', 'filesystem', 'resize', f'-{unused // 1024 - 1024*1024}K', 'image'])
1024*1024 の領域が丁度、1GBで、これを引いている。 気持ちはわかる。縮めすぎてしまうと問題が起こりそうだ… 安全のために1GB程度は残している、という意図だと思われる。 8GBというHDDイメージ領域がそろそろ狭くなっているのか、あまり余らなくなってきている、という状況と思われる。
ので、一旦、resizeする処理はスキップ(しても安全と思われるので)したい。 コメントアウトした。
# p = subprocess.Popen(['/usr/bin/env', 'btrfs', 'filesystem', 'resize', f'-{unused // 1024 - 1024*1024}K', 'image'])
# check(p)
HDDイメージの圧縮が始まった…! イメージ作成が完了した!
2023/09/26
そもそものディスクサイズを拡張した方が良さそう GenPi64Systemd.json この辺から処理を追う。 parsers/makeimage/makeimage あたりだろうか。
image = config[‘image’] (中略) system(f"truncate -s {image[‘size’]} {image[’name’]}”)
configでimageの設定を読み込んでいる。
config/pyconfig/GenPi64Config.py に 8GB という設定がある。
「フラグの管理」ってどうなるんだろうか? やり直したい。
2023/09/26 下記の対応が必要になった
k3s-stg-agent-e /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist # rm -rf build/GenPi64Systemd/chroot/etc/portage/binrepos.conf
このファイルがディレクトリになっている。本来はファイルなのだろうか? ダウンロードしてくる元レポジトリを確認する必要がありそう。
下記のエラーだった、どこかでディレクトリを作ってしまっている?
checking setup_services deps ['users']
checking news deps ['setup_services']
checking set_root_password deps ['news']
running jobs [(<Popen: returncode: None args: ['/mnt/nfs/home/exampleuser/workspace/git...>, 'portage')]
Copying portage config files for GenPi64Systemd
Writing config file /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/build/GenPi64Systemd/chroot/etc/portage/make.conf
Copying config file /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/build/GenPi64Systemd/chroot/etc/portage/savedconfig/sys-kernel/linux-firmware
Copying config file /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/build/GenPi64Systemd/chroot/etc/portage/env/dev-lang/python
Traceback (most recent call last):
File "/mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/parsers/portage/portage", line 68, in <module>
copydir(portage, f"{CHROOT_DIR}/etc/portage")
File "/mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/parsers/portage/portage", line 63, in copydir
copyconf(content, os.path.join(dest, node))
File "/mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/parsers/portage/portage", line 27, in copyconf
with open(file, 'w') as f:
IsADirectoryError: [Errno 21] Is a directory: '/mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/build/GenPi64Systemd/chroot/etc/portage/binrepos.conf'
FATAL: JOB portage FAILED with exit code 1
FATAL: JOB gentoo-base FAILED with exit code 1
run complete.
2023/09/30
export SHELL="/bin/bash”
- export SHELL=/bin/bash
- SHELL=/bin/bash export TERM=“linux”
- export TERM=linux
- TERM=linux export MAKEOPTS="-j4 -l4"
- export ‘MAKEOPTS=-j4 -l4’
- MAKEOPTS=’-j4 -l4’
emerge –verbose –update @world
emerge –verbose –update @world
IMPORTANT: 1 news items need reading for repository ‘genpi64’.
IMPORTANT: 10 news items need reading for repository ‘gentoo’.
Use eselect news read to view new items.
These are the packages that would be merged:
Calculating dependencies … done! Dependency resolution took 4.29 s.
emerge: there are no ebuilds to satisfy “app-portage/genup”. (dependency required by “@profile” [set]) (dependency required by “@world” [argument])
finish
ret=1
rm -f /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/build/GenPi64Systemd/chroot/em-3470
exit 1 FATAL: JOB emerge_new_profile FAILED with exit code 1 FATAL: JOB gentoo-base FAILED with exit code 1 run complete.
上記の対応として
vi build/GenPi64Systemd/chroot/var/db/repos/genpi64/profiles/targets/genpi64/packages 。 で
app-portage/genup のコメントアウトが必要だった。
2023/10/07 cmake-3.26.5 で The C++ compiler does not support C++11 (e.g. std::unique_ptr). のエラー
下記のエラーがでる。
Configuring source in /var/tmp/portage/dev-util/cmake-3.26.5-r2/work/cmake-3.26.5 …
- Source directory (CMAKE_USE_DIR): “/var/tmp/portage/dev-util/cmake-3.26.5-r2/work/cmake-3.26.5”
- Build directory (BUILD_DIR): “/var/tmp/portage/dev-util/cmake-3.26.5-r2/work/cmake-3.26.5_build” cmake -C /var/tmp/portage/dev-util/cmake-3.26.5-r2/work/cmake-3.26.5_build/gentoo_common_config.cmake -G Unix Makefiles -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_USE_SYSTEM_LIBRARIES=ON -DCMAKE_DOC_DIR=/share/doc/cmake-3.26.5-r2 -DCMAKE_MAN_DIR=/share/man -DCMAKE_DATA_DIR=/share/cmake -DSPHINX_MAN=no -DSPHINX_HTML=no -DBUILD_CursesDialog=yes -DBUILD_TESTING=no -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=/var/tmp/portage/dev-util/cmake-3.26.5-r2/work/cmake-3.26.5_build/gentoo_toolchain.cmake /var/tmp/portage/dev-util/cmake-3.26.5-r2/work/cmake-3.26.5 loading initial cache file /var/tmp/portage/dev-util/cmake-3.26.5-r2/work/cmake-3.26.5_build/gentoo_common_config.cmake – The C compiler identification is GNU 13.2.1 – The CXX compiler identification is GNU 13.2.1 – Detecting C compiler ABI info – Detecting C compiler ABI info - done – Check for working C compiler: /usr/lib/ccache/bin/aarch64-unknown-linux-gnu-gcc - skipped – Detecting C compile features – Detecting C compile features - done – Detecting CXX compiler ABI info – Detecting CXX compiler ABI info - done – Check for working CXX compiler: /usr/lib/ccache/bin/aarch64-unknown-linux-gnu-g++ - skipped – Detecting CXX compile features – Detecting CXX compile features - done – Checking if compiler supports C11_Thread_local – Checking if compiler supports C11_Thread_local - yes – Checking if compiler supports needed C++17 constructs – Checking if compiler supports needed C++17 constructs - yes – Checking if compiler supports C++ make_unique – Checking if compiler supports C++ make_unique - no – Checking if compiler supports C++ unique_ptr – Checking if compiler supports C++ unique_ptr - no – Checking if compiler supports C++ filesystem – Checking if compiler supports C++ filesystem - no CMake Error at CMakeLists.txt:93 (message): The C++ compiler does not support C++11 (e.g. std::unique_ptr).
– Configuring incomplete, errors occurred!
- ERROR: dev-util/cmake-3.26.5-r2::gentoo failed (configure phase):
- cmake failed
- Call stack:
ebuild.sh, line 136: Called src_configure- environment, line 2538: Called cmake_src_configure
- environment, line 1117: Called die
- The specific snippet of code:
"${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed";- If you need support, post the output of
emerge --info '=dev-util/cmake-3.26.5-r2::gentoo', - the complete build log and the output of
emerge -pqv '=dev-util/cmake-3.26.5-r2::gentoo'. - The complete build log is located at ‘/var/tmp/portage/dev-util/cmake-3.26.5-r2/temp/build.log.gz’.
- The ebuild environment file is located at ‘/var/tmp/portage/dev-util/cmake-3.26.5-r2/temp/environment’.
- Working directory: ‘/var/tmp/portage/dev-util/cmake-3.26.5-r2/work/cmake-3.26.5_build’
- S: ‘/var/tmp/portage/dev-util/cmake-3.26.5-r2/work/cmake-3.26.5’
ここでGentooのバグである可能性が指摘されている。
Gentooのバグトラッキングを見る。 691544 – dev-util/cmake-3.14.6 FEATURES=distcc - The C++ compiler does not support C++11 (e.g. std::unique_ptr)
NFS root で発生する模様。私はNFS rootではないが、NFS homeなので、同様の問題になっているのだろうか。
Also confirming that this issue can be caused by even tiny amounts of clock skew when building on NFS root.
NFS環境でのみ発生する問題のようだ、 dev-util/cmake-3.14.6のソースを修正し、チェックを行わないようにした所、ビルドが通るようになった。
micropython-1.17とgcc-13だとコンパイルできない。micropython これはパッケージ側の問題かもしれない
Failed to emerge dev-lang/micropython-1.17, Log file: ‘/var/tmp/portage/dev-lang/micropython-1.17/temp/build.log.gz’ Installing (3 of 11) sys-apps/busybox-1.36.1::gentoo Completed (3 of 11) sys-apps/busybox-1.36.1::gentoo Jobs: 4 of 11 complete, 1 failed Load avg: 2.65, 3.47, 3.21
- Package: dev-lang/micropython-1.17:0
- Repository: gentoo
- Maintainer: monsieurp@gentoo.org
- USE: arm64 elibc_glibc kernel_linux
- FEATURES: preserve-libs sandbox
Unpacking source… Unpacking micropython-1.17.tar.xz to /var/tmp/portage/dev-lang/micropython-1.17/work Source unpacked in /var/tmp/portage/dev-lang/micropython-1.17/work Preparing source in /var/tmp/portage/dev-lang/micropython-1.17/work/micropython-1.17 …
- Applying micropython-1.17-prevent-stripping.patch … [ ok ]
- Applying micropython-1.17-exclude-float-parse-tests.patch … [ ok ]
Source prepared. Configuring source in /var/tmp/portage/dev-lang/micropython-1.17/work/micropython-1.17 … Source configured. Compiling source in /var/tmp/portage/dev-lang/micropython-1.17/work/micropython-1.17 … make -j4 -l4 CC=aarch64-unknown-linux-gnu-gcc axtls Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity. make: Nothing to be done for ‘axtls’. make -j4 -l4 CC=aarch64-unknown-linux-gnu-gcc Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity. mkdir -p build-standard/genhdr mkdir -p build-standard/build-standard/ mkdir -p build-standard/extmod/ mkdir -p build-standard/lib/axtls/ssl/ mkdir -p build-standard/lib/axtls/crypto/ mkdir -p build-standard/lib/berkeley-db-1.xx/btree/ mkdir -p build-standard/ mkdir -p build-standard/shared/libc/ mkdir -p build-standard/shared/readline/ mkdir -p build-standard/shared/runtime/ mkdir -p build-standard/shared/timeutils/ make -C ../../mpy-cross/ make[1]: Entering directory ‘/var/tmp/portage/dev-lang/micropython-1.17/work/micropython-1.17/mpy-cross’ Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity. mkdir -p build/genhdr mkdir -p build/ mkdir -p build/py/ mkdir -p build/shared/runtime/ GEN build/genhdr/mpversion.h GEN build/genhdr/moduledefs.h GEN build/genhdr/qstr.i.last GEN build/genhdr/qstr.split GEN build/genhdr/qstrdefs.collected.h QSTR updated GEN build/genhdr/qstrdefs.generated.h CC ../py/mpstate.c CC ../py/nlr.c CC ../py/nlrx86.c CC ../py/nlrx64.c CC ../py/nlrthumb.c CC ../py/nlraarch64.c CC ../py/nlrpowerpc.c CC ../py/nlrxtensa.c CC ../py/nlrsetjmp.c CC ../py/malloc.c CC ../py/gc.c CC ../py/pystack.c CC ../py/qstr.c CC ../py/vstr.c CC ../py/mpprint.c CC ../py/unicode.c CC ../py/mpz.c CC ../py/reader.c CC ../py/lexer.c CC ../py/parse.c CC ../py/scope.c CC ../py/compile.c CC ../py/emitcommon.c CC ../py/emitbc.c CC ../py/asmbase.c CC ../py/asmx64.c CC ../py/emitnx64.c CC ../py/asmx86.c CC ../py/emitnx86.c CC ../py/asmthumb.c CC ../py/emitnthumb.c CC ../py/emitinlinethumb.c CC ../py/asmarm.c CC ../py/emitnarm.c CC ../py/asmxtensa.c CC ../py/emitnxtensa.c CC ../py/emitinlinextensa.c CC ../py/emitnxtensawin.c CC ../py/formatfloat.c CC ../py/parsenumbase.c CC ../py/parsenum.c CC ../py/emitglue.c CC ../py/persistentcode.c CC ../py/runtime.c CC ../py/runtime_utils.c CC ../py/scheduler.c CC ../py/nativeglue.c CC ../py/pairheap.c CC ../py/ringbuf.c CC ../py/stackctrl.c ../py/stackctrl.c: In function ‘mp_stack_ctrl_init’: ../py/stackctrl.c:32:32: error: storing the address of local variable ‘stack_dummy’ in ‘mp_state_ctx.thread.stack_top’ [-Werror=dangling-pointer=] 32 | MP_STATE_THREAD(stack_top) = (char *)&stack_dummy; ../py/stackctrl.c:31:18: note: ‘stack_dummy’ declared here 31 | volatile int stack_dummy;
| ^~~~~~~~~~~
In file included from ../py/runtime.h:29,
from ../py/stackctrl.c:27:
../py/mpstate.h:287:23: note: ‘mp_state_ctx’ declared here 287 | extern mp_state_ctx_t mp_state_ctx;
| ^~~~~~~~~~~~
cc1: all warnings being treated as errors make[1]: [../py/mkrules.mk:77: build/py/stackctrl.o] Error 1 make[1]: Leaving directory ‘/var/tmp/portage/dev-lang/micropython-1.17/work/micropython-1.17/mpy-cross’ make: [../../py/mkrules.mk:142: ../../mpy-cross/mpy-cross] Error 2
- ERROR: dev-lang/micropython-1.17::gentoo failed (compile phase):
- emake failed
- If you need support, post the output of
emerge --info '=dev-lang/micropython-1.17::gentoo', - the complete build log and the output of
emerge -pqv '=dev-lang/micropython-1.17::gentoo'. - The complete build log is located at ‘/var/tmp/portage/dev-lang/micropython-1.17/temp/build.log.gz’.
- The ebuild environment file is located at ‘/var/tmp/portage/dev-lang/micropython-1.17/temp/environment’.
- Working directory: ‘/var/tmp/portage/dev-lang/micropython-1.17/work/micropython-1.17/ports/unix’
- S: ‘/var/tmp/portage/dev-lang/micropython-1.17/work/micropython-1.17’
再度ビルドを試すがダメだった。パッケージの状況を見ると1.17はまだ検証中なのでしばらく待ってみる。
古いバージョンを利用すれば行けるか? とeixで確認してみるが使えない模様
k3s-stg-agent-e / # eix dev-lang/micropython
- dev-lang/micropython Available versions: m1.17^t {test}
Homepage: <https://github.com/micropython/micropython>
Description: Python implementation for microcontrollers
1.17でどうにかするしか無いか…
micropython側の対応を調べてみると下記が見つかった。
make mpy-cross “-Werror=dangling-pointer=” error · micropython · Discussion #12027
static変数の使用は正しくないが、このケースでのぶら下がりポインタはこのケースでは意図的という指摘がある。
下記のファイルに修正を加えた。
build/GenPi64Systemd/chroot/var/tmp/portage/dev-lang/micropython-1.17/work/micropython-1.17/py/stackctrl.c
include “py/runtime.h”
include “py/stackctrl.h”
pragma GCC diagnostic push
pragma GCC diagnostic ignored “-Wdangling-pointer=1”
void mp_stack_ctrl_init(void) {
volatile int stack_dummy;
MP_STATE_THREAD(stack_top) = (char *)&stack_dummy;
}
pragma GCC diagnostic pop
void mp_stack_set_top(void *top) {
MP_STATE_THREAD(stack_top) = top;
}
micropythonのGithubを見たところ既にwarningを無視するコードが入っている。 https://github.com/micropython/micropython/blob/516385c4ccbb1f7fa9dbd37a44ed8ae33dcf1942/py/stackctrl.c#L31C3-L31C3 GNUCのバージョンが13以上で無視する模様。
Gentoo側のソースには、この処理は入っていない。 Gentoo側も新しいソースを参照すれば解決するかもしれない。
似たイシューがGentooのBugzillaでも上がっている。 911163 – dev-lang/micropython-1.17 fails to compile (PYTHON-3.12-SYSTEM): stackctrl.c:32:32: error: storing the address of local variable [-Werror=dangling-pointer=]
Gentooが新しいバージョンを採用した方が良さそう。 そもそも、なぜ私が環境変数を減らすとこのエラーがでるようになったんだろうか…?
chroot環境でない、実機側の /etc/portage/make.conf を見ると
CC="/usr/bin/gcc-12" CXX="/usr/bin/gcc-12"
という記述があった。これだ。emergeする時にgcc-12を使っている。 またchtoot環境でない実機だとgcc-12は/usr/bin配下にインストールされるのに対し、chroot環境では/usr/sbin/gcc-13 にインストールされる。 gcc-12はインストールされていない。
Gentoo本家がmicropythonのバージョンを上げるのが妥当だと思うが、結構、放置されているので、手元でなんとかできないか…? chroot環境に入ってgcc-12のslotをインストールして chroot環境下の /etc/portage/make.confを修正するのが良さそう。
chtoot環境に入る。 /etc/resolv.confが無いので下記内容を追加。
nameserver 8.8.8.8 nameserver 8.8.4.4
ビルドをためす。ただ依存関係が激しい…
emerge -a sys-devel/gcc:12
上手くいったら https://github.com/GenPi64/Build.Dist/blob/master/config/package.mask このファイルでgcc-13をマスクするようにプルリクを書きたい。
gcc-12であればコンパイルできる。
gcc-12をコンパイルしたところgcc-13と同居する形でインストールされた。 このためmake.confに下記を追記する形で検証した。コンパイルはできる。
CC="/usr/sbin/gcc-12" CXX="/usr/sbin/gcc-12"
stage3の取得でいきなりエラーが出る 2023/10/15
https://mirror.init7.net/gentoo/releases/arm64/autobuilds/ を見ると定期的にビルドされている(凄い)ので、しばらく様子を見よう。
checking set_root_password deps ['news']
running jobs [(<Popen: returncode: None args: ['/mnt/nfs/home/exampleuser/workspace/git...>, 'downloadstage3')]
+ pushd /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist
/mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist
++ /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/parsers/config/getconfig stage3
+ stage3=stage3-arm64-systemd-mergedusr.tar.xz
++ /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/parsers/config/getconfig stage3url
+ stage3_url=https://mirror.init7.net/gentoo/releases/arm64/autobuilds/latest-stage3-arm64-systemd-mergedusr.txt
++ wget https://mirror.init7.net/gentoo/releases/arm64/autobuilds/latest-stage3-arm64-systemd-mergedusr.txt -O -
++ tail -n 1
++ cut -f 1 -d ' '
--2023-10-15 22:32:49-- https://mirror.init7.net/gentoo/releases/arm64/autobuilds/latest-stage3-arm64-systemd-mergedusr.txt
Resolving mirror.init7.net... 109.202.202.202, 2001:1620::1620
Connecting to mirror.init7.net|109.202.202.202|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 682 [text/plain]
Saving to: 'STDOUT'
- 100%[==========================================================>] 682 --.-KB/s in 0s
2023-10-15 22:32:51 (201 MB/s) - written to stdout [682/682]
+ stage3_image=-----END
++ /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/parsers/config/getconfig stage3mirror
+ stage3_mirror=https://mirror.init7.net/gentoo/releases/arm64/autobuilds/
++ wget https://mirror.init7.net/gentoo/releases/arm64/autobuilds//-----END.DIGESTS -O -
--2023-10-15 22:32:51-- https://mirror.init7.net/gentoo/releases/arm64/autobuilds//-----END.DIGESTS
Resolving mirror.init7.net... 109.202.202.202, 2001:1620::1620
Connecting to mirror.init7.net|109.202.202.202|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2023-10-15 22:32:52 ERROR 404: Not Found.
+ stage3_digests=
FATAL: JOB downloadstage3 FAILED with exit code 8
FATAL: JOB gentoo-base FAILED with exit code 1
run complete.
Todo
現状、ビルドが通るために下記の手作業が必要だが不要にしたい
chroot環境の環境変数SCRIPTの処理
diff --git a/scripts/chroot.py b/scripts/chroot.py
index 77236a7..b142e0c 100755
--- a/scripts/chroot.py
+++ b/scripts/chroot.py
@@ -13,6 +13,17 @@ if not os.path.exists(os.environ['BINPKGS_DIR']):
if not os.path.exists(os.environ['DISTFILES_DIR']):
os.mkdir(os.environ['DISTFILES_DIR'])
+print(os.environ)
+
+new_environ = {
+ "BINPKGS_DIR": os.environ["BINPKGS_DIR"],
+ "CCACHE_DIR": os.environ["CCACHE_DIR"],
+ "CHROOT_DIR": os.environ["CHROOT_DIR"],
+ "DISTFILES_DIR": os.environ["DISTFILES_DIR"],
+ "CC": "/usr/bin/gcc-12",
+ "CXX": "/usr/bin/gcc-12"
+}
+
# Retain old behavior
if 'CHROOT_CMD' in os.environ:
chroot_cmd = os.environ.get('CHROOT_CMD')
@@ -44,6 +55,7 @@ elif os.path.exists('/sbin/openrc-run'):
'-B', f'{os.environ["DISTFILES_DIR"]}:/var/cache/distfiles',
os.environ['CHROOT_DIR'],
*sys.argv[1:]], os.environ)
+ # *sys.argv[1:]], new_environ)
elif 'systemd' in os.readlink('/proc/1/exe'):
os.execvpe('systemd-nspawn',
['systemd-nspawn',
PATHを広げる
diff --git a/parsers/shrink-image/shrink-image b/parsers/shrink-image/shrink-image
index 7212935..4b91e45 100755
--- a/parsers/shrink-image/shrink-image
+++ b/parsers/shrink-image/shrink-image
@@ -5,6 +5,10 @@ import subprocess
import time
sys.path.append(os.environ['CONFIG_DIR'])
+path_value = os.environ.get('PATH', '')
+path_value += ':/bin:/usr/bin:/sbin'
+os.environ['PATH'] = path_value
+
from pyconfig import config
SDカードイメージを15GBに変更
config/pyconfig/GenPi64Config.py
gcc-13 ではなく gcc-12 を使うように変更
できあがったSDカードイメージで起動後
make.confの次の行をコメントアウトする作業が必要になる。
EMERGE_DEFAULT_OPTS="--jobs --newrepo --newuse --changed-use --changed-deps --changed-slot --deep --tree --unordered-display --nospinner --backtrack=3000 --complete-graph --with-bdeps=y --rebuild-if-new-rev --rebuild-if-new-ver --rebuild-if-unbuilt --rebuilt-binaries --binpkg-respect-use=y --binpkg-changed-deps=y --usepkg=y --buildpkg-exclude 'virtual/* sys-kernel/*-sources */*-bin acct-user/* acct-group/*'"
–deepが入っているから初めて入れるパッケージで大量のインストールが必要になる。
ansibleでloadavgとジョブ数を自動的に設定するようにしたい
coreの数が2と4で適切なロードアベレージが違うのでcore数を取得してmake.confを書き換える処理を書きたい それとジョブ数を2にしたい。
EMERGE_DEFAULT_OPTS="–jobs 2" とする事でジョブ数を設定できる。
EAPI6のエラーが出る 2024/08/20
Gentoo側がEAPI7に移行しているので、EAPI6のパッケージがエラーを出すようになったかもしれない。 ローカルのebuildファイルの6の記述を7に変更するとビルドが次に進んだ。
vi build/GenPi64Systemd/chroot/var/db/repos/genpi64/net-wireless/rpi3-bluetooth/rpi3-bluetooth-1.2.ebuild
vi build/GenPi64Systemd/chroot/var/db/repos/genpi64/net-wireless/rpi3-bluetooth/rpi3-bluetooth-1.1-r4.ebuild
vi build/GenPi64Systemd/chroot/var/db/repos/genpi64/sys-firmware/bcm4340a1-firmware/bcm4340a1-firmware-1.2.ebuild
emerge --verbose --update @world
+ emerge --verbose --update @world
* IMPORTANT: 1 news items need reading for repository 'genpi64'.
* IMPORTANT: 12 news items need reading for repository 'gentoo'.
* Use eselect news read to view new items.
These are the packages that would be merged:
Calculating dependencies . * ERROR: sys-firmware/bcm4340a1-firmware-1.2-r1::genpi64 failed (depend phase):
* git-r3: EAPI 6 not supported
*
* Call stack:
* ebuild.sh, line 632: Called source '/var/db/repos/genpi64/sys-firmware/bcm4340a1-firmware/bcm4340a1-firmware-1.2-r1.ebuild'
* bcm4340a1-firmware-1.2-r1.ebuild, line 2: Called inherit 'git-r3'
* ebuild.sh, line 312: Called __qa_source '/var/db/repos/gentoo/eclass/git-r3.eclass'
* ebuild.sh, line 123: Called source '/var/db/repos/gentoo/eclass/git-r3.eclass'
* git-r3.eclass, line 30: Called die
* The specific snippet of code:
* *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
*
* If you need support, post the output of `emerge --info '=sys-firmware/bcm4340a1-firmware-1.2-r1::genpi64'`,
* the complete build log and the output of `emerge -pqv '=sys-firmware/bcm4340a1-firmware-1.2-r1::genpi64'`.
* Working directory: '/usr/lib/python3.12/site-packages'
* S: '/var/tmp/portage/sys-firmware/bcm4340a1-firmware-1.2-r1/work/bcm4340a1-firmware-1.2'
. * ERROR: net-wireless/rpi3-bluetooth-1.1-r7::genpi64 failed (depend phase):
* git-r3: EAPI 6 not supported
*
* Call stack:
* ebuild.sh, line 632: Called source '/var/db/repos/genpi64/net-wireless/rpi3-bluetooth/rpi3-bluetooth-1.1-r7.ebuild'
* rpi3-bluetooth-1.1-r7.ebuild, line 6: Called inherit 'git-r3'
* ebuild.sh, line 312: Called __qa_source '/var/db/repos/gentoo/eclass/git-r3.eclass'
* ebuild.sh, line 123: Called source '/var/db/repos/gentoo/eclass/git-r3.eclass'
* git-r3.eclass, line 30: Called die
* The specific snippet of code:
* *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
*
* If you need support, post the output of `emerge --info '=net-wireless/rpi3-bluetooth-1.1-r7::genpi64'`,
* the complete build log and the output of `emerge -pqv '=net-wireless/rpi3-bluetooth-1.1-r7::genpi64'`.
* Working directory: '/usr/lib/python3.12/site-packages'
* S: '/var/tmp/portage/net-wireless/rpi3-bluetooth-1.1-r7/work/rpi3-bluetooth-1.1'
* ERROR: net-wireless/rpi3-bluetooth-1.1-r5::genpi64 failed (depend phase):
* git-r3: EAPI 6 not supported
*
* Call stack:
* ebuild.sh, line 632: Called source '/var/db/repos/genpi64/net-wireless/rpi3-bluetooth/rpi3-bluetooth-1.1-r5.ebuild'
* rpi3-bluetooth-1.1-r5.ebuild, line 6: Called inherit 'git-r3'
* ebuild.sh, line 312: Called __qa_source '/var/db/repos/gentoo/eclass/git-r3.eclass'
* ebuild.sh, line 123: Called source '/var/db/repos/gentoo/eclass/git-r3.eclass'
* git-r3.eclass, line 30: Called die
* The specific snippet of code:
* *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
*
* If you need support, post the output of `emerge --info '=net-wireless/rpi3-bluetooth-1.1-r5::genpi64'`,
* the complete build log and the output of `emerge -pqv '=net-wireless/rpi3-bluetooth-1.1-r5::genpi64'`.
* Working directory: '/usr/lib/python3.12/site-packages'
* S: '/var/tmp/portage/net-wireless/rpi3-bluetooth-1.1-r5/work/rpi3-bluetooth-1.1'
.... done!
Dependency resolution took 18.50 s (backtrack: 1/3000).
参考
systemdだとhostnameが設定できない可能性がある
distccを検証している情報がある
Build Fails 1/4/2023 · Issue #179 · GenPi64/Build.Dist
crudini でエラーが出る?
Broken-wont-work: Use crudini to set initramfs by jonesmz · Pull Request #142 · GenPi64/Build.Dist
シェル関連で修正が入ったタイミング
Some minor improvements for the shell code by maffblaster · Pull Request #157 · GenPi64/Build.Dist