From 17530cae106b47c11075f39dfcb323665af7dd94 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 17 Oct 2019 01:07:08 +0200 Subject: [PATCH 1/2] implement ynh_detect_arch --- conf/{arm.src => arm64.src} | 0 scripts/detect_arch | 14 -------------- scripts/install | 9 ++++++++- scripts/restore | 2 +- scripts/upgrade | 2 +- scripts/ynh_detect_arch__2 | 25 +++++++++++++++++++++++++ 6 files changed, 35 insertions(+), 17 deletions(-) rename conf/{arm.src => arm64.src} (100%) delete mode 100644 scripts/detect_arch create mode 100644 scripts/ynh_detect_arch__2 diff --git a/conf/arm.src b/conf/arm64.src similarity index 100% rename from conf/arm.src rename to conf/arm64.src diff --git a/scripts/detect_arch b/scripts/detect_arch deleted file mode 100644 index 20ab9dc..0000000 --- a/scripts/detect_arch +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -if [ -n "$(uname -m | grep x86_64)" ]; then - architecture="x86-64" -elif [ -n "$(uname -m | grep 86)" ]; then - architecture="i386" -elif [ -n "$(uname -m | grep arm)" ]; then - architecture="arm" -elif [ -n "$(uname -m | grep aarch64)" ]; then - architecture="arm" -else - ynh_die --message="Unable to detect your achitecture, please open a bug describing \ - your hardware and the result of the command \"uname -m\"." 1 -fi diff --git a/scripts/install b/scripts/install index ffad74e..59cfb79 100755 --- a/scripts/install +++ b/scripts/install @@ -7,7 +7,7 @@ #================================================= source _common.sh -source detect_arch +source ynh_detect_arch__2 source /usr/share/yunohost/helpers #================================================= @@ -41,6 +41,13 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_print_info --message="Validating installation parameters..." +architecture=$(ynh_detect_arch) +# Check machine architecture (in particular, we don't support ARM and 32bit machines) +if [ $architecture == "arm" ] +then + ynh_die --message="Sorry, but this app can only be installed on a 64 bits machine :(" +fi + final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" diff --git a/scripts/restore b/scripts/restore index b9bbdd7..9896ad4 100755 --- a/scripts/restore +++ b/scripts/restore @@ -7,7 +7,7 @@ #================================================= source ../settings/scripts/_common.sh -source detect_arch +source ../settings/scripts/ynh_detect_arch__2 source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 3b683a3..061f238 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,7 +7,7 @@ #================================================= source _common.sh -source detect_arch +source ynh_detect_arch__2 source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/ynh_detect_arch__2 b/scripts/ynh_detect_arch__2 new file mode 100644 index 0000000..b1c7375 --- /dev/null +++ b/scripts/ynh_detect_arch__2 @@ -0,0 +1,25 @@ +#!/bin/bash + +# Check the architecture +# +# example: architecture=$(ynh_detect_arch) +# +# usage: ynh_detect_arch +# +# Requires YunoHost version 2.2.4 or higher. + +ynh_detect_arch(){ + local architecture + if [ -n "$(uname -m | grep arm64)" ] || [ -n "$(uname -m | grep aarch64)" ]; then + architecture="arm64" + elif [ -n "$(uname -m | grep 64)" ]; then + architecture="x86-64" + elif [ -n "$(uname -m | grep 86)" ]; then + architecture="i386" + elif [ -n "$(uname -m | grep arm)" ]; then + architecture="arm" + else + architecture="unknown" + fi + echo $architecture +} From faa02b862bc5683255b5ba8d444122896b9751d6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 17 Oct 2019 20:17:32 +0200 Subject: [PATCH 2/2] Fix missing architecture during upgrade --- scripts/upgrade | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 061f238..0c30beb 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -29,6 +29,8 @@ secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) name=$(ynh_app_setting_get --app=$app --key=name) port=$(ynh_app_setting_get --app=$app --key=port) +architecture=$(ynh_detect_arch) + #================================================= # CHECK VERSION #=================================================