147 Commits

Author SHA1 Message Date
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
Olivier Mengué #openToWork-Paris
b8127bc462 overwrite: show setfacl suggestion only on Linux (#90)
When acquiring access to partition the device, show message about use of
"setfacl" only on Linux. Not on Darwin where it is irrelevant.
2025-03-21 21:36:30 +01: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
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
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
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
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
Bill Doyle
8edbabf668 Preserve GOKRAZY_PARENT_DIR when executing sudo (#76)
This should fix `gok overwrite` not fully utilizing this environment
variable as mentioned in a comment on gokrazy/gokrazy#222.
2025-01-20 08:18:36 +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
George Hopkins
de5f76c883 Support i386/x86 platforms (#75) 2024-08-18 16:15:51 +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
Anup Chenthamarakshan
fe5fe168ac Support non-default FirstPartitionOffsetSectors (#70)
Support devices that require non-default space before the first partition
starts (4MiB). Required to enable booting Rock64 devices
2024-07-04 17:50:25 +02:00
oliverpool
e53ba4e609 Satisfy staticcheck (#74)
* remove deprecated ioutil usage

* use more suitable functions

* add missing error handling

* remove unused variables

* select{} instead of for{}
2024-07-04 17:35:15 +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
Brad Fitzpatrick
ee071a0b95 internal/packer: use new UpdateOpts.NoPassword (#69)
Updates gokrazy/gokrazy#265
Updates tailscale/tailscale#1866

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-06-09 10:38:39 +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
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
Michael Stapelberg
d7eafaef08 write BootloaderExtraLines to config.txt
related to https://github.com/gokrazy/gokrazy/issues/216
2023-12-15 15:19:30 +01:00
Mark Dietzer
60c9d51572 Copy .dtbo overlays from firmware repo as well (#67) 2023-12-15 08:59:47 +01:00
Michael Stapelberg
dceb56ee39 pull in gokrazy/internal for updateflag.BaseURL change 2023-10-31 19:32:10 +01:00
Damiano Donati
1c3069c7e6 fix sbom generation inconsistency, take 2 (#66) 2023-10-25 08:39:46 +02:00
Mark Dietzer
c6f9ca1dab Add ability to have sub-path globs and include overlays (#63)
Add ability to have sub-path globs and include overlays/*.dtbo from kernel package
2023-10-20 10:48:15 +02:00
Damiano Donati
84c24f75e1 fix sbom generation inconsistency (#61)
prior to this commit SBOMs would have inconsistency in their hashing on
the configuration file.

The representation of the config file in fact would differ at certain
stages of the gok commands lifecycle, where at packer running time,
an extra InternalCompatibilityFlag, Sudo, would be added in memory
(while that not being the case at `gok sbom` time),
resulting in a differing config and as such differing SBOM hashes, same
goes for the differing pointer addresses that were skew the hashing
results.

This is now fixed by using the SudoOrDefault() accessor,
as well as converting the config into a string before computing the hash,
to avoid differing pointer problems.
2023-10-11 17:46:50 +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
Michael Stapelberg
c5e8689f03 build init in github.com/gokrazy/gokrazy
fixes https://github.com/gokrazy/gokrazy/issues/210

fixes https://github.com/gokrazy/gokrazy/pull/178
2023-07-28 08:45:52 +02:00
Michael Stapelberg
fa33ef8830 packer: set 022 umask to ensure the o+x bit is present
fixes https://github.com/gokrazy/gokrazy/issues/205
2023-07-13 18:06:18 +02:00
Michael Stapelberg
56839a456a packer: fix incorrect parent association in mkdirp()
A bug was triggered when the file system contained two directories with the same
basename, because all directories were incorrectly associated with the root
directory.

fixes https://github.com/gokrazy/tools/issues/58
2023-06-29 22:20:40 +02:00
Michael Stapelberg
522f5b0a23 packer: implement mkdirp() for tar directories
See the source comment for more details.

fixes https://github.com/gokrazy/tools/issues/58
2023-06-24 20:30:46 +02:00
Michael Stapelberg
cd4073ee85 improve error message when multiple packages install the same binary
This can happen when adding a program called "hello",
when the default config already pulls in github.com/gokrazy/hello.

The previous error message was confusing and non-deterministic,
because it contained the name of whichever package happens to be
validated first.
2023-06-01 22:58:05 +02:00