mirror of
https://github.com/fosskers/cargo-aur.git
synced 2026-03-24 23:39:42 -05:00
Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6f9faefdd | ||
|
|
8dbdc1ab71 | ||
|
|
b7eb36b74d | ||
|
|
5f1a44ab30 | ||
|
|
b9e6f8ce6d | ||
|
|
deb0768f3b | ||
|
|
113a00c206 | ||
|
|
a676669e63 | ||
|
|
0ea8be5a73 | ||
|
|
b8e33deed7 | ||
|
|
ffed75dcb0 | ||
|
|
6dd2e4c674 | ||
|
|
6c40291afe | ||
|
|
e1c9ff6fe1 | ||
|
|
64acbe589a | ||
|
|
ee5ee91cbc | ||
|
|
42f34e25dd | ||
|
|
32dc963fcd | ||
|
|
d47558481a | ||
|
|
f7871899d9 | ||
|
|
06c5ab9b69 | ||
|
|
8903c72da6 | ||
|
|
109d9a66a7 | ||
|
|
8e223c5a2d | ||
|
|
b1383ff6ff | ||
|
|
c8892b4189 | ||
|
|
ab018dce5f | ||
|
|
e92757c05f | ||
|
|
86adc54767 | ||
|
|
1a9d6d4a5d | ||
|
|
4d49e5de70 | ||
|
|
a7069f4516 | ||
|
|
386817305a | ||
|
|
700cd6ca81 | ||
|
|
523c30c138 | ||
|
|
d04ece223f | ||
|
|
d2753668c1 | ||
|
|
2e89c3f8cb |
6
.github/dependabot.yml
vendored
Normal file
6
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
2
.github/workflows/rust.yml
vendored
2
.github/workflows/rust.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v2.3.4
|
||||
- name: Build
|
||||
run: cargo build --verbose
|
||||
- name: Run tests
|
||||
|
||||
70
CHANGELOG.md
70
CHANGELOG.md
@@ -1,5 +1,75 @@
|
||||
# `cargo-aur` Changelog
|
||||
|
||||
## 1.4.1 (2021-09-06)
|
||||
|
||||
#### Fixed
|
||||
|
||||
- `cargo aur` now respects `CARGO_TARGET_DIR`. [#6]
|
||||
|
||||
[#6]: https://github.com/fosskers/cargo-aur/pull/6
|
||||
|
||||
## 1.4.0 (2021-06-07)
|
||||
|
||||
#### Added
|
||||
|
||||
- The `conflicts` field is now added to the `PKGBUILD`.
|
||||
- Progress messages in the terminal.
|
||||
- `LICENSE` detection and installation. If your Rust crate has a license not
|
||||
found in `/usr/share/licenses/common/` (like `MIT`), then `cargo aur` will
|
||||
copy it into the source tarball and have the PKGBUILD install it. Naturally
|
||||
this means you must actually have a `LICENSE` file in your project, or `cargo aur` will complain.
|
||||
|
||||
## 1.3.0 (2021-04-05)
|
||||
|
||||
#### Changed
|
||||
|
||||
- `cargo aur` no longer outputs `options=("strip")`, since this is set by
|
||||
default in `/etc/makepkg.conf`.
|
||||
|
||||
## 1.2.0 (2020-08-24)
|
||||
|
||||
#### Added
|
||||
|
||||
- A `--version` flag to display the current version of `cargo-aur`.
|
||||
|
||||
## 1.1.2 (2020-08-11)
|
||||
|
||||
#### 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.
|
||||
|
||||
## 1.1.1 (2020-08-11)
|
||||
|
||||
#### Fixed
|
||||
|
||||
- A breaking bug in `1.1.0` which prevented it from working at all.
|
||||
|
||||
## 1.1.0 (2020-08-10)
|
||||
|
||||
#### Added
|
||||
|
||||
- The `--musl` flag to compile the release binary with the MUSL target. In most
|
||||
cases, this will result in a fully statically linked binary.
|
||||
|
||||
## 1.0.3 (2020-07-18)
|
||||
|
||||
#### Changed
|
||||
|
||||
- Better release profile which produces smaller binaries.
|
||||
|
||||
## 1.0.2 (2020-06-22)
|
||||
|
||||
#### Changed
|
||||
|
||||
- `cargo aur` will now auto-detect the git host (Github or Gitlab) and generated
|
||||
a `source` link based on that.
|
||||
- Fewer dependencies.
|
||||
|
||||
## 1.0.1 (2020-06-17)
|
||||
|
||||
#### Changed
|
||||
|
||||
10
Cargo.toml
10
Cargo.toml
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cargo-aur"
|
||||
version = "1.0.1"
|
||||
version = "1.4.1"
|
||||
authors = ["Colin Woodbury <colin@fosskers.ca>"]
|
||||
edition = "2018"
|
||||
description = "Prepare Rust projects to be released on the Arch Linux User Repository."
|
||||
@@ -12,9 +12,13 @@ keywords = ["cargo", "subcommand", "archlinux", "aur"]
|
||||
categories = ["command-line-utilities"]
|
||||
|
||||
[dependencies]
|
||||
auto_from = "0.3"
|
||||
colored = "2.0"
|
||||
gumdrop = "0.8"
|
||||
hmac-sha256 = "0.1"
|
||||
itertools = "0.9"
|
||||
itertools = "0.10"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
toml = "0.5"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 - 2021 Colin Woodbury
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
19
README.md
19
README.md
@@ -2,6 +2,7 @@
|
||||
|
||||
[](https://github.com/fosskers/cargo-aur/actions)
|
||||
[](https://crates.io/crates/cargo-aur)
|
||||

|
||||
|
||||
`cargo-aur` is a new subcommand for `cargo` that produces a release tarball and
|
||||
PKGBUILD file for a Rust project, so that it can be released on the Arch Linux
|
||||
@@ -14,7 +15,7 @@ a PKGBUILD will be generated with all the necessary sections filled out.
|
||||
## Installation
|
||||
|
||||
Guess what? `cargo-aur` itself is on the AUR! Install it with an AUR-compatible
|
||||
package manager:
|
||||
package manager like [`aura`](https://github.com/fosskers/aura):
|
||||
|
||||
```
|
||||
sudo aura -A cargo-aur-bin
|
||||
@@ -52,11 +53,23 @@ AUR standard.
|
||||
|
||||
At this point, it is up to you to:
|
||||
|
||||
1. Create an official `Release` on Github, attaching the original binary tarball
|
||||
that `cargo aur` produced.
|
||||
1. Create an official `Release` on Github/Gitlab, attaching the original binary
|
||||
tarball that `cargo aur` produced.
|
||||
2. Copy the PKGBUILD to a git repo that tracks releases of your package.
|
||||
3. Run `makepkg --printsrcinfo > .SRCINFO`.
|
||||
4. Commit both files and push to the AUR.
|
||||
|
||||
Some of these steps may be automated in `cargo aur` at a later date if there is
|
||||
sufficient demand.
|
||||
|
||||
### Static Binaries
|
||||
|
||||
Run with `--musl` to produce a release binary that is statically linked via
|
||||
[MUSL](https://musl.libc.org/).
|
||||
|
||||
```
|
||||
> cargo aur --musl
|
||||
> cd target/x86_64-unknown-linux-musl/release/
|
||||
> ldd <your-binary>
|
||||
not a dynamic executable
|
||||
```
|
||||
|
||||
48
src/error.rs
Normal file
48
src/error.rs
Normal file
@@ -0,0 +1,48 @@
|
||||
//! Errors that can occur in this application.
|
||||
|
||||
use std::fmt::Display;
|
||||
|
||||
pub(crate) enum Error {
|
||||
IO(std::io::Error),
|
||||
Toml(toml::de::Error),
|
||||
Utf8(std::str::Utf8Error),
|
||||
Utf8OsString,
|
||||
MissingTarget,
|
||||
MissingLicense,
|
||||
}
|
||||
|
||||
impl Display for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Error::IO(e) => write!(f, "{}", e),
|
||||
Error::Toml(e) => write!(f, "{}", e),
|
||||
Error::Utf8(e) => write!(f, "{}", e),
|
||||
Error::Utf8OsString => write!(f, "The `OsString` was not UTF-8!"),
|
||||
Error::MissingTarget => write!(
|
||||
f,
|
||||
"Missing target! Try: rustup target add x86_64-unknown-linux-musl"
|
||||
),
|
||||
Error::MissingLicense => {
|
||||
write!(f, "Missing LICENSE file. See https://choosealicense.com/")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::str::Utf8Error> for Error {
|
||||
fn from(v: std::str::Utf8Error) -> Self {
|
||||
Self::Utf8(v)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<toml::de::Error> for Error {
|
||||
fn from(v: toml::de::Error) -> Self {
|
||||
Self::Toml(v)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for Error {
|
||||
fn from(v: std::io::Error) -> Self {
|
||||
Self::IO(v)
|
||||
}
|
||||
}
|
||||
325
src/main.rs
325
src/main.rs
@@ -1,9 +1,61 @@
|
||||
use auto_from::From;
|
||||
pub(crate) mod error;
|
||||
|
||||
use crate::error::Error;
|
||||
use colored::*;
|
||||
use gumdrop::{Options, ParsingStyle};
|
||||
use hmac_sha256::Hash;
|
||||
use itertools::Itertools;
|
||||
use serde_derive::Deserialize;
|
||||
use std::process::{self, Command};
|
||||
use std::{fmt, fs, io};
|
||||
use std::ffi::OsString;
|
||||
use std::fs::{DirEntry, File};
|
||||
use std::io::{BufWriter, Write};
|
||||
use std::ops::Not;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
/// Licenses avaiable from the Arch Linux `licenses` package.
|
||||
///
|
||||
/// That package contains other licenses, but I've excluded here those unlikely
|
||||
/// to be used by Rust crates.
|
||||
const LICENSES: &[&str] = &[
|
||||
"AGPL3", "APACHE", "GPL2", "GPL3", "LGPL2.1", "LGPL3", "MPL", "MPL2",
|
||||
];
|
||||
|
||||
#[derive(Options)]
|
||||
struct Args {
|
||||
/// Display this help message.
|
||||
help: bool,
|
||||
|
||||
/// Display the current version of this software.
|
||||
version: bool,
|
||||
|
||||
/// Unused.
|
||||
#[options(free)]
|
||||
args: Vec<String>,
|
||||
|
||||
/// Use the MUSL build target to produce a static binary.
|
||||
musl: bool,
|
||||
}
|
||||
|
||||
enum GitHost {
|
||||
Github,
|
||||
Gitlab,
|
||||
}
|
||||
|
||||
impl GitHost {
|
||||
fn source(&self, package: &Package) -> String {
|
||||
match self {
|
||||
GitHost::Github => format!(
|
||||
"{}/releases/download/v$pkgver/{}-$pkgver-x86_64.tar.gz",
|
||||
package.repository, package.name
|
||||
),
|
||||
GitHost::Gitlab => format!(
|
||||
"{}/-/archive/v$pkgver/{}-$pkgver-x86_64.tar.gz",
|
||||
package.repository, package.name
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct Config {
|
||||
@@ -26,113 +78,220 @@ impl Package {
|
||||
fn tarball(&self) -> String {
|
||||
format!("{}-{}-x86_64.tar.gz", self.name, self.version)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(From)]
|
||||
enum Error {
|
||||
Io(io::Error),
|
||||
Parsing(toml::de::Error),
|
||||
Utf8(std::string::FromUtf8Error),
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
Error::Io(e) => write!(f, "{}", e),
|
||||
Error::Parsing(e) => write!(f, "{}", e),
|
||||
Error::Utf8(e) => write!(f, "{}", e),
|
||||
fn git_host(&self) -> Option<GitHost> {
|
||||
if self.repository.starts_with("https://github") {
|
||||
Some(GitHost::Github)
|
||||
} else if self.repository.starts_with("https://gitlab") {
|
||||
Some(GitHost::Gitlab)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
if let Err(e) = work() {
|
||||
eprintln!("{}", e);
|
||||
process::exit(1)
|
||||
let args = Args::parse_args_or_exit(ParsingStyle::AllOptions);
|
||||
|
||||
if args.version {
|
||||
let version = env!("CARGO_PKG_VERSION");
|
||||
println!("{}", version);
|
||||
} else if let Err(e) = work(args) {
|
||||
eprintln!("{} {}: {}", "::".bold(), "Error".bold().red(), e);
|
||||
std::process::exit(1)
|
||||
} else {
|
||||
println!("{} {}", "::".bold(), "Done.".bold().green());
|
||||
}
|
||||
}
|
||||
|
||||
fn work() -> Result<(), Error> {
|
||||
let config = cargo_config()?;
|
||||
release_build()?;
|
||||
tarball(&config.package)?;
|
||||
let sha256 = sha256sum(&config.package)?;
|
||||
let pkgbuild = pkgbuild(&config.package, &sha256);
|
||||
fs::write("PKGBUILD", pkgbuild)?;
|
||||
fn work(args: Args) -> Result<(), Error> {
|
||||
// We can't proceed if the user has specified `--musl` but doesn't have the
|
||||
// target installed.
|
||||
if args.musl {
|
||||
p("Checking for musl toolchain...".bold());
|
||||
musl_check()?
|
||||
}
|
||||
|
||||
let package = cargo_config()?;
|
||||
let license = if must_copy_license(&package.license) {
|
||||
p("LICENSE file will be installed manually.".bold().yellow());
|
||||
Some(license_file()?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
release_build(args.musl)?;
|
||||
tarball(args.musl, license.as_ref(), &package)?;
|
||||
let sha256: String = sha256sum(&package)?;
|
||||
|
||||
// Write the PKGBUILD.
|
||||
let file = BufWriter::new(File::create("PKGBUILD")?);
|
||||
pkgbuild(file, &package, &sha256, license.as_ref())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn cargo_config() -> Result<Config, Error> {
|
||||
let content = fs::read_to_string("Cargo.toml")?;
|
||||
let proj = toml::from_str(&content)?;
|
||||
Ok(proj) // TODO Would like to do this in one line with the above.
|
||||
fn cargo_config() -> Result<Package, Error> {
|
||||
let content = std::fs::read_to_string("Cargo.toml")?;
|
||||
let proj: Config = toml::from_str(&content)?;
|
||||
Ok(proj.package)
|
||||
}
|
||||
|
||||
/// Produce a legal PKGBUILD.
|
||||
fn pkgbuild(package: &Package, md5: &str) -> String {
|
||||
format!(
|
||||
r#"{}
|
||||
pkgname={}-bin
|
||||
pkgver={}
|
||||
pkgrel=1
|
||||
pkgdesc="{}"
|
||||
url="{}"
|
||||
license=('{}')
|
||||
arch=('x86_64')
|
||||
provides=('{}')
|
||||
options=('strip')
|
||||
source=("{}/releases/download/v$pkgver/{}-$pkgver-x86_64.tar.gz")
|
||||
sha256sums=('{}')
|
||||
|
||||
package() {{
|
||||
install -Dm755 {} -t "$pkgdir/usr/bin/"
|
||||
}}
|
||||
"#,
|
||||
package
|
||||
.authors
|
||||
.iter()
|
||||
.map(|a| format!("# Maintainer: {}", a))
|
||||
.join("\n"),
|
||||
package.name,
|
||||
package.version,
|
||||
package.description,
|
||||
package.homepage,
|
||||
package.license,
|
||||
package.name,
|
||||
package.repository,
|
||||
package.name,
|
||||
md5,
|
||||
package.name,
|
||||
)
|
||||
/// If a AUR package's license isn't included in `/usr/share/licenses/common/`,
|
||||
/// then it must be installed manually by the PKGBUILD. MIT is such a missing
|
||||
/// license, and since many Rust crates use MIT we must make this check.
|
||||
fn must_copy_license(license: &str) -> bool {
|
||||
LICENSES.contains(&license).not()
|
||||
}
|
||||
|
||||
/// Run `cargo build --release`.
|
||||
fn release_build() -> Result<(), Error> {
|
||||
Command::new("cargo")
|
||||
.arg("build")
|
||||
.arg("--release")
|
||||
.status()?;
|
||||
/// The path to the `LICENSE` file.
|
||||
fn license_file() -> Result<DirEntry, Error> {
|
||||
std::fs::read_dir(".")?
|
||||
.filter_map(|entry| entry.ok())
|
||||
.find(|entry| {
|
||||
entry
|
||||
.file_name()
|
||||
.to_str()
|
||||
.map(|s| s.starts_with("LICENSE"))
|
||||
.unwrap_or(false)
|
||||
})
|
||||
.ok_or(Error::MissingLicense)
|
||||
}
|
||||
|
||||
/// Write a legal PKGBUILD to some `Write` instance (a `File` in this case).
|
||||
fn pkgbuild<T: Write>(
|
||||
mut file: T,
|
||||
package: &Package,
|
||||
sha256: &str,
|
||||
license: Option<&DirEntry>,
|
||||
) -> Result<(), Error> {
|
||||
let authors = package
|
||||
.authors
|
||||
.iter()
|
||||
.map(|a| format!("# Maintainer: {}", a))
|
||||
.join("\n");
|
||||
let source = package
|
||||
.git_host()
|
||||
.unwrap_or(GitHost::Github)
|
||||
.source(package);
|
||||
|
||||
writeln!(file, "{}", authors)?;
|
||||
writeln!(file, "#")?;
|
||||
writeln!(
|
||||
file,
|
||||
"# This PKGBUILD was generated by `cargo aur`: https://crates.io/crates/cargo-aur"
|
||||
)?;
|
||||
writeln!(file)?;
|
||||
writeln!(file, "pkgname={}-bin", package.name)?;
|
||||
writeln!(file, "pkgver={}", package.version)?;
|
||||
writeln!(file, "pkgrel=1")?;
|
||||
writeln!(file, "pkgdesc=\"{}\"", package.description)?;
|
||||
writeln!(file, "url=\"{}\"", package.homepage)?;
|
||||
writeln!(file, "license=(\"{}\")", package.license)?;
|
||||
writeln!(file, "arch=(\"x86_64\")")?;
|
||||
writeln!(file, "provides=(\"{}\")", package.name)?;
|
||||
writeln!(file, "conflicts=(\"{}\")", package.name)?;
|
||||
writeln!(file, "source=(\"{}\")", source)?;
|
||||
writeln!(file, "sha256sums=(\"{}\")", sha256)?;
|
||||
writeln!(file)?;
|
||||
writeln!(file, "package() {{")?;
|
||||
writeln!(
|
||||
file,
|
||||
" install -Dm755 {} -t \"$pkgdir/usr/bin\"",
|
||||
package.name
|
||||
)?;
|
||||
|
||||
if let Some(lic) = license {
|
||||
let file_name = lic
|
||||
.file_name()
|
||||
.into_string()
|
||||
.map_err(|_| Error::Utf8OsString)?;
|
||||
writeln!(
|
||||
file,
|
||||
" install -Dm644 {} \"$pkgdir/usr/share/licenses/$pkgname/{}\"",
|
||||
file_name, file_name
|
||||
)?;
|
||||
}
|
||||
|
||||
writeln!(file, "}}")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn tarball(package: &Package) -> Result<(), Error> {
|
||||
let binary = format!("target/release/{}", package.name);
|
||||
/// Run `cargo build --release`, potentially building statically.
|
||||
fn release_build(musl: bool) -> Result<(), Error> {
|
||||
let mut args = vec!["build", "--release"];
|
||||
|
||||
fs::copy(binary, &package.name)?;
|
||||
Command::new("tar")
|
||||
.arg("czf")
|
||||
.arg(package.tarball())
|
||||
.arg(&package.name)
|
||||
.status()?;
|
||||
fs::remove_file(&package.name)?;
|
||||
if musl {
|
||||
args.push("--target=x86_64-unknown-linux-musl");
|
||||
}
|
||||
|
||||
p("Running release build...".bold());
|
||||
Command::new("cargo").args(args).status()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn tarball(musl: bool, license: Option<&DirEntry>, package: &Package) -> Result<(), Error> {
|
||||
let target_dir: OsString = match std::env::var_os("CARGO_TARGET_DIR") {
|
||||
Some(p) => p,
|
||||
None => "target".into(),
|
||||
};
|
||||
|
||||
let release_dir = if musl {
|
||||
"x86_64-unknown-linux-musl/release"
|
||||
} else {
|
||||
"release"
|
||||
};
|
||||
|
||||
let mut binary: PathBuf = target_dir.into();
|
||||
binary.push(release_dir);
|
||||
binary.push(&package.name);
|
||||
|
||||
strip(&binary)?;
|
||||
std::fs::copy(binary, &package.name)?;
|
||||
|
||||
// Create the tarball.
|
||||
p("Packing tarball...".bold());
|
||||
let mut command = Command::new("tar");
|
||||
command.arg("czf").arg(package.tarball()).arg(&package.name);
|
||||
if let Some(lic) = license {
|
||||
command.arg(lic.path());
|
||||
}
|
||||
command.status()?;
|
||||
|
||||
std::fs::remove_file(&package.name)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Strip the release binary, so that we aren't compressing more bytes than we
|
||||
/// need to.
|
||||
fn strip(path: &Path) -> Result<(), Error> {
|
||||
p("Stripping binary...".bold());
|
||||
Command::new("strip").arg(path).status()?;
|
||||
Ok(()) // FIXME Would love to use my `void` package here and elsewhere.
|
||||
}
|
||||
|
||||
fn sha256sum(package: &Package) -> Result<String, Error> {
|
||||
let bytes = fs::read(package.tarball())?;
|
||||
let bytes = std::fs::read(package.tarball())?;
|
||||
let digest = Hash::hash(&bytes);
|
||||
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() -> Result<(), Error> {
|
||||
let args = vec!["target", "list", "--installed"];
|
||||
let output = Command::new("rustup").args(args).output()?.stdout;
|
||||
let installed = std::str::from_utf8(&output)?
|
||||
.lines()
|
||||
.any(|tc| tc == "x86_64-unknown-linux-musl");
|
||||
|
||||
if installed {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(Error::MissingTarget)
|
||||
}
|
||||
}
|
||||
|
||||
fn p(msg: ColoredString) {
|
||||
println!("{} {}", "::".bold(), msg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user