From 2b35ec96fe910bc090e9e291ff1799cffa87e880 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 10 Jun 2024 21:23:51 +0200 Subject: [PATCH 1/3] Move to ynh autoupdater --- .github/workflows/updater.sh | 64 ----------------------------------- .github/workflows/updater.yml | 57 ------------------------------- conf/nginx.conf | 24 ++++++------- manifest.toml | 9 ++++- scripts/_common.sh | 3 -- scripts/install | 5 +-- scripts/upgrade | 5 +-- 7 files changed, 22 insertions(+), 145 deletions(-) delete mode 100755 .github/workflows/updater.sh delete mode 100644 .github/workflows/updater.yml diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh deleted file mode 100755 index 362ef37..0000000 --- a/.github/workflows/updater.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/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. - -#================================================= -# FETCHING LATEST RELEASE AND ITS ASSETS -#================================================= - -# Fetching information -current_version=$(cat manifest.toml | tomlq -j '.version|split("~")[0]') -repo=$(cat manifest.toml | tomlq -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_raw=$(curl --silent "https://api.github.com/repos/$repo/commits/master" | jq -r ".commit.committer.date") -version=$(date -d "$version_raw" +%Y.%m.%d.%H.%M.%S) -commit_hash=$(curl --silent "https://api.github.com/repos/$repo/commits/master" | jq -r ".sha") - -# Setting up the environment variables -echo "Current version: $current_version" -echo "Latest release from upstream: $version" -echo "VERSION=$version" >> $GITHUB_ENV -echo "REPO=$repo" >> $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 - -#================================================= -# UPDATE SOURCE FILES -#================================================= - -#================================================= -# SPECIFIC UPDATE STEPS -#================================================= - -# Replace new version in _common.sh -sed -i "s/^commit_sha=.*/commit_sha=\"$commit_hash\"/" scripts/_common.sh - -#================================================= -# GENERIC FINALIZATION -#================================================= - -# Replace new version in manifest -sed -i "s/^version = .*/version = \"$version~ynh1\"/" manifest.toml - -# 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/.github/workflows/updater.yml b/.github/workflows/updater.yml deleted file mode 100644 index b79383a..0000000 --- a/.github/workflows/updater.yml +++ /dev/null @@ -1,57 +0,0 @@ -# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected. -# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization. -# This file should be enough by itself, but feel free to tune it to your needs. -# It calls updater.sh, which is where you should put the app-specific update steps. -name: Check for new upstream releases -on: - # Allow to manually trigger the workflow - workflow_dispatch: - # Run it every day at 6:00 UTC - schedule: - - cron: '0 6 * * *' -jobs: - updater: - runs-on: ubuntu-latest - steps: - - name: Fetch the source code - uses: actions/checkout@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.9' - - name: Install yq/tomlq - id: install_yq - run: pip install yq - - name: Run the updater script - id: run_updater - run: | - # Setting up Git user - git config --global user.name 'yunohost-bot' - git config --global user.email 'yunohost-bot@users.noreply.github.com' - # Run the updater script - /bin/bash .github/workflows/updater.sh - - name: Commit changes - id: commit - if: ${{ env.PROCEED == 'true' }} - run: | - git commit -am "Upgrade to v$VERSION" - - name: Create Pull Request to testing - id: cpr-testing - if: ${{ env.PROCEED == 'true' }} - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: Update to version ${{ env.VERSION }} - committer: 'yunohost-bot ' - author: 'yunohost-bot ' - signoff: false - base: testing - branch: ci-auto-update-v${{ env.VERSION }} - delete-branch: true - title: 'Upgrade to version ${{ env.VERSION }}' - body: | - Upgrade to v${{ env.VERSION }} - [See upstream release page](https://github.com/${{ env.REPO }}/releases/tag/v${{ env.VERSION }}) - draft: false diff --git a/conf/nginx.conf b/conf/nginx.conf index b4b159f..f5a4eb9 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,19 +1,19 @@ location __PATH__/ { - uwsgi_pass unix:///var/run/__APP__/app.socket; + uwsgi_pass unix:///var/run/__APP__/app.socket; - include uwsgi_params; - uwsgi_param HTTP_HOST $host; - uwsgi_param HTTP_CONNECTION $http_connection; + include uwsgi_params; + uwsgi_param HTTP_HOST $host; + uwsgi_param HTTP_CONNECTION $http_connection; - # see flaskfix.py - uwsgi_param HTTP_X_SCHEME $scheme; - uwsgi_param HTTP_X_SCRIPT_NAME /searxng; + # see flaskfix.py + uwsgi_param HTTP_X_SCHEME $scheme; + uwsgi_param HTTP_X_SCRIPT_NAME /searxng; - # see limiter.py - uwsgi_param HTTP_X_REAL_IP $remote_addr; - uwsgi_param HTTP_X_FORWARDED_FOR $proxy_add_x_forwarded_for; + # see limiter.py + uwsgi_param HTTP_X_REAL_IP $remote_addr; + uwsgi_param HTTP_X_FORWARDED_FOR $proxy_add_x_forwarded_for; - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; } diff --git a/manifest.toml b/manifest.toml index 189558d..a15be7e 100644 --- a/manifest.toml +++ b/manifest.toml @@ -7,7 +7,7 @@ description.fr = "Un méta-moteur de recherche qui rassemble les résultats de p version = "2024.05.17.07.51.17~ynh1" -maintainers = ["mh4ckt3mh4ckt1c4s"] +maintainers = ["mh4ckt3mh4ckt1c4s", "ewilly"] [upstream] license = "AGPL-3.0-or-later" @@ -40,6 +40,13 @@ ram.runtime = "200M" default = "visitors" [resources] + [resources.sources] + + [resources.sources.main] + url = "https://github.com/searxng/searxng/archive/f5eb56b63f250c7804e5e1cf4426e550bc933906.tar.gz" + sha256 = "5424c916ba6312fb22d14b7eac268e40995bda073e480b3e6c8e9d63dcd5e087" + autoupdate.strategy = "latest_github_commit" + [resources.system_user] [resources.install_dir] diff --git a/scripts/_common.sh b/scripts/_common.sh index 40ed39f..15c1ebe 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,6 @@ # COMMON VARIABLES #================================================= -repo_fullpath="https://github.com/searxng/searxng" -commit_sha="ec41b535876c7906871ea25638837db3dbc5e4ab" - #================================================= # UWSGI HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 71cfebc..3f6664d 100755 --- a/scripts/install +++ b/scripts/install @@ -16,10 +16,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -ynh_exec_fully_quiet git clone -n "$repo_fullpath" "$install_dir/searxng-src" -pushd "$install_dir/searxng-src" - ynh_exec_fully_quiet git checkout "$commit_sha" -popd +ynh_setup_source --dest_dir="$install_dir/searxng-src" ynh_script_progression --message="Installing SearXNG..." --weight=2 diff --git a/scripts/upgrade b/scripts/upgrade index d26e0ab..a9887d3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -49,10 +49,7 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_secure_remove --file="$install_dir/searxng-src" - ynh_exec_fully_quiet git clone -n "$repo_fullpath" "$install_dir/searxng-src" - pushd "$install_dir/searxng-src" - ynh_exec_fully_quiet git checkout "$commit_sha" - popd + ynh_setup_source --dest_dir="$install_dir/searxng-src" ynh_secure_remove --file="$install_dir/searxng-pyenv" python3 -m venv --system-site-packages "$install_dir/searxng-pyenv" From f3ada8be24aee6052b1b38a251951ad745b08335 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 11 Jun 2024 21:23:30 +0200 Subject: [PATCH 2/3] Fux move to ynh autoupdater --- manifest.toml | 2 +- scripts/install | 7 ++++++- scripts/upgrade | 7 ++++++- tests.toml | 5 ----- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/manifest.toml b/manifest.toml index a15be7e..71a5215 100644 --- a/manifest.toml +++ b/manifest.toml @@ -18,7 +18,7 @@ userdoc = "https://docs.searxng.org/user/" code = "https://github.com/searxng/searxng" [integration] -yunohost = ">= 11.1.9" +yunohost = ">= 11.2.14.1" architectures = "all" multi_instance = false ldap = "not_relevant" diff --git a/scripts/install b/scripts/install index 3f6664d..a16a5e3 100755 --- a/scripts/install +++ b/scripts/install @@ -16,7 +16,12 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -ynh_setup_source --dest_dir="$install_dir/searxng-src" +repo_fullpath=$(ynh_read_manifest --manifest_key="upstream.code") +commit_sha=$(ynh_read_manifest --manifest_key="resources.sources.main.url" | xargs basename | tr -d"." -f1) +ynh_exec_fully_quiet git clone -n "$repo_fullpath" "$install_dir/searxng-src" +pushd "$install_dir/searxng-src" + ynh_exec_fully_quiet git checkout "$commit_sha" +popd ynh_script_progression --message="Installing SearXNG..." --weight=2 diff --git a/scripts/upgrade b/scripts/upgrade index a9887d3..96c7be0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -49,7 +49,12 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_secure_remove --file="$install_dir/searxng-src" - ynh_setup_source --dest_dir="$install_dir/searxng-src" + repo_fullpath=$(ynh_read_manifest --manifest_key="upstream.code") + commit_sha=$(ynh_read_manifest --manifest_key="resources.sources.main.url" | xargs basename | tr -d"." -f1) + ynh_exec_fully_quiet git clone -n "$repo_fullpath" "$install_dir/searxng-src" + pushd "$install_dir/searxng-src" + ynh_exec_fully_quiet git checkout "$commit_sha" + popd ynh_secure_remove --file="$install_dir/searxng-pyenv" python3 -m venv --system-site-packages "$install_dir/searxng-pyenv" diff --git a/tests.toml b/tests.toml index 81dc0a3..be5955f 100644 --- a/tests.toml +++ b/tests.toml @@ -15,8 +15,3 @@ test_format = 1.0 # ------------------------------- # Commits to test upgrade from # ------------------------------- - test_upgrade_from.9de9cc90.name = "2023.09.17.22.15.57~ynh1 / packaging v1" - test_upgrade_from.9de9cc90.args.domain = "domain.tld" - test_upgrade_from.9de9cc90.args.path = "/path" - test_upgrade_from.9de9cc90.args.is_public = 1 - test_upgrade_from.9de9cc90.args.admin = "john" From f810e40ce910f03f956f0bb814e68e1ea2b03f74 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 12 Jun 2024 07:26:21 +0200 Subject: [PATCH 3/3] Fix move to ynh autoupdater --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index a16a5e3..e5d7de4 100755 --- a/scripts/install +++ b/scripts/install @@ -17,7 +17,7 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Setting up source files..." --weight=1 repo_fullpath=$(ynh_read_manifest --manifest_key="upstream.code") -commit_sha=$(ynh_read_manifest --manifest_key="resources.sources.main.url" | xargs basename | tr -d"." -f1) +commit_sha=$(ynh_read_manifest --manifest_key="resources.sources.main.url" | xargs basename --suffix=".tar.gz") ynh_exec_fully_quiet git clone -n "$repo_fullpath" "$install_dir/searxng-src" pushd "$install_dir/searxng-src" ynh_exec_fully_quiet git checkout "$commit_sha" diff --git a/scripts/upgrade b/scripts/upgrade index 96c7be0..09340a8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -50,7 +50,7 @@ then ynh_secure_remove --file="$install_dir/searxng-src" repo_fullpath=$(ynh_read_manifest --manifest_key="upstream.code") - commit_sha=$(ynh_read_manifest --manifest_key="resources.sources.main.url" | xargs basename | tr -d"." -f1) + commit_sha=$(ynh_read_manifest --manifest_key="resources.sources.main.url" | xargs basename --suffix=".tar.gz") ynh_exec_fully_quiet git clone -n "$repo_fullpath" "$install_dir/searxng-src" pushd "$install_dir/searxng-src" ynh_exec_fully_quiet git checkout "$commit_sha"