IJPL-442: remove tar/bzip2 dependency

IJ-CR-129069 feedback

GitOrigin-RevId: 2b7c86d48017c70dc6e4e43ad2a7a8d55c6aadac
This commit is contained in:
Ivan Pashchenko
2024-03-27 12:40:16 +01:00
committed by intellij-monorepo-bot
parent d24874fa76
commit 41cac5a331
3 changed files with 16 additions and 69 deletions

View File

@@ -237,27 +237,6 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7534301c0ea17abb4db06d75efc7b4b0fa360fce8e175a4330d721c71c942ff"
[[package]]
name = "bzip2"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8"
dependencies = [
"bzip2-sys",
"libc",
]
[[package]]
name = "bzip2-sys"
version = "0.1.11+1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc"
dependencies = [
"cc",
"libc",
"pkg-config",
]
[[package]]
name = "camino"
version = "1.1.6"
@@ -3221,17 +3200,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]]
name = "tar"
version = "0.4.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b16afcea1f22891c49a00c751c7b63b2233284064f11a200fc624137c51e2ddb"
dependencies = [
"filetime",
"libc",
"xattr",
]
[[package]]
name = "target-lexicon"
version = "0.12.14"
@@ -4010,23 +3978,11 @@ dependencies = [
"tap",
]
[[package]]
name = "xattr"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f"
dependencies = [
"libc",
"linux-raw-sys",
"rustix",
]
[[package]]
name = "xplat-launcher"
version = "0.9.0"
dependencies = [
"anyhow",
"bzip2",
"cargo-about",
"cargo-deny",
"core-foundation",
@@ -4039,7 +3995,6 @@ dependencies = [
"serde",
"serde_json",
"sha1",
"tar",
"tempfile",
"va_list",
"windows",

View File

@@ -48,10 +48,8 @@ cargo-about = "0.5.7" # generates license report
anyhow = { version = "1.0.81", features = ["std", "backtrace"] }
[target.'cfg(target_os = "windows")'.build-dependencies]
bzip2 = "0.4.4"
reqwest = { version = "0.12.0", features = ["blocking"] }
sha1 = "0.10.6"
tar = "0.4.40"
windows = { version = "0.51.1", features = [ "Win32_System_SystemInformation", "Win32_Foundation" ] }
winresource = "0.1.17"

View File

@@ -11,12 +11,12 @@ use std::path::PathBuf;
#[cfg(target_os = "windows")]
use {
anyhow::bail,
bzip2::read::BzDecoder,
reqwest::blocking::Client,
sha1::{Digest, Sha1},
std::env,
std::io::{BufRead, BufReader, Read},
std::path::Path,
std::process::Command,
windows::Win32::System::SystemInformation::GetLocalTime,
winresource::WindowsResource,
};
@@ -140,34 +140,28 @@ fn extract_tar_bz2(archive: &Path, dest: &Path, extract_marker: &Path) -> Result
assert!(!extract_marker.exists());
assert!(!dest.exists());
let archive_file_name = get_file_name(&archive)?;
let dest_file_name = get_file_name(dest)?;
let tarball_top_directory = archive_file_name
.strip_suffix(".tar.bz2")
.context("No .tar.bz2 suffix on the archive")?;
let dest_file_name = get_file_name(&dest)?;
let tmp_dest = dest.parent()
let tmp_dest = &dest.parent()
.context(format!("No parent for {dest:?}"))?
.join(format!("{dest_file_name}.tmp"));
fs_remove(&tmp_dest)?;
fs_remove(tmp_dest)?;
std::fs::create_dir_all(tmp_dest)?;
let file = File::open(archive)?;
let decompressed = BzDecoder::new(file);
let mut tarball = tar::Archive::new(decompressed);
Command::new("tar")
.arg("-xjvf")
.arg(get_non_unc_string(archive)?)
.arg("-C")
.arg(get_non_unc_string(tmp_dest)?)
.arg("--strip-components=1")
.status()?;
tarball.unpack(&tmp_dest)?;
assert!(tmp_dest.exists());
assert!(tmp_dest.is_dir());
let tarball_stripped = tmp_dest.join(tarball_top_directory);
assert!(tarball_stripped.exists());
assert!(tarball_stripped.is_dir());
std::fs::rename(&tarball_stripped, &dest)?;
File::create(&extract_marker)?;
fs_remove(&tmp_dest)?;
std::fs::rename(tmp_dest, dest)?;
File::create(extract_marker)?;
Ok(())
}