blob: 2d083628283f8b0e3524ee6b28e8c5aefd8dc4ff [file] [log] [blame]
Mads Ager418d1ca2017-05-22 09:35:49 +02001#!/usr/bin/env python
2# Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file
3# for details. All rights reserved. Use of this source code is governed by a
4# BSD-style license that can be found in the LICENSE file.
5
6# Script for uploading to x20 as a dependency in the same way we use cloud
7# storage.
8
9import optparse
10import os
11import shutil
12import stat
13import subprocess
14import sys
15import tarfile
16import utils
17
Jeffrey van Gogh5dac4482018-01-24 02:36:38 -080018GMSCORE_DEPS = '/google/data/rw/teams/r8/deps'
Mads Ager418d1ca2017-05-22 09:35:49 +020019
20def parse_options():
21 return optparse.OptionParser().parse_args()
22
Jean-Marie Henaff7a64eec2018-05-31 15:30:35 +020023def uploadFile(filename, dest):
24 print 'Uploading to %s' % dest
25 shutil.copyfile(filename, dest)
26 subprocess.check_call(['chmod', '664', dest])
Mads Ager418d1ca2017-05-22 09:35:49 +020027
28def Main():
29 (options, args) = parse_options()
30 assert len(args) == 1
31 name = args[0]
32 print 'Creating archive for %s' % name
33 if not name in os.listdir('.'):
34 print 'You must be standing directly below the directory you are uploading'
35 return 1
Jean-Marie Henaff7a64eec2018-05-31 15:30:35 +020036 filename = utils.create_archive(name)
Mads Ager418d1ca2017-05-22 09:35:49 +020037 sha1 = utils.get_sha1(filename)
38 dest = os.path.join(GMSCORE_DEPS, sha1)
Jean-Marie Henaff7a64eec2018-05-31 15:30:35 +020039 uploadFile(filename, dest)
Mads Ager418d1ca2017-05-22 09:35:49 +020040 sha1_file = '%s.sha1' % filename
41 with open(sha1_file, 'w') as output:
42 output.write(sha1)
43 print 'Sha (%s) written to: %s' % (sha1, sha1_file)
44
45if __name__ == '__main__':
46 sys.exit(Main())