portage.const: tweak style
[portage.git] / pym / portage / const.py
1 # portage: Constants
2 # Copyright 1998-2013 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 from __future__ import unicode_literals
6
7 import os
8
9 # ===========================================================================
10 # START OF CONSTANTS -- START OF CONSTANTS -- START OF CONSTANTS -- START OF
11 # ===========================================================================
12
13 # There are two types of variables here which can easily be confused,
14 # resulting in arbitrary bugs, mainly exposed with an offset
15 # installation (Prefix).  The two types relate to the usage of
16 # config_root or target_root.
17 # The first, config_root (PORTAGE_CONFIGROOT), can be a path somewhere,
18 # from which all derived paths need to be relative (e.g.
19 # USER_CONFIG_PATH) without EPREFIX prepended in Prefix.  This means
20 # config_root can for instance be set to "$HOME/my/config".  Obviously,
21 # in such case it is not appropriate to prepend EPREFIX to derived
22 # constants.  The default value of config_root is EPREFIX (in non-Prefix
23 # the empty string) -- overriding the value loses the EPREFIX as one
24 # would expect.
25 # Second there is target_root (ROOT) which is used to install somewhere
26 # completely else, in Prefix of limited use.  Because this is an offset
27 # always given, the EPREFIX should always be applied in it, hence the
28 # code always prefixes them with EROOT.
29 # The variables in this file are grouped by config_root, target_root.
30
31 # variables used with config_root (these need to be relative)
32 USER_CONFIG_PATH         = "etc/portage"
33 MAKE_CONF_FILE           = USER_CONFIG_PATH + "/make.conf"
34 MODULES_FILE_PATH        = USER_CONFIG_PATH + "/modules"
35 CUSTOM_PROFILE_PATH      = USER_CONFIG_PATH + "/profile"
36 USER_VIRTUALS_FILE       = USER_CONFIG_PATH + "/virtuals"
37 EBUILD_SH_ENV_FILE       = USER_CONFIG_PATH + "/bashrc"
38 EBUILD_SH_ENV_DIR        = USER_CONFIG_PATH + "/env"
39 CUSTOM_MIRRORS_FILE      = USER_CONFIG_PATH + "/mirrors"
40 COLOR_MAP_FILE           = USER_CONFIG_PATH + "/color.map"
41 PROFILE_PATH             = USER_CONFIG_PATH + "/make.profile"
42 MAKE_DEFAULTS_FILE       = PROFILE_PATH + "/make.defaults"  # FIXME: not used
43 DEPRECATED_PROFILE_FILE  = PROFILE_PATH + "/deprecated"
44
45 # variables used with targetroot (these need to be absolute, but not
46 # have a leading '/' since they are used directly with os.path.join on EROOT)
47 VDB_PATH                 = "var/db/pkg"
48 CACHE_PATH               = "var/cache/edb"
49 PRIVATE_PATH             = "var/lib/portage"
50 WORLD_FILE               = PRIVATE_PATH + "/world"
51 WORLD_SETS_FILE          = PRIVATE_PATH + "/world_sets"
52 CONFIG_MEMORY_FILE       = PRIVATE_PATH + "/config"
53 NEWS_LIB_PATH            = "var/lib/gentoo"
54
55 # these variables get EPREFIX prepended automagically when they are
56 # translated into their lowercase variants
57 DEPCACHE_PATH            = "/var/cache/edb/dep"
58 GLOBAL_CONFIG_PATH       = "/usr/share/portage/config"
59
60 # these variables are not used with target_root or config_root
61 # NOTE: Use realpath(__file__) so that python module symlinks in site-packages
62 # are followed back to the real location of the whole portage installation.
63 PORTAGE_BASE_PATH        = os.path.join(os.sep, os.sep.join(os.path.realpath(
64                                __file__.rstrip("co")).split(os.sep)[:-3]))
65 PORTAGE_BIN_PATH         = PORTAGE_BASE_PATH + "/bin"
66 PORTAGE_PYM_PATH         = PORTAGE_BASE_PATH + "/pym"
67 LOCALE_DATA_PATH         = PORTAGE_BASE_PATH + "/locale"  # FIXME: not used
68 EBUILD_SH_BINARY         = PORTAGE_BIN_PATH + "/ebuild.sh"
69 MISC_SH_BINARY           = PORTAGE_BIN_PATH + "/misc-functions.sh"
70 SANDBOX_BINARY           = "/usr/bin/sandbox"
71 FAKEROOT_BINARY          = "/usr/bin/fakeroot"
72 BASH_BINARY              = "/bin/bash"
73 MOVE_BINARY              = "/bin/mv"
74 PRELINK_BINARY           = "/usr/sbin/prelink"
75
76 INVALID_ENV_FILE         = "/etc/spork/is/not/valid/profile.env"
77 REPO_NAME_FILE           = "repo_name"
78 REPO_NAME_LOC            = "profiles" + "/" + REPO_NAME_FILE
79
80 PORTAGE_PACKAGE_ATOM     = "sys-apps/portage"
81 LIBC_PACKAGE_ATOM        = "virtual/libc"
82 OS_HEADERS_PACKAGE_ATOM  = "virtual/os-headers"
83 CVS_PACKAGE_ATOM         = "dev-vcs/cvs"
84 GIT_PACKAGE_ATOM         = "dev-vcs/git"
85 RSYNC_PACKAGE_ATOM       = "net-misc/rsync"
86
87 INCREMENTALS             = (
88         "ACCEPT_KEYWORDS",
89         "CONFIG_PROTECT",
90         "CONFIG_PROTECT_MASK",
91         "FEATURES",
92         "IUSE_IMPLICIT",
93         "PRELINK_PATH",
94         "PRELINK_PATH_MASK",
95         "PROFILE_ONLY_VARIABLES",
96         "USE",
97         "USE_EXPAND",
98         "USE_EXPAND_HIDDEN",
99         "USE_EXPAND_IMPLICIT",
100         "USE_EXPAND_UNPREFIXED",
101 )
102 EBUILD_PHASES            = (
103         "pretend",
104         "setup",
105         "unpack",
106         "prepare",
107         "configure",
108         "compile",
109         "test",
110         "install",
111         "package",
112         "preinst",
113         "postinst",
114         "prerm",
115         "postrm",
116         "nofetch",
117         "config",
118         "info",
119         "other",
120 )
121 SUPPORTED_FEATURES       = frozenset([
122         "assume-digests",
123         "binpkg-logs",
124         "buildpkg",
125         "buildsyspkg",
126         "candy",
127         "ccache",
128         "cgroup",
129         "chflags",
130         "clean-logs",
131         "collision-protect",
132         "compress-build-logs",
133         "compressdebug",
134         "compress-index",
135         "config-protect-if-modified",
136         "digest",
137         "distcc",
138         "distcc-pump",
139         "distlocks",
140         "downgrade-backup",
141         "ebuild-locks",
142         "fail-clean",
143         "fakeroot",
144         "fixlafiles",
145         "force-mirror",
146         "force-prefix",
147         "getbinpkg",
148         "installsources",
149         "ipc-sandbox",
150         "keeptemp",
151         "keepwork",
152         "lmirror",
153         "metadata-transfer",
154         "mirror",
155         "multilib-strict",
156         "network-sandbox",
157         "news",
158         "noauto",
159         "noclean",
160         "nodoc",
161         "noinfo",
162         "noman",
163         "nostrip",
164         "notitles",
165         "parallel-fetch",
166         "parallel-install",
167         "prelink-checksums",
168         "preserve-libs",
169         "protect-owned",
170         "python-trace",
171         "sandbox",
172         "selinux",
173         "sesandbox",
174         "sfperms",
175         "sign",
176         "skiprocheck",
177         "splitdebug",
178         "split-elog",
179         "split-log",
180         "strict",
181         "stricter",
182         "suidctl",
183         "test",
184         "test-fail-continue",
185         "unknown-features-filter",
186         "unknown-features-warn",
187         "unmerge-logs",
188         "unmerge-orphans",
189         "userfetch",
190         "userpriv",
191         "usersandbox",
192         "usersync",
193         "webrsync-gpg",
194         "xattr",
195 ])
196
197 EAPI                     = 5
198
199 HASHING_BLOCKSIZE        = 32768
200 MANIFEST1_HASH_FUNCTIONS = ("MD5", "SHA256", "RMD160")
201 MANIFEST1_REQUIRED_HASH  = "MD5"
202
203 # Past events:
204 #
205 # 20120704 - After WHIRLPOOL is supported in stable portage:
206 # - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows:
207 #     manifest-hashes = SHA256 SHA512 WHIRLPOOL
208 # - Add SHA512 and WHIRLPOOL to MANIFEST2_HASH_DEFAULTS.
209 # - Remove SHA1 and RMD160 from MANIFEST2_HASH_*.
210 #
211 # Future events:
212 #
213 # After WHIRLPOOL is supported in stable portage for at least 1 year:
214 # - Change MANIFEST2_REQUIRED_HASH to WHIRLPOOL.
215 # - Remove SHA256 from MANIFEST2_HASH_*.
216 # - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows:
217 #     manifest-hashes = SHA512 WHIRLPOOL
218 #
219 # After SHA-3 is approved:
220 # - Add new hashes to MANIFEST2_HASH_*.
221 #
222 # After SHA-3 is supported in stable portage:
223 # - Set manifest-hashes in gentoo-x86/metadata/layout.conf as follows:
224 #     manifest-hashes = SHA3 SHA512 WHIRLPOOL
225 #
226 # After layout.conf settings correspond to defaults in stable portage:
227 # - Remove redundant settings from gentoo-x86/metadata/layout.conf.
228
229 MANIFEST2_HASH_FUNCTIONS = ("SHA256", "SHA512", "WHIRLPOOL")
230 MANIFEST2_HASH_DEFAULTS = frozenset(["SHA256", "SHA512", "WHIRLPOOL"])
231 MANIFEST2_REQUIRED_HASH  = "SHA256"
232
233 MANIFEST2_IDENTIFIERS    = ("AUX", "MISC", "DIST", "EBUILD")
234
235 # The EPREFIX for the current install is hardcoded here, but access to this
236 # constant should be minimal, in favor of access via the EPREFIX setting of
237 # a config instance (since it's possible to contruct a config instance with
238 # a different EPREFIX). Therefore, the EPREFIX constant should *NOT* be used
239 # in the definition of any other constants within this file.
240 EPREFIX = ""
241
242 # pick up EPREFIX from the environment if set
243 if "PORTAGE_OVERRIDE_EPREFIX" in os.environ:
244         EPREFIX = os.environ["PORTAGE_OVERRIDE_EPREFIX"]
245         if EPREFIX:
246                 EPREFIX = os.path.normpath(EPREFIX)
247                 if EPREFIX == os.sep:
248                         EPREFIX = ""
249
250 VCS_DIRS = ("CVS", "RCS", "SCCS", ".bzr", ".git", ".hg", ".svn")
251
252 # List of known live eclasses. Keep it in sync with cnf/sets/portage.conf
253 LIVE_ECLASSES = frozenset([
254         "bzr",
255         "cvs",
256         "darcs",
257         "git",
258         "git-2",
259         "git-r3",
260         "mercurial",
261         "subversion",
262         "tla",
263 ])
264
265 SUPPORTED_BINPKG_FORMATS = ("tar", "rpm")
266
267 # Time formats used in various places like metadata.chk.
268 TIMESTAMP_FORMAT = "%a, %d %b %Y %H:%M:%S +0000"        # to be used with time.gmtime()
269
270 # ===========================================================================
271 # END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANT
272 # ===========================================================================
273
274 # Private constants for use in conditional code in order to minimize the diff
275 # between branches.
276 _DEPCLEAN_LIB_CHECK_DEFAULT = True
277 _ENABLE_SET_CONFIG      = True