190 Commits

Author SHA1 Message Date
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
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
Michael Stapelberg
05a69a38cd gok: read host-specific http-port.txt 2022-03-26 19:39:32 +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
1938385a69 do not add empty strings to package list with empty -gokrazy_pkgs= 2022-02-26 19:25:54 +01:00
Michael Stapelberg
01fcfcf8fd packer: remove extra “v” from version 2022-02-26 19:21:42 +01:00
Michael Stapelberg
0fde06653c packer: pick up _gokrazy/extrafiles/ within package dirs, too
This allows e.g. the github.com/gokrazy/wifi package to include firmware files
that end up in the root file system.

related to https://github.com/gokrazy/gokrazy/issues/13
2022-02-24 20:45:22 +01:00
Michael Stapelberg
686d00738e packer: follow symlinks 2022-02-24 20:37:02 +01:00
Michael Stapelberg
5d79ef259c packer: include loadable kernel modules from kernel repository
related to https://github.com/gokrazy/gokrazy/issues/13
2022-02-22 23:25:04 +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
Michael Stapelberg
30e91460ce errors.As should be errors.Is in this case
We’re not comparing a type, but a specific error value.
2022-01-13 09:24:17 +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
71af7271f4 packer: do not add empty -eeprom_package to list 2021-12-27 09:34:36 +01:00
Michael Stapelberg
31d26e1e37 increase timeout from 1m to 5m, for slower devices
Larger installations can take over a minute to start up.
2021-12-27 08:48:53 +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
d8eb163b39 packer: poll device until it reports the new build timestamp 2021-12-15 15:28:52 +01:00
Michael Stapelberg
a33ad86c63 gok run: automatically follow logs after uploading
related to https://github.com/gokrazy/gokrazy/issues/88
2021-12-15 14:52:22 +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
Anup Chenthamarakshan
8127d75153 packer: ignore firmware globs if -firmware_package is empty (#27)
Don't accidentally pick up firmware files from CWD if -firmware_package is unset
2021-12-01 08:54:02 +01:00
Michael Stapelberg
688793dda2 better error message when the binary was not installed 2021-11-21 21:53:20 +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
a99f2c5561 move gotool.go into packer package for upcoming re-use 2021-11-21 09:50:50 +01:00
Michael Stapelberg
21d99992a1 packer: findBins must be called after build 2021-11-20 18:43:13 +01:00
Michael Stapelberg
c8145dc98d report progress (and rate) while uploading boot/root file system 2021-11-20 18:37:58 +01:00
Michael Stapelberg
7318b6cbe7 interactively report progress for boot/root file system creation 2021-11-20 18:19:06 +01:00
Michael Stapelberg
77f6c75da6 tidy up boot file system summary 2021-11-20 17:48:57 +01:00
Michael Stapelberg
c363800e98 remove .go file name from user-facing messages 2021-11-20 17:48:10 +01:00
Michael Stapelberg
69a3b3932f packer: tidy up build summary 2021-11-20 17:01:47 +01:00
Michael Stapelberg
9ae769dee0 cacerts: log → fmt 2021-11-20 16:52:01 +01:00
Michael Stapelberg
b65fcafb54 packer: print status indicator when running go build 2021-11-20 16:51:36 +01:00
Michael Stapelberg
fd36cf8872 packer: print host and target environment 2021-11-20 16:50:05 +01:00
Michael Stapelberg
24e042947c packer: print build timestamp 2021-11-20 16:49:24 +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
2e02ea7acd fix: move guid_test to the packer package 2021-11-20 11:12:32 +01:00
Michael Stapelberg
de96a68f36 gofmt with go 1.17 2021-10-24 18:25:02 +02:00
Michael Stapelberg
8736bc10b5 -update: obey -http_port, implement syntax :80
-update=:80 means -update=yes, but on port 80 regardless of -http_port.
2021-10-24 18:21:35 +02:00
Benjamin Böhmke
c6536fc744 Include extrafiles/<package>/* in root file system (#26)
This configuration works similar to https://gokrazy.org/userguide/package-config/ and can be used to include data files that are not easy to embed into the package itself, nor appropriate to go on the `/perm` partition (i.e. should be versioned/distributed with the gokrazy image).
2021-06-28 19:24:05 +02:00
Michael Stapelberg
997ca6b27e ignore ReadMsgUnix flags return value
This returns MSG_CMSG_CLOEXEC since https://github.com/golang/go/issues/42765
(for Go 1.17).

I don’t recall why we should need to check the flags in the first place. Perhaps
that was a mistake when the code was first introduced.
2021-06-24 15:36:05 +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
0eb14eb8e1 specify -tags gokrazy when calling go list, too
This fixes building packages where all files use the gokrazy build tag.
2021-06-17 17:59:53 +02:00
Michael Stapelberg
ddba679fac partition table: make space for secondary GPT at the end of the disk
See https://en.wikipedia.org/wiki/GUID_Partition_Table
The Secondary GPT uses LBA -33 to LBA -1
2021-06-17 09:28:26 +02:00
Michael Stapelberg
929442d467 gotool: skip -eeprom_package if unspecified
Before this commit, the tool would try to “go get .”, which won’t necessarily
work.
2021-06-17 09:28:26 +02:00
Michael Stapelberg
e20e78958e packer: remove -mod=mod from go get call
Only go list and go build support the -mod flag.
2021-06-17 09:28:26 +02:00