move pxar binary to separate crate
and move its few remaining proxmox_backup deps out to pbs-tools Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
0889806a3c
commit
58a3fae773
|
@ -28,6 +28,7 @@ members = [
|
|||
"pbs-tools",
|
||||
|
||||
"proxmox-backup-banner",
|
||||
"pxar-bin",
|
||||
]
|
||||
|
||||
[lib]
|
||||
|
|
5
Makefile
5
Makefile
|
@ -38,7 +38,8 @@ SUBCRATES := \
|
|||
pbs-runtime \
|
||||
pbs-systemd \
|
||||
pbs-tools \
|
||||
proxmox-backup-banner
|
||||
proxmox-backup-banner \
|
||||
pxar-bin
|
||||
|
||||
ifeq ($(BUILD_MODE), release)
|
||||
CARGO_BUILD_ARGS += --release
|
||||
|
@ -163,6 +164,8 @@ $(COMPILED_BINS) $(COMPILEDIR)/dump-catalog-shell-cli $(COMPILEDIR)/docgen: .do-
|
|||
$(CARGO) build $(CARGO_BUILD_ARGS) \
|
||||
--package proxmox-backup-banner \
|
||||
--bin proxmox-backup-banner \
|
||||
--package pxar-bin \
|
||||
--bin pxar \
|
||||
--package proxmox-backup \
|
||||
--bin dump-catalog-shell-cli \
|
||||
--bin pmt --bin pmtx \
|
||||
|
|
|
@ -2,9 +2,12 @@
|
|||
|
||||
use std::borrow::{Borrow, BorrowMut};
|
||||
use std::collections::HashMap;
|
||||
use std::fs::File;
|
||||
use std::hash::BuildHasher;
|
||||
use std::io::{self, BufRead};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::os::unix::io::{AsRawFd, RawFd};
|
||||
use std::path::Path;
|
||||
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use nix::dir;
|
||||
|
@ -401,3 +404,27 @@ where
|
|||
|
||||
result
|
||||
}
|
||||
|
||||
/// Get an iterator over lines of a file, skipping empty lines and comments (lines starting with a
|
||||
/// `#`).
|
||||
pub fn file_get_non_comment_lines<P: AsRef<Path>>(
|
||||
path: P,
|
||||
) -> Result<impl Iterator<Item = io::Result<String>>, Error> {
|
||||
let path = path.as_ref();
|
||||
|
||||
Ok(io::BufReader::new(
|
||||
File::open(path).map_err(|err| format_err!("error opening {:?}: {}", path, err))?,
|
||||
)
|
||||
.lines()
|
||||
.filter_map(|line| match line {
|
||||
Ok(line) => {
|
||||
let line = line.trim();
|
||||
if line.is_empty() || line.starts_with('#') {
|
||||
None
|
||||
} else {
|
||||
Some(Ok(line.to_string()))
|
||||
}
|
||||
}
|
||||
Err(err) => Some(Err(err)),
|
||||
}))
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
[package]
|
||||
name = "pxar-bin"
|
||||
version = "0.1.0"
|
||||
authors = ["Proxmox Support Team <support@proxmox.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[[bin]]
|
||||
name = "pxar"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
futures = "0.3"
|
||||
nix = "0.19.1"
|
||||
serde_json = "1.0"
|
||||
tokio = { version = "1.6", features = [ "rt", "rt-multi-thread" ] }
|
||||
|
||||
pathpatterns = "0.1.2"
|
||||
proxmox = { version = "0.11.5", default-features = false, features = [] }
|
||||
pxar = { version = "0.10.1", features = [ "tokio-io" ] }
|
||||
|
||||
pbs-client = { path = "../pbs-client" }
|
||||
pbs-runtime = { path = "../pbs-runtime" }
|
||||
pbs-tools = { path = "../pbs-tools" }
|
|
@ -150,7 +150,7 @@ fn extract_archive(
|
|||
|
||||
let mut match_list = Vec::new();
|
||||
if let Some(filename) = &files_from {
|
||||
for line in proxmox_backup::tools::file_get_non_comment_lines(filename)? {
|
||||
for line in pbs_tools::fs::file_get_non_comment_lines(filename)? {
|
||||
let line = line
|
||||
.map_err(|err| format_err!("error reading {}: {}", filename, err))?;
|
||||
match_list.push(
|
|
@ -278,30 +278,6 @@ pub fn pbs_simple_http(proxy_config: Option<ProxyConfig>) -> SimpleHttp {
|
|||
SimpleHttp::with_options(options)
|
||||
}
|
||||
|
||||
/// Get an iterator over lines of a file, skipping empty lines and comments (lines starting with a
|
||||
/// `#`).
|
||||
pub fn file_get_non_comment_lines<P: AsRef<Path>>(
|
||||
path: P,
|
||||
) -> Result<impl Iterator<Item = io::Result<String>>, Error> {
|
||||
let path = path.as_ref();
|
||||
|
||||
Ok(io::BufReader::new(
|
||||
File::open(path).map_err(|err| format_err!("error opening {:?}: {}", path, err))?,
|
||||
)
|
||||
.lines()
|
||||
.filter_map(|line| match line {
|
||||
Ok(line) => {
|
||||
let line = line.trim();
|
||||
if line.is_empty() || line.starts_with('#') {
|
||||
None
|
||||
} else {
|
||||
Some(Ok(line.to_string()))
|
||||
}
|
||||
}
|
||||
Err(err) => Some(Err(err)),
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn setup_safe_path_env() {
|
||||
std::env::set_var("PATH", "/sbin:/bin:/usr/sbin:/usr/bin");
|
||||
// Make %ENV safer - as suggested by https://perldoc.perl.org/perlsec.html
|
||||
|
|
Loading…
Reference in New Issue