mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-22 05:28:42 +00:00
Add support for Txz archives
This commit is contained in:
parent
e5705171a7
commit
9c06ca94cb
5 changed files with 43 additions and 7 deletions
21
Cargo.lock
generated
21
Cargo.lock
generated
|
@ -119,6 +119,7 @@ dependencies = [
|
|||
"tempdir",
|
||||
"tinytemplate",
|
||||
"tokio",
|
||||
"xz2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -796,6 +797,17 @@ dependencies = [
|
|||
"cfg-if 0.1.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lzma-sys"
|
||||
version = "0.1.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bdb4b7c3eddad11d3af9e86c487607d2d2442d185d848575365c4856ba96d619"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matches"
|
||||
version = "0.1.8"
|
||||
|
@ -1931,3 +1943,12 @@ checksum = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c"
|
|||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xz2"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c179869f34fc7c01830d3ce7ea2086bc3a07e0d35289b667d0a8bf910258926c"
|
||||
dependencies = [
|
||||
"lzma-sys",
|
||||
]
|
||||
|
|
|
@ -35,6 +35,7 @@ dirs = "3.0.1"
|
|||
serde_derive = "1.0.118"
|
||||
crates-index = "0.16.2"
|
||||
semver = "0.11.0"
|
||||
xz2 = "0.1.6"
|
||||
|
||||
[dev-dependencies]
|
||||
env_logger = "0.8.2"
|
||||
|
|
|
@ -39,6 +39,7 @@ yes
|
|||
- [ ] Unofficial packaging
|
||||
- Package formats
|
||||
- [x] Tgz
|
||||
- [x] Txz
|
||||
- [x] Tar
|
||||
- [x] Bin
|
||||
- Extraction / Transformation
|
||||
|
|
|
@ -6,6 +6,7 @@ use log::{debug, info, error};
|
|||
use cargo_toml::{Manifest};
|
||||
use flate2::read::GzDecoder;
|
||||
use tar::Archive;
|
||||
use xz2::read::XzDecoder;
|
||||
|
||||
|
||||
use crate::{Meta};
|
||||
|
@ -66,6 +67,16 @@ pub fn extract<S: AsRef<Path>, P: AsRef<Path>>(source: S, fmt: PkgFmt, path: P)
|
|||
|
||||
tgz.unpack(path)?;
|
||||
},
|
||||
PkgFmt::Txz => {
|
||||
// Extract to install dir
|
||||
debug!("Decompressing from archive '{:?}' to `{:?}`", source.as_ref(), path.as_ref());
|
||||
|
||||
let dat = std::fs::File::open(source)?;
|
||||
let tar = XzDecoder::new(dat);
|
||||
let mut txz = Archive::new(tar);
|
||||
|
||||
txz.unpack(path)?;
|
||||
},
|
||||
PkgFmt::Bin => {
|
||||
debug!("Copying data from archive '{:?}' to `{:?}`", source.as_ref(), path.as_ref());
|
||||
// Copy to install dir
|
||||
|
|
|
@ -30,6 +30,8 @@ pub enum PkgFmt {
|
|||
Tar,
|
||||
/// Download format is TGZ (TAR + GZip)
|
||||
Tgz,
|
||||
/// Download format is TAR + XZ
|
||||
Txz,
|
||||
/// Download format is raw / binary
|
||||
Bin,
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue