Skip to content

Commit

Permalink
Pick a no-arch asset when there's a mix of assets with and without ar…
Browse files Browse the repository at this point in the history
…chitectures

An example of this is the `yt-dlp/yt-dlp` project, which has releases named
`yt-dlp_linux` and `yt-dlp_linux_aarch64`.
  • Loading branch information
autarch committed May 11, 2024
1 parent 2c3b642 commit 1b1c42b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## 0.0.30

- When a project's releases contain a mix of file names with and without an architecture, `ubi` will
try one of the no-architecture names if it doesn't find any matches for the current architecture.
An example of this is the `yt-dlp/yt-dlp` project, which has releases named `yt-dlp_linux` and
`yt-dlp_linux_aarch64`.

- `ubi` is now always compiled with `rustls`, instead of using `openssl` on some platforms.

## 0.0.29 - 2023-12-17
Expand Down
19 changes: 16 additions & 3 deletions src/ubi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ struct Release {
assets: Vec<Asset>,
}

#[derive(Debug, Deserialize)]
#[derive(Clone, Debug, Deserialize)]
struct Asset {
name: String,
url: Url,
Expand Down Expand Up @@ -397,18 +397,31 @@ impl<'a> Ubi<'a> {
matches.push(os_matches.remove(0));
}
} else {
for asset in os_matches {
for asset in os_matches.iter() {
debug!(
"matching CPU architecture against asset name = {}",
asset.name,
);
if arch_matcher.is_match(&asset.name) {
debug!("matches our CPU architecture");
matches.push(asset);
matches.push(asset.clone());
} else {
debug!("does not match our CPU architecture");
}
}

if matches.is_empty() {
debug!("no assets matched our CPU architecture, will look for assets without an architecture");
for asset in os_matches {
debug!("matching against asset name = {}", asset.name);
if all_arches_re()?.is_match(&asset.name) {
debug!("matches a CPU architecture which is not ours");
} else {
debug!("does not match any CPU architecture, so we will try it");
matches.push(asset);
}
}
}
}

if matches.is_empty() {
Expand Down
12 changes: 12 additions & 0 deletions tests/ubi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,18 @@ fn integration_tests() -> Result<()> {
}
}

// This project has some releases that contain an architecture in the name
// and some that don't, e.g. `yt-dlp_linux` and
// `yt-dlp_linux_aarch64`. This tests that we pick one of the
// no-architecture releases when there's no file matching our
// architecture.
run_test(
td.path(),
ubi.as_ref(),
&["--project", "yt-dlp/yt-dlp", "--tag", "2024.04.09"],
make_exe_pathbuf(&["bin", "yt-dlp"]),
)?;

Ok(())
}

Expand Down

0 comments on commit 1b1c42b

Please sign in to comment.