Merge "Adds an --overwrite flag to always overwrite install dir." am: 7c7b7d0ea8 am: 254f45a4dd
Original change: https://android-review.googlesource.com/c/platform/development/+/1405278 Change-Id: I5e03005a38bba83ea2e2cfc47be8e4d7d04b66a5
This commit is contained in:
@@ -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,16 +410,21 @@ 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):
|
||||||
resp = input('Directory {} already exists. IT WILL BE REMOVED.\n'
|
def remove_dir():
|
||||||
'Are you sure? (yes/no): '.format(install_dir))
|
|
||||||
if resp == 'yes':
|
|
||||||
logging.info('Removing {}'.format(install_dir))
|
logging.info('Removing {}'.format(install_dir))
|
||||||
check_call(['rm', '-rf', install_dir])
|
check_call(['rm', '-rf', install_dir])
|
||||||
elif resp == 'no':
|
if args.overwrite:
|
||||||
logging.info('Cancelled snapshot install.')
|
remove_dir()
|
||||||
return
|
|
||||||
else:
|
else:
|
||||||
raise ValueError('Did not understand: ' + resp)
|
resp = input('Directory {} already exists. IT WILL BE REMOVED.\n'
|
||||||
|
'Are you sure? (yes/no): '.format(install_dir))
|
||||||
|
if resp == 'yes':
|
||||||
|
remove_dir()
|
||||||
|
elif resp == 'no':
|
||||||
|
logging.info('Cancelled snapshot install.')
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
raise ValueError('Did not understand: ' + resp)
|
||||||
check_call(['mkdir', '-p', install_dir])
|
check_call(['mkdir', '-p', install_dir])
|
||||||
|
|
||||||
install_artifacts(
|
install_artifacts(
|
||||||
|
|||||||
Reference in New Issue
Block a user