Impl try multiple default bin dirs (#417)

From @passcod :

* Make bin-dir an Option
* Use cargo-release as a test case
* WIP: Try multiple default bin dirs
* Update bins.rs
* Update cargo_toml_binstall.rs

From @NobodyXu :
* Optimize & Prepare for support multi `bin-path`s
* Ensure quickinstall bin_dir work as usual.
* Rm dup entries in `FULL_FILENAMES`
* Add second version of `NOVERSION_FILENAMES`
* Impl multiple default `bin-dir`s
* Improve doc for `BinFile::from_product`
* Fix tests.sh

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Co-authored-by: Félix Saparelli <felix@passcod.name>
This commit is contained in:
Jiahao XU 2022-09-25 22:15:20 +10:00 committed by GitHub
parent c27c3b80b5
commit e034d69e12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 88 additions and 67 deletions

View file

@ -11,9 +11,6 @@ pub use package_formats::*;
mod package_formats;
/// Default binary name template (may be overridden in package Cargo.toml)
pub const DEFAULT_BIN_DIR: &str = "{ name }-{ target }-v{ version }/{ bin }{ binary-ext }";
/// `binstall` metadata container
///
/// Required to nest metadata under `package.metadata.binstall`
@ -26,7 +23,7 @@ pub struct Meta {
/// Metadata for binary installation use.
///
/// Exposed via `[package.metadata]` in `Cargo.toml`
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case", default)]
pub struct PkgMeta {
/// URL template for package downloads
@ -36,7 +33,7 @@ pub struct PkgMeta {
pub pkg_fmt: Option<PkgFmt>,
/// Path template for binary files in packages
pub bin_dir: String,
pub bin_dir: Option<String>,
/// Public key for package verification (base64 encoded)
pub pub_key: Option<String>,
@ -45,18 +42,6 @@ pub struct PkgMeta {
pub overrides: BTreeMap<String, PkgOverride>,
}
impl Default for PkgMeta {
fn default() -> Self {
Self {
pkg_url: None,
pkg_fmt: None,
bin_dir: DEFAULT_BIN_DIR.to_string(),
pub_key: None,
overrides: BTreeMap::new(),
}
}
}
impl PkgMeta {
pub fn clone_without_overrides(&self) -> Self {
Self {
@ -77,7 +62,7 @@ impl PkgMeta {
self.pkg_fmt = Some(*o);
}
if let Some(o) = &pkg_override.bin_dir {
self.bin_dir = o.clone();
self.bin_dir = Some(o.clone());
}
}
}