3744e111f3256a98717d42a0d6b7990c9adec4e3
[portage.git] / pym / portage / const.py
1 # portage: Constants
2 # Copyright 1998-2011 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 import os
6
7 # ===========================================================================
8 # START OF CONSTANTS -- START OF CONSTANTS -- START OF CONSTANTS -- START OF
9 # ===========================================================================
10
11 # There are two types of variables here which can easily be confused,
12 # resulting in arbitrary bugs, mainly exposed with an offset
13 # installation (Prefix).  The two types relate to the usage of
14 # config_root or target_root.
15 # The first, config_root (PORTAGE_CONFIGROOT), can be a path somewhere,
16 # from which all derived paths need to be relative (e.g.
17 # USER_CONFIG_PATH) without EPREFIX prepended in Prefix.  This means
18 # config_root can for instance be set to "$HOME/my/config".  Obviously,
19 # in such case it is not appropriate to prepend EPREFIX to derived
20 # constants.  The default value of config_root is EPREFIX (in non-Prefix
21 # the empty string) -- overriding the value loses the EPREFIX as one
22 # would expect.
23 # Second there is target_root (ROOT) which is used to install somewhere
24 # completely else, in Prefix of limited use.  Because this is an offset
25 # always given, the EPREFIX should always be applied in it, hence the
26 # code always prefixes them with EROOT.
27 # The variables in this file are grouped by config_root, target_root.
28
29 # variables used with config_root (these need to be relative)
30 MAKE_CONF_FILE           = "etc/make.conf"
31 USER_CONFIG_PATH         = "etc/portage"
32 MODULES_FILE_PATH        = USER_CONFIG_PATH + "/modules"
33 CUSTOM_PROFILE_PATH      = USER_CONFIG_PATH + "/profile"
34 USER_VIRTUALS_FILE       = USER_CONFIG_PATH + "/virtuals"
35 EBUILD_SH_ENV_FILE       = USER_CONFIG_PATH + "/bashrc"
36 EBUILD_SH_ENV_DIR        = USER_CONFIG_PATH + "/env"
37 CUSTOM_MIRRORS_FILE      = USER_CONFIG_PATH + "/mirrors"
38 COLOR_MAP_FILE           = USER_CONFIG_PATH + "/color.map"
39 PROFILE_PATH             = "etc/make.profile"
40 MAKE_DEFAULTS_FILE       = PROFILE_PATH + "/make.defaults"  # FIXME: not used
41 DEPRECATED_PROFILE_FILE  = PROFILE_PATH + "/deprecated"
42
43 # variables used with targetroot (these need to be absolute, but not
44 # have a leading '/' since they are used directly with os.path.join on EROOT)
45 VDB_PATH                 = "var/db/pkg"
46 CACHE_PATH               = "var/cache/edb"
47 PRIVATE_PATH             = "var/lib/portage"
48 WORLD_FILE               = PRIVATE_PATH + "/world"
49 WORLD_SETS_FILE          = PRIVATE_PATH + "/world_sets"
50 CONFIG_MEMORY_FILE       = PRIVATE_PATH + "/config"
51 NEWS_LIB_PATH            = "var/lib/gentoo"
52
53 # these variables get EPREFIX prepended automagically when they are
54 # translated into their lowercase variants
55 DEPCACHE_PATH            = "/var/cache/edb/dep"
56 GLOBAL_CONFIG_PATH       = "/usr/share/portage/config"
57
58 # these variables are not used with target_root or config_root
59 PORTAGE_BASE_PATH        = os.path.join(os.sep, os.sep.join(__file__.split(os.sep)[:-3]))
60 PORTAGE_BIN_PATH         = PORTAGE_BASE_PATH + "/bin"
61 PORTAGE_PYM_PATH         = PORTAGE_BASE_PATH + "/pym"
62 LOCALE_DATA_PATH         = PORTAGE_BASE_PATH + "/locale"  # FIXME: not used
63 EBUILD_SH_BINARY         = PORTAGE_BIN_PATH + "/ebuild.sh"
64 MISC_SH_BINARY           = PORTAGE_BIN_PATH + "/misc-functions.sh"
65 SANDBOX_BINARY           = "/usr/bin/sandbox"
66 FAKEROOT_BINARY          = "/usr/bin/fakeroot"
67 BASH_BINARY              = "/bin/bash"
68 MOVE_BINARY              = "/bin/mv"
69 PRELINK_BINARY           = "/usr/sbin/prelink"
70
71 INVALID_ENV_FILE         = "/etc/spork/is/not/valid/profile.env"
72 REPO_NAME_FILE           = "repo_name"
73 REPO_NAME_LOC            = "profiles" + "/" + REPO_NAME_FILE
74
75 PORTAGE_PACKAGE_ATOM     = "sys-apps/portage"
76 LIBC_PACKAGE_ATOM        = "virtual/libc"
77 OS_HEADERS_PACKAGE_ATOM  = "virtual/os-headers"
78
79 INCREMENTALS             = ("USE", "USE_EXPAND", "USE_EXPAND_HIDDEN",
80                            "FEATURES", "ACCEPT_KEYWORDS",
81                            "CONFIG_PROTECT_MASK", "CONFIG_PROTECT",
82                            "PRELINK_PATH", "PRELINK_PATH_MASK",
83                            "PROFILE_ONLY_VARIABLES")
84 EBUILD_PHASES            = ("pretend", "setup", "unpack", "prepare", "configure",
85                            "compile", "test", "install",
86                            "package", "preinst", "postinst","prerm", "postrm",
87                            "nofetch", "config", "info", "other")
88 SUPPORTED_FEATURES       = frozenset([
89                            "assume-digests", "binpkg-logs", "buildpkg", "buildsyspkg", "candy",
90                            "ccache", "chflags", "clean-logs",
91                            "collision-protect", "compress-build-logs", "compressdebug",
92                            "config-protect-if-modified",
93                            "digest", "distcc", "distcc-pump", "distlocks", "ebuild-locks", "fakeroot",
94                            "fail-clean", "force-mirror", "force-prefix", "getbinpkg",
95                            "installsources", "keeptemp", "keepwork", "fixlafiles", "lmirror",
96                            "metadata-transfer", "mirror", "multilib-strict", "news",
97                            "noauto", "noclean", "nodoc", "noinfo", "noman",
98                            "nostrip", "notitles", "parallel-fetch", "parallel-install",
99                            "parse-eapi-ebuild-head",
100                            "prelink-checksums", "preserve-libs",
101                            "protect-owned", "python-trace", "sandbox",
102                            "selinux", "sesandbox", "sfperms",
103                            "sign", "skiprocheck", "split-elog", "split-log", "splitdebug",
104                            "strict", "stricter", "suidctl", "test", "test-fail-continue",
105                            "unknown-features-filter", "unknown-features-warn",
106                            "unmerge-logs", "unmerge-orphans", "userfetch", "userpriv",
107                            "usersandbox", "usersync", "webrsync-gpg", "xattr"])
108
109 EAPI                     = 4
110
111 HASHING_BLOCKSIZE        = 32768
112 MANIFEST1_HASH_FUNCTIONS = ("MD5", "SHA256", "RMD160")
113 MANIFEST1_REQUIRED_HASH  = "MD5"
114
115 # Future events:
116 #
117 # After WHIRLPOOL is supported in stable portage:
118 # - Add SHA256 and WHIRLPOOL to MANIFEST2_HASH_DEFAULTS.
119 # - Remove SHA1 and RMD160 from MANIFEST2_HASH_*.
120 # - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows:
121 #     manifest-hashes = SHA256 SHA512 WHIRLPOOL
122 #
123 # After WHIRLPOOL is supported in stable portage for at least 1 year:
124 # - Change MANIFEST2_REQUIRED_HASH to WHIRLPOOL.
125 # - Remove SHA256 from MANIFEST2_HASH_*.
126 # - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows:
127 #     manifest-hashes = SHA512 WHIRLPOOL
128 #
129 # After SHA-3 is approved:
130 # - Add new hashes to MANIFEST2_HASH_*.
131 #
132 # After SHA-3 is supported in stable portage:
133 # - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows:
134 #     manifest-hashes = SHA3 SHA512 WHIRLPOOL
135 #
136 # After layout.conf settings correspond to defaults in stable portage:
137 # - Remove redundant settings from gentoo-x86/metadata/layout.conf.
138
139 MANIFEST2_HASH_FUNCTIONS = ("RMD160", "SHA1", "SHA256", "SHA512", "WHIRLPOOL")
140 MANIFEST2_HASH_DEFAULTS = frozenset(["SHA1", "SHA256", "RMD160"])
141 MANIFEST2_REQUIRED_HASH  = "SHA256"
142
143 MANIFEST2_IDENTIFIERS    = ("AUX", "MISC", "DIST", "EBUILD")
144
145 # The EPREFIX for the current install is hardcoded here, but access to this
146 # constant should be minimal, in favor of access via the EPREFIX setting of
147 # a config instance (since it's possible to contruct a config instance with
148 # a different EPREFIX). Therefore, the EPREFIX constant should *NOT* be used
149 # in the definition of any other constants within this file.
150 EPREFIX=""
151
152 # pick up EPREFIX from the environment if set
153 if "PORTAGE_OVERRIDE_EPREFIX" in os.environ:
154         EPREFIX = os.environ["PORTAGE_OVERRIDE_EPREFIX"]
155         if EPREFIX:
156                 EPREFIX = os.path.normpath(EPREFIX)
157
158 # ===========================================================================
159 # END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANT
160 # ===========================================================================
161
162 # Private constants for use in conditional code in order to minimize the diff
163 # between branches.
164 _ENABLE_DYN_LINK_MAP    = True
165 _ENABLE_PRESERVE_LIBS   = True
166 _ENABLE_REPO_NAME_WARN  = True
167 _ENABLE_SET_CONFIG      = True
168 _ENABLE_INHERIT_CHECK   = True
169
170
171 # The definitions above will differ between branches, so it's useful to have
172 # common lines of diff context here in order to avoid merge conflicts.
173
174 if not _ENABLE_PRESERVE_LIBS:
175         SUPPORTED_FEATURES = set(SUPPORTED_FEATURES)
176         SUPPORTED_FEATURES.remove("preserve-libs")
177         SUPPORTED_FEATURES = frozenset(SUPPORTED_FEATURES)
178
179 if not _ENABLE_SET_CONFIG:
180         WORLD_SETS_FILE = '/dev/null'