From 86f1a97f83d328fc79881ba683071eab6de467bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Thu, 6 Jun 2024 12:02:11 +0200 Subject: [PATCH] Automated packaging v2 conversion --- conf/app.src | 7 -- conf/systemd.service | 2 +- manifest.toml | 168 +++++++++++++++++++++++++++++++++++++++++++ scripts/_common.sh | 80 ++++++++++----------- scripts/backup | 10 +-- scripts/install | 70 +++++++++--------- scripts/remove | 16 ++--- scripts/restore | 24 +++---- scripts/upgrade | 22 +++--- 9 files changed, 280 insertions(+), 119 deletions(-) delete mode 100644 conf/app.src create mode 100644 manifest.toml diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index 3efc1cb..0000000 --- a/conf/app.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://gitlab.com/veloren/veloren/-/archive/v0.10.0/veloren-v0.10.0.tar.gz -SOURCE_SUM=8bda76af18db8553556cb09a4126bb9c4e0956bcf021fbb93c019de450c38016 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=veloren-v0.10.0.tar.gz -SOURCE_EXTRACT=true diff --git a/conf/systemd.service b/conf/systemd.service index 418072f..eed019b 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -8,7 +8,7 @@ User=__APP__ Group=__APP__ WorkingDirectory=__DATA_PATH__/ Environment=VELOREN_ASSETS=__FINAL_PATH__/ -ExecStart=__FINALPATH__/target/release/veloren-server-cli --basic +ExecStart=__INSTALL_DIR__/target/release/veloren-server-cli --basic KillSignal=SIGUSR1 TimeoutStopSec=150 StandardOutput=append:/var/log/__APP__/__APP__.log diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..3e28ca6 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,168 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "veloren" +name = "Veloren server" +description.en = "Multiplayer voxel RPG inspired by games such as Cube World, Legend of Zelda: Breath of the Wild, Dwarf Fortress and Minecraft" +description.fr = "RPG voxel multijoueur inspiré de jeux tels que Cube World, Legend of Zelda : Breath of the Wild, Dwarf Fortress et Minecraft" + +version = "0.10.0~ynh1" + +maintainers = ["Jules Bertholet"] + +[upstream] +license = "GPL-3.0-only" +website = "https://veloren.net/" +demo = "server.veloren.net:14004" +admindoc = "https://book.veloren.net/players/hosting-a-server.html" +userdoc = "https://book.veloren.net/players/" +code = "https://gitlab.com/veloren/veloren" +cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) +fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. + +[integration] +yunohost = ">= 4.1.3" +architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +multi_instance = true +ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. +sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[install] + [install.server_name] + ask.en = "Choose a name for the server" + ask.fr = "Choisissez un nom pour le serveur" + type = "string" + default = "Veloren Alpha" + + [install.description] + ask.en = "Choose a description for the server" + ask.fr = "Choisissez une déscription pour le serveur" + type = "string" + default = "This is the best Veloren server" + + [install.auth_server_address] + ask.en = "Choose an auth server" + ask.fr = "Choisissez un serveur d'authentification" + type = "string" + default = "https://auth.veloren.net" + + [install.max_players] + ask.en = "Set the maximum number of players that can connect to the server concurrently" + ask.fr = "Choisissez le nombre maximum de joueurs qui peuvent être connectès en méme temps" + type = "string" + default = "100" + + [install.max_view_distance] + ask.en = "Choose the maximum view distance that clients may request" + ask.fr = "Choisissez la distance maximale de visualisation que peuvent demander les clients" + type = "string" + default = "30" + + [install.max_player_group_size] + ask.en = "Choose the maximum size of player groups" + ask.fr = "Choisissez le nombre maximal de joueurs dans un groupe" + type = "string" + default = "6" + + [install.generate_custom_world] + ask.en = "Generate a custom world map? (resource-intensive)" + ask.fr = "Générer une carte personnalisée ? (nécessite beaucoup de ressources)" + type = "boolean" + default = false + + [install.world_seed] + ask.en = "Choose a seed for the custom map" + ask.fr = "Choisir une graine pour la carte personnalisé" + type = "string" + default = "59686" + + [install.world_map_size_lg_x] + ask.en = "Choose the length of the east-west dimension of the custom map (base 2 logarithm)" + ask.fr = "Choisir la longueur de la dimension est-ouest de la carte personnalisé (logarithme base 2)" + help.en = "Current default is 10, leave blank for unchanged" + help.fr = "Valeur par défault actuelle est 10, laisser vide pour ne pas changer" + type = "string" + optional = true + + [install.world_map_size_lg_y] + ask.en = "Choose the length of the north-south dimension of the custom map (base 2 logarithm)" + ask.fr = "Choisir la longueur de la dimension nord-sud de la carte personnalisé (logarithme base 2)" + help.en = "Current default is 10. Leave blank for unchanged" + help.fr = "Valeur par défault actuelle est 10. Laisser vide pour ne pas changer" + type = "string" + optional = true + + [install.continent_scale_hack] + ask.en = "Choose the level of continent detail of the custom map" + ask.fr = "Choisir le niveau de détail des continents de la carte personnalisé" + help.en = "Current default is 2.0, 4.0 gives an Earth-like result. Leave blank for unchanged" + help.fr = "Valeur par défault actuelle est 2.0, 4.0 donne un résultat semblable à la Terre. Laisser vide pour ne pas changer" + type = "string" + optional = true + + [install.days_in_month] + ask.en = "Choose the number of days in a month for the custom map economy simulation" + ask.fr = "Choisir le nombre de jours par mois pour la simulation économique de la carte personnalisé" + help.en = "Current default is 30.0. Leave blank for unchanged" + help.fr = "Valeur par défault actuelle est 30.0. Laisser vide pour ne pas changer" + type = "string" + optional = true + + [install.months_in_year] + ask.en = "Choose the number of months in a year for the custom map economy simulation" + ask.fr = "Choisir le nombre de mois par an pour la simulation économique de la carte personnalisé" + help.en = "Current default is 12.0. Leave blank for unchanged" + help.fr = "Valeur par défault actuelle est 12.0. Laisser vide pour ne pas changer" + type = "string" + optional = true + + [install.months_in_tick] + ask.en = "Choose the number of months per tick for the custom map economy simulation" + ask.fr = "Choisir le nombre de mois par étape pour la simulation économique de la carte personnalisé" + help.en = "Current default is 3.0. Leave blank for unchanged" + help.fr = "Valeur par défault actuelle est 3.0. Laisser vide pour ne pas changer" + type = "string" + optional = true + + [install.years_in_history] + ask.en = "Choose the number of years in history for the custom map economy simulation" + ask.fr = "Choisir le nombre d'années dans l'histoire pour la simulation économique de la carte personnalisé" + help.en = "Current default is 500.0. Leave blank for unchanged" + help.fr = "Valeur par défault actuelle est 500.0. Laisser vide pour ne pas changer" + type = "string" + optional = true + + [install.generate_economy_csv] + ask.en = "Choose whether to generate economy data CSV the custom map economy simulation" + ask.fr = "Choisir si générer un CSV de données pour la simulation économique de la carte personnalisé" + type = "boolean" + default = false + + [install.allow_inter_site_trade] + ask.en = "Choose whether to allow inter-site trade for the custom map economy simulation" + ask.fr = "Choisir si permettre le commerce entre sites pour la simulation économique de la carte personnalisé" + type = "boolean" + default = true + +[resources] + [resources.sources.main] + url = "https://gitlab.com/veloren/veloren/-/archive/v0.10.0/veloren-v0.10.0.tar.gz" + sha256 = "8bda76af18db8553556cb09a4126bb9c4e0956bcf021fbb93c019de450c38016" + + + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + + [resources.ports] + main.default = 14004 + metrics.default = 12345 + + [resources.apt] + packages = "cargo, rustc, ca-certificates, librust-backtrace+libbacktrace-dev, build-essential, git, git-lfs" diff --git a/scripts/_common.sh b/scripts/_common.sh index cc8bc92..da14fa8 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,14 +5,14 @@ #================================================= # dependencies used by the app -pkg_dependencies="cargo rustc ca-certificates librust-backtrace+libbacktrace-dev build-essential git git-lfs" +#REMOVEME? pkg_dependencies="cargo rustc ca-certificates librust-backtrace+libbacktrace-dev build-essential git git-lfs" #================================================= # PERSONAL HELPERS #================================================= function setup_source { - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$install_dir" patch_source @@ -27,43 +27,43 @@ function patch_source { if [ -z "$world_map_size_lg_y" ]; then world_map_size_lg_y="10" fi - ynh_replace_string -m "MapSizeLg::new(Vec2 { x: [0-9]\{1,\}, y: [0-9]\{1,\} }" -r "MapSizeLg::new(Vec2 { x: $world_map_size_lg_x, y: $world_map_size_lg_y }" -f "$final_path/world/src/sim/mod.rs" + ynh_replace_string -m "MapSizeLg::new(Vec2 { x: [0-9]\{1,\}, y: [0-9]\{1,\} }" -r "MapSizeLg::new(Vec2 { x: $world_map_size_lg_x, y: $world_map_size_lg_y }" -f "$install_dir/world/src/sim/mod.rs" fi if [ ! -z "$continent_scale_hack" ]; then - ynh_replace_string -m "continent_scale_hack = [0-9]\{1,\}\.[0-9]\{1,\}" -r "continent_scale_hack = $continent_scale_hack" -f "$final_path/world/src/sim/mod.rs" + ynh_replace_string -m "continent_scale_hack = [0-9]\{1,\}\.[0-9]\{1,\}" -r "continent_scale_hack = $continent_scale_hack" -f "$install_dir/world/src/sim/mod.rs" fi if [ ! -z "$days_in_month" ]; then - ynh_replace_string -m "MONTH: f32 = [0-9]\{1,\}\.[0-9]\{1,\}" -r "MONTH: f32 = $days_in_month" -f "$final_path/world/src/sim2/mod.rs" + ynh_replace_string -m "MONTH: f32 = [0-9]\{1,\}\.[0-9]\{1,\}" -r "MONTH: f32 = $days_in_month" -f "$install_dir/world/src/sim2/mod.rs" fi if [ ! -z "$months_in_year" ]; then - ynh_replace_string -m "YEAR: f32 = [0-9]\{1,\}\.[0-9]\{1,\}" -r "YEAR: f32 = $months_in_year" -f "$final_path/world/src/sim2/mod.rs" + ynh_replace_string -m "YEAR: f32 = [0-9]\{1,\}\.[0-9]\{1,\}" -r "YEAR: f32 = $months_in_year" -f "$install_dir/world/src/sim2/mod.rs" fi if [ ! -z "$months_in_tick" ]; then - ynh_replace_string -m "TICK_PERIOD: f32 = [0-9]\{1,\}\.[0-9]\{1,\}" -r "TICK_PERIOD: f32 = $months_in_tick" -f "$final_path/world/src/sim2/mod.rs" + ynh_replace_string -m "TICK_PERIOD: f32 = [0-9]\{1,\}\.[0-9]\{1,\}" -r "TICK_PERIOD: f32 = $months_in_tick" -f "$install_dir/world/src/sim2/mod.rs" fi if [ ! -z "$years_in_history" ]; then - ynh_replace_string -m "HISTORY_DAYS: f32 = [0-9]\{1,\}\.[0-9]\{1,\}" -r "HISTORY_DAYS: f32 = $years_in_history" -f "$final_path/world/src/sim2/mod.rs" + ynh_replace_string -m "HISTORY_DAYS: f32 = [0-9]\{1,\}\.[0-9]\{1,\}" -r "HISTORY_DAYS: f32 = $years_in_history" -f "$install_dir/world/src/sim2/mod.rs" fi if [ $generate_economy_csv -eq 1 ]; then - ynh_replace_special_string -m "GENERATE_CSV: bool = false" -r "GENERATE_CSV: bool = true" -f "$final_path/world/src/sim2/mod.rs" + ynh_replace_special_string -m "GENERATE_CSV: bool = false" -r "GENERATE_CSV: bool = true" -f "$install_dir/world/src/sim2/mod.rs" fi if [ $allow_inter_site_trade -eq 0 ]; then - ynh_replace_special_string -m "INTER_SITE_TRADE: bool = true" -r "INTER_SITE_TRADE: bool = false" -f "$final_path/world/src/sim2/mod.rs" + ynh_replace_special_string -m "INTER_SITE_TRADE: bool = true" -r "INTER_SITE_TRADE: bool = false" -f "$install_dir/world/src/sim2/mod.rs" fi } function set_permissions { - mkdir -p "$final_path" - chown -R root:$app "$final_path" - chmod -R g=u,g-w,o-rwx "$final_path" + mkdir -p "$install_dir" + chown -R root:$app "$install_dir" + chmod -R g=u,g-w,o-rwx "$install_dir" mkdir -p "$data_path" chown -R $app:$app "$data_path" @@ -77,22 +77,22 @@ function install_rust { sudo -u $app bash -c ' curl https://sh.rustup.rs -sSf | sh -s -- -q -y 2>&1 source ~/.cargo/env - rustup toolchain install $(cat "'"$final_path/rust-toolchain"'") 2>&1 + rustup toolchain install $(cat "'"$install_dir/rust-toolchain"'") 2>&1 ' } function compile_server { install_rust - chown -R $app:$app "$final_path" - pushd "$final_path" + chown -R $app:$app "$install_dir" + pushd "$install_dir" sudo -u $app bash -c " source ~/.cargo/env - NIX_GIT_HASH=\"cf2bdb20/2021-06-12-08:55\" NIX_GIT_TAG=\"v0.10.0\" VELOREN_ASSETS=\"$final_path/assets\" RUSTFLAGS=\"-D warnings\" VELOREN_USERDATA_STRATEGY=system cargo build --bin veloren-server-cli --release --quiet 2>&1 + NIX_GIT_HASH=\"cf2bdb20/2021-06-12-08:55\" NIX_GIT_TAG=\"v0.10.0\" VELOREN_ASSETS=\"$install_dir/assets\" RUSTFLAGS=\"-D warnings\" VELOREN_USERDATA_STRATEGY=system cargo build --bin veloren-server-cli --release --quiet 2>&1 " popd - sudo -u $app ln -sf "$final_path/assets" "$data_path/assets" + sudo -u $app ln -sf "$install_dir/assets" "$data_path/assets" set_permissions } @@ -103,7 +103,7 @@ function generate_custom_world { add_configuration_files pushd "$data_path" - grep -q "Server is ready to accept connections." <((sudo -u $app VELOREN_ASSETS="$final_path/assets" $final_path/target/release/veloren-server-cli --basic & echo $! >&3 ) 3>pid) + grep -q "Server is ready to accept connections." <((sudo -u $app VELOREN_ASSETS="$install_dir/assets" $install_dir/target/release/veloren-server-cli --basic & echo $! >&3 ) 3>pid) kill "$(