PageRenderTime 63ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/pym/portage/package/ebuild/_config/special_env_vars.py

https://github.com/1000timesdead/portage-funtoo
Python | 176 lines | 126 code | 22 blank | 28 comment | 0 complexity | ce9a669dcfe871398ac30388aa5d9cc3 MD5 | raw file
  1. # Copyright 2010-2011 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. __all__ = (
  4. 'case_insensitive_vars', 'default_globals', 'env_blacklist', \
  5. 'environ_filter', 'environ_whitelist', 'environ_whitelist_re',
  6. )
  7. import re
  8. # Blacklisted variables are internal variables that are never allowed
  9. # to enter the config instance from the external environment or
  10. # configuration files.
  11. env_blacklist = frozenset((
  12. "A", "AA", "CATEGORY", "DEPEND", "DESCRIPTION", "EAPI",
  13. "EBUILD_PHASE", "ED", "EMERGE_FROM", "EPREFIX", "EROOT",
  14. "HOMEPAGE", "INHERITED", "IUSE",
  15. "KEYWORDS", "LICENSE", "MERGE_TYPE",
  16. "PDEPEND", "PF", "PKGUSE", "PORTAGE_BACKGROUND",
  17. "PORTAGE_BACKGROUND_UNMERGE", "PORTAGE_BUILDIR_LOCKED",
  18. "PORTAGE_BUILT_USE", "PORTAGE_CONFIGROOT", "PORTAGE_IUSE",
  19. "PORTAGE_NONFATAL", "PORTAGE_REPO_NAME", "PORTAGE_SANDBOX_COMPAT_LEVEL",
  20. "PORTAGE_USE", "PROPERTIES", "PROVIDE", "RDEPEND", "RESTRICT",
  21. "ROOT", "SLOT", "SRC_URI"
  22. ))
  23. environ_whitelist = []
  24. # Whitelisted variables are always allowed to enter the ebuild
  25. # environment. Generally, this only includes special portage
  26. # variables. Ebuilds can unset variables that are not whitelisted
  27. # and rely on them remaining unset for future phases, without them
  28. # leaking back in from various locations (bug #189417). It's very
  29. # important to set our special BASH_ENV variable in the ebuild
  30. # environment in order to prevent sandbox from sourcing /etc/profile
  31. # in it's bashrc (causing major leakage).
  32. environ_whitelist += [
  33. "ACCEPT_LICENSE", "BASH_ENV", "BUILD_PREFIX", "D",
  34. "DISTDIR", "DOC_SYMLINKS_DIR", "EAPI", "EBUILD",
  35. "EBUILD_FORCE_TEST",
  36. "EBUILD_PHASE", "ECLASSDIR", "ECLASS_DEPTH", "ED",
  37. "EMERGE_FROM", "EPREFIX", "EROOT",
  38. "FEATURES", "FILESDIR", "HOME", "MERGE_TYPE", "NOCOLOR", "PATH",
  39. "PKGDIR",
  40. "PKGUSE", "PKG_LOGDIR", "PKG_TMPDIR",
  41. "PORTAGE_ACTUAL_DISTDIR", "PORTAGE_ARCHLIST",
  42. "PORTAGE_BASHRC", "PM_EBUILD_HOOK_DIR",
  43. "PORTAGE_BINPKG_FILE", "PORTAGE_BINPKG_TAR_OPTS",
  44. "PORTAGE_BINPKG_TMPFILE",
  45. "PORTAGE_BIN_PATH",
  46. "PORTAGE_BUILDDIR", "PORTAGE_BUNZIP2_COMMAND", "PORTAGE_BZIP2_COMMAND",
  47. "PORTAGE_COLORMAP",
  48. "PORTAGE_CONFIGROOT", "PORTAGE_DEBUG", "PORTAGE_DEPCACHEDIR",
  49. "PORTAGE_EBUILD_EXIT_FILE", "PORTAGE_FEATURES",
  50. "PORTAGE_GID", "PORTAGE_GRPNAME",
  51. "PORTAGE_INST_GID", "PORTAGE_INST_UID",
  52. "PORTAGE_IPC_DAEMON", "PORTAGE_IUSE",
  53. "PORTAGE_LOG_FILE",
  54. "PORTAGE_PYM_PATH", "PORTAGE_PYTHON", "PORTAGE_QUIET",
  55. "PORTAGE_REPO_NAME", "PORTAGE_RESTRICT",
  56. "PORTAGE_SANDBOX_COMPAT_LEVEL", "PORTAGE_SIGPIPE_STATUS",
  57. "PORTAGE_TMPDIR", "PORTAGE_UPDATE_ENV", "PORTAGE_USERNAME",
  58. "PORTAGE_VERBOSE", "PORTAGE_WORKDIR_MODE",
  59. "PORTDIR", "PORTDIR_OVERLAY", "PREROOTPATH", "PROFILE_PATHS",
  60. "REPLACING_VERSIONS", "REPLACED_BY_VERSION",
  61. "ROOT", "ROOTPATH", "T", "TMP", "TMPDIR",
  62. "USE_EXPAND", "USE_ORDER", "WORKDIR",
  63. "XARGS",
  64. ]
  65. # user config variables
  66. environ_whitelist += [
  67. "DOC_SYMLINKS_DIR", "INSTALL_MASK", "PKG_INSTALL_MASK"
  68. ]
  69. environ_whitelist += [
  70. "A", "AA", "CATEGORY", "P", "PF", "PN", "PR", "PV", "PVR"
  71. ]
  72. # misc variables inherited from the calling environment
  73. environ_whitelist += [
  74. "COLORTERM", "DISPLAY", "EDITOR", "LESS",
  75. "LESSOPEN", "LOGNAME", "LS_COLORS", "PAGER",
  76. "TERM", "TERMCAP", "USER",
  77. 'ftp_proxy', 'http_proxy', 'no_proxy',
  78. ]
  79. # tempdir settings
  80. environ_whitelist += [
  81. "TMPDIR", "TEMP", "TMP",
  82. ]
  83. # localization settings
  84. environ_whitelist += [
  85. "LANG", "LC_COLLATE", "LC_CTYPE", "LC_MESSAGES",
  86. "LC_MONETARY", "LC_NUMERIC", "LC_TIME", "LC_PAPER",
  87. "LC_ALL",
  88. ]
  89. # other variables inherited from the calling environment
  90. environ_whitelist += [
  91. "CVS_RSH", "ECHANGELOG_USER",
  92. "GPG_AGENT_INFO",
  93. "SSH_AGENT_PID", "SSH_AUTH_SOCK",
  94. "STY", "WINDOW", "XAUTHORITY",
  95. ]
  96. environ_whitelist = frozenset(environ_whitelist)
  97. environ_whitelist_re = re.compile(r'^(CCACHE_|DISTCC_).*')
  98. # Filter selected variables in the config.environ() method so that
  99. # they don't needlessly propagate down into the ebuild environment.
  100. environ_filter = []
  101. # Exclude anything that could be extremely long here (like SRC_URI)
  102. # since that could cause execve() calls to fail with E2BIG errors. For
  103. # example, see bug #262647.
  104. environ_filter += [
  105. 'DEPEND', 'RDEPEND', 'PDEPEND', 'SRC_URI',
  106. ]
  107. # misc variables inherited from the calling environment
  108. environ_filter += [
  109. "INFOPATH", "MANPATH", "USER",
  110. ]
  111. # variables that break bash
  112. environ_filter += [
  113. "HISTFILE", "POSIXLY_CORRECT",
  114. ]
  115. # portage config variables and variables set directly by portage
  116. environ_filter += [
  117. "ACCEPT_CHOSTS", "ACCEPT_KEYWORDS", "ACCEPT_PROPERTIES", "AUTOCLEAN",
  118. "CLEAN_DELAY", "COLLISION_IGNORE", "CONFIG_PROTECT",
  119. "CONFIG_PROTECT_MASK", "EGENCACHE_DEFAULT_OPTS", "EMERGE_DEFAULT_OPTS",
  120. "EMERGE_LOG_DIR",
  121. "EMERGE_WARNING_DELAY",
  122. "FETCHCOMMAND", "FETCHCOMMAND_FTP",
  123. "FETCHCOMMAND_HTTP", "FETCHCOMMAND_HTTPS",
  124. "FETCHCOMMAND_RSYNC", "FETCHCOMMAND_SFTP",
  125. "GENTOO_MIRRORS", "NOCONFMEM", "O",
  126. "PORTAGE_BACKGROUND", "PORTAGE_BACKGROUND_UNMERGE",
  127. "PORTAGE_BINHOST_CHUNKSIZE", "PORTAGE_BUILDIR_LOCKED", "PORTAGE_CALLER",
  128. "PORTAGE_ELOG_CLASSES",
  129. "PORTAGE_ELOG_MAILFROM", "PORTAGE_ELOG_MAILSUBJECT",
  130. "PORTAGE_ELOG_MAILURI", "PORTAGE_ELOG_SYSTEM",
  131. "PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS", "PORTAGE_FETCH_RESUME_MIN_SIZE",
  132. "PORTAGE_GPG_DIR",
  133. "PORTAGE_GPG_KEY", "PORTAGE_GPG_SIGNING_COMMAND",
  134. "PORTAGE_IONICE_COMMAND",
  135. "PORTAGE_PACKAGE_EMPTY_ABORT",
  136. "PORTAGE_REPO_DUPLICATE_WARN",
  137. "PORTAGE_RO_DISTDIRS",
  138. "PORTAGE_USE", "PORT_LOGDIR",
  139. "QUICKPKG_DEFAULT_OPTS",
  140. "RESUMECOMMAND", "RESUMECOMMAND_FTP",
  141. "RESUMECOMMAND_HTTP", "RESUMECOMMAND_HTTPS",
  142. "RESUMECOMMAND_RSYNC", "RESUMECOMMAND_SFTP",
  143. "SYNC", "SYNC_USER", "SYNC_UMASK", "USE_EXPAND_HIDDEN", "USE_ORDER",
  144. ]
  145. environ_filter = frozenset(environ_filter)
  146. default_globals = {
  147. 'ACCEPT_LICENSE': '* -@EULA',
  148. 'ACCEPT_PROPERTIES': '*',
  149. 'PORTAGE_BZIP2_COMMAND': 'bzip2',
  150. }
  151. validate_commands = ('PORTAGE_BZIP2_COMMAND', 'PORTAGE_BUNZIP2_COMMAND',)
  152. # To enhance usability, make some vars case insensitive
  153. # by forcing them to lower case.
  154. case_insensitive_vars = ('AUTOCLEAN', 'NOCOLOR',)