From 4704fee2a9ba6e809639de18a4f45866dfb8d6a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 2 Oct 2022 21:14:43 +0200 Subject: [PATCH] fix linter (#72) --- conf/{x86_64.src => amd64.src} | 0 scripts/_common.sh | 21 --------------------- scripts/install | 17 ++++++++--------- scripts/upgrade | 16 +++++++--------- 4 files changed, 15 insertions(+), 39 deletions(-) rename conf/{x86_64.src => amd64.src} (100%) diff --git a/conf/x86_64.src b/conf/amd64.src similarity index 100% rename from conf/x86_64.src rename to conf/amd64.src diff --git a/scripts/_common.sh b/scripts/_common.sh index 8fc49a5..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -15,24 +15,3 @@ #================================================= # FUTURE OFFICIAL HELPERS #================================================= - -# 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 86)" ]; then - architecture="i386" - elif [ -n "$(uname -m | grep 64)" ]; then - architecture="x86_64" - else - architecture="unknown" - fi - echo $architecture -} diff --git a/scripts/install b/scripts/install index 12beb0c..3256489 100644 --- a/scripts/install +++ b/scripts/install @@ -23,7 +23,6 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC -architecture=$(ynh_detect_arch) app=$YNH_APP_INSTANCE_NAME @@ -32,11 +31,11 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Validating installation parameters..." --weight=1 -# Check machine architecture (in particular, we don't support ARM 32bit machines) -if [ $architecture == "unknown" ] -then - ynh_die --message="Sorry, this app cannot be installed on a 32-bit ARM machine." -fi +# Stop if architecture is 32-bit ARM +case $YNH_ARCH in + arm|armhf) ynh_die --message="Sorry, your architecture $YNH_ARCH is not supported by $app. Aborting.";; + *) ;; +esac final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -86,11 +85,11 @@ ynh_script_progression --message="Setting up source files..." --weight=4 ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir=$final_path --source_id="$architecture" +ynh_setup_source --dest_dir=$final_path --source_id=$YNH_ARCH pushd "$final_path" - gzip --decompress $(ynh_detect_arch).gz - mv $(ynh_detect_arch) $app + gzip --decompress $YNH_ARCH.gz + mv $YNH_ARCH $app popd chmod 750 "$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index 8058570..d93dfba 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,7 +21,6 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) peer_port=$(ynh_app_setting_get --app=$app --key=peer_port) -architecture=$(ynh_detect_arch) #================================================= # CHECK VERSION @@ -48,11 +47,10 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# Check machine architecture (in particular, we don't support ARM 32bit machines) -if [ $architecture == "unknown" ] -then - ynh_die --message="Sorry, this app cannot be installed on a 32-bit ARM machine." -fi +case $YNH_ARCH in + arm|armhf) ynh_die --message="Sorry, your architecture $YNH_ARCH is not supported by $app. Aborting.";; + *) ;; +esac # Cleaning legacy permissions if ynh_legacy_permissions_exists; then @@ -87,11 +85,11 @@ then ynh_script_progression --message="Upgrading source files..." --weight=5 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir=$final_path --source_id="$architecture" --keep="config.yml" + ynh_setup_source --dest_dir=$final_path --source_id=$YNH_ARCH --keep="config.yml" pushd "$final_path" - gzip --decompress $(ynh_detect_arch).gz - mv $(ynh_detect_arch) $app + gzip --decompress $YNH_ARCH.gz + mv $YNH_ARCH $app popd fi