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({ ...@@ -219,6 +219,8 @@ _buildout_default_options = _annotate_section({
'log-level': 'INFO', 'log-level': 'INFO',
'newest': 'true', 'newest': 'true',
'offline': 'false', 'offline': 'false',
'dry_run': 'false',
'check_signature': 'true',
'parts-directory': 'parts', 'parts-directory': 'parts',
'prefer-final': 'false', 'prefer-final': 'false',
'python': 'buildout', 'python': 'buildout',
...@@ -328,6 +330,8 @@ class Buildout(UserDict.DictMixin): ...@@ -328,6 +330,8 @@ class Buildout(UserDict.DictMixin):
self._logger = logging.getLogger('zc.buildout') self._logger = logging.getLogger('zc.buildout')
self.offline = (buildout_section['offline'] == 'true') self.offline = (buildout_section['offline'] == 'true')
self.newest = (buildout_section['newest'] == '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 = ( self.accept_buildout_test_releases = (
buildout_section['accept-buildout-test-releases'] == 'true') buildout_section['accept-buildout-test-releases'] == 'true')
...@@ -705,7 +709,16 @@ class Buildout(UserDict.DictMixin): ...@@ -705,7 +709,16 @@ class Buildout(UserDict.DictMixin):
if part in install_parts: if part in install_parts:
old_options = installed_part_options[part].copy() old_options = installed_part_options[part].copy()
installed_files = old_options.pop('__buildout_installed__') 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: if old_options == new_options:
# The options are the same, but are all of the # The options are the same, but are all of the
# installed files still there? If not, we should # installed files still there? If not, we should
...@@ -750,6 +763,8 @@ class Buildout(UserDict.DictMixin): ...@@ -750,6 +763,8 @@ class Buildout(UserDict.DictMixin):
if part in installed_parts: # update if part in installed_parts: # update
__doing__ = 'Updating %s.', part __doing__ = 'Updating %s.', part
self._logger.info(*__doing__) self._logger.info(*__doing__)
if self.dry_run:
continue
old_options = installed_part_options[part] old_options = installed_part_options[part]
old_installed_files = old_options['__buildout_installed__'] old_installed_files = old_options['__buildout_installed__']
...@@ -775,6 +790,8 @@ class Buildout(UserDict.DictMixin): ...@@ -775,6 +790,8 @@ class Buildout(UserDict.DictMixin):
else: # install else: # install
__doing__ = 'Installing %s.', part __doing__ = 'Installing %s.', part
self._logger.info(*__doing__) self._logger.info(*__doing__)
if self.dry_run:
continue
installed_files = self[part]._call(recipe.install) installed_files = self[part]._call(recipe.install)
if installed_files is None: if installed_files is None:
self._logger.warning( self._logger.warning(
...@@ -794,7 +811,9 @@ class Buildout(UserDict.DictMixin): ...@@ -794,7 +811,9 @@ class Buildout(UserDict.DictMixin):
finally: finally:
installed_path = self['buildout']['installed'] installed_path = self['buildout']['installed']
if installed_parts: if self.dry_run:
pass
elif installed_parts:
new = StringIO() new = StringIO()
buildout = installed_part_options['buildout'] buildout = installed_part_options['buildout']
buildout['parts'] = ' '.join(installed_parts) buildout['parts'] = ' '.join(installed_parts)
...@@ -830,6 +849,8 @@ class Buildout(UserDict.DictMixin): ...@@ -830,6 +849,8 @@ class Buildout(UserDict.DictMixin):
# uninstall part # uninstall part
__doing__ = 'Uninstalling %s.', part __doing__ = 'Uninstalling %s.', part
self._logger.info(*__doing__) self._logger.info(*__doing__)
if self.dry_run:
return
# run uninstall recipe # run uninstall recipe
recipe, entry = _recipe(installed_part_options[part]) recipe, entry = _recipe(installed_part_options[part])
...@@ -1959,6 +1980,17 @@ Options: ...@@ -1959,6 +1980,17 @@ Options:
Squelch warnings about using an executable with a broken -S Squelch warnings about using an executable with a broken -S
implementation. 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 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,
...@@ -2029,7 +2061,7 @@ def main(args=None): ...@@ -2029,7 +2061,7 @@ def main(args=None):
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 'vqhWUoOnNDAs': while op and op[0] in 'vqhWUoOnNDAsdS':
if op[0] == 'v': if op[0] == 'v':
verbosity += 10 verbosity += 10
elif op[0] == 'q': elif op[0] == 'q':
...@@ -2050,6 +2082,10 @@ def main(args=None): ...@@ -2050,6 +2082,10 @@ def main(args=None):
debug = True debug = True
elif op[0] == 's': elif op[0] == 's':
ignore_broken_dash_s = True 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: else:
_help() _help()
op = op[1:] 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