1#!/usr/bin/env python 2# 3# Copyright 2017 Google Inc. 4# 5# Use of this source code is governed by a BSD-style license that can be 6# found in the LICENSE file. 7 8 9"""Create the asset.""" 10 11import argparse 12import os 13import subprocess 14import sys 15 16FILE_DIR = os.path.dirname(os.path.abspath(__file__)) 17INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir)) 18sys.path.insert(0, INFRA_BOTS_DIR) 19import utils 20 21URL = 'https://github.com/bazelbuild/bazel/releases/download/4.1.0/bazel-4.1.0-installer-linux-x86_64.sh' 22INSTALLER_SCRIPT = URL.split('/')[-1] 23 24 25def create_asset(target_dir): 26 """Create the asset.""" 27 with utils.tmp_dir(): 28 subprocess.call(['wget', URL]) 29 subprocess.call(['sh', INSTALLER_SCRIPT, '--prefix=' + target_dir]) 30 31 32def main(): 33 if 'linux' not in sys.platform: 34 print('This script only runs on Linux.', file=sys.stderr) 35 sys.exit(1) 36 parser = argparse.ArgumentParser() 37 parser.add_argument('--target_dir', '-t', required=True) 38 args = parser.parse_args() 39 create_asset(args.target_dir) 40 41 42if __name__ == '__main__': 43 main() 44