blob: 3ef7b7310bc19b6e1982e11fb20bffe26a96b795 [file] [log] [blame]
Ian Zernydcb172e2022-02-22 15:36:45 +01001#!/usr/bin/env python3
Mads Ager418d1ca2017-05-22 09:35:49 +02002# 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
Christoffer Quist Adamsen2434a4d2023-10-16 11:29:03 +020020
Mads Ager418d1ca2017-05-22 09:35:49 +020021def parse_options():
Christoffer Quist Adamsen2434a4d2023-10-16 11:29:03 +020022 return optparse.OptionParser().parse_args()
23
Mads Ager418d1ca2017-05-22 09:35:49 +020024
Jean-Marie Henaff7a64eec2018-05-31 15:30:35 +020025def uploadFile(filename, dest):
Christoffer Quist Adamsen2434a4d2023-10-16 11:29:03 +020026 print('Uploading to %s' % dest)
27 shutil.copyfile(filename, dest)
28 subprocess.check_call(['chmod', '664', dest])
29
Mads Ager418d1ca2017-05-22 09:35:49 +020030
31def Main():
Christoffer Quist Adamsen2434a4d2023-10-16 11:29:03 +020032 (options, args) = parse_options()
33 assert len(args) == 1
34 name = args[0]
35 print('Creating archive for %s' % name)
36 if not name in os.listdir('.'):
37 print(
38 'You must be standing directly below the directory you are uploading'
39 )
40 return 1
41 filename = utils.create_archive(name)
42 sha1 = utils.get_sha1(filename)
43 dest = os.path.join(GMSCORE_DEPS, sha1)
44 uploadFile(filename, dest)
45 sha1_file = '%s.sha1' % filename
46 with open(sha1_file, 'w') as output:
47 output.write(sha1)
48 print('Sha (%s) written to: %s' % (sha1, sha1_file))
49
Mads Ager418d1ca2017-05-22 09:35:49 +020050
51if __name__ == '__main__':
Christoffer Quist Adamsen2434a4d2023-10-16 11:29:03 +020052 sys.exit(Main())