From b30ec6b691f0e0f88c7f2baf0a181219cb424922 Mon Sep 17 00:00:00 2001 From: mbugeia Date: Tue, 18 Oct 2016 00:09:26 +0200 Subject: [PATCH] Detect arch with uname, inspired by getcaddy.com --- README.md | 2 +- scripts/_common.sh | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 9225fcf..fda8be4 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Gogs v0.9.71 - [YunoHost forum thread](https://forum.yunohost.org/t/gogs-package-an-awesome-github-alternative/1127) -Architecture: this package is compatible with amd64, i386 and arm, the package will try to detect it with the command arch and fail if it can't find it. If that happen please open an issue describing your hardware and the result of the command `arch`. +Architecture: this package is compatible with amd64, i386 and arm, the package will try to detect it with the command uname -m and fail if it can't find it. If that happen please open an issue describing your hardware and the result of the command `uname -m`. ## License Gogs is published under MIT License diff --git a/scripts/_common.sh b/scripts/_common.sh index a58b964..4a16701 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,17 +8,19 @@ APPNAME="gogs" VERSION="0.9.71" # Detect the system architecture to download the right tarball -case $(arch) in -x86_64) ARCHITECTURE="amd64" - ;; -i386|i686) ARCHITECTURE="386" - ;; -armhf|armel|armv7l) ARCHITECTURE="arm" - ;; -*) echo 'Unable to detect your achitecture, please open a bug describing \ - your hardware and the result of the command "arch".' && exit 1 - ;; -esac +# NOTE: `uname -m` is more accurate and universal than `arch` +# See https://en.wikipedia.org/wiki/Uname +if [ -n "$(uname -m | grep 64)" ]; then + ARCHITECTURE="amd64" +elif [ -n "$(uname -m | grep 86)" ]; then + ARCHITECTURE="386" +elif [ -n "$(uname -m | grep arm)" ]; then + ARCHITECTURE="arm" +else + echo 'Unable to detect your achitecture, please open a bug describing \ + your hardware and the result of the command "uname -m".' + exit 1 +fi # Remote URL to fetch Gogs tarball GOGS_BINARY_URL="https://github.com/gogits/gogs/releases/download/v${VERSION}/linux_${ARCHITECTURE}.zip"