Skip to content

Commit

Permalink
Ignore shebang of install.sh files (esp-rs#312)
Browse files Browse the repository at this point in the history
* fix: Remove -c argument

* feat: Split arguments and add checking result
  • Loading branch information
SergioGasquez committed Aug 11, 2023
1 parent 738d218 commit 142b992
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 18 deletions.
11 changes: 11 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,15 @@ pub enum Error {
#[diagnostic(code(espup::targets::unsupported_target))]
#[error("{} Target '{0}' is not supported", emoji::ERROR)]
UnsupportedTarget(String),

#[diagnostic(code(espup::toolchain::rust::rust))]
#[error("{} Failed to install 'rust' component of Xtensa Rust", emoji::ERROR)]
XtensaRust,

#[diagnostic(code(espup::toolchain::rust::rust_src))]
#[error(
"{} Failed to install 'rust-src' component of Xtensa Rust",
emoji::ERROR
)]
XtensaRustSrc,
}
54 changes: 36 additions & 18 deletions src/toolchain/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,28 @@ impl Installable for XtensaRust {
"{} Installing 'rust' component for Xtensa Rust toolchain",
emoji::WRENCH
);
let arguments = format!(
"{}/rust-nightly-{}/install.sh --destdir={} --prefix='' --without=rust-docs-json-preview,rust-docs --disable-ldconfig",
temp_rust_dir,
&self.host_triple,
self.toolchain_destination.display()
);

Command::new("/usr/bin/env")
.args(["bash", "-c", &arguments])
if !Command::new("/usr/bin/env")
.arg("bash")
.arg(format!(
"{}/rust-nightly-{}/install.sh",
temp_rust_dir, &self.host_triple,
))
.arg(format!(
"--destdir={}",
self.toolchain_destination.display()
))
.arg("--prefix=''")
.arg("--without=rust-docs-json-preview,rust-docs")
.arg("--disable-ldconfig")
.stdout(Stdio::null())
.output()?;
.output()?
.status
.success()
{
Self::uninstall(&self.toolchain_destination)?;
return Err(Error::XtensaRust);
}

let temp_rust_src_dir = tempfile::TempDir::new()
.unwrap()
Expand All @@ -257,16 +268,23 @@ impl Installable for XtensaRust {
"{} Installing 'rust-src' component for Xtensa Rust toolchain",
emoji::WRENCH
);
let arguments = format!(
"{}/rust-src-nightly/install.sh --destdir={} --prefix='' --disable-ldconfig",
temp_rust_src_dir,
self.toolchain_destination.display()
);

Command::new("/usr/bin/env")
.args(["bash", "-c", &arguments])
if !Command::new("/usr/bin/env")
.arg("bash")
.arg(format!("{}/rust-src-nightly/install.sh", temp_rust_src_dir))
.arg(format!(
"--destdir={}",
self.toolchain_destination.display()
))
.arg("--prefix=''")
.arg("--disable-ldconfig")
.stdout(Stdio::null())
.output()?;
.output()?
.status
.success()
{
Self::uninstall(&self.toolchain_destination)?;
return Err(Error::XtensaRustSrc);
}
}
// Some platfroms like Windows are available in single bundle rust + src, because install
// script in dist is not available for the plaform. It's sufficient to extract the toolchain
Expand Down

0 comments on commit 142b992

Please sign in to comment.