diff --git a/scripts/detect_arch b/scripts/detect_arch deleted file mode 100644 index 15d6696..0000000 --- a/scripts/detect_arch +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -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 - 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 335f70b..dc81366 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 #================================================= @@ -35,6 +35,7 @@ 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 == "x86_64" ] || [ $architecture == "arm" ] then diff --git a/scripts/upgrade b/scripts/upgrade index ecf86db..ab76e9e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,7 +8,7 @@ source _common.sh source ynh_package_version -source detect_arch +source ynh_detect_arch__2 source /usr/share/yunohost/helpers #================================================= @@ -154,7 +154,8 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_print_info --message="Upgrading source files..." - # Download, check integrity, uncompress and patch the source from app.src + architecture=$(ynh_detect_arch) + # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" fi 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 +}