Commit Graph
100 Commits
Author SHA1 Message Date
Michael Stapelberg ba6a8936f4 packer: do not check for HTTP→HTTPS redirect
This check was broken: it tried to construct a http URL
by changing the updateBaseUrl schema instead of constructing
such a URL based on the configured HTTPPort.

I also don’t think this check is useful:
HTTPS will be used for updates regardless of the check.
Even if an attacker intercepted HTTP traffic and removed the redirect,
that has no bearing on the update, so why bother checking.

One thing the check (implicitly) did is the required fallback
on initial installation when --insecure is specified.
We now solve that by falling back from HTTPS to HTTP explicitly
(only when --insecure is specified, of course).

related to https://github.com/gokrazy/tools/pull/94
2025-12-09 17:11:22 +01:00
Michael Stapelberg 0daf1b1ae4 packer: stop using tlsflag global state 2025-12-08 21:32:59 +01:00
Michael Stapelberg 8320e69ccc packer: move error check closer to error assignment 2025-12-08 20:58:14 +01:00
Michael Stapelberg 0a82ebcb52 remove stale comment
git commit 87444dca50 accidentally
removed the code (partuuid = 0), but not the comment.
2025-12-08 20:57:45 +01:00
Michael Stapelberg 715673f4b5 packer: clean up sbomHook hack 2025-12-06 21:54:52 +01:00
Michael Stapelberg 2848fa1a69 packer: move findPackageFiles to packerprepare.go 2025-12-06 21:38:46 +01:00
Michael Stapelberg ab66901132 packer: move find* to packerprepare.go 2025-12-06 21:37:13 +01:00
Michael Stapelberg 0bb33e2ae8 packer: move addToFileInfo to write.go 2025-12-06 21:35:56 +01:00
Michael Stapelberg 6ae03bee7a packer: move countingWriter to packerwrite.go 2025-12-06 21:32:21 +01:00
Michael Stapelberg 4fab9e7759 packer: move find* to packerprepare.go 2025-12-06 21:28:53 +01:00
Michael Stapelberg cfba731eae packer: move partitionPath to packerwrite.go 2025-12-06 21:23:36 +01:00
Michael Stapelberg bd1faa7647 packer: move overwrite{File,Device} to packerwrite.go 2025-12-06 21:21:00 +01:00
Michael Stapelberg 3def6ed054 packer: move printHowToInteract to packerwrite.go 2025-12-06 21:17:15 +01:00
Michael Stapelberg 8b448cc312 packer: move update into packerupdate.go 2025-12-06 21:16:38 +01:00
Michael Stapelberg df53492c98 packer: move write into packerwrite.go 2025-12-06 21:14:44 +01:00
Michael Stapelberg f5ddd27c7e packer: move build into packerbuild.go 2025-12-06 21:12:44 +01:00
Michael Stapelberg 23ac917f5b packer: move prepare into packerprepare.go 2025-12-06 21:11:31 +01:00
Michael Stapelberg 485405edac cleanup: remove unused parameters 2025-12-06 21:09:00 +01:00
Michael Stapelberg 45b2b940f6 cleanup: move write{Boot,Root}File next to write{Boot,Root} 2025-12-06 21:04:34 +01:00
Michael Stapelberg 67382a6dbe cleanup: move kernel GOARCH validation code into its own file 2025-12-06 20:59:01 +01:00
Michael Stapelberg b513356080 refactor: split printHowToInteract into its own method
Also remove duplicate URL construction code
2025-12-06 20:55:30 +01:00
Michael Stapelberg cbfacd97a6 refactor: split logicUpdate into a separate method 2025-12-06 20:42:09 +01:00
Michael Stapelberg 1921f918ee cleanup: inline programName now that the old packer is gone 2025-12-06 20:23:57 +01:00
Michael Stapelberg 9e3ab11076 packer: add test for losing HTTPS certificates
related to https://github.com/gokrazy/tools/pull/68
2025-12-06 08:49:22 +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 dc8c88b368 gokupdate_test: refactor to use readConfig/writeConfig 2025-12-05 08:36:19 +01:00
Michael Stapelberg 91c487c959 packer: use HTTPS client despite -insecure (post-update) (+test)
While adding the integration test for
https://gokrazy.org/userguide/tls-for-untrusted-networks/,
I noticed that the packer does not actually successfully complete
the initial HTTPS deployment (where -insecure is used).
After writing the image to disk and rebooting, the packer was stuck at:

device not yet reachable: Get "https://localhost:9080/": http:
server gave HTTP response to HTTPS client

related to https://github.com/gokrazy/tools/pull/94
2025-11-29 12:39:22 +01:00
Michael Stapelberg d1929f390f integration: enable QEMU hardware acceleration 2025-11-29 11:24:47 +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 d588a72286 integration: start QEMU VM for 'gok update' test
related to https://github.com/gokrazy/tools/pull/94
2025-11-29 09:56:11 +01:00
Michael Stapelberg 50ceea79c7 internal/packer: apply BootloaderExtraEEPROM
related to https://github.com/gokrazy/gokrazy/issues/338
2025-11-16 19:09:52 +01:00
Michael Stapelberg d57f04bf53 add internal/eeprom package (with test against other impls)
related to https://github.com/gokrazy/gokrazy/issues/338
2025-11-16 15:08:21 +01:00
Michael Stapelberg 4950fd73f6 add a flake.nix providing the two other rpi eeprom tools
see also: https://michael.stapelberg.ch/posts/2025-07-27-dev-shells-with-nix-4-quick-examples/

related to https://github.com/gokrazy/gokrazy/issues/338
2025-11-16 15:08:12 +01:00
Michael Stapelberg 57f559232c packer: eeprom: only write vl805-*.bin if present (Pi 4)
The rpi5-eeprom package no longer contains vl805, which is Pi 4-specific.

related to https://github.com/gokrazy/gokrazy/issues/332
2025-11-16 09:57:09 +01:00
Michael Stapelberg 2f0aac76a0 packer: include timestamp (ts: unixtime) in firmware .sig files
Otherwise the Pi 5 firmware will default to a timestamp of 0
and skip the update always.

related to https://github.com/gokrazy/gokrazy/issues/332
2025-11-16 09:08:03 +01:00
Michael Stapelberg 9a9519186b integration: add 'gok update' test
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 5675dbb2eb packer: set Accept header (request), not Content-Type (response) 2025-10-03 19:11:55 +02:00
Michael Stapelberg ab29b81133 tests: use t.Chdir now that we are on Go 1.24 2025-10-03 18:32:43 +02:00
Michael Stapelberg 19d09ffb32 switch from breml/rootcerts to x/crypto fallback bundle
related to https://github.com/golang/go/issues/69898
2025-09-12 09:34:42 +02:00
Michael Stapelberg 2979dc9b26 pull in latest gokrazy/updater 2025-07-05 15:59:45 +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 d145a5b689 go.mod: update to latest versions of dependencies 2025-05-30 16:58:56 +02:00
Michael Stapelberg a0558bc6a0 GitHub Actions: verify gok builds on Windows and macOS, too
related to https://github.com/gokrazy/tools/issues/89
2025-05-29 17:03:18 +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 5b15ffbd42 packer: move unix-specific code into build tag guarded files
related to https://github.com/gokrazy/tools/issues/89
2025-05-29 16:17:58 +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 8ff2f69410 measure: suppress output when stdout is not a terminal
related to https://github.com/gokrazy/tools/issues/91
2025-05-29 15:19:04 +02:00
Michael Stapelberg fc2e1562e8 packer: include KernelExtraArgs in the kernel cmdline
related to https://github.com/gokrazy/gokrazy/issues/312
2025-05-20 23:01:12 +02:00
Michael Stapelberg 97ed031a8e packer: refactor write phase out of logic() 2025-04-17 22:59:29 +02:00
Michael Stapelberg e1ed8d681f packer: refactor build phase out of logic() 2025-04-17 22:57:40 +02:00
Michael Stapelberg 4868f92932 packer: refactor preparation phase out of logic() 2025-04-17 22:48:39 +02:00
Michael Stapelberg ff72417a88 packer: add missing error assignment 2025-04-17 22:36:41 +02:00
Michael Stapelberg 9a554ea21e check whether partitions are mounted early on, improve error message
related to https://github.com/gokrazy/gokrazy/discussions/308
2025-04-17 22:30:32 +02:00
Michael Stapelberg 640a6ea131 clearly label errors as such
related to https://github.com/gokrazy/gokrazy/discussions/308
2025-04-17 22:30:19 +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
Michael Stapelberg f608e1a4d0 pull in latest gokrazy/internal
related to https://github.com/gokrazy/gokrazy/issues/303
2025-02-24 07:16:10 +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 c3e6903b57 fix gokrun_test on macOS 2025-02-21 21:29:05 +01:00
Michael Stapelberg 803c1f293b GitHub Actions: bump Go version and action versions 2025-02-21 20:24:20 +01:00
Michael Stapelberg 9e9952330e delete now-obsolete gokrpacker_test, too
related to https://github.com/gokrazy/gokrazy/issues/301
2025-02-21 20:18:56 +01:00
Michael Stapelberg ceba4a4391 delete cmd/gokr-packer and cmd/gokr-updater
Users who need to use gokr-packer to migrate an existing setup to the
instance-centric config can use the following command to install the
last version before it was deleted:

go install github.com/gokrazy/tools/cmd/gokr-packer@703a8605028963d13a9d00815ccedfae13f0ce6d

fixes https://github.com/gokrazy/gokrazy/issues/301
2025-02-21 20:10:23 +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
Michael Stapelberg 1b3cfe35b3 packer: do not compute SBOM twice when writing a GAF file
related to https://github.com/gokrazy/gokrazy/issues/299
2025-02-21 17:53:55 +01:00
Michael Stapelberg 4726b7d4b2 sbom: fix ExtraFileHashes paths (accidentally pointed to go.mod)
related to https://github.com/gokrazy/gokrazy/issues/299
2025-02-21 17:52:03 +01:00
Michael Stapelberg 8bcde52fb8 go.mod: set language version to go 1.24 2025-02-14 21:32:01 +01:00
Michael Stapelberg ef5cd4d241 pull in latest gokrazy/internal 2025-02-14 21:31:08 +01:00
Michael Stapelberg 30b9fe0c81 pull in latest golang.org/x/mod for tools directive
fixes https://github.com/gokrazy/gokrazy/issues/298
2025-02-12 17:19:15 +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 70c48e594c sbom: use absolute instancePath, not (relative) config.InstancePath
fixes https://github.com/gokrazy/gokrazy/issues/292
2025-01-25 21:02:04 +01:00
Michael Stapelberg f1a87939e4 GitHub Actions: create dummy SSH key for breakglass.authorized_keys 2025-01-22 21:54:04 +01:00
Michael Stapelberg 5762235ac5 make ExtraFilePaths absolute earlier to fix sbom in relative parents
fixes https://github.com/gokrazy/gokrazy/issues/289
2025-01-22 21:49:32 +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 37e2f95c5c create an empty /bin mount point
This is useful for mounting a tmpfs and installing busybox
(e.g. the version that comes with the serial-busybox package):

    mount -t tmpfs tmpfs /bin
    ln -s /tmp/serial-busybox/ash busybox
    ./busybox --install -s /bin

Afterwards, TRAMP (transparent remote access) in Emacs works:

    emacs /ssh:scan2drive:/perm/keep/index.md
2024-12-29 16:36:13 +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 0c67e08b0a packer: partially restore buildPackagesFromFlags()
Commit a59c9ad5f4 was not entirely correct:
It is desired to call getGokrazySystemPackages(), but we should also
keep looking at cfg.Packages (which the commit didn’t).
2024-09-11 18:27:24 +02:00
Michael Stapelberg feda2a35da sbom: move too-late os.Chdir call earlier
This fixes errors such as:

2024/09/11 08:41:50 Error: build directory
"/home/michael/gokrazy/router7/builddir/github.com/stapelberg/prober7/cmd/probe"
does not exist in
"/home/michael/gokrazy/router7/builddir/github.com/gokrazy/serial-busybox"
2024-09-11 08:47:35 +02:00
Michael Stapelberg a59c9ad5f4 FindExtraFiles: unify packages to consider with sbom logic
This fixes 'gok -i hello sbom' when the hello instance
directory (~/gokrazy/hello) has an empty build directory.

related to #51
2024-09-09 17:20:29 +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
Michael Stapelberg d9a4bf387a update gokrazy/internal: fix bootloader 15/16 MB kernel size limit
related to https://github.com/gokrazy/gokrazy/issues/248
2024-08-27 21:09:36 +02:00
Michael Stapelberg fbd9e5d9cc GitHub Actions: delete unused LSIF workflow 2024-08-27 20:45:50 +02:00
Michael Stapelberg 809775d2b7 go.mod: bump language version to go 1.22 (oldest supported release) 2024-08-27 20:45:30 +02:00
Michael Stapelberg f7db22daab gotool: add missing -tags=gokrazy for list
I noticed this while working on the integration test.
2024-08-18 21:39:22 +02:00
Michael Stapelberg d0d0a0a6ae GitHub Actions: stick to go 1.22 until telemetry is fixed 2024-08-18 11:10:46 +02:00
Michael Stapelberg 9f81add3a9 kernelGlobs: include overlay_map.dtb
See “The overlay map file” in the Raspberry Pi Configuration docs:
https://www.raspberrypi.com/documentation/computers/configuration.html#part2.2.10

related to https://github.com/gokrazy/gokrazy/issues/273
2024-07-30 21:25:48 +02:00
Michael Stapelberg 41f11fbe3a pull in latest gokrazy/internal for default kernel switch
related to https://github.com/gokrazy/gokrazy/issues/223
2024-06-23 11:10:41 +02:00
Michael Stapelberg efa3f22802 packer: prevent accidental overwrites on boot partition
related to https://github.com/gokrazy/gokrazy/issues/264

Currently, both the gokrazy/firmware and the gokrazy/kernel.rpi repository
contain an overlays directory. The desired state is that only gokrazy/kernel.rpi
contains an overlays directory, as that is the repository from which the
overlays are built (whereas the are only copied into the firmware repository).

To prevent confusion between different versions, the packer now returns an error
instead of silently overwriting files on the boot partition when there are
multiple sources for a file.
2024-06-23 10:34:02 +02:00
Michael Stapelberg 3919dda31d packer: error out on invalid ExtraFilePaths
Before this change, the packer created an empty directory unconditionally,
which resulted in surprising errors in programs like breakglass.

closes https://github.com/gokrazy/breakglass/issues/19
2024-06-15 18:09:21 +02:00
Michael Stapelberg 0798935a7a packer: rename to addExtraFilesFromDir 2024-06-15 17:57:14 +02:00
Michael Stapelberg 34b02e215b include mount device config in /etc/gokrazy/mountdevices.json
related to https://github.com/gokrazy/gokrazy/issues/236
2024-05-10 19:03:41 +02:00
Michael Stapelberg f7be03f9cb create mount device targets in /mnt
related to https://github.com/gokrazy/gokrazy/issues/236
2024-05-10 19:03:19 +02:00
Michael Stapelberg 06656d4340 bump language version to go 1.21 (oldest supported release) 2024-05-10 17:46:08 +02:00
Michael Stapelberg 04de7ab994 create /var as a symlink to /perm/var instead of empty directory
The /var directory is meant to hold data that changes (see hier(7)).

With the previous behavior, users had to bind-mount a writable
and persistent directory over /var, for example as documented in
https://gokrazy.org/packages/docker-containers/

With this commit, there is one fewer hurdle to get podman running.
2024-05-10 17:40:40 +02:00
Michael Stapelberg 80a59f1153 dirhash: use zip.CheckDir() to find valid files
The sumdb/dirhash package was built to work with extracted Go module zip files,
but we are working with directories on local disk (working copies).

So, to reflect what the Go tool would see as source code,
we now use the same code.

Specifically, the old approach failed with symbolic links to directories,
because it treated them as regular files (Go module zips do not contain
irregular files such as symlinks).
2023-12-22 09:00:07 +01:00