From 199aa4355903be2f561ca20e0fca64ba17eed21e Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 31 Aug 2024 02:57:24 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- .gitignore | 1 + manifest.toml | 4 +- scripts/_common.sh | 10 +---- scripts/backup | 19 +++------ scripts/change_url | 16 ++------ scripts/install | 48 ++++++++++------------- scripts/remove | 29 ++++++-------- scripts/restore | 45 +++++++++------------ scripts/upgrade | 63 ++++++++++++------------------ sources/extra_files/app/.gitignore | 2 - sources/patches/.gitignore | 2 - 11 files changed, 87 insertions(+), 152 deletions(-) delete mode 100644 sources/extra_files/app/.gitignore delete mode 100644 sources/patches/.gitignore diff --git a/.gitignore b/.gitignore index 783a4ae..8f144f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ *.sw[op] +.DS_Store diff --git a/manifest.toml b/manifest.toml index 596b064..35e1a97 100644 --- a/manifest.toml +++ b/manifest.toml @@ -18,7 +18,8 @@ userdoc = "https://docs.libretro.com/" code = "https://github.com/libretro/RetroArch" [integration] -yunohost = ">= 11.1.18" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = false ldap = "not_relevant" @@ -54,6 +55,7 @@ ram.runtime = "50M" [resources.system_user] [resources.install_dir] + group = "www-data:r-x" [resources.permissions] main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index 6605f76..53127a8 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,18 +1,10 @@ #!/bin/bash #================================================= -# COMMON VARIABLES +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= # dependencies used by the app #REMOVEME? pkg_dependencies="p7zip" nodejs_version=10 - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= diff --git a/scripts/backup b/scripts/backup index 3327f7f..1056440 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,30 +1,21 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC BACKUP @@ -32,10 +23,10 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/cron.d/$app" +ynh_backup "/etc/cron.d/$app" #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index d76cdb7..0aed466 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,23 +1,13 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers - -#================================================= -# STANDARD MODIFICATIONS #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx - -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index bdc4014..9da5ce2 100755 --- a/scripts/install +++ b/scripts/install @@ -1,35 +1,29 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=13 +ynh_script_progression "Installing dependencies..." -ynh_install_nodejs --nodejs_version=$nodejs_version -ynh_use_nodejs -ynh_npm install -g coffeescript +ynh_nodejs_install + +npm install -g coffeescript #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=60 +ynh_script_progression "Setting up source files..." # uncompress and patch done manually as 7z format is not supported ynh_setup_source --dest_dir="$install_dir" #7z archive not handled by ynh and no way to strip component, have to move it manually 7zr x $install_dir/main -o$install_dir mv $install_dir/retroarch/* $install_dir/ -ynh_secure_remove --file="$install_dir/main" -ynh_secure_remove --file="$install_dir/retroarch" +ynh_safe_rm "$install_dir/main" +ynh_safe_rm "$install_dir/retroarch" touch $install_dir/analytics.js #https://github.com/libretro/RetroArch/issues/4539#issuecomment-473345195 @@ -39,54 +33,54 @@ chmod +x $install_dir/indexer #================================================= #SETTING MULTIMEDIA DIRECTORY #================================================= -ynh_script_progression --message="Setting up Multimedia directory..." --weight=9 +ynh_script_progression "Setting up Multimedia directory..." ynh_multimedia_build_main_dir mkdir -p $install_dir/assets/cores/Game ynh_multimedia_addfolder --source_dir="$install_dir/assets/cores/Game" --dest_dir="/share/Game" -ynh_add_config --template="../conf/README.GAME" --destination="$install_dir/assets/cores/Game/README" +ynh_config_add --template="README.GAME" --destination="$install_dir/assets/cores/Game/README" chmod 666 $install_dir/assets/cores/Game/README # SETUP CRON FILE FOR INDEXER #setup indexer bash script -ynh_add_config --template="../conf/indexer.sh" --destination="$install_dir/indexer.sh" +ynh_config_add --template="indexer.sh" --destination="$install_dir/indexer.sh" chown www-data: $install_dir/indexer.sh chmod 744 $install_dir/indexer.sh #setup cron file cron_path="/etc/cron.d/$app" -ynh_add_config --template="../conf/retroarch.cron" --destination="$cron_path" -chmod 644 "$cron_path" +ynh_config_add --template="retroarch.cron" --destination="$cron_path" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "$cron_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=3 +ynh_script_progression "Configuring NGINX web server..." #backup & Update nginx MIME type so wasm mime type is recognized if [ !$(grep wasm /etc/nginx/mime.types) ]; then ynh_print_info "/etc/nginx/mime.types saved as /etc/nginx/mime.types.$app" cp /etc/nginx/mime.types /etc/nginx/mime.types.$app - ynh_replace_string --match_string=" application/octet-stream bin exe dll;" --replace_string=" application/wasm wasm;\n\n application/octet-stream bin exe dll;" --target_file="/etc/nginx/mime.types" - ynh_store_file_checksum --file="/etc/nginx/mime.types" + ynh_replace --match=" application/octet-stream bin exe dll;" --replace=" application/wasm wasm;\n\n application/octet-stream bin exe dll;" --file="/etc/nginx/mime.types" + ynh_store_file_checksum "/etc/nginx/mime.types" fi # Create a dedicated nginx config -ynh_add_nginx_config +ynh_config_add_nginx # Set permissions to app files -chown -R www-data:multimedia $install_dir -# Requested so that multimedia group can see the Game folder : all parent folder should be readable by others -chmod 750 $install_dir +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R www-data:multimedia $install_dir +# Requested so that multimedia group can see the Game folder : all parent folder should be readable by others +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 $install_dir #================================================= # SETUP INDEX #================================================= #indexer use the current directory to run #https://github.com/libretro/RetroArch/tree/master/pkg/emscripten, # so we have to cd in it to use it correctly => last step of the install so to not mess with other commands relative path #Indexer will list the available ROM and cores for Retroarch -ynh_script_progression --message="Setup Indexer for content..." --weight=3 +ynh_script_progression "Setup Indexer for content..." cd $install_dir/assets/frontend/bundle/ ../../../indexer > .index-xhr @@ -97,4 +91,4 @@ cd $install_dir/assets/cores # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 82774e6..9f38e2c 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,42 +1,35 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --weight=7 +ynh_script_progression "Removing dependencies..." # Remove metapackage and its dependencies -ynh_use_nodejs -ynh_npm uninstall -g coffeescript -ynh_remove_nodejs + +npm uninstall -g coffeescript +ynh_nodejs_remove #================================================= # REMOVE MULTIMEDIA SYMBOLIC LINK #================================================= -ynh_script_progression --message="Removing Game folder..." --weight=1 +ynh_script_progression "Removing Game folder..." # Remove the app directory securely -ynh_secure_remove --file="/home/yunohost.multimedia/share/Game" -ynh_secure_remove --file="/etc/cron.d/$app" - +ynh_safe_rm "/home/yunohost.multimedia/share/Game" +ynh_safe_rm "/etc/cron.d/$app" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 +ynh_script_progression "Removing NGINX web server configuration..." # Remove the dedicated nginx config -ynh_remove_nginx_config -if [ "$(ynh_app_setting_get --app=$app --key=checksum__etc_nginx_mime.types)" == "$(md5sum "/etc/nginx/mime.types" | cut -d ' ' -f 1)" ]; then +ynh_config_remove_nginx +if [ "$(ynh_app_setting_get --key=checksum__etc_nginx_mime.types)" == "$(md5sum "/etc/nginx/mime.types" | cut -d ' ' -f 1)" ]; then #file has not changed, restore the previous mime.type rm /etc/nginx/mime.types mv /etc/nginx/mime.types.$app /etc/nginx/mime.types @@ -49,4 +42,4 @@ fi # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 2118172..fd9f3ef 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,63 +1,56 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers - #================================================= # STANDARD RESTORATION STEPS #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" #backup & Update nginx MIME type so wasm mime type is recognized if [ !$(grep wasm /etc/nginx/mime.types) ]; then ynh_print_info "/etc/nginx/mime.types saved as /etc/nginx/mime.types.$app" cp /etc/nginx/mime.types /etc/nginx/mime.types.$app - ynh_replace_string --match_string=" application/octet-stream bin exe dll;" --replace_string=" application/wasm wasm;\n\n application/octet-stream bin exe dll;" --target_file="/etc/nginx/mime.types" - ynh_store_file_checksum --file="/etc/nginx/mime.types" + ynh_replace --match=" application/octet-stream bin exe dll;" --replace=" application/wasm wasm;\n\n application/octet-stream bin exe dll;" --file="/etc/nginx/mime.types" + ynh_store_file_checksum "/etc/nginx/mime.types" fi #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" +ynh_restore "$install_dir" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=5 +ynh_script_progression "Reinstalling dependencies..." # Define and install dependencies #Dependencies are not really required as this is just to unzip the 7z file #However, npm IS required to run the coffeescript -ynh_install_nodejs --nodejs_version=$nodejs_version -ynh_use_nodejs -ynh_npm install -g coffeescript +ynh_nodejs_install + +npm install -g coffeescript #================================================= #SETTING MULTIMEDIA DIRECTORY #================================================= -ynh_script_progression --message="Setting up Multimedia directory..." --weight=5 +ynh_script_progression "Setting up Multimedia directory..." ynh_multimedia_build_main_dir mkdir -p $install_dir/assets/cores/Game ynh_multimedia_addfolder --source_dir="$install_dir/assets/cores/Game" --dest_dir="/share/Game" -ynh_add_config --template="../conf/README.GAME" --destination="$install_dir/assets/cores/Game/README" +ynh_config_add --template="README.GAME" --destination="$install_dir/assets/cores/Game/README" chmod 666 $install_dir/assets/cores/Game/README #================================================= @@ -65,27 +58,25 @@ chmod 666 $install_dir/assets/cores/Game/README #================================================= # Restore permissions on app files -chown -R www-data:multimedia $install_dir -# Requested so that multimedia group can see the Game folder : all parent folder should be readable by others -chmod 750 $install_dir +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R www-data:multimedia $install_dir +# Requested so that multimedia group can see the Game folder : all parent folder should be readable by others +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 $install_dir #================================================= # RESTORE THE CRON FILE #================================================= -ynh_restore_file --origin_path="/etc/cron.d/$app" +ynh_restore "/etc/cron.d/$app" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 +ynh_script_progression "Reloading nginx web server..." -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 6140a46..57a7b7f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,41 +1,28 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Downward Compatibility checks..." --weight=1 +ynh_script_progression "Downward Compatibility checks..." #move from /opt/yunohost to /var/www : symbolic link will be remade by multimedia dir -if ynh_compare_current_package_version --comparison lt --version 1.15.0~ynh3; then +if ynh_app_upgrading_from_version_before 1.15.0~ynh3; then if [ -L /home/yunohost.multimedia/share/Game ]; then - #ynh_secure_remove --file="/home/yunohost.multimedia/share/Game" - rm /home/yunohost.multimedia/share/Game #ynh_secure_remove does not remove link + #ynh_safe_rm "/home/yunohost.multimedia/share/Game" + rm /home/yunohost.multimedia/share/Game #ynh_safe_rm does not remove link fi fi #================================================= -# STANDARD UPGRADE STEPS -#================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -if [ "$upgrade_type" == "UPGRADE_APP" ] +# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed +if ynh_app_upstream_version_changed then - ynh_script_progression --message="Upgrading source files..." --weight=5 + ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" @@ -43,7 +30,7 @@ then 7zr x $install_dir/main -o$install_dir #mv not working as target directory is not empty cp -R $install_dir/retroarch/* $install_dir/ - ynh_secure_remove --file="$install_dir/main" + ynh_safe_rm "$install_dir/main" touch $install_dir/analytics.js #https://github.com/libretro/RetroArch/issues/4539#issuecomment-473345195 #Get the indexer as exe so that folder w/ ROMs can be indexed chmod +x $install_dir/indexer @@ -52,58 +39,56 @@ fi # SETUP CRON FILE FOR INDEXER #setup indexer bash script -ynh_add_config --template="../conf/indexer.sh" --destination="$install_dir/indexer.sh" +ynh_config_add --template="indexer.sh" --destination="$install_dir/indexer.sh" chown www-data: $install_dir/indexer.sh chmod 744 $install_dir/indexer.sh #setup cron file cron_path="/etc/cron.d/$app" -ynh_add_config --template="../conf/retroarch.cron" --destination="$cron_path" -chown root: "$cron_path" -chmod 644 "$cron_path" +ynh_config_add --template="retroarch.cron" --destination="$cron_path" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root: "$cron_path" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "$cron_path" #================================================= #SETTING MULTIMEDIA DIRECTORY #================================================= -ynh_script_progression --message="Setting up Multimedia directory..." --weight=4 +ynh_script_progression "Setting up Multimedia directory..." ynh_multimedia_build_main_dir mkdir -p $install_dir/assets/cores/Game ynh_multimedia_addfolder --source_dir="$install_dir/assets/cores/Game" --dest_dir="/share/Game" -ynh_add_config --template="../conf/README.GAME" --destination="$install_dir/assets/cores/Game/README" +ynh_config_add --template="README.GAME" --destination="$install_dir/assets/cores/Game/README" chmod 666 $install_dir/assets/cores/Game/README #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 +ynh_script_progression "Upgrading NGINX web server configuration..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=20 +ynh_script_progression "Upgrading dependencies..." # Define and install dependencies #Dependencies are not really required as this is just to unzip the 7z file #However, npm IS required to run the coffeescript -ynh_install_nodejs --nodejs_version=$nodejs_version -ynh_use_nodejs -ynh_npm install -g coffeescript +ynh_nodejs_install + +npm install -g coffeescript -#================================================= -# SPECIFIC UPGRADE #================================================= # Set permissions on app files #================================================= -chown -R www-data:multimedia $install_dir -# Requested so that multimedia group can see the Game folder : all parent folder should be readable by others -chmod 750 $install_dir +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R www-data:multimedia $install_dir +# Requested so that multimedia group can see the Game folder : all parent folder should be readable by others +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 $install_dir #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed" diff --git a/sources/extra_files/app/.gitignore b/sources/extra_files/app/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/extra_files/app/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] diff --git a/sources/patches/.gitignore b/sources/patches/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/patches/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op]