Commit Graph

190 Commits

Author SHA1 Message Date
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
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
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
Michael Stapelberg
d5f9cee29d gok: use config.NewStruct()
related to https://github.com/gokrazy/tools/issues/43
2023-01-17 19:05:43 +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
d9681ee8cb gok run, logs: remove --update flag in favor of --instance 2023-01-15 17:15:52 +01:00
Michael Stapelberg
bdb14f7080 use new httpclient.For() instead of GetHTTPClientForInstance() 2023-01-15 16:41:49 +01:00
Michael Stapelberg
c61213349c provide a programmatic entry point to the gok CLI
This interfaces with spf13/cobra without typing ourselves to its types, and
exerting control (for better of for worse) about what aspects one can control.

With this, we can move the code in cmd to internal/
2023-01-15 15:55:51 +01:00
Michael Stapelberg
10ba0192aa gok new: generate a machine-id(5) by default 2023-01-15 14:44:44 +01:00
Michael Stapelberg
a84f008488 identify gokrazy packer vs. gok in log output 2023-01-10 20:41:41 +01:00
Michael Stapelberg
444a52a283 gok add: store go.mod at package level for local disk additions
This way, non-local and local operate at the same hierarchy level, which means
you can switch from non-local to local override.
2023-01-07 18:50:11 +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
12d755c6e9 gok run: read instance config to set build flags/tags 2023-01-07 16:16:46 +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
Michael Stapelberg
2b958254f0 gok add: copy replace directives from local go.mod
This fixes the build of github.com/evcc-io/evcc, which doesn’t build without
the replace directives from its go.mod file.
2023-01-07 16:16:46 +01:00
Michael Stapelberg
e3e0c0fb2a gok add: create go.mod in non-local mode, too
The go tool needs a go.mod to function.
2023-01-07 16:16:46 +01:00
Michael Stapelberg
1b8e74f331 gok add: use go mod edit instead of go get for adding require line
Adding the require line using `go get` does not work for
https://github.com/evcc-io/evcc as of commit
504ed7172efdd6e849985280a21feccbbf455b9d:

panic: internal error: can't find reason for requirement on
github.com/rogpeppe/go-internal@v1.6.1.
2023-01-07 16:16:46 +01:00
Michael Stapelberg
1194a73d20 group commands in gok help output 2023-01-07 16:01:39 +01:00
Michael Stapelberg
d4fa52f791 uppercase HTTP(S) 2023-01-07 16:01:39 +01:00
Michael Stapelberg
ec011de8da gok new: create config.json with 0600 permissions
The instance config contains the device password.
2023-01-07 16:01:39 +01:00
Michael Stapelberg
c72e5e19f4 rename instance_dir to parent_dir, to make its role clearer 2023-01-07 16:01:39 +01:00
Michael Stapelberg
dc4131ed8b implement gok add 2023-01-07 16:01:39 +01:00
Michael Stapelberg
a2832b7d25 move left-over flags 2023-01-07 16:01:39 +01:00
Michael Stapelberg
3a96e0840b implement gok edit 2023-01-07 16:01:39 +01:00
Michael Stapelberg
e8957193c6 implement gok new 2023-01-07 16:01:39 +01:00
Michael Stapelberg
c3a5ed85c0 remove hook calling TODO (design doc has been updated)
It is cleaner to have this happen outside of the gok tool.
That way, users can see the config, as the tool will read it,
using `cat config.json` before calling gok.
2023-01-07 16:01:39 +01:00
Michael Stapelberg
64ebf287f9 gok: long help output 2023-01-07 16:01:39 +01:00
Michael Stapelberg
492ee69a2e wire up gok version 2023-01-07 16:01:39 +01:00
Michael Stapelberg
86312ca8d8 move config package to gokrazy/internal 2023-01-07 16:01:39 +01:00
Michael Stapelberg
038a9233cf add gok overwrite subcommand 2023-01-07 16:01:39 +01:00
Michael Stapelberg
434e942c97 refactor packer code into internal/packer, add gok update entrypoint
related to https://github.com/gokrazy/gokrazy/issues/147
2023-01-07 16:01:35 +01:00
Michael Stapelberg
1339700a0d implement writing/reading config.json
related to https://github.com/gokrazy/gokrazy/issues/147
2023-01-07 15:59:17 +01:00
Michael Stapelberg
52922bae3e register --instance flag on root command for --help 2023-01-07 15:59:17 +01:00
Michael Stapelberg
d3bc434581 implement gok --version 2023-01-07 15:59:17 +01:00
Anmol Khirbat
360a12cb46 Pass fs-size to mkfs.ext4 so it doesn't scribble over secondary GPT (#42) 2022-12-06 10:44:48 +01:00
Michael Stapelberg
b0f51bdf92 update remaining outdated messages regarding supported devices
related to https://github.com/gokrazy/gokrazy/issues/157
2022-11-20 16:21:15 +01:00
Michael Stapelberg
a889f31ae4 fix empty directory when an empty -gokrazy_pkgs= flag is set
This is one of several changes we need to fix the gokrazy/gokrazy GitHub Actions.
2022-09-24 10:48:36 +02:00
Michael Stapelberg
4bb2a85745 check that compiled files actually are ELF binaries
related to https://github.com/golang/go/issues/53804

When validation fails, the error message looks like this:

2022/09/17 20:53:07 /tmp/gokrazy-bins-1604202262/dhcp4d is not an ELF binary!
bad magic number '[0 0 0 0]' in record at byte 0x0
2022-09-17 20:57:44 +02:00
Mark Dietzer
01edd60bd7 Use shared helper to build http client for log and run. (#39) 2022-09-14 08:41:31 +02:00
Adam Jensen
332d4775bd gokr-packer: Fix typo in cert message (#40) 2022-09-13 21:01:30 +02:00
Michael Stapelberg
2e1812da69 make packer.BuildDir function configurable, fix gok run
related to https://github.com/gokrazy/tools/pull/39
2022-09-13 20:44:38 +02:00
Michael Stapelberg
d873acb6b7 cobra: context and error plumbing
This will make an integration test way easier.
2022-09-13 19:26:40 +02:00
Michael Stapelberg
c3979e1ceb Use builddir/ for storing go.mod/go.sum per package
Before

Before this commit, gokr-packer was building all Go binaries to include in the
gokrazy root file system from the same working directory, meaning the same
go.mod and go.sum files were used for all packages.

This wasn’t really an intentional choice, instead it was the easiest way to get
things working when Go switched from GOPATH to modules.

The downside of that approach is that updates in one package can result in other
packages no longer building. In the most extreme cases, it can mean that two
packages cannot be built into the same gokrazy root file system at all.

After

With this commit, gokr-packer will build each package in a subdirectory of the
new builddir/ directory in your gokrazy instance directory,
e.g. ~/gokrazy/scan2drive/builddir.

If there is no go.mod file in the builddir yet, gokr-packer will copy the
top-level go.mod/go.sum files into the builddir to keep your current module
selection, and hopefully build exactly the same binary as before.

Influencing the granularity

Often, one Go package will be the only package you use from a certain Go
module. But this isn’t always the case: for example, the system packages
github.com/gokrazy/gokrazy/cmd/dhcp and github.com/gokrazy/gokrazy/cmd/ntp both
come from the github.com/gokrazy/gokrazy module.

gokr-packer will by default create a separate builddir, including a separate
go.mod and go.sum, for each package, even when they come from the same module.

If you want to add module-wide replace directives to your go.mod file,
you can influence the granularity at which gokr-packer works as follows.

Move the go.mod/go.sum files to the directory level within the builddir/
hierarchy at which you would like to work. gokr-packer will look for
go.mod/go.sum files at the package level, going one level up until it finds the
files.

Hence, you can use the following locations, ordered from finest to coarsest
granularity:

1. per-package builddir (default), e.g.:
   builddir/github.com/gokrazy/gokrazy/cmd/dhcp/go.mod

2. per-module builddir (convenient when working with replace directives), e.g.:
   builddir/github.com/gokrazy/gokrazy/go.mod

3. per-org builddir (convenient for wide-reaching replace directives), e.g.:
   builddir/github.com/gokrazy/go.mod

4. single builddir, preserving the previous behavior, e.g.:
   builddir/go.mod

related to https://github.com/gokrazy/tools/issues/38
2022-09-04 19:56:52 +02:00
Damiano Donati
0d3aef012e add arm64 uefi support, bump systemd third_party (#36)
- adds the systemd-bootaa64.efi file to support UEFI boot for
arm64 machines that can do UEFI.

- bumps the systemd package from systemd-248.3-2 to systemd-250.5-1 (I
couldn't find the arm64 version for systemd-248.3-2 so I bumped them
both).

The packages come from the arch linux package registries:
- amd64: https://archlinuxarm.org/packages/aarch64/systemd
- arm64: http://mirror.archlinuxarm.org/aarch64/core/systemd-250.5-1-aarch64.pkg.tar.xz

fixes https://github.com/gokrazy/gokrazy/issues/129
2022-05-07 17:24:25 +02:00
Michael Stapelberg
b62909004c gokr-packer: verify either -update or -overwrite are used, not both
fixes https://github.com/gokrazy/tools/issues/35
2022-05-07 14:50:58 +02:00
Joonas Kuorilehto
8579a1abae gokr-packer: validate certificate matches key (#34)
Fixes gokrazy/gokrazy#130.
2022-05-01 13:19:23 +02:00
Michael Stapelberg
49d3ee847d update flag is called -update in gokr-packer and gok
related to https://github.com/gokrazy/breakglass/issues/13
2022-04-30 21:26:27 +02:00
Michael Stapelberg
2ac0100719 gokr-packer: use internal/tlsflag
related to https://github.com/gokrazy/breakglass/issues/13
2022-04-30 21:22:21 +02:00