on master help sign in
Merge pull request #2408 from return42/rm-brand-make

[mod] move brand options from Makefile to settings.yml

commit9c55d772e98f5e51da4a34389dc240cfb3b14852 authorAlexandre Flament <alex@al-f.net> dateTue 12 Jan 2021, 10:52 (6 years ago) parent8d0312d424e6ab
16 files changed+253−166
Makefile+2−32 docs/admin/installation-searx.rst+10−3 docs/admin/installation.rst+1−1 docs/admin/settings.rst+110−58 docs/blog/lxcdev-202006.rst+2−2 docs/conf.py+20−18 docs/dev/makefile.rst+4−36 docs/utils/index.rst+2−2 manage.sh+2−2 searx/__init__.py+46 searx/brand.py−7 searx/settings.yml+10 searx/webapp.py+1 setup.py+2−4 utils/brand.env+3−1 utils/build_env.py+38
Makefile+2−32
@@ -1,14 +1,6 @@
11# -*- coding: utf-8; mode: makefile-gmake -*-
22.DEFAULT_GOAL=help
33
4−# START Makefile setup
5−export GIT_URL=https://github.com/searx/searx
6−export GIT_BRANCH=master
7−export SEARX_URL=https://searx.me
8−export DOCS_URL=https://searx.github.io/searx
9−# export CONTACT_URL=mailto:contact@example.com
10−# END Makefile setup
11−
124include utils/makefile.include
135
146PYOBJECTS = searx
@@ -43,12 +35,6 @@ help-min:
4335 @echo ' docker - build Docker image'
4436 @echo ' node.env - download & install npm dependencies locally'
4537 @echo ''
46− @echo 'environment'
47− @echo ' SEARX_URL = $(SEARX_URL)'
48− @echo ' GIT_URL = $(GIT_URL)'
49− @echo ' DOCS_URL = $(DOCS_URL)'
50− @echo ' CONTACT_URL = $(CONTACT_URL)'
51− @echo ''
5238 @$(MAKE) -e -s make-help
5339
5440help-all: help-min
@@ -118,24 +104,8 @@ useragents.update: pyenvinstall
118104 $(Q)echo "Update searx/data/useragents.json with the most recent versions of Firefox."
119105 $(Q)$(PY_ENV_ACT); python utils/fetch_firefox_version.py
120106
121−buildenv:
122− $(Q)echo "build searx/brand.py"
123− $(Q)echo "GIT_URL = '$(GIT_URL)'" > searx/brand.py
124− $(Q)echo "GIT_BRANCH = '$(GIT_BRANCH)'" >> searx/brand.py
125− $(Q)echo "ISSUE_URL = 'https://github.com/searx/searx/issues'" >> searx/brand.py
126− $(Q)echo "SEARX_URL = '$(SEARX_URL)'" >> searx/brand.py
127− $(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py
128− $(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py
129− $(Q)echo "CONTACT_URL = '$(CONTACT_URL)'" >> searx/brand.py
130− $(Q)echo "build utils/brand.env"
131− $(Q)echo "export GIT_URL='$(GIT_URL)'" > utils/brand.env
132− $(Q)echo "export GIT_BRANCH='$(GIT_BRANCH)'" >> utils/brand.env
133− $(Q)echo "export ISSUE_URL='https://github.com/searx/searx/issues'" >> utils/brand.env
134− $(Q)echo "export SEARX_URL='$(SEARX_URL)'" >> utils/brand.env
135− $(Q)echo "export DOCS_URL='$(DOCS_URL)'" >> utils/brand.env
136− $(Q)echo "export PUBLIC_INSTANCES='https://searx.space'" >> utils/brand.env
137− $(Q)echo "export CONTACT_URL='$(CONTACT_URL)'" >> utils/brand.env
138−
107+buildenv: pyenv
108+ $(Q)$(PY_ENV_ACT); SEARX_DEBUG=1 python utils/build_env.py
139109
140110# node / npm
141111# ----------
docs/admin/installation-searx.rst+10−3
@@ -70,13 +70,20 @@ from the login (*~/.profile*):
7070Configuration
7171=============
7272
73+.. sidebar:: ``use_default_settings: True``
74+
75+ - :ref:`settings global`
76+ - :ref:`settings location`
77+ - :ref:`settings use_default_settings`
78+ - :origin:`/etc/searx/settings.yml <utils/templates/etc/searx/use_default_settings.yml>`
79+
7380To create a initial ``/etc/searx/settings.yml`` you can start with a copy of the
7481file :origin:`utils/templates/etc/searx/use_default_settings.yml`. This setup
75−:option:ref:`use default settings <settings use_default_settings>` from
82+:ref:`use default settings <settings use_default_settings>` from
7683:origin:`searx/settings.yml` and is recommended since :pull:`2291` is merged.
7784
78−For minimal Setup, configure like shown below – replace ``searx@\$(uname -n)``
79−with a name of your choice, set ``ultrasecretkey`` -- *and/or* edit
85+For a *minimal setup*, configure like shown below – replace ``searx@$(uname
86+-n)`` with a name of your choice, set ``ultrasecretkey`` -- *and/or* edit
8087``/etc/searx/settings.yml`` to your needs.
8188
8289.. kernel-include:: $DOCS_BUILD/includes/searx.rst
docs/admin/installation.rst+1−1
@@ -76,6 +76,6 @@ If all services are running fine, you can add it to your HTTP server:
7676.. tip::
7777
7878 About script's installation options have a look at chapter :ref:`toolboxing
79− setup`. How to brand your instance see chapter :ref:`makefile setup`. To
79+ setup`. How to brand your instance see chapter :ref:`settings global`. To
8080 *stash* your instance's setup, `git stash`_ your clone's :origin:`Makefile`
8181 and :origin:`.config.sh` file .
docs/admin/settings.rst+110−58
@@ -27,7 +27,8 @@ First, searx will try to load settings.yml from these locations:
27271. the full path specified in the ``SEARX_SETTINGS_PATH`` environment variable.
28282. ``/etc/searx/settings.yml``
2929
30−If these files don't exist (or are empty or can't be read), searx uses the :origin:`searx/settings.yml` file.
30+If these files don't exist (or are empty or can't be read), searx uses the
31+:origin:`searx/settings.yml` file.
3132
3233
3334.. _settings global:
@@ -35,16 +36,46 @@ If these files don't exist (or are empty or can't be read), searx uses the :orig
3536Global Settings
3637===============
3738
39+``general:``
40+------------
41+
3842.. code:: yaml
3943
4044 general:
4145 debug : False # Debug mode, only for development
4246 instance_name : "searx" # displayed name
47+ git_url: https://github.com/searx/searx
48+ git_branch: master
49+ issue_url: https://github.com/searx/searx/issues
50+ docs_url: https://searx.github.io/searx
51+ public_instances: https://searx.space
52+ contact_url: False # mailto:contact@example.com
53+ wiki_url: https://github.com/searx/searx/wiki
54+ twitter_url: https://twitter.com/Searx_engine
4355
4456``debug`` :
4557 Allow a more detailed log if you run searx directly. Display *detailed* error
4658 messages in the browser too, so this must be deactivated in production.
4759
60+``contact_url``:
61+ Contact ``mailto:`` address or WEB form.
62+
63+``git_url`` and ``git_branch``:
64+ Changes this, to point to your searx fork (branch).
65+
66+``docs_url``
67+ If you host your own documentation, change this URL.
68+
69+``wiki_url``:
70+ Link to your wiki (or ``False``)
71+
72+``twitter_url``:
73+ Link to your tweets (or ``False``)
74+
75+
76+``server:``
77+-----------
78+
4879.. code:: yaml
4980
5081 server:
@@ -90,6 +121,8 @@ Global Settings
90121``default_http_headers``:
91122 Set additional HTTP headers, see `#755 <https://github.com/searx/searx/issues/715>`__
92123
124+``outgoing:``
125+-------------
93126
94127.. code:: yaml
95128
@@ -139,6 +172,10 @@ Global Settings
139172 If you use multiple network interfaces, define from which IP the requests must
140173 be made. This parameter is ignored when ``proxies`` is set.
141174
175+
176+``locales:``
177+------------
178+
142179.. code:: yaml
143180
144181 locales:
@@ -244,61 +281,76 @@ Engine settings
244281use_default_settings
245282====================
246283
247−.. note::
248−
249− If searx is cloned from a git repository, most probably there is no need to have an user settings.
250−
251−The user defined settings.yml can relied on the default configuration :origin:`searx/settings.yml` using ``use_default_settings: True``.
284+.. sidebar:: ``use_default_settings: True``
252285
253−In the following example, the actual settings are the default settings defined in :origin:`searx/settings.yml` with the exception of the ``secret_key`` and the ``bind_address``:
254−
255−.. code-block:: yaml
256−
257− use_default_settings: True
258− server:
259− secret_key: "uvys6bRhKHUdFF5CqbJonSDSRN8H0sCBziNSrDGNVdpz7IeZhveVart3yvghoKHA"
260− bind_address: "0.0.0.0"
261−
262−With ``use_default_settings: True``, each settings can be override in a similar way, the ``engines`` section is merged according to the engine ``name``.
263−
264−In this example, searx will load all the engine and the arch linux wiki engine has a :ref:`token<private engines>`:
265−
266−.. code-block:: yaml
267−
268− use_default_settings: True
269− server:
270− secret_key: "uvys6bRhKHUdFF5CqbJonSDSRN8H0sCBziNSrDGNVdpz7IeZhveVart3yvghoKHA"
271− engines:
272− - name: arch linux wiki
273− tokens: ['$ecretValue']
274−
275−It is possible to remove some engines from the default settings. The following example is similar to the above one, but searx doesn't load the the google engine:
276−
277−.. code-block:: yaml
278−
279− use_default_settings:
280− engines:
281− remove:
282− - google
283− server:
284− secret_key: "uvys6bRhKHUdFF5CqbJonSDSRN8H0sCBziNSrDGNVdpz7IeZhveVart3yvghoKHA"
285− engines:
286− - name: arch linux wiki
287− tokens: ['$ecretValue']
288−
289−As an alternative, it is possible to specify the engines to keep. In the following example, searx has only two engines:
290−
291−.. code-block:: yaml
292−
293− use_default_settings:
294− engines:
295− keep_only:
296− - google
297− - duckduckgo
298− server:
299− secret_key: "uvys6bRhKHUdFF5CqbJonSDSRN8H0sCBziNSrDGNVdpz7IeZhveVart3yvghoKHA"
300− engines:
301− - name: google
302− tokens: ['$ecretValue']
303− - name: duckduckgo
304− tokens: ['$ecretValue']
286+ - :ref:`settings location`
287+ - :ref:`use_default_settings.yml`
288+ - :origin:`/etc/searx/settings.yml <utils/templates/etc/searx/use_default_settings.yml>`
289+
290+The user defined ``settings.yml`` is loaded from the :ref:`settings location`
291+and can relied on the default configuration :origin:`searx/settings.yml` using:
292+
293+ ``use_default_settings: True``
294+
295+``server:``
296+ In the following example, the actual settings are the default settings defined
297+ in :origin:`searx/settings.yml` with the exception of the ``secret_key`` and
298+ the ``bind_address``:
299+
300+ .. code-block:: yaml
301+
302+ use_default_settings: True
303+ server:
304+ secret_key: "uvys6bRhKHUdFF5CqbJonSDSRN8H0sCBziNSrDGNVdpz7IeZhveVart3yvghoKHA"
305+ bind_address: "0.0.0.0"
306+
307+``engines:``
308+ With ``use_default_settings: True``, each settings can be override in a
309+ similar way, the ``engines`` section is merged according to the engine
310+ ``name``. In this example, searx will load all the engine and the arch linux
311+ wiki engine has a :ref:`token<private engines>`:
312+
313+ .. code-block:: yaml
314+
315+ use_default_settings: True
316+ server:
317+ secret_key: "uvys6bRhKHUdFF5CqbJonSDSRN8H0sCBziNSrDGNVdpz7IeZhveVart3yvghoKHA"
318+ engines:
319+ - name: arch linux wiki
320+ tokens: ['$ecretValue']
321+
322+``engines:`` / ``remove:``
323+ It is possible to remove some engines from the default settings. The following
324+ example is similar to the above one, but searx doesn't load the the google
325+ engine:
326+
327+ .. code-block:: yaml
328+
329+ use_default_settings:
330+ engines:
331+ remove:
332+ - google
333+ server:
334+ secret_key: "uvys6bRhKHUdFF5CqbJonSDSRN8H0sCBziNSrDGNVdpz7IeZhveVart3yvghoKHA"
335+ engines:
336+ - name: arch linux wiki
337+ tokens: ['$ecretValue']
338+
339+``engines:`` / ``keep_only:``
340+ As an alternative, it is possible to specify the engines to keep. In the
341+ following example, searx has only two engines:
342+
343+ .. code-block:: yaml
344+
345+ use_default_settings:
346+ engines:
347+ keep_only:
348+ - google
349+ - duckduckgo
350+ server:
351+ secret_key: "uvys6bRhKHUdFF5CqbJonSDSRN8H0sCBziNSrDGNVdpz7IeZhveVart3yvghoKHA"
352+ engines:
353+ - name: google
354+ tokens: ['$ecretValue']
355+ - name: duckduckgo
356+ tokens: ['$ecretValue']
docs/blog/lxcdev-202006.rst+2−2
@@ -259,8 +259,8 @@ suite. For this, we have to keep an eye on the :ref:`installation basic`:
259259- virtualenv in: ``/usr/local/searx/searx-pyenv``
260260- searx software in: ``/usr/local/searx/searx-src``
261261
262−The searx software is a clone of the ``GIT_URL`` (see :ref:`makefile setup`) and
263−the working tree is checked out from the ``GIT_BRANCH``. With the use of the
262+The searx software is a clone of the ``git_url`` (see :ref:`settings global`) and
263+the working tree is checked out from the ``git_branch``. With the use of the
264264:ref:`searx.sh` the searx service was installed as :ref:`uWSGI application
265265<searx uwsgi>`. To maintain this service, we can use ``systemctl`` (compare
266266:ref:`service architectures on distributions <uwsgi configuration>`).
docs/conf.py+20−18
@@ -2,14 +2,10 @@
22
33import sys, os
44from sphinx_build_tools import load_sphinx_config
5−from searx.version import VERSION_STRING
65from pallets_sphinx_themes import ProjectLink
76
8−from searx.brand import GIT_URL
9−GIT_BRANCH = os.environ.get("GIT_BRANCH", "master")
10−from searx.brand import SEARX_URL
11−from searx.brand import DOCS_URL
12−
7+from searx import brand
8+from searx.version import VERSION_STRING
139
1410# Project --------------------------------------------------------------
1511
@@ -46,10 +42,10 @@ extlinks['wiki'] = ('https://github.com/searx/searx/wiki/%s', ' ')
4642extlinks['pull'] = ('https://github.com/searx/searx/pull/%s', 'PR ')
4743
4844# links to custom brand
49−extlinks['origin'] = (GIT_URL + '/blob/' + GIT_BRANCH + '/%s', 'git://')
50−extlinks['patch'] = (GIT_URL + '/commit/%s', '#')
51−extlinks['search'] = (SEARX_URL + '/%s', '#')
52−extlinks['docs'] = (DOCS_URL + '/%s', 'docs: ')
45+extlinks['origin'] = (brand.GIT_URL + '/blob/' + brand.GIT_BRANCH + '/%s', 'git://')
46+extlinks['patch'] = (brand.GIT_URL + '/commit/%s', '#')
47+extlinks['search'] = (brand.SEARX_URL + '/%s', '#')
48+extlinks['docs'] = (brand.DOCS_URL + '/%s', 'docs: ')
5349extlinks['pypi'] = ('https://pypi.org/project/%s', 'PyPi: ')
5450extlinks['man'] = ('https://manpages.debian.org/jump?q=%s', '')
5551#extlinks['role'] = (
@@ -104,14 +100,20 @@ imgmath_font_size = 14
104100# sphinx.ext.imgmath setup END
105101
106102html_theme_options = {"index_sidebar_logo": True}
107−html_context = {
108− "project_links": [
109− ProjectLink("Source", GIT_URL),
110− ProjectLink("Wiki", "https://github.com/searx/searx/wiki"),
111− ProjectLink("Public instances", "https://searx.space/"),
112− ProjectLink("Twitter", "https://twitter.com/Searx_engine"),
113− ]
114−}
103+html_context = {"project_links": [] }
104+if brand.GIT_URL:
105+ html_context["project_links"].append(ProjectLink("Source", brand.GIT_URL))
106+if brand.WIKI_URL:
107+ html_context["project_links"].append(ProjectLink("Wiki", brand.WIKI_URL))
108+if brand.PUBLIC_INSTANCES:
109+ html_context["project_links"].append(ProjectLink("Public instances", brand.PUBLIC_INSTANCES))
110+if brand.TWITTER_URL:
111+ html_context["project_links"].append(ProjectLink("Twitter", brand.TWITTER_URL))
112+if brand.ISSUE_URL:
113+ html_context["project_links"].append(ProjectLink("Issue Tracker", brand.ISSUE_URL))
114+if brand.CONTACT_URL:
115+ html_context["project_links"].append(ProjectLink("Contact", brand.CONTACT_URL))
116+
115117html_sidebars = {
116118 "**": ["project.html", "relations.html", "searchbox.html"],
117119}
docs/dev/makefile.rst+4−36
@@ -8,8 +8,7 @@ Makefile Targets
88
99.. sidebar:: build environment
1010
11− Before looking deeper at the targets, first read about :ref:`makefile setup`
12− and :ref:`make pyenv`.
11+ Before looking deeper at the targets, first read about :ref:`make pyenv`.
1312
1413 To install system requirements follow :ref:`buildhosts`.
1514
@@ -28,37 +27,6 @@ Calling the ``help`` target gives a first overview (``make help``):
2827 :local:
2928 :backlinks: entry
3029
31−
32−.. _makefile setup:
33−
34−Makefile setup
35−==============
36−
37−.. _git stash: https://git-scm.com/docs/git-stash
38−
39−.. sidebar:: fork & upstream
40−
41− Commit changes in your (local) branch, fork or whatever, but do not push them
42− upstream / `git stash`_ is your friend.
43−
44−The main setup is done in the :origin:`Makefile`.
45−
46−.. literalinclude:: ../../Makefile
47− :start-after: START Makefile setup
48− :end-before: END Makefile setup
49−
50−:GIT_URL: Changes this, to point to your searx fork.
51−:GIT_BRANCH: Changes this, to point to your searx branch.
52−:SEARX_URL: Changes this, to point to your searx instance.
53−:DOCS_URL: If you host your own (*brand*) documentation, change this URL.
54−
55−If you change any of this build environment variables, you have to run ``make
56−buildenv``::
57−
58− $ make buildenv
59− build searx/brand.py
60− build utils/brand.env
61−
6230.. _make pyenv:
6331
6432Python environment
@@ -148,7 +116,7 @@ clean`` stop all processes using :ref:`make pyenv`.
148116We describe the usage of the ``doc*`` targets in the :ref:`How to contribute /
149117Documentation <contrib docs>` section. If you want to edit the documentation
150118read our :ref:`make docs-live` section. If you are working in your own brand,
151−adjust your :ref:`Makefile setup <makefile setup>`.
119+adjust your :ref:`settings global`.
152120
153121.. _make books:
154122
@@ -185,8 +153,8 @@ Use ``make docs-help`` to see which books available:
185153``make gh-pages``
186154=================
187155
188−To deploy on github.io first adjust your :ref:`Makefile setup <makefile
189−setup>`. For any further read :ref:`deploy on github.io`.
156+To deploy on github.io first adjust your :ref:`settings global`. For any
157+further read :ref:`deploy on github.io`.
190158
191159.. _make test:
192160
docs/utils/index.rst+2−2
@@ -47,8 +47,8 @@ Scripts to maintain services often dispose of common commands and environments.
4747Tooling box setup
4848=================
4949
50−The main setup is done in the :origin:`.config.sh` (read also :ref:`makefile
51−setup`).
50+The main setup is done in the :origin:`.config.sh` (read also :ref:`settings
51+global`).
5252
5353.. literalinclude:: ../../.config.sh
5454 :language: bash
manage.sh+2−2
@@ -123,9 +123,9 @@ docker_build() {
123123 SEARX_GIT_VERSION=$(git describe --match "v[0-9]*\.[0-9]*\.[0-9]*" HEAD 2>/dev/null | awk -F'-' '{OFS="-"; $1=substr($1, 2); if ($3) { $3=substr($3, 2); } print}')
124124
125125 # add the suffix "-dirty" if the repository has uncommited change
126− # /!\ HACK for searx/searx: ignore searx/brand.py and utils/brand.env
126+ # /!\ HACK for searx/searx: ignore utils/brand.env
127127 git update-index -q --refresh
128− if [ ! -z "$(git diff-index --name-only HEAD -- | grep -v 'searx/brand.py' | grep -v 'utils/brand.env')" ]; then
128+ if [ ! -z "$(git diff-index --name-only HEAD -- | grep -v 'utils/brand.env')" ]; then
129129 SEARX_GIT_VERSION="${SEARX_GIT_VERSION}-dirty"
130130 fi
131131
searx/__init__.py+46
@@ -60,3 +60,49 @@ if 'SEARX_SECRET' in environ:
6060 settings['server']['secret_key'] = environ['SEARX_SECRET']
6161if 'SEARX_BIND_ADDRESS' in environ:
6262 settings['server']['bind_address'] = environ['SEARX_BIND_ADDRESS']
63+
64+
65+class _brand_namespace:
66+
67+ @classmethod
68+ def get_val(cls, group, name, default=''):
69+ return settings.get(group, {}).get(name) or default
70+
71+ @property
72+ def SEARX_URL(self):
73+ return self.get_val('server', 'base_url')
74+
75+ @property
76+ def CONTACT_URL(self):
77+ return self.get_val('general', 'contact_url')
78+
79+ @property
80+ def GIT_URL(self):
81+ return self.get_val('brand', 'git_url')
82+
83+ @property
84+ def GIT_BRANCH(self):
85+ return self.get_val('brand', 'git_branch')
86+
87+ @property
88+ def ISSUE_URL(self):
89+ return self.get_val('brand', 'issue_url')
90+
91+ @property
92+ def DOCS_URL(self):
93+ return self.get_val('brand', 'docs_url')
94+
95+ @property
96+ def PUBLIC_INSTANCES(self):
97+ return self.get_val('brand', 'public_instances')
98+
99+ @property
100+ def WIKI_URL(self):
101+ return self.get_val('brand', 'wiki_url')
102+
103+ @property
104+ def TWITTER_URL(self):
105+ return self.get_val('brand', 'twitter_url')
106+
107+
108+brand = _brand_namespace()
searx/brand.pydeleted−7
@@ -1,7 +0,0 @@
1−GIT_URL = 'https://github.com/searx/searx'
2−GIT_BRANCH = 'master'
3−ISSUE_URL = 'https://github.com/searx/searx/issues'
4−SEARX_URL = 'https://searx.me'
5−DOCS_URL = 'https://searx.github.io/searx'
6−PUBLIC_INSTANCES = 'https://searx.space'
7−CONTACT_URL = ''
searx/settings.yml+10
@@ -1,6 +1,16 @@
11general:
22 debug : False # Debug mode, only for development
33 instance_name : "searx" # displayed name
4+ contact_url: False # mailto:contact@example.com
5+
6+brand:
7+ git_url: https://github.com/searx/searx
8+ git_branch: master
9+ issue_url: https://github.com/searx/searx/issues
10+ docs_url: https://searx.github.io/searx
11+ public_instances: https://searx.space
12+ wiki_url: https://github.com/searx/searx/wiki
13+ twitter_url: https://twitter.com/Searx_engine
414
515search:
616 safe_search : 0 # Filter results. 0: None, 1: Moderate, 2: Strict
searx/webapp.py+1
@@ -1071,6 +1071,7 @@ def config():
10711071 'default_theme': settings['ui']['default_theme'],
10721072 'version': VERSION_STRING,
10731073 'brand': {
1074+ 'CONTACT_URL': brand.CONTACT_URL,
10741075 'GIT_URL': brand.GIT_URL,
10751076 'DOCS_URL': brand.DOCS_URL
10761077 },
setup.py+2−4
@@ -7,10 +7,8 @@ from setuptools import find_packages
77import os
88import sys
99
10−# required to load VERSION_STRING constant
11−sys.path.insert(0, './searx')
12−from version import VERSION_STRING
13−import brand
10+from searx.version import VERSION_STRING
11+from searx import brand
1412
1513with open('README.rst', encoding='utf-8') as f:
1614 long_description = f.read()
utils/brand.env+3−1
@@ -1,7 +1,9 @@
1+export SEARX_URL=''
12export GIT_URL='https://github.com/searx/searx'
23export GIT_BRANCH='master'
34export ISSUE_URL='https://github.com/searx/searx/issues'
4−export SEARX_URL='https://searx.me'
55export DOCS_URL='https://searx.github.io/searx'
66export PUBLIC_INSTANCES='https://searx.space'
77export CONTACT_URL=''
8+export WIKI_URL='https://github.com/searx/searx/wiki'
9+export TWITTER_URL='https://twitter.com/Searx_engine'
utils/build_env.pynew file+38
@@ -0,0 +1,38 @@
1+# SPDX-License-Identifier: AGPL-3.0-or-later
2+"""build environment used by shell scripts
3+"""
4+
5+# set path
6+import sys
7+import os
8+from os.path import realpath, dirname, join, sep, abspath
9+
10+repo_root = realpath(dirname(realpath(__file__)) + sep + '..')
11+sys.path.insert(0, repo_root)
12+os.environ['SEARX_SETTINGS_PATH'] = abspath(dirname(__file__) + '/settings.yml')
13+
14+# Under the assumption that a brand is always a fork assure that the settings
15+# file from reposetorie's working tree is used to generate the build_env, not
16+# from /etc/searx/settings.yml.
17+os.environ['SEARX_SETTINGS_PATH'] = abspath(dirname(__file__) + sep + 'settings.yml')
18+
19+from searx import brand
20+
21+name_val = [
22+ ('SEARX_URL' , brand.SEARX_URL),
23+ ('GIT_URL' , brand.GIT_URL),
24+ ('GIT_BRANCH' , brand.GIT_BRANCH),
25+ ('ISSUE_URL' , brand.ISSUE_URL),
26+ ('DOCS_URL' , brand.DOCS_URL),
27+ ('PUBLIC_INSTANCES' , brand.PUBLIC_INSTANCES),
28+ ('CONTACT_URL' , brand.CONTACT_URL),
29+ ('WIKI_URL' , brand.WIKI_URL),
30+ ('TWITTER_URL' , brand.TWITTER_URL),
31+]
32+
33+brand_env = 'utils' + sep + 'brand.env'
34+
35+print('build %s' % brand_env)
36+with open(repo_root + sep + brand_env, 'w', encoding='utf-8') as f:
37+ for name, val in name_val:
38+ print("export %s='%s'" % (name, val), file=f)