Update x11/sddm to version 0.18.1
[dports.git] / lang / rust / files / patch-src_bootstrap_bootstrap.py
1 https://github.com/rust-lang/rust/commit/8d56bcc59c92
2
3 --- src/bootstrap/bootstrap.py.orig     2019-11-04 15:45:21 UTC
4 +++ src/bootstrap/bootstrap.py
5 @@ -102,10 +102,10 @@ def verify(path, sha_path, verbose):
6      return verified
7  
8  
9 -def unpack(tarball, dst, verbose=False, match=None):
10 +def unpack(tarball, tarball_suffix, dst, verbose=False, match=None):
11      """Unpack the given tarball file"""
12      print("extracting", tarball)
13 -    fname = os.path.basename(tarball).replace(".tar.gz", "")
14 +    fname = os.path.basename(tarball).replace(tarball_suffix, "")
15      with contextlib.closing(tarfile.open(tarball)) as tar:
16          for member in tar.getnames():
17              if "/" not in member:
18 @@ -331,6 +331,18 @@ class RustBuild(object):
19          self.use_vendored_sources = ''
20          self.verbose = False
21  
22 +        def support_xz():
23 +            try:
24 +                with tempfile.NamedTemporaryFile(delete=False) as temp_file:
25 +                    temp_path = temp_file.name
26 +                with tarfile.open(temp_path, "w:xz") as tar:
27 +                    pass
28 +                return True
29 +            except tarfile.CompressionError:
30 +                return False
31 +
32 +        self.tarball_suffix = '.tar.xz' if support_xz() else '.tar.gz'
33 +
34      def download_stage0(self):
35          """Fetch the build system for Rust, written in Rust
36  
37 @@ -349,12 +361,13 @@ class RustBuild(object):
38                   self.program_out_of_date(self.rustc_stamp())):
39              if os.path.exists(self.bin_root()):
40                  shutil.rmtree(self.bin_root())
41 -            filename = "rust-std-{}-{}.tar.gz".format(
42 -                rustc_channel, self.build)
43 +            filename = "rust-std-{}-{}{}".format(
44 +                rustc_channel, self.build, self.tarball_suffix)
45              pattern = "rust-std-{}".format(self.build)
46              self._download_stage0_helper(filename, pattern)
47  
48 -            filename = "rustc-{}-{}.tar.gz".format(rustc_channel, self.build)
49 +            filename = "rustc-{}-{}{}".format(rustc_channel, self.build,
50 +                                              self.tarball_suffix)
51              self._download_stage0_helper(filename, "rustc")
52              self.fix_executable("{}/bin/rustc".format(self.bin_root()))
53              self.fix_executable("{}/bin/rustdoc".format(self.bin_root()))
54 @@ -365,14 +378,15 @@ class RustBuild(object):
55              # libraries/binaries that are included in rust-std with
56              # the system MinGW ones.
57              if "pc-windows-gnu" in self.build:
58 -                filename = "rust-mingw-{}-{}.tar.gz".format(
59 -                    rustc_channel, self.build)
60 +                filename = "rust-mingw-{}-{}{}".format(
61 +                    rustc_channel, self.build, self.tarball_suffix)
62                  self._download_stage0_helper(filename, "rust-mingw")
63  
64          if self.cargo().startswith(self.bin_root()) and \
65                  (not os.path.exists(self.cargo()) or
66                   self.program_out_of_date(self.cargo_stamp())):
67 -            filename = "cargo-{}-{}.tar.gz".format(cargo_channel, self.build)
68 +            filename = "cargo-{}-{}{}".format(cargo_channel, self.build,
69 +                                              self.tarball_suffix)
70              self._download_stage0_helper(filename, "cargo")
71              self.fix_executable("{}/bin/cargo".format(self.bin_root()))
72              with output(self.cargo_stamp()) as cargo_stamp:
73 @@ -388,7 +402,7 @@ class RustBuild(object):
74          tarball = os.path.join(rustc_cache, filename)
75          if not os.path.exists(tarball):
76              get("{}/{}".format(url, filename), tarball, verbose=self.verbose)
77 -        unpack(tarball, self.bin_root(), match=pattern, verbose=self.verbose)
78 +        unpack(tarball, self.tarball_suffix, self.bin_root(), match=pattern, verbose=self.verbose)
79  
80      @staticmethod
81      def fix_executable(fname):