-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(aqua): make bin paths executable #6010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+59
−26
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
54b60df
feat(aqua): make bin paths executable
risu729 bec130a
registry: add powershell test
risu729 b87d566
[autofix.ci] apply automated fixes
autofix-ci[bot] d7f49a0
refactor: use first_bin_path var
risu729 6d33939
fix: restore make_executable for raw
risu729 036329d
fix(aqua): only make executable if exists
risu729 e2f1a1c
fix: use src instead of name
risu729 dd7156c
[autofix.ci] apply automated fixes
autofix-ci[bot] e2ed09b
style: remove type declaration
risu729 8489bf7
fix: fallback to file.name if file.src is not set
risu729 0ce4650
[autofix.ci] apply automated fixes
autofix-ci[bot] 42a256b
fix: add warning
risu729 1b0dc1a
fix: improve error message
risu729 857ce1a
[autofix.ci] apply automated fixes
autofix-ci[bot] 059ed2b
fix: correctly use fallback
risu729 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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}; | ||
|
|
||
|
|
@@ -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"); | ||
| 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; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Package Installation Fails for Subdirectories and Executable PermissionsThe commit introduces two issues during package installation:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } else if format == "dmg" { | ||
| file::un_dmg(&tarball_path, &install_path)?; | ||
| } else if format == "pkg" { | ||
|
|
@@ -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()); | ||
|
risu729 marked this conversation as resolved.
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| for (src, dst) in self.srcs(pkg, tv)? { | ||
| if src != dst && src.exists() && !dst.exists() { | ||
| if cfg!(windows) { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.