400 Commits

Author SHA1 Message Date
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
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
Michael Stapelberg
afe3e5085f apply default build tags also to init binary build
related to https://github.com/stapelberg/scan2drive/issues/18
2022-04-21 21:17:42 +02:00
Michael Stapelberg
4fe1051453 revert GOFLAGS, add buildtags per-package config, add osusergo/netgo
The GOFLAGS handling is the opposite of how the Go tool handles it, where
GOFLAGS provides default values that the command line then overwrites. I think
it’s better to match that behavior.

Instead, allow extending gokr-packer’s list of build tags via the buildtags/
per-package config directive.

Also, add osusergo and netgo build tags by default so that even when cgo is
enabled, gokrazy code results in statically linked binaries.

related to https://github.com/stapelberg/scan2drive/issues/18
2022-04-21 21:17:36 +02:00
Michael Stapelberg
32c5136e01 respect GOFLAGS=-tags (don’t set -tags=gokrazy)
related to https://github.com/stapelberg/scan2drive/issues/18
2022-04-20 21:13:08 +02:00
Michael Stapelberg
125418d8b3 respect CGO_ENABLED=1 if explicitly specified in environment
Our default is still CGO_ENABLED=0

related to https://github.com/stapelberg/scan2drive/issues/18
2022-04-20 21:12:58 +02:00
Michael Stapelberg
8dc754717c look for architecture-dependent extrafiles tar first
related to https://github.com/gokrazy/podman/issues/2
2022-04-14 13:06:12 +02:00
Michael Stapelberg
ec0f87b260 packer: add support for extrafiles.tar
This offers a way to get around Go package zip file restrictions,
such as:

• executable modes are lost in a Go package zip file
• files that only differ in casing can’t be stored in a Go package zip file

fixes https://github.com/gokrazy/tools/issues/32
2022-04-05 08:50:03 +02:00
Michael Stapelberg
3e1cf33c58 add /var and /run directories to root file system
related to https://github.com/gokrazy/gokrazy/issues/124
2022-04-03 23:11:25 +02:00
oliverpool
07643813fd packer: fail on small device (#33) 2022-03-31 09:10:30 +02:00
Michael Stapelberg
05a69a38cd gok: read host-specific http-port.txt 2022-03-26 19:39:32 +01:00
Michael Stapelberg
7eae294c96 GitHub Actions: bump to Go 1.18 2022-03-20 16:02:08 +01:00
Michael Stapelberg
e364146e37 switch -serial_console default to serial0 alias
This alias resolves to ttyAMA0 currently, but will be rewritten by the Raspberry
Pi firmware to resolve to ttyS0 once we drop our custom dtb patches.

related to https://github.com/gokrazy/gokrazy/issues/49
2022-03-18 09:47:13 +01:00
Michael Stapelberg
d603a85f0b explicitly set console=tty1 in cmdline.txt
This means we no longer need the dtb patch where we change the default kernel
command line to contain console=tty1.

related to https://github.com/gokrazy/gokrazy/issues/49
2022-03-18 09:40:48 +01:00
Michael Stapelberg
e5926c62b2 Introduce -serial_console=off to set enable_uart=0 in config.txt
The currently valid values are:

-serial_console=UART0 (see next option)
-serial_console=ttyAMA0,115200 (for example)
-serial_console=disabled (serial available for userspace)
-serial_console=off (serial turned off)

related to https://github.com/gokrazy/gokrazy/issues/49
2022-03-18 09:32:36 +01:00
Michael Stapelberg
c1b172b2f0 bugfix: allow both, $PWD/extrafiles/ and <pkg>/_gokrazy/extrafiles 2022-03-01 22:55:40 +01:00
Michael Stapelberg
0721be4715 move (*os.File).Sync() call into linux-specific packer_linux.go
This fixes the following error on macOS:

sync /dev/disk2: inappropriate ioctl for device

related to https://github.com/gokrazy/gokrazy/issues/22
2022-03-01 18:04:43 +01:00