Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions registry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ black.backends = ["aqua:psf/black"]
black.test = ["black --version", "black, {{version}}"]
bob.description = "A version manager for neovim"
bob.backends = [
# "aqua:MordechaiHadad/bob", # +x permission not set
"aqua:MordechaiHadad/bob",
"ubi:MordechaiHadad/bob[matching_regex=bob-(linux|macos|windows)-(arm|x86_64)\\.zip$]",
"cargo:bob-nvim"
]
Expand Down Expand Up @@ -1225,11 +1225,7 @@ gitsign.backends = ["aqua:sigstore/gitsign", "asdf:spencergilbert/asdf-gitsign"]
gitsign.os = ["linux", "macos"]
gitsign.test = ["gitsign --version", "gitsign version v{{version}}"]
gitu.description = "A TUI Git client inspired by Magit"
gitu.backends = [
# "aqua:altsem/gitu", # +x permission not set
"ubi:altsem/gitu",
"cargo:gitu"
]
gitu.backends = ["aqua:altsem/gitu", "ubi:altsem/gitu", "cargo:gitu"]
gitu.test = ["gitu --version", "gitu v{{version}}"]
gitui.description = "Blazing 💥 fast terminal-ui for git written in rust"
gitui.backends = ["aqua:extrawurst/gitui", "asdf:looztra/asdf-gitui"]
Expand Down Expand Up @@ -2181,7 +2177,7 @@ mint.description = "🍃 A refreshing programming language for the front-end web
mint.backends = ["ubi:mint-lang/mint", "asdf:mint-lang/asdf-mint"]
mirrord.description = "Connect your local process and your cloud environment, and run local code in cloud conditions"
mirrord.backends = [
# "aqua:metalbear-co/mirrord", # +x permission not set
"aqua:metalbear-co/mirrord",
"ubi:metalbear-co/mirrord",
"asdf:metalbear-co/asdf-mirrord"
]
Expand Down Expand Up @@ -2504,6 +2500,7 @@ powershell-core.backends = [
"aqua:PowerShell/PowerShell",
"asdf:daveneeley/asdf-powershell-core"
]
powershell-core.test = ["pwsh --version", "PowerShell {{version}}"]
pre-commit.description = "A framework for managing and maintaining multi-language pre-commit hooks"
pre-commit.backends = [
"aqua:pre-commit/pre-commit",
Expand Down
74 changes: 55 additions & 19 deletions src/backend/aqua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use eyre::{ContextCompat, Result, bail};
use indexmap::IndexSet;
use itertools::Itertools;
use regex::Regex;
use std::borrow::Cow;
use std::fmt::Debug;
use std::{collections::HashSet, sync::Arc};

Expand Down Expand Up @@ -697,50 +698,74 @@ impl AquaBackend {
let install_path = tv.install_path();
file::remove_all(&install_path)?;
let format = pkg.format(v)?;
let mut bin_path = install_path.join(
pkg.files
.first()
.map(|f| f.name.as_str())
.or_else(|| pkg.name.as_ref().and_then(|n| n.split('/').next_back()))
.unwrap_or(&pkg.repo_name),
);
if cfg!(windows) && pkg.complete_windows_ext {
bin_path = bin_path.with_extension("exe");
let mut bin_names: Vec<Cow<'_, str>> = pkg
.files
.iter()
.filter_map(|file| match file.src(pkg, v) {
Ok(Some(s)) => Some(Cow::Owned(s)),
Ok(None) => Some(Cow::Borrowed(file.name.as_str())),
Err(_) => None,
})
.collect();
if bin_names.is_empty() {
let fallback_name = pkg
.name
.as_deref()
.and_then(|n| n.split('/').next_back())
.unwrap_or(&pkg.repo_name);
bin_names = vec![Cow::Borrowed(fallback_name)];
}
let bin_paths: Vec<_> = bin_names
.iter()
.map(|name| install_path.join(name.as_ref()))
.map(|path| {
if cfg!(windows) && pkg.complete_windows_ext {
path.with_extension("exe")
} else {
path
}
})
.collect();
let first_bin_path = bin_paths
.first()
.expect("at least one bin path should exist");
Comment thread
risu729 marked this conversation as resolved.
let mut tar_opts = TarOptions {
format: format.parse().unwrap_or_default(),
pr: Some(&ctx.pr),
strip_components: 0,
};
let mut make_executable = false;
if let AquaPackageType::GithubArchive = pkg.r#type {
file::untar(&tarball_path, &install_path, &tar_opts)?;
} else if let AquaPackageType::GithubContent = pkg.r#type {
tar_opts.strip_components = 1;
file::untar(&tarball_path, &install_path, &tar_opts)?;
} else if format == "raw" {
file::create_dir_all(&install_path)?;
file::copy(&tarball_path, &bin_path)?;
file::make_executable(&bin_path)?;
file::copy(&tarball_path, first_bin_path)?;
make_executable = true;
} else if format.starts_with("tar") {
file::untar(&tarball_path, &install_path, &tar_opts)?;
make_executable = true;
} else if format == "zip" {
file::unzip(&tarball_path, &install_path, &Default::default())?;
make_executable = true;
} else if format == "gz" {
file::create_dir_all(&install_path)?;
file::un_gz(&tarball_path, &bin_path)?;
file::make_executable(&bin_path)?;
file::un_gz(&tarball_path, first_bin_path)?;
make_executable = true;
} else if format == "xz" {
file::create_dir_all(&install_path)?;
file::un_xz(&tarball_path, &bin_path)?;
file::make_executable(&bin_path)?;
file::un_xz(&tarball_path, first_bin_path)?;
make_executable = true;
} else if format == "zst" {
file::create_dir_all(&install_path)?;
file::un_zst(&tarball_path, &bin_path)?;
file::make_executable(&bin_path)?;
file::un_zst(&tarball_path, first_bin_path)?;
make_executable = true;
} else if format == "bz2" {
file::create_dir_all(&install_path)?;
file::un_bz2(&tarball_path, &bin_path)?;
file::make_executable(&bin_path)?;
file::un_bz2(&tarball_path, first_bin_path)?;
make_executable = true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Package Installation Fails for Subdirectories and Executable Permissions

The commit introduces two issues during package installation:

  1. For raw, gz, xz, zst, and bz2 formats, file::copy or file::un_* operations fail if first_bin_path (derived from file.src()) includes subdirectories. This occurs because only the install_path is created, not the necessary parent directories for the target binary.
  2. For GithubArchive and GithubContent package types, the make_executable flag is not set. Consequently, extracted binaries are not made executable, potentially leaving tools unusable if their archives lack executable permissions.
Fix in Cursor Fix in Web

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. That's true, but I don't think we need to care about it, as we shouldn't have files[].src for single binaries.
  2. I intentionally excluded it because they should set permissions in Git. I'll consider it if someone find such cases.

} else if format == "dmg" {
file::un_dmg(&tarball_path, &install_path)?;
} else if format == "pkg" {
Expand All @@ -749,6 +774,17 @@ impl AquaBackend {
bail!("unsupported format: {}", format);
}

if make_executable {
for bin_path in &bin_paths {
// bin_path should exist, but doesn't when the registry is outdated
if bin_path.exists() {
file::make_executable(bin_path)?;
} else {
warn!("bin path does not exist: {}", bin_path.display());
Comment thread
risu729 marked this conversation as resolved.
}
}
}

for (src, dst) in self.srcs(pkg, tv)? {
if src != dst && src.exists() && !dst.exists() {
if cfg!(windows) {
Expand Down
Loading