Merge "Adds an --overwrite flag to always overwrite install dir." am: 7c7b7d0ea8 am: 254f45a4dd am: f244dc9292 am: d44e2870ab

Original change: https://android-review.googlesource.com/c/platform/development/+/1405278

Change-Id: I5767e5f7274d76dc5fec4954c6652d1f4880d5ab
This commit is contained in:
Treehugger Robot
2020-08-20 01:01:09 +00:00
committed by Automerger Merge Worker

View File

@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
"""Installs vendor snapshot under prebuilts/vendor/v{version}.""" """Unzips and installs the vendor snapshot."""
import argparse import argparse
import glob import glob
@@ -359,6 +359,11 @@ def get_args():
help=( help=(
'Base directory to which vendor snapshot artifacts are installed. ' 'Base directory to which vendor snapshot artifacts are installed. '
'Example: --install-dir vendor/<company name>/vendor_snapshot/v30')) 'Example: --install-dir vendor/<company name>/vendor_snapshot/v30'))
parser.add_argument(
'--overwrite',
action='store_true',
help=(
'If provided, does not ask before overwriting the install-dir.'))
parser.add_argument( parser.add_argument(
'-v', '-v',
@@ -405,11 +410,16 @@ def main():
install_dir = os.path.expanduser(args.install_dir) install_dir = os.path.expanduser(args.install_dir)
if os.path.exists(install_dir): if os.path.exists(install_dir):
def remove_dir():
logging.info('Removing {}'.format(install_dir))
check_call(['rm', '-rf', install_dir])
if args.overwrite:
remove_dir()
else:
resp = input('Directory {} already exists. IT WILL BE REMOVED.\n' resp = input('Directory {} already exists. IT WILL BE REMOVED.\n'
'Are you sure? (yes/no): '.format(install_dir)) 'Are you sure? (yes/no): '.format(install_dir))
if resp == 'yes': if resp == 'yes':
logging.info('Removing {}'.format(install_dir)) remove_dir()
check_call(['rm', '-rf', install_dir])
elif resp == 'no': elif resp == 'no':
logging.info('Cancelled snapshot install.') logging.info('Cancelled snapshot install.')
return return