124 Commits
Author SHA1 Message Date
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 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 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 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
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 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 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
oliverpool b44363c41f gok: improve the error message for wrong target arch (#56) 2023-05-26 10:36:33 +02:00
Nhân 78e00a0be6 gok: ignore error when updating over tailscale (#55)
This is not a real fix. I still haven't figured out why a `connection
reset by peer` happens in the first place. `target.Reboot()` will still
block for a bit before giving up. At least it doesn't falsely report a
fail now.

Also moved canc() up so the terminal isn't littered with `[update boot
file system] 0.00% of 16 MiB, uploading at 0 B/s` during the wait.

Related: https://github.com/gokrazy/gokrazy/issues/199
2023-05-19 08:43:20 +02:00
Michael Stapelberg 03c240ea00 extrafiles: verify none are configured for /perm
related to https://github.com/gokrazy/gokrazy/issues/197
2023-04-30 09:39:39 +02:00
Brad Fitzpatrick fa27ee75eb validate target userspace architecture matches kernel's architecture (#54)
For gokrazy/gokrazy#191.

Perhaps we'll make it automatic in the future, though. This is a
guardrail meanwhile.
2023-04-06 20:00:02 +02:00
Michael Stapelberg 7b9dd260c5 sbom: chdir to build directory to make relative replace paths work
fixes https://github.com/gokrazy/tools/issues/49
2023-03-11 11:14:30 +01:00
Michael Stapelberg 2b2e2d9f24 gok: fix serial console default 2023-02-28 22:11:43 +01:00
Michael Stapelberg 626d0c7d06 sbom: include replace directives
We do this by using the dirhash package, but filtering out any hidden
files (starting with .) and using hash/fnv because we are not interested in
cryptographically secure hashes of local directory contents, just whether the
contents changed.

fixes https://github.com/gokrazy/gokrazy/issues/171
2023-02-16 22:48:10 +01:00
Michael Stapelberg abef3a8e0b skip Raspberry Pi 4 EEPROM updates when the version is unchanged
This shaves about 10s off of the `gok update` time.
2023-02-15 18:29:25 +01:00
Michael Stapelberg 05762f796b packer: initialize pack.Pack correctly in sudo child process
fixes https://github.com/gokrazy/gokrazy/issues/170
2023-02-06 22:47:48 +01:00
Michael Stapelberg 2b269a6d8d correctly plumb through config struct to GenerateSBOM 2023-02-05 21:43:49 +01:00