From edd77196c2b9aa0325c1a25e4731eb3d1ea2d194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 27 Jan 2024 12:41:53 +0100 Subject: [PATCH] Finalize and fix packaging v2 --- manifest.toml | 28 +++++++++++++------ scripts/install | 26 +++++++++-------- scripts/remove | 4 +-- scripts/restore | 21 ++++++++------ scripts/upgrade | 45 +++++++++--------------------- sources/extra_files/app/.gitignore | 2 -- sources/patches/.gitignore | 2 -- tests.toml | 4 ++- 8 files changed, 65 insertions(+), 67 deletions(-) delete mode 100644 sources/extra_files/app/.gitignore delete mode 100644 sources/patches/.gitignore diff --git a/manifest.toml b/manifest.toml index ba74d70..ef44625 100644 --- a/manifest.toml +++ b/manifest.toml @@ -1,3 +1,5 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + packaging_format = 2 id = "emoncms" @@ -41,15 +43,18 @@ ram.runtime = "50M" [resources] [resources.sources] + [resources.sources.main] + url = "https://github.com/emoncms/emoncms/archive/refs/tags/11.4.2.tar.gz" + sha256 = "a8ee0c1d37ca5d9a192dffcd11ca6e77c505b4a4100bd71b1ea00755d0dc3ecb" + autoupdate.strategy = "latest_github_tag" + autoupdate.asset = "tarball" - [resources.sources.main] - url = "https://github.com/emoncms/emoncms/archive/refs/tags/11.4.2.tar.gz" - sha256 = "a8ee0c1d37ca5d9a192dffcd11ca6e77c505b4a4100bd71b1ea00755d0dc3ecb" - - [resources.sources.graph] - url = "https://github.com/emoncms/graph/archive/refs/tags/2.2.3.tar.gz" - sha256 = "a110e881638a07e82b23a5d8df860b49af1e067eb98f4e93a8bad8aebc4ec882" - in_subdir = false + [resources.sources.graph] + url = "https://github.com/emoncms/graph/archive/refs/tags/2.2.3.tar.gz" + sha256 = "a110e881638a07e82b23a5d8df860b49af1e067eb98f4e93a8bad8aebc4ec882" + in_subdir = false + autoupdate.strategy = "latest_github_tag" + autoupdate.asset = "tarball" [resources.system_user] allow_email = true @@ -62,7 +67,12 @@ ram.runtime = "50M" main.url = "/" [resources.apt] - main.url = "mariadb-server, php8.0-fpm, php8.0-redis, php8.0-mysql" + packages = [ + "mariadb-server", + "php8.0-fpm", + "php8.0-redis", + "php8.0-mysql", + ] [resources.database] type = "mysql" diff --git a/scripts/install b/scripts/install index ae85d63..2421cdb 100755 --- a/scripts/install +++ b/scripts/install @@ -9,6 +9,10 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# INITIALIZE AND STORE SETTINGS +#================================================= + email=$(ynh_user_get_info --username=$admin --key=mail) #================================================= @@ -21,16 +25,7 @@ ynh_setup_source --dest_dir="$install_dir" ynh_setup_source --dest_dir="$install_dir/Modules" --source_id="graph" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" - -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 - -ynh_add_fpm_config - -ynh_add_nginx_config +chown -R "$app:www-data" "$install_dir" #================================================= # ADD A CONFIGURATION @@ -40,7 +35,16 @@ ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_add_config --template="example.settings.ini" --destination="$install_dir/settings.ini" chmod 400 "$install_dir/settings.ini" -chown $app:$app "$install_dir/settings.ini" +chown "$app:$app" "$install_dir/settings.ini" + +#================================================= +# SYSTEM CONFIGURATION +#================================================= +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 + +ynh_add_fpm_config + +ynh_add_nginx_config #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index ac762c0..a6a8ac5 100755 --- a/scripts/remove +++ b/scripts/remove @@ -10,9 +10,9 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# REMOVE NGINX CONFIGURATION +# REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 ynh_remove_nginx_config diff --git a/scripts/restore b/scripts/restore index c6bddcd..97fb9e4 100755 --- a/scripts/restore +++ b/scripts/restore @@ -18,7 +18,16 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" + +#================================================= +# RESTORE THE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Restoring the data directory..." --weight=1 + +ynh_restore_file --origin_path="$data_dir" --not_mandatory + +chown -R "$app:www-data" "$data_dir" #================================================= # RESTORE THE MYSQL DATABASE @@ -28,13 +37,9 @@ ynh_script_progression --message="Restoring the MySQL database..." --weight=1 ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= -# RESTORE THE DATA DIRECTORY +# RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring the data directory..." --weight=1 - -ynh_restore_file --origin_path="$data_dir" --not_mandatory - -chown -R $app:www-data "$data_dir" +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" @@ -47,7 +52,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 -ynh_systemd_action --service_name=php$phpversion-fpm --action=reload +ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 6fa03fc..a27d8c7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,43 +9,15 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# STANDARD UPGRADE STEPS -#================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 - -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Upgrading source files..." --weight=1 -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." --weight=1 - - ynh_setup_source --dest_dir="$install_dir" --keep="settings.ini" -fi +ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="settings.ini" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" - -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 - -ynh_add_fpm_config - -ynh_add_nginx_config +chown -R "$app:www-data" "$install_dir" #================================================= # UPDATE A CONFIG FILE @@ -55,7 +27,16 @@ ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_add_config --template="example.settings.ini" --destination="$install_dir/settings.ini" chmod 400 "$install_dir/settings.ini" -chown $app:$app "$install_dir/settings.ini" +chown "$app:$app" "$install_dir/settings.ini" + +#================================================= +# REAPPLY SYSTEM CONFIGURATIONS +#================================================= +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 + +ynh_add_fpm_config + +ynh_add_nginx_config #================================================= # END OF SCRIPT 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] diff --git a/tests.toml b/tests.toml index 91daf17..953b195 100644 --- a/tests.toml +++ b/tests.toml @@ -1,7 +1,9 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + test_format = 1.0 [default] # ------------ # Tests to run - # ------------ \ No newline at end of file + # ------------