• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
11
12import argparse
13import os
14import subprocess
15
16NODE_URL = "https://nodejs.org/dist/v12.16.3/node-v12.16.3-linux-x64.tar.xz"
17NODE_EXTRACT_NAME = "node-v12.16.3-linux-x64"
18
19def create_asset(target_dir):
20  """Create the asset."""
21  p1 = subprocess.Popen(["curl", NODE_URL], stdout=subprocess.PIPE)
22  p2 = subprocess.Popen(["tar", "-C", target_dir, "-xJf" "-"], stdin=p1.stdout)
23  p1.stdout.close()  # Allow p1 to receive a SIGPIPE if p2 exits.
24  _,_ = p2.communicate()
25  os.rename(
26    os.path.join(target_dir, NODE_EXTRACT_NAME),
27    os.path.join(target_dir, "node")
28  )
29
30
31def main():
32  parser = argparse.ArgumentParser()
33  parser.add_argument('--target_dir', '-t', required=True)
34  args = parser.parse_args()
35  create_asset(args.target_dir)
36
37
38if __name__ == '__main__':
39  main()
40