Commit f49d495b authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Add 'dry_run' option (-d) and 'ignore __buildout_signature__ difference' option (-S).

parent c5036bf4
......@@ -219,6 +219,8 @@ _buildout_default_options = _annotate_section({
'log-level': 'INFO',
'newest': 'true',
'offline': 'false',
'dry_run': 'false',
'check_signature': 'true',
'parts-directory': 'parts',
'prefer-final': 'false',
'python': 'buildout',
......@@ -328,6 +330,8 @@ class Buildout(UserDict.DictMixin):
self._logger = logging.getLogger('zc.buildout')
self.offline = (buildout_section['offline'] == 'true')
self.newest = (buildout_section['newest'] == 'true')
self.dry_run = (buildout_section['dry_run'] == 'true')
self.check_signature = (buildout_section['check_signature'] == 'true')
self.accept_buildout_test_releases = (
buildout_section['accept-buildout-test-releases'] == 'true')
......@@ -705,7 +709,16 @@ class Buildout(UserDict.DictMixin):
if part in install_parts:
old_options = installed_part_options[part].copy()
installed_files = old_options.pop('__buildout_installed__')
new_options = self.get(part)
new_options = self.get(part).copy()
if not self.check_signature:
old_signature = old_options.pop(
'__buildout_signature__', None)
new_signature = new_options.pop(
'__buildout_signature__', None)
if old_signature != new_signature:
self._logger.info(
'[%s]: __buildout_signature__ is different '
'but ignored.' % part)
if old_options == new_options:
# The options are the same, but are all of the
# installed files still there? If not, we should
......@@ -750,6 +763,8 @@ class Buildout(UserDict.DictMixin):
if part in installed_parts: # update
__doing__ = 'Updating %s.', part
self._logger.info(*__doing__)
if self.dry_run:
continue
old_options = installed_part_options[part]
old_installed_files = old_options['__buildout_installed__']
......@@ -775,6 +790,8 @@ class Buildout(UserDict.DictMixin):
else: # install
__doing__ = 'Installing %s.', part
self._logger.info(*__doing__)
if self.dry_run:
continue
installed_files = self[part]._call(recipe.install)
if installed_files is None:
self._logger.warning(
......@@ -794,7 +811,9 @@ class Buildout(UserDict.DictMixin):
finally:
installed_path = self['buildout']['installed']
if installed_parts:
if self.dry_run:
pass
elif installed_parts:
new = StringIO()
buildout = installed_part_options['buildout']
buildout['parts'] = ' '.join(installed_parts)
......@@ -830,6 +849,8 @@ class Buildout(UserDict.DictMixin):
# uninstall part
__doing__ = 'Uninstalling %s.', part
self._logger.info(*__doing__)
if self.dry_run:
return
# run uninstall recipe
recipe, entry = _recipe(installed_part_options[part])
......@@ -1959,6 +1980,17 @@ Options:
Squelch warnings about using an executable with a broken -S
implementation.
-d
Dry-run mode. With this setting, buildout will display what will
be uninstalled and what will be installed without doing anything
in reality.
-S
Ignore __buildout_signature__ difference in comparing with the
previously installed state.
Assignments are of the form: section:option=value and are used to
provide configuration options that override those given in the
configuration file. For example, to run the buildout in offline mode,
......@@ -2029,7 +2061,7 @@ def main(args=None):
if args[0][0] == '-':
op = orig_op = args.pop(0)
op = op[1:]
while op and op[0] in 'vqhWUoOnNDAs':
while op and op[0] in 'vqhWUoOnNDAsdS':
if op[0] == 'v':
verbosity += 10
elif op[0] == 'q':
......@@ -2050,6 +2082,10 @@ def main(args=None):
debug = True
elif op[0] == 's':
ignore_broken_dash_s = True
elif op[0] == 'd':
options.append(('buildout', 'dry_run', 'true'))
elif op[0] == 'S':
options.append(('buildout', 'check_signature', 'false'))
else:
_help()
op = op[1:]
......
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