bind10_config.py.in 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # Copyright (C) 2010 Internet Systems Consortium.
  2. #
  3. # Permission to use, copy, modify, and distribute this software for any
  4. # purpose with or without fee is hereby granted, provided that the above
  5. # copyright notice and this permission notice appear in all copies.
  6. #
  7. # THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
  8. # DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
  9. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
  10. # INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
  11. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
  12. # FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  13. # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  14. # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. # This is a base-level module intended to provide configure-time
  16. # variables to python scripts and libraries.
  17. import os
  18. def reload():
  19. # In a function, for testing purposes
  20. global BIND10_MSGQ_SOCKET_FILE
  21. global DATA_PATH
  22. global PLUGIN_PATHS
  23. global PREFIX
  24. global LIBEXECPATH
  25. global SYSCONFPATH
  26. BIND10_MSGQ_SOCKET_FILE = os.path.join("@localstatedir@",
  27. "@PACKAGE_NAME@",
  28. "msgq_socket").replace("${prefix}",
  29. "@prefix@")
  30. PREFIX = "@prefix@"
  31. SYSCONFPATH="@sysconfdir@/@PACKAGE@".replace('${prefix}', PREFIX)
  32. # B10_FROM_SOURCE is set in the environment for internal tests and
  33. # an experimental run without installation. In that case we need to
  34. # specialize some configuration variables, generally so that they refer
  35. # to somewhere in the source tree instead of the appropriate places
  36. # after installation.
  37. #
  38. # DATA_PATH: used by the config manager to find configuration files.
  39. # When "FROM_SOURCE", we use data files from a directory relative to the
  40. # value of that variable, or, if defined, relative to the value of
  41. # B10_FROM_SOURCE_LOCALSTATEDIR. Otherwise we use the ones installed on
  42. # the system.
  43. # PLUGIN_PATHS: configuration modules that are not associated to specific
  44. # process
  45. # LIBEXECPATH: Paths to programs invoked by the b10-init process
  46. # The b10-init process (directly or via a helper module) uses this as
  47. # the prefererred PATH before starting a child process.
  48. # When "FROM_SOURCE", it lists the directories where the programs are
  49. # built so that when BIND 10 is experimentally started on the source
  50. # tree the programs in the tree (not installed ones) will be used.
  51. # SYSCONFPATH: Path where the system-wide configuration files are
  52. # stored (e.g. <prefix>/var/<package name>). This value is *not*
  53. # overwritten if B10_FROM_SOURCE is specified.
  54. #
  55. # B10_FROM_SOURCE_LOCALSTATEDIR is specifically intended to be used for
  56. # tests where we want to use various types of configuration within the test
  57. # environment. (We may want to make it even more generic so that the path
  58. # is passed from the b10-init process)
  59. if "B10_FROM_SOURCE" in os.environ:
  60. if "B10_FROM_SOURCE_LOCALSTATEDIR" in os.environ:
  61. DATA_PATH = os.environ["B10_FROM_SOURCE_LOCALSTATEDIR"]
  62. else:
  63. DATA_PATH = os.environ["B10_FROM_SOURCE"]
  64. PLUGIN_PATHS = [os.environ["B10_FROM_SOURCE"] +
  65. '/src/bin/cfgmgr/local_plugins',
  66. os.environ["B10_FROM_SOURCE"] +
  67. '/src/bin/cfgmgr/plugins']
  68. programdirs = ['auth', 'cfgmgr', 'cmdctl', 'ddns', 'dhcp6', 'msgq',
  69. 'resolver', 'sockcreator', 'stats', 'xfrin', 'xfrout',
  70. 'zonemgr']
  71. LIBEXECPATH = ':'.join(['@abs_top_builddir@/src/bin/' + p for p in
  72. programdirs])
  73. else:
  74. DATA_PATH = "@localstatedir@/@PACKAGE@".replace("${prefix}", PREFIX)
  75. PLUGIN_PATHS = ["@prefix@/share/@PACKAGE@/config_plugins"]
  76. LIBEXECPATH = ("@libexecdir@/@PACKAGE@"). \
  77. replace("${exec_prefix}", "@exec_prefix@"). \
  78. replace("${prefix}", "@prefix@")
  79. # For testing the plugins so they can find their own spec files
  80. if "B10_TEST_PLUGIN_DIR" in os.environ:
  81. PLUGIN_PATHS = os.environ["B10_TEST_PLUGIN_DIR"].split(':')
  82. reload()