gokrazy / tools

this repository contains the gok CLI tool of gokrazy
https://gokrazy.org
BSD 3-Clause "New" or "Revised" License
50 stars 26 forks source link

Using `replace` to test a locally compiled kernel triggers `CheckDir(...): ... malformed file path ...` #72

Closed oliverpool closed 1 day ago

oliverpool commented 3 days ago

I am compiling https://github.com/gokrazy-community/kernel-rpi-os-32 locally. When I adjust the go.mod file to use it:

replace github.com/gokrazy-community/kernel-rpi-os-32 => /home/path/to/kernel-rpi-os-32

I get an error:

Including loadable kernel modules from:
/home/path/to/kernel-rpi-os-32/dist/lib/modules
2024/07/02 23:34:23 CheckDir(/home/path/to/kernel-rpi-os-32): /home/path/to/kernel-rpi-os-32/linux-sources/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c: malformed file path "linux-sources/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c": "aux" disallowed as path element component on Windows

This is due to: https://github.com/gokrazy/tools/blob/41f11fbe3a53695e8ad701b98ec105d4b88084b6/internal/packer/sbom.go#L143 which calls hashDir, which calls zip.CheckDir, which is unhappy.

Ideally, only the dist subdir should be checked (since this is the actually imported path).

stapelberg commented 3 days ago

Huh, this is the first time I realize that the kernel-rpi-os-32 includes the sources as a git submodule. I wonder if that’s necessary? The other kernel repositories don’t do that and hence don’t run into this issue.

oliverpool commented 3 days ago

the sources as a git submodule

Pros:

Cons:

I should probably study how you compile the kernel for the rpi64 and adjust my code accordingly...

oliverpool commented 1 day ago

I found a simple workaround: disguise the submodule as a go module by adding a go.mod file: https://github.com/gokrazy-community/kernel-rpi-os-32/commit/53b1566e0ecec36177ac4644d08001f1f84e8174

This workaround could be documented in the error message. Something like CheckDir failed, visit https://github.com/gokrazy/tools/issues/72 for a possible workaround: ....