420 Commits
Author SHA1 Message Date
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 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 41ef295683 pull in latest gokrazy/internal 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 12d755c6e9 gok run: read instance config to set build flags/tags 2023-01-07 16:16:46 +01:00
Michael Stapelberg 2cce27b0b0 add Makefile with a few example invocation make targets 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 496c018caf remove Env 2023-01-07 16:01:39 +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 64966b412e make package config overrideable in config.json
related to https://github.com/gokrazy/gokrazy/issues/147
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 c87c806562 go.mod migration: don’t incorrectly absolutize non-path replace
fixes https://github.com/gokrazy/gokrazy/issues/148
2022-10-08 11:00:41 +02:00
Michael Stapelberg 93542fb1da log a pointer to the documentation when migrating go.mod
related to https://github.com/gokrazy/tools/issues/38
2022-09-29 22:16:43 +02: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
Michael Stapelberg cd779ce972 go mod tidy 2022-09-13 22:15:59 +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 edb2616fdb integration test for gok run 2022-09-13 19:27:13 +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
Michael Stapelberg 0d6c95b05c GitHub Actions: better names 2022-09-04 19:56:52 +02:00
Michael Stapelberg fb528d102c go.mod: update to language version go 1.18, tidy 2022-08-07 10:40:21 +02:00
Michael Stapelberg 4df52a4926 GitHub Actions: bump to Go 1.19 2022-08-07 10:13:22 +02:00
Michael Stapelberg af53862da7 pull in latest gokrazy/internal
related to https://github.com/gokrazy/gokrazy/issues/131
2022-07-09 19:27:09 +02:00
Michael Stapelberg 926380a6d6 split sourcegraph job into separate file that only runs on push
also use a separate GitHub Actions secret
2022-06-26 10:13:33 +02:00
Michael Stapelberg 9439776c92 add sourcegraph LSIF indexing for precise code navigation
https://docs.sourcegraph.com/code_intelligence/how-to/index_a_go_repository
2022-06-26 09:56:30 +02:00