Build.distでビルドできなかったのでプルリクを作成した
Posted:
背景
2023/06時点、ラズパイ上でのGentooが起動するGenPi64をゼロからイメージ作成するBuild.Distはイメージ作成に失敗する。
私が成功するまで3つ程、ハードルがあったのでプルリクを作成したい。 その時のメモ。
原因
parsers/rawcommand/rawcommand、シェルのヒアドキュメントの箇所で、本来、タブであるべき所が空白になってしまっている。
画面上は分かりにくいがgit pullすると確認できる。 また全てのシェルスクリプトがNGという訳ではなく、他のシェルスクリプトはタブになっていた。
この問題に起因すると思われるイシュー
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 は基本的な処理だと思うが。
- systemd-nspawn だと上手くいくらしい。別のフローに入るのだろうか?
- “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.`”
- 内容を調査する
過去の経緯を軽く確認
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 の設定が入っていないだろうか?
既に近いプルリクがある
Jan 14 2023 poole by jlpoolen · Pull Request #185 · GenPi64/Build.Dist
そのコメントで causes the written file to have all leading whitespace omitted. This change shouldn’t be necessary.と答えてる方がいる。
cat <<- EOF > filename
causes the written file to have all leading whitespace omitted.
This change shouldn't be necessary.
https://linuxize.com/post/bash-heredoc/
いや、bashのヒアドキュメントの場合、タブは削除されるけど、空白は削除されないような… 参照先リンクを見てみる。
Appending a minus sign to the redirection operator <<-,
will cause all leading tab characters to be ignored.
This allows you to use indentation when writing here-documents in shell scripts.
Leading whitespace characters are not allowed, only tab.
エディタ上で空白とタブが見分けが付きにくいからなぁ。 あとプルリク側も空白を全て消すのではなく、タブだったらな、とも思う。
一旦、コメントを残す。
時間がたったプルリクへのコメントで申し訳ない。 このファイルの問題かと思って、このコメントに辿り着きました。 参考のURL( https://linuxize.com/post/bash-heredoc/ )のコメントを見ると下記のように書いてありました。
Appending a minus sign to the redirection operator <<-,
will cause all leading tab characters to be ignored.
This allows you to use indentation when writing here-documents in shell scripts.
Leading whitespace characters are not allowed, only tab.
この記述方法はタブは消してくれるのですが、スペースは消してくれないようです。 ただしタブは消してくれます。 例えば他のヒアドキュメント、例えば Build.Dist/parsers/emerge/emerge はタブです。
私にはコミットでは空白を全て消しているように見えました。 ですがタブに変更する事で動作もできます。
プルリク出した
change white space to tabs by exampleuser · Pull Request #205 · GenPi64/Build.Dist