local retval
source "$@"
retval=$?
+ set +e
[[ $shopts != $(shopt) ]] &&
eqawarn "QA Notice: Global shell options changed and were not restored while sourcing '$*'"
[[ "$IFS" != "$OLDIFS" ]] &&
local retval
"$@"
retval=$?
+ set +e
[[ $shopts != $(shopt) ]] &&
eqawarn "QA Notice: Global shell options changed and were not restored while calling '$*'"
[[ "$IFS" != "$OLDIFS" ]] &&
action="store_true",
help="enable rsync stat collision workaround " + \
"for bug 139134 (use with --update)")
+ parser.add_option("--ignore-default-opts",
+ action="store_true",
+ help="do not use the EGENCACHE_DEFAULT_OPTS environment variable")
options, args = parser.parse_args(args)
- if not options.update:
- parser.error('No action specified (--update ' + \
- 'is the only available action)')
+ if options.jobs:
+ jobs = None
+ try:
+ jobs = int(options.jobs)
+ except ValueError:
+ jobs = -1
+
+ if jobs < 1:
+ parser.error("Invalid: --jobs='%s'" % \
+ (options.jobs,))
+
+ options.jobs = jobs
+
+ else:
+ options.jobs = None
+
+ if options.load_average:
+ try:
+ load_average = float(options.load_average)
+ except ValueError:
+ load_average = 0.0
+
+ if load_average <= 0.0:
+ parser.error("Invalid: --load-average='%s'" % \
+ (options.load_average,))
+
+ options.load_average = load_average
+
+ else:
+ options.load_average = None
if options.config_root is not None and \
not os.path.isdir(options.config_root):
if str(atom) != atom.cp:
parser.error('Atom is too specific: %s' % (atom,))
- return options, args
+ return parser, options, args
class GenCache(object):
def __init__(self, portdb, cp_iter=None, max_jobs=None, max_load=None,
# file mtime nor size changes, it will prevent rsync from
# detecting changes. Cache backends may raise this
# exception from _setitem() if they detect this type of stat
- # collision. These exceptions are be handled by bumping the
+ # collision. These exceptions are handled by bumping the
# mtime on the ebuild (and the corresponding cache entry).
# See bug #139134.
max_mtime = sc.mtime
level=logging.ERROR, noiselevel=-1)
def egencache_main(args):
- options, args = parse_args(args)
+ parser, options, atoms = parse_args(args)
config_root = options.config_root
if config_root is None:
settings = portage.config(config_root=config_root,
target_root='/', env=env)
- if 'metadata-transfer' not in settings.features:
- writemsg_level("ecachegen: error: " + \
- "FEATURES=metadata-transfer is not enabled\n",
- level=logging.ERROR, noiselevel=-1)
+ default_opts = None
+ if not options.ignore_default_opts:
+ default_opts = settings.get('EGENCACHE_DEFAULT_OPTS', '').split()
+
+ if default_opts:
+ parser, options, args = parse_args(default_opts + args)
+
+ if options.config_root is not None:
+ config_root = options.config_root
+
+ if options.cache_dir is not None:
+ env['PORTAGE_DEPCACHEDIR'] = options.cache_dir
+
+ settings = portage.config(config_root=config_root,
+ target_root='/', env=env)
+
+ if not options.update:
+ parser.error('No action specified (--update ' + \
+ 'is the only available action)')
return 1
+ if 'metadata-transfer' not in settings.features:
+ writemsg_level("ecachegen: warning: " + \
+ "automatically enabling FEATURES=metadata-transfer\n",
+ level=logging.WARNING, noiselevel=-1)
+ settings.features.add('metadata-transfer')
+ settings['FEATURES'] = ' '.join(sorted(settings.features))
+ settings.backup_changes('FEATURES')
+
+ settings.lock()
+
portdb = portage.portdbapi(settings["PORTDIR"], mysettings=settings)
cp_iter = None
- if args:
- cp_iter = iter(args)
+ if atoms:
+ cp_iter = iter(atoms)
gen_cache = GenCache(portdb, cp_iter=cp_iter,
max_jobs=options.jobs,
}
die() {
+ set +e
if [ -n "${QA_INTERCEPTORS}" ] ; then
# die was called from inside inherit. We need to clean up
# QA_INTERCEPTORS since sed is called below.
dispatch-conf.1 \
ebuild.1 \
ebuild.5 \
+ egencache.1 \
emaint.1 \
emerge.1 \
env-update.1 \
making the appropriate patches to the sources so that they're ready
for compilation.
.TP
+.BR prepare
+Prepares the extracted sources by running the \fIsrc_prepare()\fR
+function specified in the ebuild file. When src_prepare() starts, the
+current working directory will be set to ${S}. This function is supported
+beginning with \fBEAPI 2\fR.
+.TP
+.BR configure
+Configures the extracted sources by running the \fIsrc_configure()\fR
+function specified in the ebuild file. When src_configure() starts, the
+current working directory will be set to ${S}. This function is supported
+beginning with \fBEAPI 2\fR.
+.TP
.BR compile
Compiles the extracted sources by running the \fIsrc_compile()\fR
function specified in the ebuild file. When src_compile() starts, the
--- /dev/null
+.TH "EGENCACHE" "1" "March 2009" "Portage 2.2" "Portage"
+.SH "NAME"
+egencache \- generate metadata cache for ebuild repositories
+.SH "SYNOPSIS"
+.B egencache
+.I [options] --update [ATOM]\fR...
+.SH "DESCRIPTION"
+The egencache program generates metadata cache for ebuild repositories and
+stores it in the \fImetadata/cache/\fR directory within the repository itself,
+for distribution. Currenly, only the repository located at \fBPORTDIR\fR
+(configured in \fBmake.conf(5)\fR) can be updated by this program, but a
+future version will have the ability to select a different repository.
+.SH ACTIONS
+.TP
+.BR "\-\-update [ATOM] ... "
+Update the \fImetadata/cache/\fR directory (generate metadata as necessary).
+If no package atoms are specified then all will be updated. See ebuild(5)
+for the details on package atom syntax.
+.SH OPTIONS
+.TP
+.BR "\-\-cache\-dir=CACHE_DIR"
+Location of the intermediate metadata cache which is stored in a different
+format that includes eclass state. See the \fBBUGS\fR section for
+information about why this is necessary.
+.br
+Defaults to /var/cache/edb/dep.
+.TP
+.BR "\-\-config\-root=CONFIG_ROOT"
+Location of portage config files.
+.br
+Defaults to /.
+.TP
+.BR "\-\-ignore-default-opts"
+Causes \fIEGENCACHE_DEFAULT_OPTS\fR to be ignored.
+.TP
+.BR "\-\-jobs=JOBS"
+Specifies the maximum number of ebuild processes to spawn simultaneously.
+Also see the related \fB\-\-load\-average\fR option.
+.TP
+.BR \-\-load\-average=LOAD
+Specifies that maximum load allowed when spawning multiple jobs.
+.TP
+.BR "\-\-rsync"
+When used together with the \fB\-\-update\fR action, this enables a workaround
+for cases in which the content of a cache entry changes and neither the file
+mtime nor size changes, preventing rsync from detecting changes. Such cases are
+handled by bumping the mtime on the ebuild (and the corresponding cache entry).
+This option should only be needed for distribution via something like
+\fBrsync\fR(1), which relies on timestamps and file sizes to detect changes
+(see \fBbug 139134\fR). It's not needed with \fBgit\fR(1) since that uses a
+more thorough mechanism which allows it to detect changed inode numbers
+(described in \fIracy-git.txt\fR in the git technical docs).
+.SH "ENVIRONMENT OPTIONS"
+.TP
+\fBEGENCACHE_DEFAULT_OPTS\fR
+If this variable is set in \fBmake.conf\fR(5) then any options that it
+contains will be added to the beginning of the command line on every
+invocation. These options will not be added if the
+\fB\-\-ignore-default\-opts\fR option is specified.
+.SH "BUGS"
+There are significant limitations associated with the metadata
+cache format that is distributed in the \fImetadata/cache/\fR directory
+of the repository. These limitations are related to the cache validation
+mechanism. Currently, the validation mechanism involves comparison of
+a cache entry mtime to the mtime of the corresponding \fBebuild(5)\fR. This
+mechanism is unreliable in cases when eclass changes result in metadata
+changes, since no information about eclass state is available in the cache.
+Also, since the mtime of the cache entry must correspond to that of the
+ebuild, the cache format is only suitable for distribution via protocols
+that preserve timestamps (such as \fBrsync(1))\fR. For cache that is
+distributed via \fBgit(1)\fR repositories, there is currently a workaround
+implemented in \fBemerge\fR(1) \fB\-\-sync\fR which updates ebuild mtimes
+to match their corresponding cache entries (except for ebuilds that are
+modified relative to HEAD).
+
+In order to solve the above problems, a future extension
+to the cache format will include additional
+validation data in the form of digests for both the ebuild
+and its inherited eclasses. Until the
+cache format has been extended in this way, it is necessary to enable
+\fBmetadata-transfer\fR in \fBFEATURES\fR (see \fBmake.conf(5)\fR).
+This causes intermediate cache (in a different format that includes
+eclass state) to be generated inside the directory which is configurable
+via the \fB\-\-cache\-dir\fR option.
+.SH "REPORTING BUGS"
+Please report bugs via http://bugs.gentoo.org/
+.SH "AUTHORS"
+.nf
+Zac Medico <zmedico@gentoo.org>
+.fi
+.SH "FILES"
+.TP
+.B /etc/make.conf
+Contains variables.
+.SH "SEE ALSO"
+.BR emerge (1),
+.BR make.conf (5),
+.BR portage (5)
Results may vary, but the general outcome is a reduced or condensed
output from portage's displays.
.TP
-.BR "\-\-rdeps\-only"
-Discard all build\-time dependencies. This option is commonly used together
-with \fBROOT\fR and it should not be enabled under normal circumstances. For
-currently supported \fBEAPI\fR values, the dependencies specified in the
-\fBDEPEND\fR variable are discarded. However, behavior may change for new
-\fBEAPI\fRs when related extensions are added in the future.
-.TP
.BR "\-\-reinstall changed\-use"
Tells emerge to include installed packages where USE flags have
changed since installation. Unlike \fB\-\-newuse\fR, this option does
.BR \-\-root=DIR
Set the \fBROOT\fR environment variable.
.TP
-.BR "\-\-root\-deps"
-Install build\-time dependencies to \fBROOT\fR instead of /. This option
-should not be enabled under normal circumstances. For currently supported
-\fBEAPI\fR values, the dependencies specified in the \fBDEPEND\fR variable
-are used. However, behavior may change for new
+.BR "\-\-root\-deps[=rdeps]"
+If no argument is given then build\-time dependencies of packages for
+\fBROOT\fR are installed to
+\fBROOT\fR instead of /. If the \fBrdeps\fR argument is given then discard
+all build\-time dependencies of packages for \fBROOT\fR. This option is
+only meaningful when used together with \fBROOT\fR and it should not
+be enabled under normal circumstances. For currently supported
+\fBEAPI\fR values, the build-time dependencies are specified in the
+\fBDEPEND\fR variable. However, behavior may change for new
\fBEAPI\fRs when related extensions are added in the future.
.TP
.BR "\-\-skipfirst"
"--nospinner", "--oneshot",
"--onlydeps", "--pretend",
"--quiet", "--resume",
-"--rdeps-only", "--root-deps",
"--searchdesc", "--selective",
"--skipfirst",
"--tree",
edepend["DEPEND"] = ""
bdeps_root = "/"
- if self.target_root != "/":
- if "--root-deps" in self.myopts:
- bdeps_root = myroot
- if "--rdeps-only" in self.myopts:
- bdeps_root = "/"
- edepend["DEPEND"] = ""
+ root_deps = self.myopts.get("--root-deps")
+ if root_deps is not None:
+ if root_deps is True:
+ bdeps_root = myroot
+ elif root_deps == "rdeps":
+ edepend["DEPEND"] = ""
deps = (
(bdeps_root, edepend["DEPEND"],
new_args = []
jobs_opts = ("-j", "--jobs")
+ root_deps_opt = '--root-deps'
+ root_deps_choices = ('True', 'rdeps')
arg_stack = args[:]
arg_stack.reverse()
while arg_stack:
arg = arg_stack.pop()
+ if arg == root_deps_opt:
+ new_args.append(arg)
+ if arg_stack and arg_stack[-1] in root_deps_choices:
+ new_args.append(arg_stack.pop())
+ else:
+ # insert default argument
+ new_args.append('True')
+ continue
+
short_job_opt = bool("j" in arg and arg[:1] == "-" and arg[:2] != "--")
if not (short_job_opt or arg in jobs_opts):
new_args.append(arg)
"help" : "specify the target root filesystem for merging packages",
"action" : "store"
},
+
+ "--root-deps": {
+ "help" : "modify interpretation of depedencies",
+ "type" : "choice",
+ "choices" :("True", "rdeps")
+ },
}
from optparse import OptionParser
myoptions, myargs = parser.parse_args(args=tmpcmdline)
+ if myoptions.root_deps == "True":
+ myoptions.root_deps = True
+
if myoptions.jobs:
jobs = None
if myoptions.jobs == "True":
print " Effects vary, but the general outcome is a reduced or condensed"
print " output from portage's displays."
print
- print " "+green("--rdeps-only")
- desc = "Discard all build-time dependencies. This option is commonly used together " + \
- "with ROOT and it should not be enabled under normal circumstances. For " + \
- "currently supported EAPI values, the dependencies specified in the " + \
- "DEPEND variable are discarded. However, behavior may change for new " + \
- "EAPIs when related extensions are added in the future."
- for line in wrap(desc, desc_width):
- print desc_indent + line
- print
print " "+green("--reinstall ") + turquoise("changed-use")
print " Tells emerge to include installed packages where USE flags have"
print " changed since installation. Unlike --newuse, this option does"
for line in wrap(desc, desc_width):
print desc_indent + line
print
- print " "+green("--root-deps")
- desc = "Install build-time dependencies to ROOT instead of /. This option " + \
- "should not be enabled under normal circumstances. For currently supported " + \
- "EAPI values, the dependencies specified in the DEPEND variable " + \
- "are used. However, behavior may change for new " + \
+ print " "+green("--root-deps[=rdeps]")
+ desc = "If no argument is given then build-time dependencies of packages for " + \
+ "ROOT are installed to " + \
+ "ROOT instead of /. If the rdeps argument is given then discard " + \
+ "all build-time dependencies of packages for ROOT. This option is " + \
+ "only meaningful when used together with ROOT and it should not " + \
+ "be enabled under normal circumstances. For currently supported " + \
+ "EAPI values, the build-time dependencies are specified in the " + \
+ "DEPEND variable. However, behavior may change for new " + \
"EAPIs when related extensions are added in the future."
for line in wrap(desc, desc_width):
print desc_indent + line
_environ_filter += [
"ACCEPT_KEYWORDS", "AUTOCLEAN",
"CLEAN_DELAY", "COLLISION_IGNORE", "CONFIG_PROTECT",
- "CONFIG_PROTECT_MASK", "EMERGE_DEFAULT_OPTS",
+ "CONFIG_PROTECT_MASK", "EGENCACHE_DEFAULT_OPTS", "EMERGE_DEFAULT_OPTS",
"EMERGE_WARNING_DELAY", "FETCHCOMMAND", "FETCHCOMMAND_FTP",
"FETCHCOMMAND_HTTP", "FETCHCOMMAND_SFTP",
"GENTOO_MIRRORS", "NOCONFMEM", "O",