custom-pkgbuilds/serialsearch-git/PKGBUILD
2025-02-23 08:36:39 -03:00

87 lines
3.3 KiB
Bash

# Maintainer: Lain Iwakura <lain@serialexperiments.club>
# Contributor: HLFH <gaspard@dhautefeuille.eu>
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"
}