Commit d0d08271 authored by jim's avatar jim

Feature Changes

---------------

- A new command-line argument, -U, suppresses reading user defaults.

- You can now suppress use of an installed-part database
  (e.g. .installed.cfg) by sprifying an empty value for the buildout
  installed option.


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@71488 62d5b8a3-27da-0310-9561-8e5933582275
parent 06d5ca82
...@@ -23,6 +23,15 @@ Change History ...@@ -23,6 +23,15 @@ Change History
1.0.0b15 (2006-12-07) 1.0.0b15 (2006-12-07)
===================== =====================
Feature Changes
---------------
- A new command-line argument, -U, suppresses reading user defaults.
- You can now suppress use of an installed-part database
(e.g. .installed.cfg) by sprifying an empty value for the buildout
installed option.
Bugs Fixed Bugs Fixed
---------- ----------
......
...@@ -56,7 +56,8 @@ class MissingSection(zc.buildout.UserError, KeyError): ...@@ -56,7 +56,8 @@ class MissingSection(zc.buildout.UserError, KeyError):
class Buildout(UserDict.DictMixin): class Buildout(UserDict.DictMixin):
def __init__(self, config_file, cloptions, windows_restart=False): def __init__(self, config_file, cloptions,
user_defaults=True, windows_restart=False):
config_file = os.path.abspath(config_file) config_file = os.path.abspath(config_file)
self._config_file = config_file self._config_file = config_file
self.__windows_restart = windows_restart self.__windows_restart = windows_restart
...@@ -79,7 +80,7 @@ class Buildout(UserDict.DictMixin): ...@@ -79,7 +80,7 @@ class Buildout(UserDict.DictMixin):
}) })
# load user defaults, which override defaults # load user defaults, which override defaults
if 'HOME' in os.environ: if user_defaults and 'HOME' in os.environ:
user_config = os.path.join(os.environ['HOME'], user_config = os.path.join(os.environ['HOME'],
'.buildout', 'default.cfg') '.buildout', 'default.cfg')
if os.path.exists(user_config): if os.path.exists(user_config):
...@@ -112,8 +113,9 @@ class Buildout(UserDict.DictMixin): ...@@ -112,8 +113,9 @@ class Buildout(UserDict.DictMixin):
d = self._buildout_path(options[name+'-directory']) d = self._buildout_path(options[name+'-directory'])
options[name+'-directory'] = d options[name+'-directory'] = d
options['installed'] = os.path.join(options['directory'], if options['installed']:
options['installed']) options['installed'] = os.path.join(options['directory'],
options['installed'])
self._setup_logging() self._setup_logging()
...@@ -394,8 +396,8 @@ class Buildout(UserDict.DictMixin): ...@@ -394,8 +396,8 @@ class Buildout(UserDict.DictMixin):
options['__buildout_signature__'] = ' '.join(sig) options['__buildout_signature__'] = ' '.join(sig)
def _read_installed_part_options(self): def _read_installed_part_options(self):
old = self._installed_path() old = self['buildout']['installed']
if os.path.isfile(old): if old and os.path.isfile(old):
parser = ConfigParser.RawConfigParser() parser = ConfigParser.RawConfigParser()
parser.optionxform = lambda s: s parser.optionxform = lambda s: s
parser.read(old) parser.read(old)
...@@ -413,9 +415,6 @@ class Buildout(UserDict.DictMixin): ...@@ -413,9 +415,6 @@ class Buildout(UserDict.DictMixin):
else: else:
return {'buildout': Options(self, 'buildout', {'parts': ''})} return {'buildout': Options(self, 'buildout', {'parts': ''})}
def _installed_path(self):
return self._buildout_path(self['buildout']['installed'])
def _uninstall(self, installed): def _uninstall(self, installed):
for f in installed.split('\n'): for f in installed.split('\n'):
if not f: if not f:
...@@ -443,7 +442,10 @@ class Buildout(UserDict.DictMixin): ...@@ -443,7 +442,10 @@ class Buildout(UserDict.DictMixin):
def _save_installed_options(self, installed_options): def _save_installed_options(self, installed_options):
f = open(self._installed_path(), 'w') installed = self['buildout']['installed']
if not installed:
return
f = open(installed, 'w')
_save_options('buildout', installed_options['buildout'], f) _save_options('buildout', installed_options['buildout'], f)
for part in installed_options['buildout']['parts'].split(): for part in installed_options['buildout']['parts'].split():
print >>f print >>f
...@@ -919,6 +921,10 @@ Options: ...@@ -919,6 +921,10 @@ Options:
This defaults to the file named "buildout.cfg" in the current This defaults to the file named "buildout.cfg" in the current
working directory. working directory.
-U
Don't read user defaults.
Assignments are of the form: section:option=value and are used to Assignments are of the form: section:option=value and are used to
provide configuration options that override those given in the provide configuration options that override those given in the
configuration file. For example, to run the buildout in offline mode, configuration file. For example, to run the buildout in offline mode,
...@@ -953,17 +959,20 @@ def main(args=None): ...@@ -953,17 +959,20 @@ def main(args=None):
verbosity = 0 verbosity = 0
options = [] options = []
windows_restart = False windows_restart = False
user_defaults = True
while args: while args:
if args[0][0] == '-': if args[0][0] == '-':
op = orig_op = args.pop(0) op = orig_op = args.pop(0)
op = op[1:] op = op[1:]
while op and op[0] in 'vqhW': while op and op[0] in 'vqhWU':
if op[0] == 'v': if op[0] == 'v':
verbosity += 10 verbosity += 10
elif op[0] == 'q': elif op[0] == 'q':
verbosity -= 10 verbosity -= 10
elif op[0] == 'W': elif op[0] == 'W':
windows_restart = True windows_restart = True
elif op[0] == 'U':
user_defaults = False
else: else:
_help() _help()
op = op[1:] op = op[1:]
...@@ -1004,7 +1013,8 @@ def main(args=None): ...@@ -1004,7 +1013,8 @@ def main(args=None):
try: try:
try: try:
buildout = Buildout(config_file, options, windows_restart) buildout = Buildout(config_file, options,
user_defaults, windows_restart)
getattr(buildout, command)(args) getattr(buildout, command)(args)
except zc.buildout.UserError, v: except zc.buildout.UserError, v:
_error(str(v)) _error(str(v))
......
...@@ -773,6 +773,22 @@ delimiter.) ...@@ -773,6 +773,22 @@ delimiter.)
op7 7 op7 7
recipe recipes:debug recipe recipes:debug
A buildout command-line argument, -U, can be used to suppress reading
user defaults:
>>> print system(buildout + ' -U'),
buildout: Develop: /sample-buildout/recipes
buildout: Uninstalling debug
buildout: Installing debug
name base
op buildout
op1 b1 1
op2 b2 2
op3 b2 3
op4 b3 4
op5 b3base 5
recipe recipes:debug
>>> del os.environ['HOME'] >>> del os.environ['HOME']
Log level Log level
...@@ -1051,7 +1067,7 @@ Command-line usage ...@@ -1051,7 +1067,7 @@ Command-line usage
A number of arguments can be given on the buildout command line. The A number of arguments can be given on the buildout command line. The
command usage is:: command usage is::
buildout [-h] [-c file] [-q] [-v] [assignments] [command [command arguments]] buildout [-h] [-c file] [-q] [-v] [-U] [assignments] [command [command arguments]]
The -h (or --help) option causes basic usage information to be The -h (or --help) option causes basic usage information to be
printed. If this option is used, then all other options are ignored. printed. If this option is used, then all other options are ignored.
...@@ -1064,6 +1080,8 @@ verbosity is used to adjust the logging level. The verbosity is ...@@ -1064,6 +1080,8 @@ verbosity is used to adjust the logging level. The verbosity is
subtracted from the numeric value of the log-level option specified in subtracted from the numeric value of the log-level option specified in
the configuration file. the configuration file.
The -U option suppresses reading user defaults.
Assignments are of the form:: Assignments are of the form::
section_name:option_name=value section_name:option_name=value
...@@ -1593,6 +1611,48 @@ connected to the internet. It also makes buildouts run much ...@@ -1593,6 +1611,48 @@ connected to the internet. It also makes buildouts run much
faster. This option is typically given as a command-line option faster. This option is typically given as a command-line option
``buildout:offline=true``. ``buildout:offline=true``.
Controlling the installation database
-------------------------------------
The buildout installed uption is used to specify the file used to save
information on installed parts. This option is initialized to
".installed.cfg", but it can be overridded in the configuration file
or on the command line:
>>> os.remove('.installed.cfg')
>>> print system(buildout+' buildout:installed=inst.cfg'),
>>> ls(sample_buildout)
- b1.cfg
- b2.cfg
- base.cfg
d bin
- buildout.cfg
d develop-eggs
d eggs
- inst.cfg
d parts
d recipes
The installation database can be disabled by supplying an empty
buildout installed opttion:
>>> os.remove('inst.cfg')
>>> print system(buildout+' buildout:installed='),
>>> ls(sample_buildout)
- b1.cfg
- b2.cfg
- base.cfg
d bin
- buildout.cfg
d develop-eggs
d eggs
d parts
d recipes
Extensions Extensions
---------- ----------
......
...@@ -398,6 +398,10 @@ Options: ...@@ -398,6 +398,10 @@ Options:
Specify the path to the buildout configuration file to be used. Specify the path to the buildout configuration file to be used.
This defaults to the file named "buildout.cfg" in the current This defaults to the file named "buildout.cfg" in the current
working directory. working directory.
<BLANKLINE>
-U
<BLANKLINE>
Don't read user defaults.
<BLANKLINE> <BLANKLINE>
Assignments are of the form: section:option=value and are used to Assignments are of the form: section:option=value and are used to
provide configuration options that override those given in the provide configuration options that override those given in the
...@@ -445,6 +449,10 @@ Options: ...@@ -445,6 +449,10 @@ Options:
Specify the path to the buildout configuration file to be used. Specify the path to the buildout configuration file to be used.
This defaults to the file named "buildout.cfg" in the current This defaults to the file named "buildout.cfg" in the current
working directory. working directory.
<BLANKLINE>
-U
<BLANKLINE>
Don't read user defaults.
<BLANKLINE> <BLANKLINE>
Assignments are of the form: section:option=value and are used to Assignments are of the form: section:option=value and are used to
provide configuration options that override those given in the provide configuration options that override those given in the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment