162 Commits
Author SHA1 Message Date
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
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
oliverpool ea81144d87 gok: fix adding module with uppercase letters (#53) 2023-04-06 12:18:53 +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 fe8d59ca7d add gok push
related to https://github.com/gokrazy/gokrazy/issues/167
2023-02-19 15:03:41 +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 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
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
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
Michael Stapelberg 20bd48bfb6 include SBOM as /etc/gokrazy/sbom.json
related to https://github.com/gokrazy/gokrazy/issues/167
2023-02-05 16:14: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 86691439bf drop github.com/gokrazy/gokrazy dependency
This should not make a difference with Go modules enabled,
which should be the case for all running gokrazy installations.
2023-01-29 19:42:57 +01:00
Michael Stapelberg ce2433aa1a gok: move code to internal/gok 2023-01-29 19:30:23 +01:00
Mark Drayton a515c601c0 parttable: pass HOME env var to sudo (#44)
Without passing $HOME into the `sudo` invocation the instance parent
directory detection
(https://github.com/gokrazy/internal/blob/main/instanceflag/instanceflag.go#L19)
fails:

  $ gok -i test overwrite --full /dev/sdc
  [..]
  2023/01/25 22:13:04 partitioning /dev/sdc (GPT + Hybrid MBR)
  2023/01/25 22:13:04 Using sudo to gain permission to format /dev/sdc
  2023/01/25 22:13:04 If you prefer, cancel and use: sudo setfacl -m u:${USER}:rw /dev/sdc
  2023/01/25 22:13:04 open os.UserHomeDir failed: $HOME is not defined/gokrazy/test/config.json: no such file or directory
  2023/01/25 22:13:04 exit status 1

This commit does the necessary passing.
2023-01-25 23:22:13 +01:00
Michael Stapelberg 45ce7ad200 implement 'gok get' subcommand
fixes https://github.com/gokrazy/gokrazy/issues/162
2023-01-15 18:27:02 +01:00
Michael Stapelberg f354e13fdf packer: get host fallback from instance hostname, not update host
The instance hostname is the logical hostname of the instance, e.g. consrv,
whereas the update hostname is the way to cross the network to get to said
instance, e.g. consrv.monkey-turtle.ts.net (on port 2345).
2023-01-15 16:55:25 +01:00
Michael Stapelberg 5e5fb5cf29 packer: use the httpclient package directly 2023-01-15 16:26:10 +01:00
Michael Stapelberg 4f93af68c8 packer: set HTTP(S)Port fallback values after host-specific fallback 2023-01-15 16:15:42 +01:00
Michael Stapelberg e11eeb6a52 localtime: document why time/tzdata does not help 2023-01-15 14:12:11 +01:00
Michael Stapelberg a84f008488 identify gokrazy packer vs. gok in log output 2023-01-10 20:41:41 +01:00
Michael Stapelberg 8f9863a4c2 Config.Update.Hostname: fall back to Config.Hostname if empty 2023-01-07 18:59:26 +01:00
Michael Stapelberg b169c0894c use two dashes for flags in error messages
That way, they work for cobra (gok) and Go flag parsing (gokr-packer).
2023-01-07 18:50:11 +01:00
Michael Stapelberg 9ed9d3b936 internal/version: pull git revision out of module version, too
Before this commit, the version would be blank when built as a Go module.
2023-01-07 18:50:11 +01:00
Michael Stapelberg 05070adf9d gokr-packer: convert common -update URLs to config.Update fields 2023-01-07 18:50:11 +01:00
Michael Stapelberg 7d22eb8e32 add integration test for gokr-packer and its migration path 2023-01-07 16:16:46 +01:00
Michael Stapelberg 5b3aa31300 populate PackageConfig for packer logic / writing config.json 2023-01-07 16:16:46 +01:00