diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index cc10d67c551db2da45c32aedc8ca7ffd112f19ab..5cbaf03d02908f38844f80d96803dd551cba2e44 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -894,29 +894,6 @@ fn run(self, builder: &Builder<'_>) -> GeneratedTarball { } } -// We have to run a few shell scripts, which choke quite a bit on both `\` -// characters and on `C:\` paths, so normalize both of them away. -pub fn sanitize_sh(path: &Path) -> String { - let path = path.to_str().unwrap().replace("\\", "/"); - return change_drive(unc_to_lfs(&path)).unwrap_or(path); - - fn unc_to_lfs(s: &str) -> &str { - s.strip_prefix("//?/").unwrap_or(s) - } - - fn change_drive(s: &str) -> Option { - let mut ch = s.chars(); - let drive = ch.next().unwrap_or('C'); - if ch.next() != Some(':') { - return None; - } - if ch.next() != Some('/') { - return None; - } - Some(format!("/{}/{}", drive, &s[drive.len_utf8() + 2..])) - } -} - #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Cargo { pub compiler: Compiler, diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index 08e37a16279903a8a7f080cf7f6bcdcdab1826f4..6e49f39ffb6aa5924aa1d6a00b86725c85951c9e 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -5,12 +5,12 @@ use std::env; use std::fs; -use std::path::{Component, PathBuf}; +use std::path::{Component, Path, PathBuf}; use std::process::Command; use crate::util::t; -use crate::dist::{self, sanitize_sh}; +use crate::dist; use crate::tarball::GeneratedTarball; use crate::Compiler; @@ -22,6 +22,29 @@ #[cfg(not(target_os = "illumos"))] const SHELL: &str = "sh"; +// We have to run a few shell scripts, which choke quite a bit on both `\` +// characters and on `C:\` paths, so normalize both of them away. +fn sanitize_sh(path: &Path) -> String { + let path = path.to_str().unwrap().replace("\\", "/"); + return change_drive(unc_to_lfs(&path)).unwrap_or(path); + + fn unc_to_lfs(s: &str) -> &str { + s.strip_prefix("//?/").unwrap_or(s) + } + + fn change_drive(s: &str) -> Option { + let mut ch = s.chars(); + let drive = ch.next().unwrap_or('C'); + if ch.next() != Some(':') { + return None; + } + if ch.next() != Some('/') { + return None; + } + Some(format!("/{}/{}", drive, &s[drive.len_utf8() + 2..])) + } +} + fn install_sh( builder: &Builder<'_>, package: &str,