From e211bdd96bdcbdabf55a745616adfe41f54b7460 Mon Sep 17 00:00:00 2001 From: Risu <79110363+risu729@users.noreply.github.com> Date: Tue, 1 Jul 2025 12:45:50 +1000 Subject: [PATCH 1/5] Revert "Revert "fix(aqua): handle hard links in aqua packages" (#5485)" This reverts commit 5cb642fbe78cfd12b1c96600f2dc84c7213773d6. --- registry.toml | 2 ++ src/file.rs | 51 +++++++++++++++++++++++++++++++++++---------------- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/registry.toml b/registry.toml index 37095e7a52..a162c22876 100644 --- a/registry.toml +++ b/registry.toml @@ -870,6 +870,7 @@ github-markdown-toc.backends = [ "aqua:ekalinin/github-markdown-toc", "asdf:skyzyx/asdf-github-markdown-toc" ] +github-markdown-toc.test = ["gh-md-toc --version", "{{version}}"] gitleaks.backends = ["aqua:gitleaks/gitleaks", "asdf:jmcvetta/asdf-gitleaks"] gitleaks.test = ["gitleaks --version", "gitleaks version {{version}}"] gitsign.backends = ["aqua:sigstore/gitsign", "asdf:spencergilbert/asdf-gitsign"] @@ -1441,6 +1442,7 @@ license-plist.backends = [ "asdf:MacPaw/asdf-license-plist" ] lima.backends = ["aqua:lima-vm/lima", "asdf:CrouchingMuppet/asdf-lima"] +lima.test = ["lima --version", "limactl version {{version}}"] linkerd.backends = ["aqua:linkerd/linkerd2", "asdf:kforsthoevel/asdf-linkerd"] liqoctl.backends = ["aqua:liqotech/liqo", "asdf:pdemagny/asdf-liqoctl"] liquibase.backends = ["asdf:mise-plugins/mise-liquibase"] diff --git a/src/file.rs b/src/file.rs index c58a9cb76c..d71140ad8c 100644 --- a/src/file.rs +++ b/src/file.rs @@ -16,7 +16,6 @@ use eyre::bail; use filetime::{FileTime, set_file_times}; use flate2::read::GzDecoder; use itertools::Itertools; -use path_absolutize::Absolutize; use std::sync::LazyLock as Lazy; use tar::Archive; use walkdir::WalkDir; @@ -164,7 +163,7 @@ pub fn copy_dir_all, Q: AsRef>(from: P, to: Q) -> Result<() let from = from.as_ref(); let to = to.as_ref(); trace!("cp -r {} {}", from.display(), to.display()); - recursive_ls(from)?.into_iter().try_for_each(|path| { + recursive_ls(from, false)?.into_iter().try_for_each(|path| { let relative = path.strip_prefix(from)?; let dest = to.join(relative); create_dir_all(dest.parent().unwrap())?; @@ -329,7 +328,7 @@ pub fn ls(dir: &Path) -> Result> { Ok(output) } -pub fn recursive_ls(dir: &Path) -> Result> { +pub fn recursive_ls(dir: &Path, include_dirs: bool) -> Result> { if !dir.is_dir() { return Ok(Default::default()); } @@ -337,7 +336,7 @@ pub fn recursive_ls(dir: &Path) -> Result> { Ok(WalkDir::new(dir) .follow_links(true) .into_iter() - .filter_ok(|e| e.file_type().is_file()) + .filter_ok(|e| e.file_type().is_file() || (include_dirs && e.file_type().is_dir())) .map_ok(|e| e.path().to_path_buf()) .try_collect()?) } @@ -713,24 +712,44 @@ pub fn untar(archive: &Path, dest: &Path, opts: &TarOptions) -> Result<()> { // pr.set_length(total); // } // } + create_dir_all(dest).wrap_err_with(err)?; for entry in Archive::new(tar).entries().wrap_err_with(err)? { let mut entry = entry.wrap_err_with(err)?; - let path: PathBuf = entry - .path() - .wrap_err_with(err)? - .components() - .skip(opts.strip_components) - .filter(|c| c.as_os_str() != ".") - .collect::() - .absolutize_virtually(dest)? - .to_path_buf(); - create_dir_all(path.parent().unwrap()).wrap_err_with(err)?; - trace!("extracting {}", display_path(&path)); - entry.unpack(&path).wrap_err_with(err)?; + trace!("extracting {}", entry.path().wrap_err_with(err)?.display()); + entry.unpack_in(dest).wrap_err_with(err)?; if let Some(pr) = &opts.pr { pr.set_length(entry.raw_file_position()); } } + if opts.strip_components > 0 { + debug!( + "moving files with strip-components={}", + opts.strip_components + ); + let entries = recursive_ls(dest, true).wrap_err_with(err)?; + for entry in entries.into_iter().rev() { + if entry.is_dir() { + if is_empty_dir(&entry).wrap_err_with(err)? { + fs::remove_dir(&entry).wrap_err_with(err)?; + } + continue; + } + let relative = entry + .strip_prefix(dest) + .wrap_err_with(err)? + .components() + .skip(opts.strip_components) + .collect::(); + if relative.is_empty() { + // remove the file if the path components are all stripped + fs::remove_file(&entry).wrap_err_with(err)?; + continue; + } + let stripped = dest.join(relative); + create_dir_all(stripped.parent().unwrap()).wrap_err_with(err)?; + fs::rename(&entry, &stripped).wrap_err_with(err)?; + } + } // if let Some(pr) = &opts.pr { // pr.set_position(total); // } From e2ccb89d78cec8267c6c9c45af215fee3389b8f3 Mon Sep 17 00:00:00 2001 From: Risu <79110363+risu729@users.noreply.github.com> Date: Tue, 1 Jul 2025 14:24:41 +1000 Subject: [PATCH 2/5] test: enable swift e2e test for now --- e2e/core/{test_swift_slow => test_swift} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename e2e/core/{test_swift_slow => test_swift} (100%) diff --git a/e2e/core/test_swift_slow b/e2e/core/test_swift similarity index 100% rename from e2e/core/test_swift_slow rename to e2e/core/test_swift From 21b75aa8a495dc136b17a21f27ffb600417c7719 Mon Sep 17 00:00:00 2001 From: Risu <79110363+risu729@users.noreply.github.com> Date: Wed, 2 Jul 2025 15:28:38 +1000 Subject: [PATCH 3/5] fix: reuse strip_components logic for zip --- src/file.rs | 137 +++++++++++++++++++++------------------------------- 1 file changed, 54 insertions(+), 83 deletions(-) diff --git a/src/file.rs b/src/file.rs index d71140ad8c..256a487e58 100644 --- a/src/file.rs +++ b/src/file.rs @@ -664,95 +664,66 @@ pub fn untar(archive: &Path, dest: &Path, opts: &TarOptions) -> Result<()> { }; if format == TarFormat::Zip { unzip(archive, dest)?; - match opts.strip_components { - 0 => {} - 1 => { - let entries = ls(dest)? - .into_iter() - .map(|p| ls(&p)) - .collect::>>()? - .into_iter() - .flatten() - .collect::>(); - for entry in entries { - let mut new_dest = dest.to_path_buf(); - new_dest.push(entry.file_name().unwrap()); - fs::rename(entry, new_dest)?; - } - } - _ => bail!("strip-components not supported for zip archives"), - } - return Ok(()); - } - debug!("tar -xf {} -C {}", archive.display(), dest.display()); - if let Some(pr) = &opts.pr { - pr.set_message(format!( - "extract {}", - archive.file_name().unwrap().to_string_lossy() - )); - } - let tar = open_tar(format, archive)?; - let err = || { - let archive = display_path(archive); - let dest = display_path(dest); - format!("failed to extract tar: {archive} to {dest}") - }; - // TODO: put this back in when we can read+write in parallel - // let mut cur = Cursor::new(vec![]); - // let mut total = 0; - // loop { - // let mut buf = Cursor::new(vec![0; 1024 * 1024]); - // let n = tar.read(buf.get_mut()).wrap_err_with(err)?; - // cur.get_mut().extend_from_slice(&buf.get_ref()[..n]); - // if n == 0 { - // break; - // } - // if let Some(pr) = &opts.pr { - // total += n as u64; - // pr.set_length(total); - // } - // } - create_dir_all(dest).wrap_err_with(err)?; - for entry in Archive::new(tar).entries().wrap_err_with(err)? { - let mut entry = entry.wrap_err_with(err)?; - trace!("extracting {}", entry.path().wrap_err_with(err)?.display()); - entry.unpack_in(dest).wrap_err_with(err)?; + } else { + debug!("tar -xf {} -C {}", archive.display(), dest.display()); if let Some(pr) = &opts.pr { - pr.set_length(entry.raw_file_position()); + pr.set_message(format!( + "extract {}", + archive.file_name().unwrap().to_string_lossy() + )); } - } - if opts.strip_components > 0 { - debug!( - "moving files with strip-components={}", - opts.strip_components - ); - let entries = recursive_ls(dest, true).wrap_err_with(err)?; - for entry in entries.into_iter().rev() { - if entry.is_dir() { - if is_empty_dir(&entry).wrap_err_with(err)? { - fs::remove_dir(&entry).wrap_err_with(err)?; - } - continue; + let tar = open_tar(format, archive)?; + let err = || { + let archive = display_path(archive); + let dest = display_path(dest); + format!("failed to extract tar: {archive} to {dest}") + }; + // TODO: put this back in when we can read+write in parallel + // let mut cur = Cursor::new(vec![]); + // let mut total = 0; + // loop { + // let mut buf = Cursor::new(vec![0; 1024 * 1024]); + // let n = tar.read(buf.get_mut()).wrap_err_with(err)?; + // cur.get_mut().extend_from_slice(&buf.get_ref()[..n]); + // if n == 0 { + // break; + // } + // if let Some(pr) = &opts.pr { + // total += n as u64; + // pr.set_length(total); + // } + // } + create_dir_all(dest).wrap_err_with(err)?; + for entry in Archive::new(tar).entries().wrap_err_with(err)? { + let mut entry = entry.wrap_err_with(err)?; + trace!("extracting {}", entry.path().wrap_err_with(err)?.display()); + entry.unpack_in(dest).wrap_err_with(err)?; + if let Some(pr) = &opts.pr { + pr.set_length(entry.raw_file_position()); } - let relative = entry - .strip_prefix(dest) - .wrap_err_with(err)? - .components() - .skip(opts.strip_components) - .collect::(); - if relative.is_empty() { - // remove the file if the path components are all stripped - fs::remove_file(&entry).wrap_err_with(err)?; - continue; + } + // if let Some(pr) = &opts.pr { + // pr.set_position(total); + // } + } + match opts.strip_components { + 0 => {} + 1 => { + let entries = ls(dest)? + .into_iter() + .map(|p| ls(&p)) + .collect::>>()? + .into_iter() + .flatten() + .collect::>(); + for entry in entries { + let mut new_dest = dest.to_path_buf(); + new_dest.push(entry.file_name().unwrap()); + fs::rename(entry, new_dest)?; } - let stripped = dest.join(relative); - create_dir_all(stripped.parent().unwrap()).wrap_err_with(err)?; - fs::rename(&entry, &stripped).wrap_err_with(err)?; } + _ => bail!("strip-components > 1 is not supported"), } - // if let Some(pr) = &opts.pr { - // pr.set_position(total); - // } Ok(()) } From 267f38a6b1647350994c913ad0831e1d17d1265a Mon Sep 17 00:00:00 2001 From: Risu <79110363+risu729@users.noreply.github.com> Date: Wed, 2 Jul 2025 15:30:47 +1000 Subject: [PATCH 4/5] revert: revert change for recursive_ls --- src/file.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/file.rs b/src/file.rs index 256a487e58..c7b26d9105 100644 --- a/src/file.rs +++ b/src/file.rs @@ -163,7 +163,7 @@ pub fn copy_dir_all, Q: AsRef>(from: P, to: Q) -> Result<() let from = from.as_ref(); let to = to.as_ref(); trace!("cp -r {} {}", from.display(), to.display()); - recursive_ls(from, false)?.into_iter().try_for_each(|path| { + recursive_ls(from)?.into_iter().try_for_each(|path| { let relative = path.strip_prefix(from)?; let dest = to.join(relative); create_dir_all(dest.parent().unwrap())?; @@ -328,7 +328,7 @@ pub fn ls(dir: &Path) -> Result> { Ok(output) } -pub fn recursive_ls(dir: &Path, include_dirs: bool) -> Result> { +pub fn recursive_ls(dir: &Path) -> Result> { if !dir.is_dir() { return Ok(Default::default()); } @@ -336,7 +336,7 @@ pub fn recursive_ls(dir: &Path, include_dirs: bool) -> Result> Ok(WalkDir::new(dir) .follow_links(true) .into_iter() - .filter_ok(|e| e.file_type().is_file() || (include_dirs && e.file_type().is_dir())) + .filter_ok(|e| e.file_type().is_file()) .map_ok(|e| e.path().to_path_buf()) .try_collect()?) } From 60c9ffc6840267707e6615d7dc9adf8c9485a4fd Mon Sep 17 00:00:00 2001 From: Risu <79110363+risu729@users.noreply.github.com> Date: Wed, 2 Jul 2025 15:43:49 +1000 Subject: [PATCH 5/5] Revert "test: enable swift e2e test for now" This reverts commit e2ccb89d78cec8267c6c9c45af215fee3389b8f3. --- e2e/core/{test_swift => test_swift_slow} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename e2e/core/{test_swift => test_swift_slow} (100%) diff --git a/e2e/core/test_swift b/e2e/core/test_swift_slow similarity index 100% rename from e2e/core/test_swift rename to e2e/core/test_swift_slow