build_env.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # SPDX-License-Identifier: AGPL-3.0-or-later
  2. """build environment used by shell scripts
  3. """
  4. # set path
  5. import sys
  6. import os
  7. from os.path import realpath, dirname, join, sep, abspath
  8. repo_root = realpath(dirname(realpath(__file__)) + sep + '..')
  9. sys.path.insert(0, repo_root)
  10. os.environ['SEARX_SETTINGS_PATH'] = abspath(dirname(__file__) + '/settings.yml')
  11. # Under the assumption that a brand is always a fork assure that the settings
  12. # file from reposetorie's working tree is used to generate the build_env, not
  13. # from /etc/searx/settings.yml.
  14. os.environ['SEARX_SETTINGS_PATH'] = abspath(dirname(__file__) + sep + 'settings.yml')
  15. from searx import brand
  16. name_val = [
  17. ('SEARX_URL' , brand.SEARX_URL),
  18. ('GIT_URL' , brand.GIT_URL),
  19. ('GIT_BRANCH' , brand.GIT_BRANCH),
  20. ('ISSUE_URL' , brand.ISSUE_URL),
  21. ('DOCS_URL' , brand.DOCS_URL),
  22. ('PUBLIC_INSTANCES' , brand.PUBLIC_INSTANCES),
  23. ('CONTACT_URL' , brand.CONTACT_URL),
  24. ('WIKI_URL' , brand.WIKI_URL),
  25. ('TWITTER_URL' , brand.TWITTER_URL),
  26. ]
  27. brand_env = 'utils' + sep + 'brand.env'
  28. print('build %s' % brand_env)
  29. with open(repo_root + sep + brand_env, 'w', encoding='utf-8') as f:
  30. for name, val in name_val:
  31. print("export %s='%s'" % (name, val), file=f)