From df04e4c28a08fcdda4a8fa8af7608c08855e1cbf Mon Sep 17 00:00:00 2001 From: shanker JJ Date: Sun, 23 Oct 2022 16:36:16 +0900 Subject: [PATCH 1/3] Adding support for OpenWrt-mips arch --- netclient/bin-maker.sh | 2 +- scripts/netclient-install.sh | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/netclient/bin-maker.sh b/netclient/bin-maker.sh index 10988606..d86c4fee 100755 --- a/netclient/bin-maker.sh +++ b/netclient/bin-maker.sh @@ -20,7 +20,7 @@ function build build $_goarch $_goose 5 && build $_goarch $_goose 6 && build $_goarch $_goose 7 else echo $_out - GOARM=$_goarm GOARCH=$_goarch GOOS=$_goose GOHOSTARCH=$__HOST_ARCH CGO_ENABLED=0 go build -ldflags="-X 'main.version=$VERSION'" -o $_out + if [ "$_goarch" == "mips" ]; then GOMIPS=softfloat; fi; GOARM=$_goarm GOARCH=$_goarch GOOS=$_goose GOHOSTARCH=$__HOST_ARCH CGO_ENABLED=0 go build -ldflags="-X 'main.version=$VERSION'" -o $_out fi } diff --git a/scripts/netclient-install.sh b/scripts/netclient-install.sh index e49c5515..91992ce0 100755 --- a/scripts/netclient-install.sh +++ b/scripts/netclient-install.sh @@ -148,8 +148,11 @@ case $(uname | tr A-Z a-z) in arm*) dist=netclient-$CPU_ARCH ;; - mipsle) + mipsle) dist=netclient-mipsle + ;; + mips*) + dist=netclient-$CPU_ARCH ;; *) fatal "$CPU_ARCH : cpu architecture not supported" @@ -240,6 +243,8 @@ if [ "${OS}" = "OpenWRT" ] || [ "${OS}" = "TurrisOS" ]; then else wget $curl_opts -O netclient.service.tmp https://raw.githubusercontent.com/gravitl/netmaker/master/scripts/openwrt-daemon.sh fi + elif [ "${OS}" = "OpenWRT" ] && [ "$CPU_ARCH" = "mips" ]; then + wget $curl_opts -O netclient.service.tmp https://raw.githubusercontent.com/gravitl/netmaker/master/scripts/openwrt-daemon.sh else cat << 'END_OF_FILE' > ./netclient.service.tmp #!/bin/sh /etc/rc.common @@ -292,5 +297,4 @@ END_OF_FILE /etc/init.d/netclient start else rm -f netclient -fi - +fi \ No newline at end of file From 6c76a2bfcf2c8f4bad42116ddfdf3a148dd14520 Mon Sep 17 00:00:00 2001 From: shanker JJ Date: Mon, 24 Oct 2022 11:10:32 +0900 Subject: [PATCH 2/3] Adding support in workflow to uploade mips binary in release --- .github/workflows/buildandrelease.yml | 42 +++++++++++++++++++++++++++ netclient/bin-maker.sh | 6 +++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/.github/workflows/buildandrelease.yml b/.github/workflows/buildandrelease.yml index 9b9b4fc2..eb4a3ac0 100644 --- a/.github/workflows/buildandrelease.yml +++ b/.github/workflows/buildandrelease.yml @@ -306,6 +306,48 @@ jobs: prerelease: true asset_name: netclient-mipsle + netclient-mips: + runs-on: ubuntu-latest + needs: version + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set Variables + run: | + TAG=${{needs.version.outputs.tag}} + VERSION=${{needs.version.outputs.version}} + echo "NETMAKER_VERSION=${TAG}" >> $GITHUB_ENV + echo "PACKAGE_VERSION=${VERSION}" >> $GITHUB_ENV + - name: Setup go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + - name: Build + run: | + cd netclient + env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "-s -w -X 'main.version=$NETMAKER_VERSION'" -o build/netclient-mips/netclient main.go + env CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "-s -w -X 'main.version=$NETMAKER_VERSION'" -o build/netclient-mips-upx/netclient main.go && upx build/netclient-mips-upx/netclient + + - name: Upload mips to Release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: netclient/build/netclient-mips/netclient + tag: ${{ env.NETMAKER_VERSION }} + overwrite: true + prerelease: true + asset_name: netclient-mips + + - name: Upload upx compressed version of mips to Release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: netclient/build/netclient-mips-upx/netclient + tag: ${{ env.NETMAKER_VERSION }} + overwrite: true + prerelease: true + asset_name: netclient-mips-upx + netclient-freebsd: runs-on: ubuntu-latest needs: version diff --git a/netclient/bin-maker.sh b/netclient/bin-maker.sh index d86c4fee..00f59e3b 100755 --- a/netclient/bin-maker.sh +++ b/netclient/bin-maker.sh @@ -20,7 +20,11 @@ function build build $_goarch $_goose 5 && build $_goarch $_goose 6 && build $_goarch $_goose 7 else echo $_out - if [ "$_goarch" == "mips" ]; then GOMIPS=softfloat; fi; GOARM=$_goarm GOARCH=$_goarch GOOS=$_goose GOHOSTARCH=$__HOST_ARCH CGO_ENABLED=0 go build -ldflags="-X 'main.version=$VERSION'" -o $_out + if [ "$_goarch" == "mips" ]; then + GOARM=$_goarm GOMIPS=softfloat GOARCH=mipsle GOOS=$_goose GOHOSTARCH=$__HOST_ARCH CGO_ENABLED=0 go build -ldflags="-X 'main.version=$VERSION'" -o $_out + else + GOARM=$_goarm GOARCH=$_goarch GOOS=$_goose GOHOSTARCH=$__HOST_ARCH CGO_ENABLED=0 go build -ldflags="-X 'main.version=$VERSION'" -o $_out + fi fi } From 6acdedb211de612846bd7a367afd4f242115d1a3 Mon Sep 17 00:00:00 2001 From: shanker JJ Date: Tue, 25 Oct 2022 06:35:19 +0900 Subject: [PATCH 3/3] Adding comment in bin-maker.sh --- netclient/bin-maker.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/netclient/bin-maker.sh b/netclient/bin-maker.sh index 00f59e3b..05808fa4 100755 --- a/netclient/bin-maker.sh +++ b/netclient/bin-maker.sh @@ -21,6 +21,7 @@ function build else echo $_out if [ "$_goarch" == "mips" ]; then + # If the binary created through `GOMIPS=softfloat GOARCH=mipsle` is not compatible with your hardware, try changing these variables and creating a binary file compatible with your hardware. GOARM=$_goarm GOMIPS=softfloat GOARCH=mipsle GOOS=$_goose GOHOSTARCH=$__HOST_ARCH CGO_ENABLED=0 go build -ldflags="-X 'main.version=$VERSION'" -o $_out else GOARM=$_goarm GOARCH=$_goarch GOOS=$_goose GOHOSTARCH=$__HOST_ARCH CGO_ENABLED=0 go build -ldflags="-X 'main.version=$VERSION'" -o $_out