OLD | NEW |
1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Implementation of the 'clean' chromite command.""" | 5 """Implementation of the 'clean' chromite command.""" |
6 | 6 |
7 # Python imports | 7 # Python imports |
8 import optparse | 8 import optparse |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 96 matching lines...) Loading... |
107 Args: | 107 Args: |
108 raw_argv: Command line arguments, including this command's name, but not | 108 raw_argv: Command line arguments, including this command's name, but not |
109 the chromite command name or chromite options. | 109 the chromite command name or chromite options. |
110 chroot_config: A SafeConfigParser for the chroot config; or None chromite | 110 chroot_config: A SafeConfigParser for the chroot config; or None chromite |
111 was called from within the chroot. | 111 was called from within the chroot. |
112 """ | 112 """ |
113 # Parse options for command... | 113 # Parse options for command... |
114 usage_str = ('usage: %%prog [chromite_options] %s [options] [target]' % | 114 usage_str = ('usage: %%prog [chromite_options] %s [options] [target]' % |
115 raw_argv[0]) | 115 raw_argv[0]) |
116 parser = optparse.OptionParser(usage=usage_str) | 116 parser = optparse.OptionParser(usage=usage_str) |
117 # This option won't work until a later CL plumbs in optparse | 117 parser.add_option('-y', '--yes', default=False, action='store_true', |
118 #parser.add_option('-y', '--yes', default=False, action='store_true', | 118 help='Answer "YES" to "are you sure?" questions.') |
119 #help='Answer "YES" to "are you sure?" questions.') | |
120 (options, argv) = parser.parse_args(raw_argv[1:]) | 119 (options, argv) = parser.parse_args(raw_argv[1:]) |
121 options.yes = False | |
122 | 120 |
123 # Make sure the chroot exists first, before possibly prompting for board... | 121 # Make sure the chroot exists first, before possibly prompting for board... |
124 # ...not really required, but nice for the user... | 122 # ...not really required, but nice for the user... |
125 if not cros_lib.IsInsideChroot(): | 123 if not cros_lib.IsInsideChroot(): |
126 if not utils.DoesChrootExist(chroot_config): | 124 if not utils.DoesChrootExist(chroot_config): |
127 cros_lib.Die("Nothing to clean: the chroot doesn't exist.\n %s" % | 125 cros_lib.Die("Nothing to clean: the chroot doesn't exist.\n %s" % |
128 utils.GetChrootAbsDir(chroot_config)) | 126 utils.GetChrootAbsDir(chroot_config)) |
129 | 127 |
130 # Load the build config... | 128 # Load the build config... |
131 argv, build_config = utils.GetBuildConfigFromArgs(argv) | 129 argv, build_config = utils.GetBuildConfigFromArgs(argv) |
132 if argv: | 130 if argv: |
133 cros_lib.Die('Unknown arguments: %s' % ' '.join(argv)) | 131 cros_lib.Die('Unknown arguments: %s' % ' '.join(argv)) |
134 | 132 |
135 # If they do clean host, we'll delete the whole chroot | 133 # If they do clean host, we'll delete the whole chroot |
136 if build_config is None: | 134 if build_config is None: |
137 _DoDistClean(self.cros_env, chroot_config, options.yes) | 135 _DoDistClean(self.cros_env, chroot_config, options.yes) |
138 else: | 136 else: |
139 _DoClean(self.cros_env, chroot_config, build_config, options.yes) | 137 _DoClean(self.cros_env, chroot_config, build_config, options.yes) |
OLD | NEW |