From eb6c4eb132d45f9ded7a85eab49cf91b0829d47c Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Wed, 15 Jan 2020 18:58:12 +0300 Subject: [PATCH] + release.sh: add armv5 build Close #1239 Squashed commit of the following: commit 707e2f8e265e294c7b1328c375648f799a5ae293 Author: Simon Zolin Date: Fri Jan 10 16:32:52 2020 +0300 leave "AdGuardHome_linux_arm" by default commit cca01fd03200e70d6ee2201540570382f2b7fdf4 Author: Simon Zolin Date: Fri Jan 10 14:53:37 2020 +0300 fix auto-update; update readme commit f393a4f511861ef1998c68775bb8f234c5ce1838 Author: Simon Zolin Date: Fri Jan 10 13:00:37 2020 +0300 + release.sh: add armv5 build; rename armv6 build commit 73f2d20ba6b0a94a9929882fe15175ba80b528d7 Author: Simon Zolin Date: Fri Jan 10 12:59:55 2020 +0300 * release.sh: fix indentation --- Makefile | 3 ++- README.md | 5 +++-- home/control_update.go | 6 +++++- home/home.go | 4 +++- main.go | 5 ++++- release.sh | 24 +++++++++++++++--------- 6 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index a0b6e73c..0c3bd56b 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ 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 @@ -23,7 +24,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)" -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_VER)" -asmflags="-trimpath=$(PWD)" -gcflags="-trimpath=$(PWD)" PATH=$(GOPATH)/bin:$(PATH) packr clean clean: diff --git a/README.md b/README.md index 3a1aedfb..8b9dc5d6 100644 --- a/README.md +++ b/README.md @@ -170,14 +170,15 @@ or you can use the Docker image from the `edge` tag, which is synced with the re * [Docker Hub](https://hub.docker.com/r/adguard/adguardhome) * Beta builds - * [Rapsberry Pi (32-bit ARM)](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_arm.tar.gz) + * [Raspberry Pi (32-bit ARMv6)](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_arm.tar.gz) * [MacOS](https://static.adguard.com/adguardhome/beta/AdGuardHome_MacOS.zip) * [Windows 64-bit](https://static.adguard.com/adguardhome/beta/AdGuardHome_Windows_amd64.zip) * [Windows 32-bit](https://static.adguard.com/adguardhome/beta/AdGuardHome_Windows_386.zip) * [Linux 64-bit](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_amd64.tar.gz) * [Linux 32-bit](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_386.tar.gz) * [FreeBSD 64-bit](https://static.adguard.com/adguardhome/beta/AdGuardHome_freebsd_amd64.tar.gz) - * [64-bit ARM](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_arm64.tar.gz) + * [Linux 64-bit ARM](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_arm64.tar.gz) + * [Linux 32-bit ARMv5](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_armv5.tar.gz) * [MIPS](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_mips.tar.gz) * [MIPSLE](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_mipsle.tar.gz) diff --git a/home/control_update.go b/home/control_update.go index 02c1fec0..69c62885 100644 --- a/home/control_update.go +++ b/home/control_update.go @@ -42,7 +42,11 @@ func getVersionResp(data []byte) []byte { return []byte{} } - _, ok := versionJSON[fmt.Sprintf("download_%s_%s", runtime.GOOS, runtime.GOARCH)] + dloadName := fmt.Sprintf("download_%s_%s", runtime.GOOS, runtime.GOARCH) + if runtime.GOARCH == "arm" && ARMVersion != "6" { + dloadName = fmt.Sprintf("download_%s_%sv%s", runtime.GOOS, runtime.GOARCH, ARMVersion) + } + _, ok := versionJSON[dloadName] if ok && ret["new_version"] != versionString && versionString >= selfUpdateMinVersion { ret["can_autoupdate"] = true } diff --git a/home/home.go b/home/home.go index fcefa4b6..44fbe855 100644 --- a/home/home.go +++ b/home/home.go @@ -42,6 +42,7 @@ var ( versionString string updateChannel string versionCheckURL string + ARMVersion string ) const versionCheckPeriod = time.Hour * 8 @@ -64,10 +65,11 @@ type homeContext struct { var Context homeContext // Main is the entry point -func Main(version string, channel string) { +func Main(version string, channel string, armVer string) { // Init update-related global variables versionString = version updateChannel = channel + ARMVersion = armVer versionCheckURL = "https://static.adguard.com/adguardhome/" + updateChannel + "/version.json" // config can be specified, which reads options from there, but other command line flags have to override config values diff --git a/main.go b/main.go index 823890ea..9d441aee 100644 --- a/main.go +++ b/main.go @@ -12,7 +12,10 @@ var version = "undefined" // channel can be set via ldflags var channel = "release" +// ARM version number. Set via linker flags. +var goarm = "" + func main() { debug.SetGCPercent(10) - home.Main(version, channel) + home.Main(version, channel, goarm) } diff --git a/release.sh b/release.sh index 748e407a..4f2a4c42 100755 --- a/release.sh +++ b/release.sh @@ -12,17 +12,21 @@ version=`git describe --abbrev=4 --dirty --always --tags` f() { make cleanfast; CGO_DISABLED=1 make if [[ $GOOS == darwin ]]; then - zip $dst/AdGuardHome_MacOS.zip AdGuardHome README.md LICENSE.txt + zip $dst/AdGuardHome_MacOS.zip AdGuardHome README.md LICENSE.txt elif [[ $GOOS == windows ]]; then - zip $dst/AdGuardHome_Windows_"$GOARCH".zip AdGuardHome.exe README.md LICENSE.txt + zip $dst/AdGuardHome_Windows_"$GOARCH".zip AdGuardHome.exe README.md LICENSE.txt else - rm -rf dist/AdguardHome - mkdir -p dist/AdGuardHome - cp -pv {AdGuardHome,LICENSE.txt,README.md} dist/AdGuardHome/ - pushd dist - tar zcvf AdGuardHome_"$GOOS"_"$GOARCH".tar.gz AdGuardHome/ - popd - rm -rf dist/AdguardHome + rm -rf dist/AdguardHome + mkdir -p dist/AdGuardHome + cp -pv {AdGuardHome,LICENSE.txt,README.md} dist/AdGuardHome/ + pushd dist + if [[ $GOARCH == arm ]] && [[ $GOARM != 6 ]]; then + tar zcvf AdGuardHome_"$GOOS"_armv"$GOARM".tar.gz AdGuardHome/ + else + tar zcvf AdGuardHome_"$GOOS"_"$GOARCH".tar.gz AdGuardHome/ + fi + popd + rm -rf dist/AdguardHome fi } @@ -37,6 +41,7 @@ mkdir -p $dst CHANNEL=$channel GOOS=darwin GOARCH=amd64 f CHANNEL=$channel GOOS=linux GOARCH=amd64 f CHANNEL=$channel GOOS=linux GOARCH=386 GO386=387 f +CHANNEL=$channel GOOS=linux GOARCH=arm GOARM=5 f CHANNEL=$channel GOOS=linux GOARCH=arm GOARM=6 f CHANNEL=$channel GOOS=linux GOARCH=arm64 GOARM=6 f CHANNEL=$channel GOOS=windows GOARCH=amd64 f @@ -59,6 +64,7 @@ echo " \"download_darwin_amd64\": \"$baseUrl/AdGuardHome_MacOS.zip\"," >> $dst/ echo " \"download_linux_amd64\": \"$baseUrl/AdGuardHome_linux_amd64.tar.gz\"," >> $dst/version.json echo " \"download_linux_386\": \"$baseUrl/AdGuardHome_linux_386.tar.gz\"," >> $dst/version.json echo " \"download_linux_arm\": \"$baseUrl/AdGuardHome_linux_arm.tar.gz\"," >> $dst/version.json +echo " \"download_linux_armv5\": \"$baseUrl/AdGuardHome_linux_armv5.tar.gz\"," >> $dst/version.json echo " \"download_linux_arm64\": \"$baseUrl/AdGuardHome_linux_arm64.tar.gz\"," >> $dst/version.json echo " \"download_linux_mips\": \"$baseUrl/AdGuardHome_linux_mips.tar.gz\"," >> $dst/version.json echo " \"download_linux_mipsle\": \"$baseUrl/AdGuardHome_linux_mipsle.tar.gz\"," >> $dst/version.json