37 Commits

Author SHA1 Message Date
Michael Stapelberg
1921f918ee cleanup: inline programName now that the old packer is gone 2025-12-06 20:23:57 +01:00
Michael Stapelberg
52cab9f145 packer: stop using updateflag global state
related to https://github.com/gokrazy/tools/pull/68
2025-12-06 08:37:24 +01:00
Michael Stapelberg
2c805ed001 refactor cobra command initialization to avoid stale state
Before this commit, we held onto *cobra.Command objects,
but that is not actually supported: after the first Execute(),
commands like updateCmd are stuck on the first-ever provided ctx.

Instead, turn command initialization into functions.

I only noticed this when trying to do two 'gok update'
from within the same test, where the fake build timestamp
is injected via the context (the timestamp was always the same).
2025-11-29 10:47:48 +01:00
Michael Stapelberg
9a9519186b integration: add 'gok update' test
Some checks failed
gokrazy CI / CI (macos-latest) (push) Has been cancelled
gokrazy CI / CI (ubuntu-latest) (push) Has been cancelled
gokrazy CI / CI (windows-latest) (push) Has been cancelled
2025-10-03 19:12:17 +02:00
Michael Stapelberg
ab76ef531d update to latest gokrazy/updater (now needs a context) 2025-06-01 08:57:36 +02:00
Michael Stapelberg
2e390edb12 gok vm run: print a tip for how to enable the serial console
This should make it a little easier for users.
2025-05-30 19:00:00 +02:00
Michael Stapelberg
6ae0267df2 gok add: use renameio/maybe on GOOS=windows
related to https://github.com/gokrazy/tools/issues/89
2025-05-29 16:23:38 +02:00
Michael Stapelberg
f606b3de4f gok sbom: buffer build output and only print (to stderr!) on error
fixes https://github.com/gokrazy/tools/issues/91
2025-05-29 15:26:31 +02:00
Michael Stapelberg
105d190cbc internal/packer: introduce Pack.Env (with a logger) and log to it
related to https://github.com/gokrazy/tools/issues/91
2025-05-29 15:26:31 +02:00
Michael Stapelberg
bdb09ed67a gok vm run: pass extra arguments to QEMU as-is
fixes https://github.com/gokrazy/tools/issues/87
2025-04-17 17:03:41 +02:00
Michael Stapelberg
4f97436034 implement Package.GoBuildEnvironment option
This allows setting e.g. CGO_ENABLED=1 for only specific programs.
2025-03-30 11:14:56 +02:00
thielepaul
b0f9892141 allow overriding basename in package config (#86)
related to https://github.com/gokrazy/gokrazy/issues/303
2025-02-27 20:28:19 +01:00
Michael Stapelberg
a5127466af add gok ps — the output is still quite minimal
This command might become useful on its own in the future,
but for now mostly demonstrates how to use the gokapi package.
2025-02-22 09:05:31 +01:00
Michael Stapelberg
ed3a455463 gok vm run: allocate 512 MB of /perm disk 2025-02-21 21:29:52 +01:00
Michael Stapelberg
703a860502 sbom: do not hash source files, record buildid of binaries instead
Before this commit, the mere presence of files with certain names in local
package directories would make the build fail (see nonmodulefiles_test.go).

With this commit, we now record the buildinfo and buildid of all built Go
programs of this gokrazy instance.

related to https://github.com/gokrazy/gokrazy/issues/297

fixes https://github.com/gokrazy/gokrazy/issues/299
2025-02-21 18:51:16 +01:00
andig
6316042495 gok vm: add -netdev command-line flag (#79) 2025-01-28 21:01:51 +01:00
Damiano Donati
9a2d41569f use newest arm64 UEFI and amd64 OVMF CODE/VARS firmware (#81)
it updates the arm64 UEFI firmware to a version newer than 2023.11,
as running on qemu >= 9.0 can trigger a bug in the older versions of the EDK2 guest firmware,
causing Synchronous Exception and potential bootloops.

While doing so it updates the amd64 OVMF firmware, which now has removed
support for the 2M firmware and only supports the 4M one.
The 4M OVMF firmware comes with split CODE and VARS images, which need
to be loaded as pflash drives in the qemu vm, rather than via the -bios
flag.

For more details on the migration see: https://salsa.debian.org/qemu-team/edk2/-/blob/debian/latest/debian/howto-2M-to-4M-migration.md

Fixes https://github.com/gokrazy/tools/issues/80
2025-01-28 19:00:02 +01:00
Michael Stapelberg
28d96f8788 gok new: add GOOS and GOARCH by default
related to https://github.com/gokrazy/gokrazy/issues/191
2025-01-26 22:49:25 +01:00
Michael Stapelberg
5f4d95c2d4 gok: apply Environment from config.json
For gok vm run, this means an explicit -arch=amd64 or -arch=arm64
might become necessary. In general, I recommend configuring
GOOS and GOARCH in config.json explicitly:

    {
        "Hostname": "repro",
        "Environment": [
            "GOOS=linux",
            "GOARCH=amd64"
        ],
    […]

related to https://github.com/gokrazy/gokrazy/issues/191
2025-01-26 22:43:19 +01:00
Michael Stapelberg
ea613267ff gok new: use relative path for breakglass.authorized_keys
related to https://github.com/gokrazy/gokrazy/issues/289
2025-01-22 21:41:48 +01:00
Michael Stapelberg
ca8464f58d overwrite: add --trace_file flag for performance analysis
related to https://github.com/gokrazy/gokrazy/issues/287
2025-01-13 21:56:14 +01:00
Michael Stapelberg
6bec690fe5 add embedded version of edk2 firmware files
Whether edk2 is available on operating systems varies,
so the best choice is to embed the amd64/arm64 EFI files.

We need these files to boot amd64 images in EFI mode,
and also for arm64 images to boot at all.
2024-09-27 08:21:46 +02:00
Michael Stapelberg
b8ffcd451e gok: add vm run subcommand
This is inspired by https://github.com/damdo/gokrazy-machine :)
2024-09-26 22:12:36 +02:00
Michael Stapelberg
a2dd9b9a09 sbom: move os.Chdir into 'gok sbom' (but not gokr-packer)
fixes #51
2024-09-09 17:20:07 +02:00
Damiano Donati
1c3069c7e6 fix sbom generation inconsistency, take 2 (#66) 2023-10-25 08:39:46 +02:00
Michael Stapelberg
231dea4b57 gok edit: run $EDITOR/$VISUAL through /bin/sh -c
This makes command line arguments in these environment variables work,
e.g. 'code -w', or 'emacs -q'

fixes https://github.com/gokrazy/gokrazy/issues/217
2023-09-21 19:13:28 +02:00
oliverpool
ea81144d87 gok: fix adding module with uppercase letters (#53) 2023-04-06 12:18:53 +02:00
Michael Stapelberg
fe8d59ca7d add gok push
related to https://github.com/gokrazy/gokrazy/issues/167
2023-02-19 15:03:41 +01:00
Michael Stapelberg
2b758083ad gok add: resolve Go module, use go.mod from upstream
fixes https://github.com/gokrazy/gokrazy/issues/172
2023-02-14 22:21:52 +01:00
Michael Stapelberg
b4784d268c pull in latest gokrazy/updater for Divert() fallback fix 2023-02-06 23:05:40 +01:00
Mark Drayton
8c7ed9ae16 gok: pass command line flags to run 2023-02-06 20:54:01 +01:00
Michael Stapelberg
2b269a6d8d correctly plumb through config struct to GenerateSBOM 2023-02-05 21:43:49 +01:00
Damiano Donati
7e4c5df8fb gok overwrite: add gaf as output format
gaf is the new gokrazy archive format output type.
It is immagined for storage and upgrade.
A single, uncompressed zip archive files that contains:
- the MBR image (mbr.img)
- the boot image (boot.img)
- the root image (root.img)
- the SBOM of the gokrazy build (sbom.json)

It is lighter in size than a "full" disk image (it doesn't have the
partition filling bits).
It contains all the necessary bits to upgrade a gokrazy instance (all it
takes is the 3 imgs).
It can be directly accessed for a single file extraction (non compressed
zip property).
It can be easily unarchived by gokrazy appliances (cheap unzipping).
It is easy to verify what the build contains (SBOM alongside to be read).
2023-02-05 13:51:32 +01:00
Damiano Donati
239461d80e packer: use Pack as receiver for Main and logic 2023-02-05 13:51:32 +01:00
Damiano Donati
db4f55e31a gok sbom: prefactor mv GenerateSBOM to internal/packer 2023-02-05 13:51:32 +01:00
Michael Stapelberg
ca01203cad gok: add sbom subcommand 2023-01-29 21:55:42 +01:00
Michael Stapelberg
ce2433aa1a gok: move code to internal/gok 2023-01-29 19:30:23 +01:00