[fix] apply shell formating / shfmt (make format.shell)

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2025-07-16 17:52:32 +02:00 committed by Markus Heiser
parent cd062d7349
commit 8c2c3430da
16 changed files with 492 additions and 419 deletions

24
manage
View File

@ -129,7 +129,6 @@ dev.env() {
fi fi
} }
if [ "$VERBOSE" = "1" ]; then if [ "$VERBOSE" = "1" ]; then
SPHINX_VERBOSE="-v" SPHINX_VERBOSE="-v"
PYLINT_VERBOSE="-v" PYLINT_VERBOSE="-v"
@ -172,7 +171,8 @@ gecko.driver() {
build_msg INSTALL "gecko.driver" build_msg INSTALL "gecko.driver"
# run installation in a subprocess and activate pyenv # run installation in a subprocess and activate pyenv
( set -e (
set -e
pyenv.activate pyenv.activate
INSTALLED_VERSION=$(geckodriver -V 2>/dev/null | head -1 | awk '{ print "v" $2}') || INSTALLED_VERSION="" INSTALLED_VERSION=$(geckodriver -V 2>/dev/null | head -1 | awk '{ print "v" $2}') || INSTALLED_VERSION=""
@ -189,7 +189,7 @@ gecko.driver() {
"windows 64 bit") ARCH="win64" ;; "windows 64 bit") ARCH="win64" ;;
"mac 64bit") ARCH="macos" ;; "mac 64bit") ARCH="macos" ;;
esac esac
GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-$ARCH.tar.gz"; GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-$ARCH.tar.gz"
build_msg GECKO "Installing ${PY_ENV_BIN}/geckodriver from $GECKODRIVER_URL" build_msg GECKO "Installing ${PY_ENV_BIN}/geckodriver from $GECKODRIVER_URL"
@ -210,7 +210,8 @@ py.build() {
py.clean() { py.clean() {
build_msg CLEAN pyenv build_msg CLEAN pyenv
( set -e (
set -e
pyenv.drop pyenv.drop
[ "$VERBOSE" = "1" ] && set -x [ "$VERBOSE" = "1" ] && set -x
rm -rf "${PYDIST}" "${PYBUILD}" "${PY_ENV}" ./.tox ./*.egg-info rm -rf "${PYDIST}" "${PYBUILD}" "${PY_ENV}" ./.tox ./*.egg-info
@ -236,7 +237,8 @@ pyenv.install() {
return 0 return 0
fi fi
( set -e (
set -e
pyenv pyenv
build_msg PYENV "[install] pip install --use-pep517 --no-build-isolation -e 'searx${PY_SETUP_EXTRAS}'" build_msg PYENV "[install] pip install --use-pep517 --no-build-isolation -e 'searx${PY_SETUP_EXTRAS}'"
"${PY_ENV_BIN}/python" -m pip install --use-pep517 --no-build-isolation -e ".${PY_SETUP_EXTRAS}" "${PY_ENV_BIN}/python" -m pip install --use-pep517 --no-build-isolation -e ".${PY_SETUP_EXTRAS}"
@ -249,8 +251,8 @@ pyenv.install() {
pyenv.uninstall() { pyenv.uninstall() {
build_msg PYENV "[pyenv.uninstall] uninstall packages: ${PYOBJECTS}" build_msg PYENV "[pyenv.uninstall] uninstall packages: ${PYOBJECTS}"
pyenv.cmd python setup.py develop --uninstall 2>&1 \ pyenv.cmd python setup.py develop --uninstall 2>&1 |
| prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] " prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
} }
@ -282,7 +284,8 @@ docs.prebuild() {
main() { main() {
local _type local _type
local cmd="$1"; shift local cmd="$1"
shift
if [ "$cmd" == "" ]; then if [ "$cmd" == "" ]; then
help help
@ -291,7 +294,10 @@ main() {
fi fi
case "$cmd" in case "$cmd" in
--getenv) var="$1"; echo "${!var}";; --getenv)
var="$1"
echo "${!var}"
;;
--help) help ;; --help) help ;;
--*) --*)
help help

View File

@ -4,11 +4,20 @@
# shellcheck disable=SC2059,SC1117 # shellcheck disable=SC2059,SC1117
# ubuntu, debian, arch, fedora, centos ... # ubuntu, debian, arch, fedora, centos ...
DIST_ID=$(source /etc/os-release; echo "$ID"); DIST_ID=$(
source /etc/os-release
echo "$ID"
)
# shellcheck disable=SC2034 # shellcheck disable=SC2034
DIST_VERS=$(source /etc/os-release; echo "$VERSION_ID"); DIST_VERS=$(
source /etc/os-release
echo "$VERSION_ID"
)
# shellcheck disable=SC2034 # shellcheck disable=SC2034
DIST_VERSION_CODENAME=$(source /etc/os-release; echo "$VERSION_CODENAME"); DIST_VERSION_CODENAME=$(
source /etc/os-release
echo "$VERSION_CODENAME"
)
ADMIN_NAME="${ADMIN_NAME:-$(git config user.name)}" ADMIN_NAME="${ADMIN_NAME:-$(git config user.name)}"
ADMIN_NAME="${ADMIN_NAME:-$USER}" ADMIN_NAME="${ADMIN_NAME:-$USER}"
@ -150,12 +159,12 @@ rst_para() {
} }
die() { die() {
echo -e "${_BRed}ERROR:${_creset} ${BASH_SOURCE[1]}: line ${BASH_LINENO[0]}: ${2-died ${1-1}}" >&2; echo -e "${_BRed}ERROR:${_creset} ${BASH_SOURCE[1]}: line ${BASH_LINENO[0]}: ${2-died ${1-1}}" >&2
exit "${1-1}" exit "${1-1}"
} }
die_caller() { die_caller() {
echo -e "${_BRed}ERROR:${_creset} ${BASH_SOURCE[2]}: line ${BASH_LINENO[1]}: ${FUNCNAME[1]}(): ${2-died ${1-1}}" >&2; echo -e "${_BRed}ERROR:${_creset} ${BASH_SOURCE[2]}: line ${BASH_LINENO[1]}: ${FUNCNAME[1]}(): ${2-died ${1-1}}" >&2
exit "${1-1}" exit "${1-1}"
} }
@ -233,7 +242,8 @@ ask_yn() {
# shellcheck disable=SC2086,SC2229 # shellcheck disable=SC2086,SC2229
read -r -n1 $_t read -r -n1 $_t
if [[ -z $REPLY ]]; then if [[ -z $REPLY ]]; then
printf "$default\n"; break printf "$default\n"
break
elif [[ $REPLY =~ ^[Yy]$ ]]; then elif [[ $REPLY =~ ^[Yy]$ ]]; then
exit_val=${EXIT_YES} exit_val=${EXIT_YES}
printf "\n" printf "\n"
@ -260,7 +270,7 @@ tee_stderr () {
# >>> print("hello") # >>> print("hello")
# hello # hello
local _t="0"; local _t="0"
if [[ -n $1 ]]; then _t="$1"; fi if [[ -n $1 ]]; then _t="$1"; fi
(while read -r line; do (while read -r line; do
@ -320,9 +330,11 @@ cache_download() {
info_msg "caching: $1" info_msg "caching: $1"
info_msg " --> ${CACHE}/$2" info_msg " --> ${CACHE}/$2"
if [[ -n ${SUDO_USER} ]]; then if [[ -n ${SUDO_USER} ]]; then
sudo -u "${SUDO_USER}" wget --progress=bar -O "${CACHE}/$2" "$1" ; exit_value=$? sudo -u "${SUDO_USER}" wget --progress=bar -O "${CACHE}/$2" "$1"
exit_value=$?
else else
wget --progress=bar -O "${CACHE}/$2" "$1" ; exit_value=$? wget --progress=bar -O "${CACHE}/$2" "$1"
exit_value=$?
fi fi
if [[ ! $exit_value = 0 ]]; then if [[ ! $exit_value = 0 ]]; then
err_msg "failed to download: $1" err_msg "failed to download: $1"
@ -350,7 +362,7 @@ choose_one() {
local default=${DEFAULT_SELECT-1} local default=${DEFAULT_SELECT-1}
local REPLY local REPLY
local env_name=$1 && shift local env_name=$1 && shift
local choice=$1; local choice=$1
local max="${#@}" local max="${#@}"
local _t local _t
[[ -n $FORCE_TIMEOUT ]] && _t=$FORCE_TIMEOUT [[ -n $FORCE_TIMEOUT ]] && _t=$FORCE_TIMEOUT
@ -414,8 +426,14 @@ install_template() {
for i in "$@"; do for i in "$@"; do
case $i in case $i in
--no-eval) do_eval=0; shift ;; --no-eval)
--variant=*) variant=":${i#*=}"; shift ;; do_eval=0
shift
;;
--variant=*)
variant=":${i#*=}"
shift
;;
*) pos_args+=("$i") ;; *) pos_args+=("$i") ;;
esac esac
done done
@ -503,6 +521,7 @@ install_template() {
;; ;;
"diff files") "diff files")
$DIFF_CMD "${dst}" "${template_file}" | prefix_stdout $DIFF_CMD "${dst}" "${template_file}" | prefix_stdout
;;
esac esac
done done
} }
@ -563,8 +582,8 @@ pyenv() {
# files. # files.
required_commands \ required_commands \
sha256sum "${PYTHON}" \ sha256sum "${PYTHON}" ||
|| exit exit
local pip_req=() local pip_req=()
@ -583,8 +602,8 @@ pyenv() {
( (
[ "$VERBOSE" = "1" ] && set -x [ "$VERBOSE" = "1" ] && set -x
# shellcheck disable=SC2086 # shellcheck disable=SC2086
"${PY_ENV_BIN}/python" -m pip install "${pip_req[@]}" \ "${PY_ENV_BIN}/python" -m pip install "${pip_req[@]}" &&
&& sha256sum ${PY_ENV_REQ} > "${PY_ENV}/requirements.sha256" sha256sum ${PY_ENV_REQ} >"${PY_ENV}/requirements.sha256"
) )
fi fi
pyenv.OK pyenv.OK
@ -602,17 +621,17 @@ pyenv.OK() {
return 1 return 1
fi fi
if [ ! -f "${PY_ENV}/requirements.sha256" ] \ if [ ! -f "${PY_ENV}/requirements.sha256" ] ||
|| ! sha256sum -c "${PY_ENV}/requirements.sha256" > /dev/null 2>&1; then ! sha256sum -c "${PY_ENV}/requirements.sha256" >/dev/null 2>&1; then
build_msg PYENV "[virtualenv] requirements.sha256 failed" build_msg PYENV "[virtualenv] requirements.sha256 failed"
sed 's/^/ [virtualenv] - /' <"${PY_ENV}/requirements.sha256" sed 's/^/ [virtualenv] - /' <"${PY_ENV}/requirements.sha256"
return 1 return 1
fi fi
if [ "$VERBOSE" = "1" ]; then if [ "$VERBOSE" = "1" ]; then
pyenv.check \ pyenv.check |
| "${PY_ENV_BIN}/python" 2>&1 \ "${PY_ENV_BIN}/python" 2>&1 |
| prefix_stdout "${_Blue}PYENV ${_creset}[check] " prefix_stdout "${_Blue}PYENV ${_creset}[check] "
else else
pyenv.check | "${PY_ENV_BIN}/python" 1>/dev/null pyenv.check | "${PY_ENV_BIN}/python" 1>/dev/null
fi fi
@ -708,19 +727,19 @@ pyenv.uninstall() {
build_msg PYENV "[uninstall] ${PYOBJECTS}" build_msg PYENV "[uninstall] ${PYOBJECTS}"
if [ "." = "${PYOBJECTS}" ]; then if [ "." = "${PYOBJECTS}" ]; then
pyenv.cmd python setup.py develop --uninstall 2>&1 \ pyenv.cmd python setup.py develop --uninstall 2>&1 |
| prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] " prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
else else
# shellcheck disable=SC2086 # shellcheck disable=SC2086
pyenv.cmd python -m pip uninstall --yes ${PYOBJECTS} 2>&1 \ pyenv.cmd python -m pip uninstall --yes ${PYOBJECTS} 2>&1 |
| prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] " prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
fi fi
} }
pyenv.cmd() { pyenv.cmd() {
pyenv.install pyenv.install
( set -e (
set -e
# shellcheck source=/dev/null # shellcheck source=/dev/null
source "${PY_ENV_BIN}/activate" source "${PY_ENV_BIN}/activate"
[ "$VERBOSE" = "1" ] && set -x [ "$VERBOSE" = "1" ] && set -x
@ -728,14 +747,12 @@ pyenv.cmd() {
) )
} }
pyenv.activate() { pyenv.activate() {
pyenv.install pyenv.install
# shellcheck source=/dev/null # shellcheck source=/dev/null
source "${PY_ENV_BIN}/activate" source "${PY_ENV_BIN}/activate"
} }
# Sphinx doc # Sphinx doc
# ---------- # ----------
@ -858,7 +875,6 @@ interactive_shell(){
sudo -H -u "${1}" -i sudo -H -u "${1}" -i
} }
# systemd # systemd
# ------- # -------
@ -927,7 +943,6 @@ systemctl status --no-pager ${1}.service
EOF EOF
} }
# nginx # nginx
# ----- # -----
@ -1042,8 +1057,7 @@ nginx_include_apps_enabled() {
( (
local line local line
local stage=0 local stage=0
while IFS= read -r line while IFS= read -r line; do
do
echo "$line" echo "$line"
if [[ $stage = 0 ]]; then if [[ $stage = 0 ]]; then
if [[ $line =~ ^[[:space:]]*server*[[:space:]]*\{ ]]; then if [[ $line =~ ^[[:space:]]*server*[[:space:]]*\{ ]]; then
@ -1095,7 +1109,6 @@ nginx_disable_app() {
nginx_reload nginx_reload
} }
# Apache # Apache
# ------ # ------
@ -1626,7 +1639,6 @@ EOF
fi fi
} }
# IP # IP
# -- # --
@ -1647,9 +1659,9 @@ primary_ip() {
case $DIST_ID in case $DIST_ID in
arch) arch)
ip -o addr show \ ip -o addr show |
| sed -nr 's/[0-9]*:\s*([a-z0-9]*).*inet[6]?\s*([a-z0-9.:]*).*scope global.*/\2/p' \ sed -nr 's/[0-9]*:\s*([a-z0-9]*).*inet[6]?\s*([a-z0-9.:]*).*scope global.*/\2/p' |
| head -n 1 head -n 1
;; ;;
*) hostname -I | cut -d' ' -f1 ;; *) hostname -I | cut -d' ' -f1 ;;
esac esac

View File

@ -21,7 +21,6 @@ redis.:
EOF EOF
} }
redis.remove() { redis.remove() {
sudo_or_exit sudo_or_exit
( (
@ -36,7 +35,6 @@ redis.shell() {
interactive_shell "${REDIS_USER}" interactive_shell "${REDIS_USER}"
} }
redis.userdel() { redis.userdel() {
sudo_or_exit sudo_or_exit
drop_service_account "${REDIS_USER}" drop_service_account "${REDIS_USER}"

View File

@ -13,7 +13,8 @@ EOF
} }
data.all() { data.all() {
( set -e (
set -e
pyenv.activate pyenv.activate
data.traits data.traits
@ -35,9 +36,9 @@ data.all() {
) )
} }
data.traits() { data.traits() {
( set -e (
set -e
pyenv.activate pyenv.activate
build_msg DATA "update searx/data/engine_traits.json" build_msg DATA "update searx/data/engine_traits.json"
python searxng_extra/update/update_engine_traits.py python searxng_extra/update/update_engine_traits.py
@ -53,7 +54,8 @@ data.useragents() {
} }
data.locales() { data.locales() {
( set -e (
set -e
pyenv.activate pyenv.activate
build_msg DATA "update searx/data/locales.json" build_msg DATA "update searx/data/locales.json"
python searxng_extra/update/update_locales.py python searxng_extra/update/update_locales.py
@ -62,7 +64,8 @@ data.locales() {
} }
data.currencies() { data.currencies() {
( set -e (
set -e
pyenv.activate pyenv.activate
build_msg DATA "update searx/data/currencies.json" build_msg DATA "update searx/data/currencies.json"
python searxng_extra/update/update_currencies.py python searxng_extra/update/update_currencies.py

View File

@ -24,7 +24,8 @@ nodejs.ensure() {
node.env() { node.env() {
nodejs.ensure nodejs.ensure
( set -e (
set -e
build_msg INSTALL "[npm] ./client/simple/package.json" build_msg INSTALL "[npm] ./client/simple/package.json"
npm --prefix client/simple install npm --prefix client/simple install
) )
@ -43,17 +44,19 @@ node.clean() {
return 0 return 0
fi fi
build_msg CLEAN "themes -- locally installed npm dependencies" build_msg CLEAN "themes -- locally installed npm dependencies"
( set -e (
npm --prefix client/simple run clean \ set -e
| prefix_stdout "${_Blue}CLEAN ${_creset} " npm --prefix client/simple run clean |
prefix_stdout "${_Blue}CLEAN ${_creset} "
if [ "${PIPESTATUS[0]}" -ne "0" ]; then if [ "${PIPESTATUS[0]}" -ne "0" ]; then
return 1 return 1
fi fi
) )
build_msg CLEAN "locally installed developer and CI tools" build_msg CLEAN "locally installed developer and CI tools"
( set -e (
npm --prefix . run clean \ set -e
| prefix_stdout "${_Blue}CLEAN ${_creset} " npm --prefix . run clean |
prefix_stdout "${_Blue}CLEAN ${_creset} "
if [ "${PIPESTATUS[0]}" -ne "0" ]; then if [ "${PIPESTATUS[0]}" -ne "0" ]; then
return 1 return 1
fi fi

View File

@ -1,7 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
STATIC_BUILD_COMMIT="[build] /static" STATIC_BUILD_COMMIT="[build] /static"
STATIC_BUILT_PATHS=( STATIC_BUILT_PATHS=(
'searx/templates/simple/icons.html' 'searx/templates/simple/icons.html'
@ -96,7 +95,8 @@ static.build.commit() {
# drop existing commit from previous build # drop existing commit from previous build
static.build.drop &>/dev/null static.build.drop &>/dev/null
( set -e (
set -e
# fix & build the themes # fix & build the themes
themes.fix themes.fix
themes.lint themes.lint

View File

@ -28,7 +28,8 @@ test.yamllint() {
} }
test.pylint() { test.pylint() {
( set -e (
set -e
pyenv.activate pyenv.activate
PYLINT_OPTIONS="--rcfile .pylintrc" PYLINT_OPTIONS="--rcfile .pylintrc"
@ -60,13 +61,13 @@ test.pyright() {
build_msg TEST "[pyright/types] suppress warnings related to intentional monkey patching" build_msg TEST "[pyright/types] suppress warnings related to intentional monkey patching"
# We run Pyright in the virtual environment because pyright executes # We run Pyright in the virtual environment because pyright executes
# "python" to determine the Python version. # "python" to determine the Python version.
pyenv.cmd npx --no-install pyright -p pyrightconfig.json \ pyenv.cmd npx --no-install pyright -p pyrightconfig.json |
| grep -E '\.py:[0-9]+:[0-9]+'\ grep -E '\.py:[0-9]+:[0-9]+' |
| grep -v '/engines/.*.py.* - warning: "logger" is not defined'\ grep -v '/engines/.*.py.* - warning: "logger" is not defined' |
| grep -v '/plugins/.*.py.* - error: "logger" is not defined'\ grep -v '/plugins/.*.py.* - error: "logger" is not defined' |
| grep -v '/engines/.*.py.* - warning: "supported_languages" is not defined' \ grep -v '/engines/.*.py.* - warning: "supported_languages" is not defined' |
| grep -v '/engines/.*.py.* - warning: "language_aliases" is not defined' \ grep -v '/engines/.*.py.* - warning: "language_aliases" is not defined' |
| grep -v '/engines/.*.py.* - warning: "categories" is not defined' grep -v '/engines/.*.py.* - warning: "categories" is not defined'
# ignore exit value from pyright # ignore exit value from pyright
# dump_return ${PIPESTATUS[0]} # dump_return ${PIPESTATUS[0]}
return 0 return 0
@ -93,7 +94,8 @@ test.unit() {
test.coverage() { test.coverage() {
build_msg TEST 'unit test coverage' build_msg TEST 'unit test coverage'
( set -e (
set -e
pyenv.activate pyenv.activate
# shellcheck disable=SC2086 # shellcheck disable=SC2086
python -m nose2 ${TEST_NOSE2_VERBOSE} -C --log-capture --with-coverage --coverage searx -s tests/unit python -m nose2 ${TEST_NOSE2_VERBOSE} -C --log-capture --with-coverage --coverage searx -s tests/unit

View File

@ -13,14 +13,16 @@ EOF
} }
themes.all() { themes.all() {
( set -e (
set -e
vite.simple.build vite.simple.build
) )
dump_return $? dump_return $?
} }
themes.simple() { themes.simple() {
( set -e (
set -e
build_msg SIMPLE "theme: run build (simple)" build_msg SIMPLE "theme: run build (simple)"
vite.simple.build vite.simple.build
) )
@ -28,7 +30,8 @@ themes.simple() {
} }
themes.fix() { themes.fix() {
( set -e (
set -e
build_msg SIMPLE "theme: fix (all themes)" build_msg SIMPLE "theme: fix (all themes)"
vite.simple.fix vite.simple.fix
) )
@ -36,7 +39,8 @@ themes.fix() {
} }
themes.lint() { themes.lint() {
( set -e (
set -e
build_msg SIMPLE "theme: lint (all themes)" build_msg SIMPLE "theme: lint (all themes)"
vite.simple.lint vite.simple.lint
) )
@ -44,7 +48,8 @@ themes.lint() {
} }
themes.test() { themes.test() {
( set -e (
set -e
# we run a build to test (in CI) # we run a build to test (in CI)
build_msg SIMPLE "theme: run build (to test)" build_msg SIMPLE "theme: run build (to test)"
vite.simple.build vite.simple.build

View File

@ -30,7 +30,8 @@ VITE_SIMPLE_THEME="${REPO_ROOT}/client/simple"
# } # }
vite.simple.build() { vite.simple.build() {
( set -e (
set -e
templates.simple.pygments templates.simple.pygments
node.env node.env
@ -44,14 +45,16 @@ vite.simple.build() {
} }
vite.simple.fix() { vite.simple.fix() {
( set -e (
set -e
node.env node.env
npm --prefix client/simple run fix npm --prefix client/simple run fix
) )
} }
vite.simple.lint() { vite.simple.lint() {
( set -e (
set -e
node.env node.env
npm --prefix client/simple run lint npm --prefix client/simple run lint
) )
@ -59,8 +62,8 @@ vite.simple.lint() {
templates.simple.pygments() { templates.simple.pygments() {
build_msg PYGMENTS "searxng_extra/update/update_pygments.py" build_msg PYGMENTS "searxng_extra/update/update_pygments.py"
pyenv.cmd python searxng_extra/update/update_pygments.py \ pyenv.cmd python searxng_extra/update/update_pygments.py |
| prefix_stdout "${_Blue}PYGMENTS ${_creset} " prefix_stdout "${_Blue}PYGMENTS ${_creset} "
if [ "${PIPESTATUS[0]}" -ne "0" ]; then if [ "${PIPESTATUS[0]}" -ne "0" ]; then
build_msg PYGMENTS "building LESS files for pygments failed" build_msg PYGMENTS "building LESS files for pygments failed"
return 1 return 1

View File

@ -19,7 +19,8 @@ weblate.translations.worktree() {
# #
# remote weblate https://translate.codeberg.org/git/searxng/searxng/ # remote weblate https://translate.codeberg.org/git/searxng/searxng/
( set -e (
set -e
if ! git remote get-url weblate 2>/dev/null; then if ! git remote get-url weblate 2>/dev/null; then
git remote add weblate https://translate.codeberg.org/git/searxng/searxng/ git remote add weblate https://translate.codeberg.org/git/searxng/searxng/
fi fi
@ -49,7 +50,8 @@ weblate.to.translations() {
# 4. In translations worktree, merge changes of branch 'translations' from # 4. In translations worktree, merge changes of branch 'translations' from
# remote 'weblate' and push it on branch 'translations' of 'origin' # remote 'weblate' and push it on branch 'translations' of 'origin'
( set -e (
set -e
pyenv.activate pyenv.activate
if [ "$(wlc lock-status)" != "locked: True" ]; then if [ "$(wlc lock-status)" != "locked: True" ]; then
die 1 "weblate must be locked, currently: $(wlc lock-status)" die 1 "weblate must be locked, currently: $(wlc lock-status)"
@ -77,14 +79,18 @@ weblate.translations.commit() {
# create a commit in the local branch (master) # create a commit in the local branch (master)
local existing_commit_hash commit_body commit_message exitcode local existing_commit_hash commit_body commit_message exitcode
( set -e (
set -e
pyenv.activate pyenv.activate
# lock change on weblate # lock change on weblate
wlc lock wlc lock
# get translations branch in git worktree (TRANSLATIONS_WORKTREE) # get translations branch in git worktree (TRANSLATIONS_WORKTREE)
weblate.translations.worktree weblate.translations.worktree
existing_commit_hash=$(cd "${TRANSLATIONS_WORKTREE}"; git log -n1 --pretty=format:'%h') existing_commit_hash=$(
cd "${TRANSLATIONS_WORKTREE}"
git log -n1 --pretty=format:'%h'
)
# pull weblate commits # pull weblate commits
weblate.to.translations weblate.to.translations
@ -101,7 +107,10 @@ weblate.translations.commit() {
data.locales data.locales
# git add/commit (no push) # git add/commit (no push)
commit_body=$(cd "${TRANSLATIONS_WORKTREE}"; git log --pretty=format:'%h - %as - %aN <%ae>' "${existing_commit_hash}..HEAD") commit_body=$(
cd "${TRANSLATIONS_WORKTREE}"
git log --pretty=format:'%h - %as - %aN <%ae>' "${existing_commit_hash}..HEAD"
)
commit_message=$(echo -e "[l10n] update translations from Weblate\n\n${commit_body}") commit_message=$(echo -e "[l10n] update translations from Weblate\n\n${commit_body}")
git add searx/translations git add searx/translations
git add searx/data/locales.json git add searx/data/locales.json
@ -135,7 +144,8 @@ weblate.push.translations() {
local messages_pot diff_messages_pot last_commit_hash last_commit_detail \ local messages_pot diff_messages_pot last_commit_hash last_commit_detail \
exitcode exitcode
messages_pot="${TRANSLATIONS_WORKTREE}/searx/translations/messages.pot" messages_pot="${TRANSLATIONS_WORKTREE}/searx/translations/messages.pot"
( set -e (
set -e
pyenv.activate pyenv.activate
# get translations branch in git worktree (TRANSLATIONS_WORKTREE) # get translations branch in git worktree (TRANSLATIONS_WORKTREE)
weblate.translations.worktree weblate.translations.worktree
@ -147,8 +157,10 @@ weblate.push.translations() {
"searx/" "searx/"
# stop if there is no meaningful change in the master branch # stop if there is no meaningful change in the master branch
diff_messages_pot=$(cd "${TRANSLATIONS_WORKTREE}";\ diff_messages_pot=$(
git diff -- "searx/translations/messages.pot") cd "${TRANSLATIONS_WORKTREE}"
git diff -- "searx/translations/messages.pot"
)
if ! echo "$diff_messages_pot" | grep -qE "[\+\-](msgid|msgstr)"; then if ! echo "$diff_messages_pot" | grep -qE "[\+\-](msgid|msgstr)"; then
build_msg BABEL 'no changes detected, exiting' build_msg BABEL 'no changes detected, exiting'
return 42 return 42

View File

@ -169,17 +169,27 @@ main() {
apache_distro_setup apache_distro_setup
uWSGI_distro_setup uWSGI_distro_setup
required_commands \ required_commands \
sudo systemctl install git wget curl \ sudo systemctl install git wget curl ||
|| exit exit
;; ;;
esac esac
local _usage="unknown or missing $1 command $2" local _usage="unknown or missing $1 command $2"
case $1 in case $1 in
--getenv) var="$2"; echo "${!var}"; exit 0;; --getenv)
--cmd) shift; "$@";; var="$2"
-h|--help) usage; exit 0;; echo "${!var}"
exit 0
;;
--cmd)
shift
"$@"
;;
-h | --help)
usage
exit 0
;;
install) install)
sudo_or_exit sudo_or_exit
case $2 in case $2 in
@ -194,7 +204,10 @@ main() {
nginx) searxng.nginx.install ;; nginx) searxng.nginx.install ;;
apache) searxng.apache.install ;; apache) searxng.apache.install ;;
valkey) searxng.install.valkey ;; valkey) searxng.install.valkey ;;
*) usage "$_usage"; exit 42;; *)
usage "$_usage"
exit 42
;;
esac esac
;; ;;
remove) remove)
@ -209,7 +222,10 @@ main() {
remove) searxng.nginx.remove ;; remove) searxng.nginx.remove ;;
valkey) searxng.remove.valkey ;; valkey) searxng.remove.valkey ;;
redis) searxng.remove.redis ;; redis) searxng.remove.redis ;;
*) usage "$_usage"; exit 42;; *)
usage "$_usage"
exit 42
;;
esac esac
;; ;;
instance) instance)
@ -228,19 +244,30 @@ main() {
;; ;;
cmd) cmd)
sudo_or_exit sudo_or_exit
shift; shift; searxng.instance.exec "$@" shift
shift
searxng.instance.exec "$@"
;; ;;
get_setting) get_setting)
shift; shift; searxng.instance.get_setting "$@" shift
shift
searxng.instance.get_setting "$@"
;; ;;
call) call)
# call a function in instance's environment # call a function in instance's environment
shift; shift; searxng.instance.self.call "$@" shift
shift
searxng.instance.self.call "$@"
;; ;;
_call) _call)
shift; shift; "$@" shift
shift
"$@"
;;
*)
usage "$_usage"
exit 42
;; ;;
*) usage "$_usage"; exit 42;;
esac esac
;; ;;
*) *)
@ -611,7 +638,6 @@ searxng.install.valkey() {
valkey.install valkey.install
} }
searxng.instance.localtest() { searxng.instance.localtest() {
rst_title "Test SearXNG instance locally" section rst_title "Test SearXNG instance locally" section
rst_para "Activate debug mode, start a minimal SearXNG " \ rst_para "Activate debug mode, start a minimal SearXNG " \
@ -885,7 +911,8 @@ searxng.doc.rst() {
echo -e "\n.. START searxng uwsgi-description $DIST_NAME" echo -e "\n.. START searxng uwsgi-description $DIST_NAME"
case $DIST_ID-$DIST_VERS in case $DIST_ID-$DIST_VERS in
ubuntu-*|debian-*) cat <<EOF ubuntu-* | debian-*)
cat <<EOF
.. code:: bash .. code:: bash
@ -902,7 +929,8 @@ searxng.doc.rst() {
EOF EOF
;; ;;
arch-*) cat <<EOF arch-*)
cat <<EOF
.. code:: bash .. code:: bash
@ -920,7 +948,8 @@ EOF
EOF EOF
;; ;;
fedora-*|centos-7) cat <<EOF fedora-* | centos-7)
cat <<EOF
.. code:: bash .. code:: bash