]> git.proxmox.com Git - rustc.git/blob - src/etc/get-stage0.py
New upstream version 1.12.0+dfsg1
[rustc.git] / src / etc / get-stage0.py
1 #!/usr/bin/env python
2 #
3 # Copyright 2016 The Rust Project Developers. See the COPYRIGHT
4 # file at the top-level directory of this distribution and at
5 # http://rust-lang.org/COPYRIGHT.
6 #
7 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10 # option. This file may not be copied, modified, or distributed
11 # except according to those terms.
12
13 import os
14 import sys
15
16 path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../bootstrap"))
17 sys.path.append(path)
18
19 import bootstrap
20
21 def main(triple):
22 src_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
23 data = bootstrap.stage0_data(src_root)
24
25 channel, date = data['rustc'].split('-', 1)
26
27 dl_dir = 'dl'
28 if not os.path.exists(dl_dir):
29 os.makedirs(dl_dir)
30
31 filename = 'rustc-{}-{}.tar.gz'.format(channel, triple)
32 url = 'https://static.rust-lang.org/dist/{}/{}'.format(date, filename)
33 dst = dl_dir + '/' + filename
34 bootstrap.get(url, dst)
35
36 stage0_dst = triple + '/stage0'
37 if os.path.exists(stage0_dst):
38 for root, _, files in os.walk(stage0_dst):
39 for f in files:
40 os.unlink(os.path.join(root, f))
41 else:
42 os.makedirs(stage0_dst)
43 bootstrap.unpack(dst, stage0_dst, match='rustc', verbose=True)
44
45 if __name__ == '__main__':
46 main(sys.argv[1])