From 0a8d7c6a86ad3ead6b49a807b1d47eba0337cdb5 Mon Sep 17 00:00:00 2001 From: Lain Iwakura Date: Sun, 23 Feb 2025 08:36:39 -0300 Subject: [PATCH] Add serialsearch --- serialsearch-git/PKGBUILD | 87 +++++++++++++++++++++++++++++++ serialsearch-git/searxng.ini | 25 +++++++++ serialsearch-git/searxng.sysusers | 1 + serialsearch-git/searxng.tmpfiles | 6 +++ serialsearch-git/settings.yml | 9 ++++ 5 files changed, 128 insertions(+) create mode 100644 serialsearch-git/PKGBUILD create mode 100644 serialsearch-git/searxng.ini create mode 100644 serialsearch-git/searxng.sysusers create mode 100644 serialsearch-git/searxng.tmpfiles create mode 100644 serialsearch-git/settings.yml diff --git a/serialsearch-git/PKGBUILD b/serialsearch-git/PKGBUILD new file mode 100644 index 0000000..c4c2a61 --- /dev/null +++ b/serialsearch-git/PKGBUILD @@ -0,0 +1,87 @@ +# Maintainer: Lain Iwakura +# Contributor: HLFH + +pkgname=serialsearch-git +pkgver=r8394.712a871 +pkgrel=1 +pkgdesc="Serial Search based on SearXNG" +arch=('any') +url="https://search.serialexperiments.club" +license=('AGPL-3.0-or-later') +makedepends=('openssl' 'git') +depends=('uwsgi' + 'uwsgi-plugin-python') +provides=('searxng') +conflicts=('searxng' 'searx' 'searx-git') +backup=('etc/searxng/settings.yml' 'etc/uwsgi/searxng.ini') +source=(git+ssh://git@git.serialexperiments.club/lain/serialsearch + 'searxng.ini' + 'searxng.sysusers' + 'searxng.tmpfiles' + 'settings.yml') +b2sums=('SKIP' + 'cb75d9f55524183d3b47dc0f638dcd4a74bfb137616725460a44577e9b2e76e28c0c865a8f86407700e02e4425a499c46d940b1e3e341ac5a94138182cf2c3c2' + 'f2c8eb0191c9856965d811ce81e2ac864fb88d32cb7f4554151cf14f792a8c60876bb183c25561132bb037902ca356f1481ef732570c3c9887a0bc2e1c42cbaf' + 'f3a8a9805a45e995ad66f599c9bf0c57e621749bb6aa8cd70eff8b97a3c0e5f1045810e38204594354eb817e7dafe5a99bc3f93b38fab8d58d539243e714a089' + 'df61197eebe379e3cbfa93c4093a5b0a8767fdc5fa22537b3b226fde5ebed62aca6ae98f3d6f7e2dd7867ea928ca4785033d3b9a20785b506f670dbc8d880b17') + +pkgver() { + cd serialsearch + ( set -o pipefail + git describe --long --abbrev=7 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' || + printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)" + ) +} + +build() { + cd "$srcdir/serialsearch" + rm -rf .venv + python -m venv .venv + source .venv/bin/activate + pip install --upgrade pip build installer wheel setuptools + + pip install -r requirements.txt + + # Generate a random secret key + sed -i -e "s/ultrasecretkey\" # change this\!/`openssl rand -hex 32`\"/g" "../settings.yml" + + local SEARXNG_SETTINGS_PATH="../settings.yml" + python -m searx.version freeze + sed -i "s|GIT_URL =.*|GIT_URL = \"ssh://git@git.serialexperiments.club/lain/SerialSearch.git\"|g" searx/version_frozen.py + sed -i "s|GIT_BRANCH =.*|GIT_BRANCH = \"master\"|g" searx/version_frozen.py + + # Build the package + python -m build --wheel --no-isolation +} + +package() { + cd "$srcdir/serialsearch" + source .venv/bin/activate + + local _site_packages="$(python -c 'import site, os; print(os.path.relpath(site.getsitepackages()[0]))')" + + # Install package + python -m installer dist/*.whl + + # Update the .venv path + pip install virtualenv-tools4 + cd .venv + virtualenv-tools --update-path /var/lib/searxng/.venv/ + + # Copy the .venv directory + rm -rf "bin/__pycache__" + install -d -m 750 "$pkgdir/var/lib/searxng/.venv" + cp -r . "$pkgdir/var/lib/searxng/.venv" + + install -Dm644 "${srcdir}/searxng.ini" "${pkgdir}/etc/uwsgi/searxng.ini" + install -Dm644 "${srcdir}/settings.yml" "${pkgdir}/etc/searxng/settings.yml" + install -Dm644 "${srcdir}/serialsearch/searx/limiter.toml" "${pkgdir}/etc/searxng/limiter.toml" + install -Dm644 "${srcdir}/serialsearch/searx/version_frozen.py" "${pkgdir}/var/lib/searxng/${_site_packages}/searx/version_frozen.py" + install -Dm644 "${srcdir}/serialsearch/LICENSE" "${pkgdir}/usr/share/licenses/searxng/LICENSE" + + install -Dm644 "${srcdir}/searxng.sysusers" "${pkgdir}/usr/lib/sysusers.d/searxng.conf" + install -Dm644 "$srcdir/searxng.tmpfiles" "$pkgdir/usr/lib/tmpfiles.d/searxng.conf" + + # Clean build + rm -rf "$srcdir/serialsearch" +} diff --git a/serialsearch-git/searxng.ini b/serialsearch-git/searxng.ini new file mode 100644 index 0000000..91cc9a4 --- /dev/null +++ b/serialsearch-git/searxng.ini @@ -0,0 +1,25 @@ +[uwsgi] +uid = searxng +gid = searxng +env = LANG=C.UTF-8 +env = LANGUAGE=C.UTF-8 +env = LC_ALL=C.UTF-8 +env = SEARX_SETTINGS_PATH=/etc/searxng/settings.yml +logger = systemd +disable-logging = true +single-interpreter = true +master = true +lazy-apps = true +plugin = python +enable-threads = true +workers = %k +threads = 4 +module = searx.webapp +chmod-socket = 666 +socket = /run/searxng/searxng.sock +buffer-size = 8192 +virtualenv = /var/lib/searxng/.venv +static-map = /static=/var/lib/searxng/.venv/lib/python3.13/site-packages/searx/static +static-expires = /* 86400 +static-gzip-all = True +offload-threads = %k diff --git a/serialsearch-git/searxng.sysusers b/serialsearch-git/searxng.sysusers new file mode 100644 index 0000000..c1e4faa --- /dev/null +++ b/serialsearch-git/searxng.sysusers @@ -0,0 +1 @@ +u searxng - "Searxng server user" /var/lib/searxng diff --git a/serialsearch-git/searxng.tmpfiles b/serialsearch-git/searxng.tmpfiles new file mode 100644 index 0000000..0da53d7 --- /dev/null +++ b/serialsearch-git/searxng.tmpfiles @@ -0,0 +1,6 @@ +d /etc/searxng 0750 root searxng +f /etc/searxng/settings.yml 0640 root searxng +f /etc/searxng/limiter.toml 0640 root searxng +d /var/lib/searxng 0700 searxng searxng +Z /var/lib/searxng - searxng searxng +d /run/searxng 0755 searxng searxng diff --git a/serialsearch-git/settings.yml b/serialsearch-git/settings.yml new file mode 100644 index 0000000..d9b74e1 --- /dev/null +++ b/serialsearch-git/settings.yml @@ -0,0 +1,9 @@ +use_default_settings: true +server: + secret_key: "ultrasecretkey" # change this! + limiter: true +checker: + scheduling: + start_after: [300, 1800] # delay to start the first run of the checker + every: [86400, 90000] # how often the checker runs +