Skip to content

Commit

Permalink
chore: upgrade grokrazy (#18209)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Feb 1, 2025
1 parent 24ae29e commit 31e476c
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 121 deletions.
45 changes: 27 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ DOCKER_TAG := testing
PLATFORM := linux/amd64,linux/arm64,linux/arm/v6

# gokrazy image
IMAGE_FILE := evcc_$(TAG_NAME).image
IMAGE_OPTIONS := -hostname evcc -http_port 8080 github.com/gokrazy/serial-busybox github.com/gokrazy/breakglass github.com/gokrazy/mkfs github.com/gokrazy/wifi github.com/evcc-io/evcc
GOK_DIR := packaging/gokrazy
GOK_NETDEV := user,id=net0,hostfwd=tcp::8080-:80,hostfwd=tcp::8022-:22,hostfwd=tcp::8888-:8080
GOK := gok -i evcc --parent_dir $(GOK_DIR)
IMAGE_FILE := evcc_$(TAG_NAME).img

# deb
PACKAGES = ./release
Expand Down Expand Up @@ -104,25 +106,32 @@ apt-release::
cloudsmith push deb evcc/stable/any-distro/any-version $(file); \
)

# gokrazy image
gokrazy::
go install github.com/gokrazy/tools/cmd/gokr-packer@main
mkdir -p flags/github.com/gokrazy/breakglass
echo "-forward=private-network" > flags/github.com/gokrazy/breakglass/flags.txt
mkdir -p env/github.com/evcc-io/evcc
echo "EVCC_NETWORK_PORT=80" > env/github.com/evcc-io/evcc/env.txt
echo "EVCC_DATABASE_DSN=/perm/evcc.db" >> env/github.com/evcc-io/evcc/env.txt
mkdir -p buildflags/github.com/evcc-io/evcc
echo "$(BUILD_TAGS),gokrazy" > buildflags/github.com/evcc-io/evcc/buildflags.txt
echo "-ldflags=$(LD_FLAGS)" >> buildflags/github.com/evcc-io/evcc/buildflags.txt
gokr-packer -hostname evcc -http_port 8080 -overwrite=$(IMAGE_FILE) -target_storage_bytes=1258299392 $(IMAGE_OPTIONS)
# gokrazy
gok::
which gok || go install github.com/gokrazy/tools/cmd/gok@main
# https://stackoverflow.com/questions/1250079/how-to-escape-single-quotes-within-single-quoted-strings
sed 's!"GoBuildFlags": null!"GoBuildFlags": ["$(BUILD_TAGS) -trimpath -ldflags='"'"'$(LD_FLAGS)'"'"'"]!g' $(GOK_DIR)/config.tmpl.json > $(GOK_DIR)/evcc/config.json
${GOK} add .
# ${GOK} add tailscale.com/cmd/tailscaled
# ${GOK} add tailscale.com/cmd/tailscale

# build image
gok-image:: gok
${GOK} overwrite --full=$(IMAGE_FILE) --target_storage_bytes=1258299392
# gzip -f $(IMAGE_FILE)

gokrazy-run::
MACHINE=arm64 IMAGE_FILE=$(IMAGE_FILE) ./packaging/gokrazy/run.sh
# run qemu
gok-run:: gok
${GOK} vm run --netdev $(GOK_NETDEV)

# run qemu on mac
gok-mac:: gok
mv $(GOK_DIR)/evcc/config.json $(GOK_DIR)/evcc/linux.json
sed 's!"SerialConsole": "ttyAMA0,115200"!"KernelPackage": "github.com/gokrazy/kernel.arm64",'\\n' "SerialConsole": "ttyAMA0,115200"!g' $(GOK_DIR)/evcc/linux.json > $(GOK_DIR)/evcc/config.json
${GOK} vm run --netdev $(GOK_NETDEV)

gokrazy-update::
gokr-packer -update yes $(IMAGE_OPTIONS)
gok-update::
${GOK} update yes $(IMAGE_OPTIONS)

soc::
@echo Version: $(VERSION) $(SHA) $(BUILD_DATE)
Expand Down
3 changes: 2 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ func runRoot(cmd *cobra.Command, args []string) {

httpd.RegisterSystemHandler(valueChan, cache, auth, func() {
log.INFO.Println("evcc was stopped by user. OS should restart the service. Or restart manually.")
once.Do(func() { close(stopC) }) // signal loop to end
err = errors.New("restart required") // https://gokrazy.org/development/process-interface/
once.Do(func() { close(stopC) }) // signal loop to end
})

// show and check version, reduce api load during development
Expand Down
44 changes: 44 additions & 0 deletions packaging/gokrazy/config.tmpl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"Hostname": "evcc",
"Update": {
"HTTPPort": "8080",
"HTTPPassword": "HjJv6aBX51G4wT8EueCc"
},
"Packages": [
"github.com/gokrazy/breakglass",
"tailscale.com/cmd/tailscaled",
"tailscale.com/cmd/tailscale",
"github.com/gokrazy/mkfs",
"github.com/gokrazy/fbstatus",
"github.com/gokrazy/serial-busybox",
"github.com/gokrazy/wifi"
],
"PackageConfig": {
"github.com/evcc-io/evcc": {
"GoBuildFlags": null,
"Environment": [
"EVCC_NETWORK_PORT=80",
"EVCC_DATABASE_DSN=/perm/evcc.db"
],
"ExtraFileContents": {
"/etc/evcc.yaml": " "
}
},
"github.com/gokrazy/breakglass": {
"CommandLineFlags": [
"-authorized_keys=/etc/breakglass.authorized_keys",
"-forward=private-network"
],
"ExtraFileContents": {
"/etc/breakglass.authorized_keys": " "
}
},
"tailscale.com/cmd/tailscale": {
"CommandLineFlags": [
"up",
"--ssh=true"
]
}
},
"SerialConsole": "ttyAMA0,115200"
}
102 changes: 0 additions & 102 deletions packaging/gokrazy/run.sh

This file was deleted.

0 comments on commit 31e476c

Please sign in to comment.