diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh new file mode 100755 index 0000000..4efd496 --- /dev/null +++ b/.github/workflows/updater.sh @@ -0,0 +1,137 @@ +#!/bin/bash + +#================================================= +# PACKAGE UPDATING HELPER +#================================================= + +# This script is meant to be run by GitHub Actions +# The YunoHost-Apps organisation offers a template Action to run this script periodically +# Since each app is different, maintainers can adapt its contents so as to perform +# automatic actions when a new upstream release is detected. + +# Remove this exit command when you are ready to run this Action +#exit 1 + +#================================================= +# FETCHING LATEST RELEASE AND ITS ASSETS +#================================================= + +# Fetching information +current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') +repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') +# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) +version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) +assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) + +# Later down the script, we assume the version has only digits and dots +# Sometimes the release name starts with a "v", so let's filter it out. +# You may need more tweaks here if the upstream repository has different naming conventions. +if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then + version=${version:1} +fi + +# Setting up the environment variables +echo "Current version: $current_version" +echo "Latest release from upstream: $version" +echo "VERSION=$version" >> $GITHUB_ENV +# For the time being, let's assume the script will fail +echo "PROCEED=false" >> $GITHUB_ENV + +# Proceed only if the retrieved version is greater than the current one +if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then + echo "::warning ::No new version available" + exit 0 +# Proceed only if a PR for this new version does not already exist +elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then + echo "::warning ::A branch already exists for this update" + exit 0 +fi + +# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) +echo "${#assets[@]} available asset(s)" + +#================================================= +# UPDATE SOURCE FILES +#================================================= + +# Here we use the $assets variable to get the resources published in the upstream release. +# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like. + +# Let's loop over the array of assets URLs +for asset_url in ${assets[@]}; do + +echo "Handling asset at $asset_url" + +# Assign the asset to a source file in conf/ directory +# Here we base the source file name upon a unique keyword in the assets url (admin vs. update) +# Leave $src empty to ignore the asset +case $asset_url in + *"Jackett.Binaries.LinuxAMDx64.tar.gz") + src="amd64" + ;; + *"Jackett.Binaries.LinuxARM64.tar.gz") + src="arm64" + ;; + *"Jackett.Binaries.LinuxARM32.tar.gz") + src="armhf" + ;; +esac + +# If $src is not empty, let's process the asset +if [ ! -z "$src" ]; then + +# Create the temporary directory +tempdir="$(mktemp -d)" + +# Download sources and calculate checksum +filename=${asset_url##*/} +curl --silent -4 -L $asset_url -o "$tempdir/$filename" +checksum=$(sha256sum "$tempdir/$filename" | head -c 64) + +# Delete temporary directory +rm -rf $tempdir + +# Get extension +if [[ $filename == *.tar.gz ]]; then + extension=tar.gz +else + extension=${filename##*.} +fi + +# Rewrite source file +cat < conf/$src.src +SOURCE_URL=$asset_url +SOURCE_SUM=$checksum +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=$extension +SOURCE_IN_SUBDIR=true +SOURCE_EXTRACT=true +SOURCE_FILENAME=jackett.tar.gz +EOT +echo "... conf/$src.src updated" + +else +echo "... asset ignored" +fi + +done + +#================================================= +# SPECIFIC UPDATE STEPS +#================================================= + +# Any action on the app's source code can be done. +# The GitHub Action workflow takes care of committing all changes after this script ends. + +#================================================= +# GENERIC FINALIZATION +#================================================= + +# Replace new version in manifest +echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json + +# No need to update the README, yunohost-bot takes care of it + +# The Action will proceed only if the PROCEED environment variable is set to true +echo "PROCEED=true" >> $GITHUB_ENV +exit 0 diff --git a/README.md b/README.md index 01399b6..928a26b 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -It provides API support for your favorite torrent trackers. +API support for your favorite torrent trackers -**Shipped version:** 0.18.98~ynh1 +**Shipped version:** 0.20.53~ynh1 **Demo:** https://github.com/Jackett/Jackett @@ -32,8 +32,6 @@ It provides API support for your favorite torrent trackers. ## Documentation and resources * Official app website: https://github.com/Jackett/Jackett -* Official user documentation: https://yunohost.org/apps -* Official admin documentation: https://yunohost.org/packaging_apps * Upstream app code repository: https://github.com/Jackett/Jackett * YunoHost documentation for this app: https://yunohost.org/app_jackett * Report a bug: https://github.com/YunoHost-Apps/jackett_ynh/issues diff --git a/README_fr.md b/README_fr.md index 216332e..856441b 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,9 +11,9 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble -Expliquez en *quelques* (10~15) mots l'utilité de l'app ou ce qu'elle fait (l'objectif est de donner une idée grossière pour des utilisateurs qui naviguent dans un catalogue de 100+ apps) +API pour vos trackers torrent préférés -**Version incluse :** 0.18.98~ynh1 +**Version incluse :** 0.20.53~ynh1 **Démo :** https://github.com/Jackett/Jackett @@ -28,8 +28,6 @@ Expliquez en *quelques* (10~15) mots l'utilité de l'app ou ce qu'elle fait (l'o ## Documentations et ressources * Site officiel de l'app : https://github.com/Jackett/Jackett -* Documentation officielle utilisateur : https://yunohost.org/apps -* Documentation officielle de l'admin : https://yunohost.org/packaging_apps * Dépôt de code officiel de l'app : https://github.com/Jackett/Jackett * Documentation YunoHost pour cette app : https://yunohost.org/app_jackett * Signaler un bug : https://github.com/YunoHost-Apps/jackett_ynh/issues diff --git a/check_process b/check_process index c0e773e..de4d7c4 100644 --- a/check_process +++ b/check_process @@ -1,14 +1,8 @@ -# See here for more information -# https://github.com/YunoHost/package_check#syntax-check_process-file - -# Move this file from check_process.default to check_process when you have filled it. - ;; Test complet ; Manifest domain="domain.tld" path="/path" is_public=1 - port="666" ; Checks pkg_linter=1 setup_sub_dir=1 @@ -20,7 +14,6 @@ upgrade=1 from_commit=CommitHash backup_restore=1 multi_instance=1 - port_already_use=0 change_url=1 ;;; Options Email= diff --git a/conf/app.arm64.src b/conf/amd64.src similarity index 50% rename from conf/app.arm64.src rename to conf/amd64.src index 9e635ff..1cdea48 100644 --- a/conf/app.arm64.src +++ b/conf/amd64.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/Jackett/Jackett/releases/download/v0.18.98/Jackett.Binaries.LinuxARM64.tar.gz -SOURCE_SUM=0f936344d82e155a2dcb904d2f47bbcfc85ebae6484879f7790a108db021a4d6 +SOURCE_URL=https://github.com/Jackett/Jackett/releases/download/v0.20.53/Jackett.Binaries.LinuxAMDx64.tar.gz +SOURCE_SUM=ea6283621b5c1a61dc4613b27261d010bf959520db530939767a4be8e925f5dd SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/app.src.default b/conf/app.src.default deleted file mode 100644 index 17489bf..0000000 --- a/conf/app.src.default +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=url of app's source -SOURCE_SUM=sha256 checksum -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/app.x64.src b/conf/arm64.src similarity index 50% rename from conf/app.x64.src rename to conf/arm64.src index 61eb3cb..103b3d4 100644 --- a/conf/app.x64.src +++ b/conf/arm64.src @@ -1,7 +1,7 @@ -SOURCE_URL=https://github.com/Jackett/Jackett/releases/download/v0.18.98/Jackett.Binaries.LinuxAMDx64.tar.gz -SOURCE_SUM=d63e783faa4a443ac81876dacc1e54e66ffd1022fa056430a57964b1c92efc84 +SOURCE_URL=https://github.com/Jackett/Jackett/releases/download/v0.20.53/Jackett.Binaries.LinuxARM64.tar.gz +SOURCE_SUM=aa51da64c79511901bf40c552c198a3046c61309cc2495795f8b7087893acd52 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true SOURCE_EXTRACT=true -SOURCE_FILENAME=jackett.tar.gz \ No newline at end of file +SOURCE_FILENAME=jackett.tar.gz diff --git a/conf/app.arm.src b/conf/armhf.src similarity index 50% rename from conf/app.arm.src rename to conf/armhf.src index 79f389a..d2a0697 100644 --- a/conf/app.arm.src +++ b/conf/armhf.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/Jackett/Jackett/releases/download/v0.18.98/Jackett.Binaries.LinuxARM32.tar.gz -SOURCE_SUM=23a704eef13a41a8e4a17830de330f5ff1176f47e7040714b3df90d7733239dc +SOURCE_URL=https://github.com/Jackett/Jackett/releases/download/v0.20.53/Jackett.Binaries.LinuxARM32.tar.gz +SOURCE_SUM=77197e9a617664a1950534154de3d057c9c9e04bab6ef7f1d1c917c541ed8643 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/nginx.conf b/conf/nginx.conf index 158d806..35e5861 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,10 +1,5 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__ { - - # Force usage of https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } proxy_pass http://127.0.0.1:9117; proxy_set_header X-Real-IP $remote_addr; @@ -12,6 +7,7 @@ location __PATH__ { proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Host $http_host; proxy_redirect off; + # Allow the Jackett API location __PATH__/api { auth_request off; diff --git a/manifest.json b/manifest.json index 1082c30..8746673 100644 --- a/manifest.json +++ b/manifest.json @@ -3,17 +3,15 @@ "id": "jackett", "packaging_format": 1, "description": { - "en": "It provides API support for your favorite torrent trackers.", - "fr": "Expliquez en *quelques* (10~15) mots l'utilité de l'app ou ce qu'elle fait (l'objectif est de donner une idée grossière pour des utilisateurs qui naviguent dans un catalogue de 100+ apps)" + "en": "API support for your favorite torrent trackers", + "fr": "API pour vos trackers torrent préférés" }, - "version": "0.18.98~ynh1", - "url": "https://example.com", + "version": "0.20.53~ynh1", + "url": "https://github.com/Jackett/Jackett", "upstream": { "license": "GPL-2.0", "website": "https://github.com/Jackett/Jackett", "demo": "https://github.com/Jackett/Jackett", - "admindoc": "https://yunohost.org/packaging_apps", - "userdoc": "https://yunohost.org/apps", "code": "https://github.com/Jackett/Jackett" }, "license": "GPL-2.0", @@ -22,7 +20,7 @@ "email": "navanchauhan+yunohost@gmail.com" }, "requirements": { - "yunohost": ">= 4.1.3" + "yunohost": ">= 4.3.0" }, "multi_instance": true, "services": [ @@ -32,8 +30,7 @@ "install" : [ { "name": "domain", - "type": "domain", - "example": "example.com" + "type": "domain" }, { "name": "path", @@ -43,9 +40,6 @@ }, { "name": "is_public", - "help": { - "en": "Should the user interface be exposed to the public" - }, "type": "boolean", "default": true } diff --git a/scripts/_common.sh b/scripts/_common.sh index 1408dc9..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,26 +4,10 @@ # COMMON VARIABLES #================================================= -# Supported architectures -supported_architectures=("arm" "arm64" "x64") - #================================================= # PERSONAL HELPERS #================================================= -get_architecture() { - architecture=$(dpkg --print-architecture) - if [ $architecture = "amd64" ]; then - architecture="x64" - elif [[ $architecture = arm* ]] && [[ $(getconf LONG_BIT) = 32 ]]; then - architecture="arm" - elif [[ $architecture = arm* ]] && [[ $(getconf LONG_BIT) = 64 ]]; then - architecture="arm64" - elif [[ $(echo ${supported_architectures[@]} | grep -ow "$architecture" | wc -w) = 0 ]]; then - ynh_die --message="Unsupported architecture $architecture" - fi -} - #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/change_url b/scripts/change_url index d902869..6779d86 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -105,12 +105,6 @@ then ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= - #================================================= # GENERIC FINALISATION #================================================= diff --git a/scripts/install b/scripts/install index 8e725a5..7dd3a42 100755 --- a/scripts/install +++ b/scripts/install @@ -23,6 +23,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC +architecture=$YNH_ARCH app=$YNH_APP_INSTANCE_NAME @@ -74,14 +75,8 @@ get_architecture 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="app.$architecture" +ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" -# FIXME: this should be managed by the core in the future -# Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www-data) can access -# files in some cases. -# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - -# this will be treated as a security issue. chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app: $final_path diff --git a/scripts/remove b/scripts/remove index a5f4976..35a0cb0 100755 --- a/scripts/remove +++ b/scripts/remove @@ -65,16 +65,6 @@ ynh_script_progression --message="Removing logrotate configuration..." # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port..." - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - #================================================= # SPECIFIC REMOVE #================================================= diff --git a/scripts/restore b/scripts/restore index c5f8749..533d23f 100755 --- a/scripts/restore +++ b/scripts/restore @@ -37,8 +37,6 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= ynh_script_progression --message="Validating restoration parameters..." -ynh_webpath_available --domain=$domain --path_url=$path_url \ - || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " @@ -66,12 +64,6 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -# FIXME: this should be managed by the core in the future -# Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www-data) can access -# files in some cases. -# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - -# this will be treated as a security issue. chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" @@ -125,4 +117,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --time --last +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 3940eb4..2de53f2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,17 +19,12 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +architecture=$YNH_ARCH #================================================= # CHECK VERSION #================================================= -### This helper will compare the version of the currently installed app and the version of the upstream package. -### $upgrade_type can have 2 different values -### - UPGRADE_APP if the upstream app version has changed -### - UPGRADE_PACKAGE if only the YunoHost package has changed -### ynh_check_app_version_changed will stop the upgrade if the app is up to date. -### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. upgrade_type=$(ynh_check_app_version_changed) #================================================= @@ -60,27 +55,6 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app #================================================= ynh_script_progression --message="Ensuring downward compatibility..." -# -# N.B. : the followings setting migrations snippets are provided as *EXAMPLES* -# of what you may want to do in some cases (e.g. a setting was not defined on -# some legacy installs and you therefore want to initiaze stuff during upgrade) -# - -# If db_name doesn't exist, create it -#if [ -z "$db_name" ]; then -# db_name=$(ynh_sanitize_dbid --db_name=$app) -# ynh_app_setting_set --app=$app --key=db_name --value=$db_name -#fi - -# If final_path doesn't exist, create it -#if [ -z "$final_path" ]; then -# final_path=/var/www/$app -# ynh_app_setting_set --app=$app --key=final_path --value=$final_path -#fi - -### If nobody installed your app before 4.1, -### then you may safely remove these lines - # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all @@ -114,18 +88,10 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." - get_architecture - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" --source_id="app.$architecture" + ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" fi -# FIXME: this should be managed by the core in the future -# Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www-data) can access -# files in some cases. -# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - -# this will be treated as a security issue. chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path"