From 808618602c092956a9c0ae7ca1b300ca8be98d55 Mon Sep 17 00:00:00 2001
From: Andrey Meshkov <am@adguard.com>
Date: Thu, 6 Feb 2020 20:55:37 +0300
Subject: [PATCH] *(global): fix ARM build auto-update
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

✅ Closes: https://github.com/AdguardTeam/AdGuardHome/issues/1391
---
 Makefile               | 3 +--
 home/control_update.go | 4 +++-
 home/home.go           | 6 +++++-
 main.go                | 2 +-
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 0c3bd56b..74934562 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,6 @@ GOPATH := $(shell go env GOPATH)
 JSFILES = $(shell find client -path client/node_modules -prune -o -type f -name '*.js')
 STATIC = build/static/index.html
 CHANNEL ?= release
-GOARM_VER :=
 
 TARGET=AdGuardHome
 
@@ -24,7 +23,7 @@ $(STATIC): $(JSFILES) client/node_modules
 $(TARGET): $(STATIC) *.go home/*.go dhcpd/*.go dnsfilter/*.go dnsforward/*.go
 	GOOS=$(NATIVE_GOOS) GOARCH=$(NATIVE_GOARCH) GO111MODULE=off go get -v github.com/gobuffalo/packr/...
 	PATH=$(GOPATH)/bin:$(PATH) packr -z
-	CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=$(GIT_VERSION) -X main.channel=$(CHANNEL) -X main.goarm=$(GOARM_VER)" -asmflags="-trimpath=$(PWD)" -gcflags="-trimpath=$(PWD)"
+	CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=$(GIT_VERSION) -X main.channel=$(CHANNEL) -X main.goarm=$(GOARM)" -asmflags="-trimpath=$(PWD)" -gcflags="-trimpath=$(PWD)"
 	PATH=$(GOPATH)/bin:$(PATH) packr clean
 
 clean:
diff --git a/home/control_update.go b/home/control_update.go
index 6cabdcab..7864cfbb 100644
--- a/home/control_update.go
+++ b/home/control_update.go
@@ -42,8 +42,10 @@ func getVersionResp(data []byte) []byte {
 		return []byte{}
 	}
 
+	// the key is download_linux_arm or download_linux_arm64 for regular ARM versions
 	dloadName := fmt.Sprintf("download_%s_%s", runtime.GOOS, runtime.GOARCH)
-	if runtime.GOARCH == "arm" && ARMVersion != "6" {
+	if runtime.GOARCH == "arm" && ARMVersion == "5" {
+		// the key is download_linux_armv5 for ARMv5
 		dloadName = fmt.Sprintf("download_%s_%sv%s", runtime.GOOS, runtime.GOARCH, ARMVersion)
 	}
 	_, ok := versionJSON[dloadName]
diff --git a/home/home.go b/home/home.go
index b965b74c..5b34847b 100644
--- a/home/home.go
+++ b/home/home.go
@@ -101,7 +101,11 @@ func run(args options) {
 	configureLogger(args)
 
 	// print the first message after logger is configured
-	log.Printf("AdGuard Home, version %s, channel %s\n", versionString, updateChannel)
+	msg := "AdGuard Home, version %s, channel %s\n, arch %s %s"
+	if ARMVersion != "" {
+		msg = msg + " v" + ARMVersion
+	}
+	log.Printf(msg, versionString, updateChannel, runtime.GOOS, runtime.GOARCH, ARMVersion)
 	log.Debug("Current working directory is %s", config.ourWorkingDir)
 	if args.runningAsService {
 		log.Info("AdGuard Home is running as a service")
diff --git a/main.go b/main.go
index 9d441aee..36946082 100644
--- a/main.go
+++ b/main.go
@@ -12,7 +12,7 @@ var version = "undefined"
 // channel can be set via ldflags
 var channel = "release"
 
-// ARM version number.  Set via linker flags.
+// GOARM value - set via ldflags
 var goarm = ""
 
 func main() {