mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-23 02:56:37 +00:00
fix: Skip binaries user didn't requst (#2199)
* fix: Skip binaries user didn't requst Users may request only a subset of binaries via the --bin flag. In that case, do not fail if binaries other than the ones requested are missing from the downloaded archive. * fix resolve.rs Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * fix resolve.rs Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * fix resolve.rs --------- Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Co-authored-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
This commit is contained in:
parent
aa459296fa
commit
4628235403
4 changed files with 56 additions and 1 deletions
|
@ -193,6 +193,7 @@ async fn resolve_inner(
|
||||||
&package_info,
|
&package_info,
|
||||||
&opts.install_path,
|
&opts.install_path,
|
||||||
opts.no_symlinks,
|
opts.no_symlinks,
|
||||||
|
&opts.bins,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
|
@ -289,6 +290,7 @@ async fn download_extract_and_verify(
|
||||||
package_info: &PackageInfo,
|
package_info: &PackageInfo,
|
||||||
install_path: &Path,
|
install_path: &Path,
|
||||||
no_symlinks: bool,
|
no_symlinks: bool,
|
||||||
|
bins: &Option<Vec<CompactString>>,
|
||||||
) -> Result<Vec<bins::BinFile>, BinstallError> {
|
) -> Result<Vec<bins::BinFile>, BinstallError> {
|
||||||
// Download and extract it.
|
// Download and extract it.
|
||||||
// If that fails, then ignore this fetcher.
|
// If that fails, then ignore this fetcher.
|
||||||
|
@ -316,6 +318,14 @@ async fn download_extract_and_verify(
|
||||||
.iter()
|
.iter()
|
||||||
.zip(bin_files)
|
.zip(bin_files)
|
||||||
.filter_map(|(bin, bin_file)| {
|
.filter_map(|(bin, bin_file)| {
|
||||||
|
// skip binaries that were not requested by user
|
||||||
|
if bins
|
||||||
|
.as_ref()
|
||||||
|
.is_some_and(|bins| !bins.iter().any(|b| b == bin.name))
|
||||||
|
{
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
match bin_file.check_source_exists(&mut |p| extracted_files.has_file(p)) {
|
match bin_file.check_source_exists(&mut |p| extracted_files.has_file(p)) {
|
||||||
Ok(()) => Some(Ok(bin_file)),
|
Ok(()) => Some(Ok(bin_file)),
|
||||||
|
|
||||||
|
|
17
e2e-tests/manifests/skipping-required-bin-Cargo.toml
Normal file
17
e2e-tests/manifests/skipping-required-bin-Cargo.toml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
[package]
|
||||||
|
name = "cargo-binstall"
|
||||||
|
description = "Rust binary package installer for CI integration"
|
||||||
|
repository = "https://github.com/cargo-bins/cargo-binstall"
|
||||||
|
version = "0.12.0"
|
||||||
|
rust-version = "1.61.0"
|
||||||
|
authors = ["ryan <ryan@kurte.nz>"]
|
||||||
|
edition = "2021"
|
||||||
|
license = "GPL-3.0"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "cargo-binstall"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "test"
|
||||||
|
path = "src/te.rs"
|
27
e2e-tests/skipping-required-bin.sh
Executable file
27
e2e-tests/skipping-required-bin.sh
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
unset CARGO_INSTALL_ROOT
|
||||||
|
|
||||||
|
CARGO_HOME=$(mktemp -d 2>/dev/null || mktemp -d -t 'cargo-home')
|
||||||
|
export CARGO_HOME
|
||||||
|
export PATH="$CARGO_HOME/bin:$PATH"
|
||||||
|
|
||||||
|
# Install binaries using `--manifest-path`
|
||||||
|
# Also test default github template
|
||||||
|
"./$1" binstall \
|
||||||
|
--force \
|
||||||
|
--manifest-path "manifests/skipping-required-bin-Cargo.toml" \
|
||||||
|
--no-confirm \
|
||||||
|
cargo-binstall \
|
||||||
|
--strategies crate-meta-data \
|
||||||
|
--bin cargo-binstall
|
||||||
|
|
||||||
|
# Test that the installed binaries can be run
|
||||||
|
cargo binstall --help >/dev/null
|
||||||
|
|
||||||
|
cargo_binstall_version="$(cargo binstall -V)"
|
||||||
|
echo "$cargo_binstall_version"
|
||||||
|
|
||||||
|
[ "$cargo_binstall_version" = "cargo-binstall 0.12.0" ]
|
3
justfile
3
justfile
|
@ -225,6 +225,7 @@ e2e-test-continue-on-failure: (e2e-test "continue-on-failure")
|
||||||
e2e-test-private-github-repo: (e2e-test "private-github-repo")
|
e2e-test-private-github-repo: (e2e-test "private-github-repo")
|
||||||
e2e-test-self-install: (e2e-test "self-install")
|
e2e-test-self-install: (e2e-test "self-install")
|
||||||
e2e-test-specific-binaries: (e2e-test "specific-binaries")
|
e2e-test-specific-binaries: (e2e-test "specific-binaries")
|
||||||
|
e2e-test-skipping-required-bin: (e2e-test "skipping-required-bin")
|
||||||
|
|
||||||
# WinTLS (Windows in CI) does not have TLS 1.3 support
|
# WinTLS (Windows in CI) does not have TLS 1.3 support
|
||||||
[windows]
|
[windows]
|
||||||
|
@ -234,7 +235,7 @@ e2e-test-tls: (e2e-test "tls" "1.2")
|
||||||
e2e-test-tls: (e2e-test "tls" "1.2") (e2e-test "tls" "1.3")
|
e2e-test-tls: (e2e-test "tls" "1.2") (e2e-test "tls" "1.3")
|
||||||
|
|
||||||
# e2e-test-self-install needs to be the last task to run, as it would consume the cargo-binstall binary
|
# e2e-test-self-install needs to be the last task to run, as it would consume the cargo-binstall binary
|
||||||
e2e-tests: e2e-test-live e2e-test-manifest-path e2e-test-git e2e-test-other-repos e2e-test-strategies e2e-test-version-syntax e2e-test-upgrade e2e-test-tls e2e-test-self-upgrade-no-symlink e2e-test-uninstall e2e-test-subcrate e2e-test-no-track e2e-test-registries e2e-test-signing e2e-test-continue-on-failure e2e-test-private-github-repo e2e-test-specific-binaries e2e-test-self-install
|
e2e-tests: e2e-test-live e2e-test-manifest-path e2e-test-git e2e-test-other-repos e2e-test-strategies e2e-test-version-syntax e2e-test-upgrade e2e-test-tls e2e-test-self-upgrade-no-symlink e2e-test-uninstall e2e-test-subcrate e2e-test-no-track e2e-test-registries e2e-test-signing e2e-test-continue-on-failure e2e-test-private-github-repo e2e-test-specific-binaries e2e-test-skipping-required-bin e2e-test-self-install
|
||||||
|
|
||||||
unit-tests: print-env
|
unit-tests: print-env
|
||||||
cargo test --no-run --target {{target}}
|
cargo test --no-run --target {{target}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue