From 48466cebd2c6118b00095d23ee389e56a0bc84ef Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@robotics.uk.to>
Date: Thu, 29 Sep 2016 10:16:52 +0100
Subject: [PATCH] Architecture detection

---
 src/freedombone-app-cjdns |  5 +----
 src/freedombone-app-gogs  |  6 ++----
 src/freedombone-app-ipfs  | 24 +++++++++++++-----------
 src/freedombone-utils-go  | 14 ++++++++++++--
 4 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/src/freedombone-app-cjdns b/src/freedombone-app-cjdns
index bc18d0c1a..94f598bd6 100755
--- a/src/freedombone-app-cjdns
+++ b/src/freedombone-app-cjdns
@@ -483,10 +483,7 @@ function install_cjdns_tools {
         install_cjdns
     fi
 
-    function_check select_go_version
-    select_go_version
-
-    apt-get -y install golang mercurial
+    apt-get -y install mercurial
     if [ ! -f ~/.bashrc ]; then
         touch ~/.bashrc
     fi
diff --git a/src/freedombone-app-gogs b/src/freedombone-app-gogs
index 5ac939d48..100bfdda2 100755
--- a/src/freedombone-app-gogs
+++ b/src/freedombone-app-gogs
@@ -47,7 +47,7 @@ function gogs_parameters {
     if [[ $ARCHITECTURE == *"386" || $ARCHITECTURE == *"686" ]]; then
         CURR_ARCH=386
     fi
-    if [[ $ARCHITECTURE == *"amd64" ]]; then
+    if [[ $ARCHITECTURE == *"amd64" || $ARCHITECTURE == "x86_64" ]]; then
         CURR_ARCH=amd64
     fi
     if [[ $ARCHITECTURE == *"arm"* ]]; then
@@ -59,7 +59,7 @@ function gogs_parameters {
         if [[ $ARCHITECTURE == "arm"* ]]; then
             CURR_ARCH=arm
         fi
-        if [[ $ARCHITECTURE == "amd"* ]]; then
+        if [[ $ARCHITECTURE == "amd"* || $ARCHITECTURE == "x86_64" ]]; then
             CURR_ARCH=amd64
         fi
         if [[ $ARCHITECTURE == *"386" || $ARCHITECTURE == *"686" ]]; then
@@ -317,8 +317,6 @@ function remove_gogs {
     if ! grep -Fxq "install_gogs" $COMPLETION_FILE; then
         return
     fi
-    function_check select_go_version
-    select_go_version
 
     systemctl stop gogs
     systemctl disable gogs
diff --git a/src/freedombone-app-ipfs b/src/freedombone-app-ipfs
index c2b5d561a..040915f5b 100755
--- a/src/freedombone-app-ipfs
+++ b/src/freedombone-app-ipfs
@@ -28,7 +28,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-VARIANTS='mesh'
+VARIANTS=''
 
 IPFS_GO_REPO_BASE="github.com/ipfs/go-ipfs"
 IPFS_GO_REPO="https://${IPFS_GO_REPO_BASE}"
@@ -54,9 +54,6 @@ function upgrade_ipfs_go {
         return
     fi
 
-    function_check select_go_version
-    select_go_version
-
     function_check set_repo_commit
     set_repo_commit $GOPATH/src/github.com/ipfs/go-ipfs "ipfs commit" "$IPFS_COMMIT" $IPFS_REPO
 }
@@ -153,8 +150,6 @@ function remove_ipfs_go {
     if ! grep -Fxq "install_ipfs_go" $COMPLETION_FILE; then
         return
     fi
-    function_check select_go_version
-    select_go_version
     systemctl stop ipfs
     systemctl disable ipfs
     systemctl daemon-reload
@@ -398,14 +393,24 @@ function mesh_install_ipfs_go {
     if [[ $ARCHITECTURE == *"386" || $ARCHITECTURE == *"686" ]]; then
         IPFS_ARCH=386
     fi
-    if [[ $ARCHITECTURE == *"amd64" ]]; then
+    if [[ $ARCHITECTURE == *"amd64" || $ARCHITECTURE == "x86_64" ]]; then
         IPFS_ARCH=amd64
     fi
     if [[ $ARCHITECTURE == *"arm"* ]]; then
         IPFS_ARCH=arm
     fi
     if [ ! $IPFS_ARCH ]; then
-        return
+        echo $'No architecture specified'
+        ARCHITECTURE=$(uname -m)
+        if [[ $ARCHITECTURE == "arm"* ]]; then
+            IPFS_ARCH=arm
+        fi
+        if [[ $ARCHITECTURE == "amd"* || $ARCHITECTURE == "x86_64" ]]; then
+            IPFS_ARCH=amd64
+        fi
+        if [[ $ARCHITECTURE == *"386" || $ARCHITECTURE == *"686" ]]; then
+            IPFS_ARCH=386
+        fi
     fi
 
     IPFS_FILE=go-ipfs_v${IPFS_GO_VERSION}_linux-${IPFS_ARCH}.tar.gz
@@ -450,9 +455,6 @@ function install_ipfs_go {
         return
     fi
 
-    function_check select_go_version
-    select_go_version
-
     apt-get -y install golang libpam0g-dev fuse
 
     if [ ! -d /home/git ]; then
diff --git a/src/freedombone-utils-go b/src/freedombone-utils-go
index bbf5b1a25..ba2ff20a6 100755
--- a/src/freedombone-utils-go
+++ b/src/freedombone-utils-go
@@ -141,14 +141,24 @@ function mesh_upgrade_golang {
     if [[ $ARCHITECTURE == *"386" || $ARCHITECTURE == *"686" ]]; then
         GOARCH=386
     fi
-    if [[ $ARCHITECTURE == *"amd64" ]]; then
+    if [[ $ARCHITECTURE == *"amd64" || $ARCHITECTURE == "x86_64" ]]; then
         GOARCH=amd64
     fi
     if [[ $ARCHITECTURE == *"arm"* ]]; then
         GOARCH=armv6l
     fi
     if [ ! $GOARCH ]; then
-        return
+        echo $'No architecture specified'
+        ARCHITECTURE=$(uname -m)
+        if [[ $ARCHITECTURE == "arm"* ]]; then
+            GOARCH=armv6l
+        fi
+        if [[ $ARCHITECTURE == "amd"* || $ARCHITECTURE == "x86_64" ]]; then
+            GOARCH=amd64
+        fi
+        if [[ $ARCHITECTURE == *"386" || $ARCHITECTURE == *"686" ]]; then
+            GOARCH=386
+        fi
     fi
     GO_SOURCE=https://storage.googleapis.com/golang/go${GO_VERSION}.linux-${GOARCH}.tar.gz
 
-- 
GitLab