mirror of
https://github.com/fosskers/cargo-aur.git
synced 2026-03-11 17:34:53 -05:00
Warn if the MUSL target is missing when using --musl
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
#### Added
|
||||
|
||||
- When using `--musl`, the user is warned if they don't have the
|
||||
`x86_64-unknown-linux-musl` target installed.
|
||||
|
||||
#### Changed
|
||||
|
||||
- Run `strip` on the release binary before `tar`ring it.
|
||||
|
||||
25
src/main.rs
25
src/main.rs
@@ -1,9 +1,11 @@
|
||||
use anyhow::anyhow;
|
||||
use gumdrop::{Options, ParsingStyle};
|
||||
use hmac_sha256::Hash;
|
||||
use itertools::Itertools;
|
||||
use serde_derive::Deserialize;
|
||||
use std::fs;
|
||||
use std::process::{self, Command};
|
||||
use std::str;
|
||||
|
||||
#[derive(Options)]
|
||||
struct Args {
|
||||
@@ -79,6 +81,12 @@ fn main() {
|
||||
}
|
||||
|
||||
fn work(args: Args) -> anyhow::Result<()> {
|
||||
// We can't proceed if the user has specified `--musl` but doesn't have the
|
||||
// target installed.
|
||||
if args.musl {
|
||||
musl_check()?
|
||||
}
|
||||
|
||||
let config = cargo_config()?;
|
||||
release_build(args.musl)?;
|
||||
tarball(args.musl, &config.package)?;
|
||||
@@ -179,3 +187,20 @@ fn sha256sum(package: &Package) -> anyhow::Result<String> {
|
||||
let hex = digest.iter().map(|u| format!("{:02x}", u)).collect();
|
||||
Ok(hex)
|
||||
}
|
||||
|
||||
/// Does the user have the `x86_64-unknown-linux-musl` target installed?
|
||||
fn musl_check() -> anyhow::Result<()> {
|
||||
let args = vec!["target", "list", "--installed"];
|
||||
let output = Command::new("rustup").args(args).output()?.stdout;
|
||||
let installed = str::from_utf8(&output)?
|
||||
.lines()
|
||||
.any(|tc| tc == "x86_64-unknown-linux-musl");
|
||||
|
||||
if installed {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(anyhow!(
|
||||
"Missing target! Try: rustup target add x86_64-unknown-linux-musl"
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user