84 Commits

Author SHA1 Message Date
Michael Stapelberg
7d22eb8e32 add integration test for gokr-packer and its migration path 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
dc4131ed8b implement gok add 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
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
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
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
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
Anup Chenthamarakshan
45e6b6fc6c Update github.com/gokrazy/internal version (#30) 2022-01-30 14:37:02 +01:00
Darshil Chanpura
0dec06d488 packer: implement waitforclock per-package config files (#29)
This allows wait for the clock to be synced before starting the service
2022-01-13 09:39:42 +01:00
Anup Chenthamarakshan
8bb7e491ea packer: allow using MBR partition tables (#28)
Some ARM devices (like Odroid XU4/HC1/HC2) only support MBR booting.
Allow generating MBR partition table for such devices.
2022-01-13 09:20:34 +01:00
Michael Stapelberg
3bb6d56203 packer: implement dontstart per-package config files
This is useful when including non-service binaries in the image, such as the
tailscale CLI.
2021-12-18 19:51:38 +01:00
Michael Stapelberg
07d209a9ed implement gok logs command for streaming logs
Log streaming was implemented in https://github.com/gokrazy/gokrazy/pull/100

related to https://github.com/gokrazy/gokrazy/issues/88
2021-12-15 14:32:03 +01:00
Michael Stapelberg
157ff3011f refactor into internal 2021-11-21 17:01:03 +01:00
Michael Stapelberg
34f3ddd1ac introduce gok CLI
This is a subcommand based CLI for gokrazy.

Its first subcommand is “run”, to be used like so:

  cd ~/scan2drive/cmd/scan2drive
  gok run --instance=scan2drive

related to https://github.com/gokrazy/gokrazy/issues/88
2021-11-21 17:01:03 +01:00
Michael Stapelberg
3342126429 use github.com/breml/rootcerts as fallback system CA certificates
fixes https://github.com/gokrazy/gokrazy/issues/98
2021-11-20 11:12:32 +01:00
Michael Stapelberg
df18adcb4e update to latest gokrazy/... packages 2021-10-24 18:24:08 +02:00
Michael Stapelberg
bea67498b5 Switch to GPT partition tables, add systemd-boot for UEFI boot
This is useful for running gokrazy on PC platforms (e.g. for
https://router7.org/), where the first systems without legacy BIOS support are
starting to ship.

The existing boot methods (Legacy BIOS MBR boot, Raspberry Pi) are unaffected by
this change and keep working.

Regardless of the bootloader (BIOS, UEFI, Raspberry Pi), we now use a GPT
partition table with hybrid MBR (= protective MBR + FAT32 /boot partition
which the Raspberry Pi bootloader requires).

This change should have no effect on existing installations.

To switch to GPT, you’ll need to use the -overwrite= flag to partition the
device (e.g. SD card). If you want to keep your /perm partition, you’ll need to
shrink the file system (using resize2fs) by 1 MB to make space for the secondary
GPT partition table copy at the end of the device.

Previously, the partition *table* contained a UUID that we used as root=
parameter for the Linux kernel, e.g. root=PARTUUID=471cad93-03

Now, individual partitions (not the partition *table*) have a UUID that begins
with 60c24cc1-f3f9-427a-8199,
e.g. root=PARTUUID=60c24cc1-f3f9-427a-8199-2e18c40c0004

fixes https://github.com/gokrazy/gokrazy/issues/87
2021-06-24 13:52:55 +02:00
Michael Stapelberg
9e2217c2fd pad cmdline with enough space for during-testboot kernel parameters
related to https://github.com/gokrazy/gokrazy/issues/75
2021-01-30 18:55:40 +01:00
andig
86f779c5f0 Split package build flags (one per line) (#23) 2021-01-18 09:39:32 +01:00
Michael Stapelberg
49dfc09d9e update gokrazy/gokrazy to latest 2021-01-08 09:12:44 +01:00
Michael Stapelberg
f31e3ce19b bump dependencies to latest versions 2021-01-06 22:31:47 +01:00
Michael Stapelberg
608ca46ed4 packer: use new github.com/gokrazy/updater package 2021-01-06 22:03:29 +01:00
Michael Stapelberg
ea3341009e pull in new gokrazy for gokrazy.Model() 2020-06-26 12:02:34 +02:00
Michael Stapelberg
c3fceda232 pull in new updater for crc32 checksumming 2020-06-26 11:05:52 +02:00
Michael Stapelberg
71c8662bff switch to new updater API 2020-06-26 10:56:42 +02:00
Michael Stapelberg
a664377a48 packer: use go build with tempdir instead of go install
fixes https://github.com/gokrazy/tools/issues/2
2020-06-21 09:08:31 +02:00
Michael Stapelberg
d080103072 packer: pass through -insecure
This fixes disabling TLS via a network update.
2020-06-01 14:04:02 +02:00
Janis Streib
3d2ae8ed96 gokr-packer: TLS support (#7) (#14)
The new `-tls` parameter is empty by default, retaining the current behavior (no change).

If `-tls=self-signed` is specified, the packer generates and signs a RSA4096 certificate, stored in the host-specific config directory, e.g. typically `~/.config/gokrazy/<hostname>/{cert,key}.pem` on Linux.

If `-tls=<certpath>[,<keypath>]` is specified, the packer uses the specified certificate and key.

When TLS is used, the certificate/key is included in the gokrazy root file system at  `/etc/ssl/{web,web_key}.pem`.

To switch an unencrypted (HTTP) installation to HTTPS, use the `-insecure` flag for the first update, e.g.:
`gokr-packer -tls=self-signed -insecure …`
…then remove it for all subsequent updates, which will now be done via HTTPS:
`gokr-packer -tls=self-signed …`
2020-05-31 23:19:06 +02:00
Michael Stapelberg
3f33129918 pull in newer gokrazy/internal 2020-05-30 21:00:39 +02:00
Michael Stapelberg
4d98088ffe refactor ensurePasswordFileExists to use internal/config 2020-05-27 18:37:13 +02:00