parent
fb788e375a
commit
caacef29e6
@ -8,7 +8,7 @@
|
|||||||
use super::build_sysroot::{BUILD_SYSROOT, ORIG_BUILD_SYSROOT, SYSROOT_RUSTC_VERSION, SYSROOT_SRC};
|
use super::build_sysroot::{BUILD_SYSROOT, ORIG_BUILD_SYSROOT, SYSROOT_RUSTC_VERSION, SYSROOT_SRC};
|
||||||
use super::path::{Dirs, RelPath};
|
use super::path::{Dirs, RelPath};
|
||||||
use super::rustc_info::{get_file_name, get_rustc_version};
|
use super::rustc_info::{get_file_name, get_rustc_version};
|
||||||
use super::utils::{copy_dir_recursively, spawn_and_wait, Compiler};
|
use super::utils::{copy_dir_recursively, retry_spawn_and_wait, spawn_and_wait, Compiler};
|
||||||
|
|
||||||
pub(crate) fn prepare(dirs: &Dirs) {
|
pub(crate) fn prepare(dirs: &Dirs) {
|
||||||
if RelPath::DOWNLOAD.to_path(dirs).exists() {
|
if RelPath::DOWNLOAD.to_path(dirs).exists() {
|
||||||
@ -140,8 +140,22 @@ fn clone_repo_shallow_github(dirs: &Dirs, download_dir: &Path, user: &str, repo:
|
|||||||
|
|
||||||
// Download zip archive
|
// Download zip archive
|
||||||
let mut download_cmd = Command::new("curl");
|
let mut download_cmd = Command::new("curl");
|
||||||
download_cmd.arg("--location").arg("--output").arg(&archive_file).arg(archive_url);
|
download_cmd
|
||||||
spawn_and_wait(download_cmd);
|
.arg("--max-time")
|
||||||
|
.arg("600")
|
||||||
|
.arg("-y")
|
||||||
|
.arg("30")
|
||||||
|
.arg("-Y")
|
||||||
|
.arg("10")
|
||||||
|
.arg("--connect-timeout")
|
||||||
|
.arg("30")
|
||||||
|
.arg("--continue-at")
|
||||||
|
.arg("-")
|
||||||
|
.arg("--location")
|
||||||
|
.arg("--output")
|
||||||
|
.arg(&archive_file)
|
||||||
|
.arg(archive_url);
|
||||||
|
retry_spawn_and_wait(5, download_cmd);
|
||||||
|
|
||||||
// Unpack tar archive
|
// Unpack tar archive
|
||||||
let mut unpack_cmd = Command::new("tar");
|
let mut unpack_cmd = Command::new("tar");
|
||||||
|
@ -188,6 +188,22 @@ pub(crate) fn spawn_and_wait(mut cmd: Command) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Based on the retry function in rust's src/ci/shared.sh
|
||||||
|
#[track_caller]
|
||||||
|
pub(crate) fn retry_spawn_and_wait(tries: u64, mut cmd: Command) {
|
||||||
|
for i in 1..tries+1 {
|
||||||
|
if i != 1 {
|
||||||
|
println!("Command failed. Attempt {i}/{tries}:");
|
||||||
|
}
|
||||||
|
if cmd.spawn().unwrap().wait().unwrap().success() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::thread::sleep(std::time::Duration::from_secs(i * 5));
|
||||||
|
}
|
||||||
|
println!("The command has failed after {tries} attempts.");
|
||||||
|
process::exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub(crate) fn spawn_and_wait_with_input(mut cmd: Command, input: String) -> String {
|
pub(crate) fn spawn_and_wait_with_input(mut cmd: Command, input: String) -> String {
|
||||||
let mut child = cmd
|
let mut child = cmd
|
||||||
|
Loading…
Reference in New Issue
Block a user