diff --git a/scripts/_common.sh b/scripts/_common.sh index 299c8b8..1408dc9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,15 +4,26 @@ # COMMON VARIABLES #================================================= -architecture=$(dpkg --print-architecture) -if [ $architecture = "amd64" ]; then - architecture="x64" -fi +# Supported architectures +supported_architectures=("arm" "arm64" "x64") #================================================= # PERSONAL HELPERS #================================================= +get_architecture() { + architecture=$(dpkg --print-architecture) + if [ $architecture = "amd64" ]; then + architecture="x64" + elif [[ $architecture = arm* ]] && [[ $(getconf LONG_BIT) = 32 ]]; then + architecture="arm" + elif [[ $architecture = arm* ]] && [[ $(getconf LONG_BIT) = 64 ]]; then + architecture="arm64" + elif [[ $(echo ${supported_architectures[@]} | grep -ow "$architecture" | wc -w) = 0 ]]; then + ynh_die --message="Unsupported architecture $architecture" + fi +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index d46a2f0..8e725a5 100755 --- a/scripts/install +++ b/scripts/install @@ -68,7 +68,9 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +ynh_script_progression --message="Setting up source files..." + +get_architecture ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src diff --git a/scripts/upgrade b/scripts/upgrade index c3019a5..3940eb4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -112,10 +112,12 @@ ynh_system_user_create --username=$app --home_dir="$final_path" if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." + ynh_script_progression --message="Upgrading source files..." + + get_architecture # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$final_path" --source_id="app.$architecture" fi # FIXME: this should be managed by the core in the future