You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a gok build command that allows to build an image without writing it to a device.
Rationale
Building an image is already possible withgok overwrite --full <file> --target_storage_bytes <bytes>.
However, the gok overwrite command requires much OS-specific code to write the image, especially as this usually requires admin privileges. That part could be handled by other platform specific tool (ex: rufus) that a user could invoke independently of gok once an image is built.
Currently it is not possible to build gok on Windows because of the overwrite command because it is dependent on Unix-specific bits such as dependency on non-portable module golang.org/x/unix.
If gok was refactored to isolate a build command, a developer (well, myself 😜 ) could more easily make a version of gok available on Windows with the build command but, as a first step, without the overwrite command. And port the overwrite command later.
I don’t think introducing a separate command to the CLI is necessary or helpful for making gok work on Windows, which I think is your actual goal :)
In fact, I’ll do you one better: with the two most recent commits, gok now builds and runs on Windows:
Microsoft Windows [Version 10.0.22631.4751]
(c) Microsoft Corporation. All rights reserved.
michael stapelberg@BEAST C:\Users\Michael Stapelberg\gokrazy\hello>"C:\Users\Michael Stapelberg\gok" overwrite --root root.squashfs
2025/05/29 14:29:54 gokrazy gok g5b15ff+ on GOARCH=amd64 GOOS=windows
2025/05/29 14:29:54
2025/05/29 14:29:54 Build target: CGO_ENABLED=0 GOARCH=arm64 GOARCH=arm64 GOOS=linux GOOS=linux
2025/05/29 14:29:54 Build timestamp: 2025-05-29T14:29:54+02:00
2025/05/29 14:29:54 Loading system CA certificates from bundled Mozilla CA list
2025/05/29 14:29:54 Building 3 Go packages:
2025/05/29 14:29:54
2025/05/29 14:29:54 github.com/gokrazy/fbstatus
2025/05/29 14:29:54
2025/05/29 14:29:54 github.com/gokrazy/hello
2025/05/29 14:29:54
2025/05/29 14:29:54 github.com/gokrazy/serial-busybox
2025/05/29 14:29:54
[building (go compiler)]go: finding module for package github.com/gokrazy/gokrazy/cmd/dhcp
go: downloading github.com/gokrazy/gokrazy v0.0.0-20250520211131-8916805aa0c7
go: finding module for package github.com/gokrazy/gokrazy/cmd/dhcp
go: toolchain upgrade needed to resolve github.com/gokrazy/gokrazy/cmd/dhcp
go: github.com/gokrazy/gokrazy@v0.0.0-20250520211131-8916805aa0c7 requires go >= 1.24 (running go 1.23.6)
2025/05/29 14:29:57 getting incomplete packages [github.com/gokrazy/gokrazy/cmd/dhcp]
[…]
[done] in 58.29s
2025/05/29 14:30:52
2025/05/29 14:30:54 Including extra files for Go packages:
2025/05/29 14:30:54
2025/05/29 14:30:54 github.com/gokrazy/serial-busybox
2025/05/29 14:30:54 will include extra files in the root file system
2025/05/29 14:30:54 from C:\Users\Michael Stapelberg\go\pkg\mod\github.com\gokrazy\serial-busybox@v0.0.0-20250119153030-ac58ba7574e7\_gokrazy\extrafiles_arm64.tar
2025/05/29 14:30:54 last modified: 2025-01-19T15:59:16+01:00 (3117h31m38s ago)
2025/05/29 14:30:54
2025/05/29 14:30:54 Including loadable kernel modules from:
2025/05/29 14:30:54 C:\Users\Michael Stapelberg\go\pkg\mod\github.com\gokrazy\kernel.rpi@v0.0.0-20250520195459-906287a872d7\lib\modules
2025/05/29 14:30:55
2025/05/29 14:30:55 Feature summary:
2025/05/29 14:30:55 use GPT: true
2025/05/29 14:30:55 use PARTUUID: true
2025/05/29 14:30:55 use GPT PARTUUID: true
2025/05/29 14:30:55
2025/05/29 14:30:55 Creating root file system
[done] in 0.78s
2025/05/29 14:30:56
2025/05/29 14:30:56 Build complete!
2025/05/29 14:30:56
2025/05/29 14:30:56 To interact with the device, gokrazy provides a web interface reachable at:
2025/05/29 14:30:56
2025/05/29 14:30:56 http://gokrazy:redacted@hello/
2025/05/29 14:30:56
2025/05/29 14:30:56 In addition, the following Linux consoles are set up:
2025/05/29 14:30:56
2025/05/29 14:30:56 1. foreground Linux framebuffer console on HDMI
2025/05/29 14:30:56
The resulting squashfs image still has a few issues:
The \etc/machine-id is wrong, and similar for usr\local\bin/busybox. In both cases, the OS path separator (\) leaks into the output file system, which should unconditionally use / (forward slashes). Maybe you can send a PR to fix this issue and any other potential Windows-specific issues? I don’t use Windows myself.
Activity
packer: move unix-specific code into build tag guarded files
gok add: use renameio/maybe on GOOS=windows
[-]Refactor `overwrite` and extract a `build` command[/-][+]Make gok work on Windows[/+]stapelberg commentedon May 29, 2025
I don’t think introducing a separate command to the CLI is necessary or helpful for making gok work on Windows, which I think is your actual goal :)
In fact, I’ll do you one better: with the two most recent commits, gok now builds and runs on Windows:
The resulting squashfs image still has a few issues:
The
\etc/machine-idis wrong, and similar forusr\local\bin/busybox. In both cases, the OS path separator (\) leaks into the output file system, which should unconditionally use/(forward slashes). Maybe you can send a PR to fix this issue and any other potential Windows-specific issues? I don’t use Windows myself.GitHub Actions: verify gok builds on Windows and macOS, too
GitHub Actions: verify gok builds on Windows and macOS, too
GitHub Actions: verify gok builds on Windows and macOS, too