Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[autopatch] Automatic patch attempt for helpers 2.1 #62

Open
wants to merge 1 commit into
base: testing
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*~
*.sw[op]
.DS_Store
4 changes: 3 additions & 1 deletion manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -54,6 +55,7 @@ ram.runtime = "50M"
[resources.system_user]

[resources.install_dir]
group = "www-data:r-x"

[resources.permissions]
main.url = "/"
Expand Down
10 changes: 1 addition & 9 deletions scripts/_common.sh
Original file line number Diff line number Diff line change
@@ -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
#=================================================
19 changes: 5 additions & 14 deletions scripts/backup
Original file line number Diff line number Diff line change
@@ -1,41 +1,32 @@
#!/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
#=================================================
# 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)."
16 changes: 3 additions & 13 deletions scripts/change_url
Original file line number Diff line number Diff line change
@@ -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_change_url_nginx_config
ynh_script_progression "Updating NGINX web server configuration..."

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"
48 changes: 21 additions & 27 deletions scripts/install
Original file line number Diff line number Diff line change
@@ -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_nodejs_install

ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_use_nodejs
ynh_npm install -g coffeescript
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

Expand All @@ -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
Expand All @@ -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"
29 changes: 11 additions & 18 deletions scripts/remove
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -49,4 +42,4 @@ fi
# END OF SCRIPT
#=================================================

ynh_script_progression --message="Removal of $app completed" --last
ynh_script_progression "Removal of $app completed"
Loading