mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 14:29:45 +00:00
appmgr: update tokio tar to v3
This commit is contained in:
committed by
Keagan McClelland
parent
431ff86647
commit
7b0f99881b
46
appmgr/Cargo.lock
generated
46
appmgr/Cargo.lock
generated
@@ -64,7 +64,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_yaml",
|
"serde_yaml",
|
||||||
"simple-logging",
|
"simple-logging",
|
||||||
"tokio 0.3.4",
|
"tokio 0.3.5",
|
||||||
"tokio-compat-02",
|
"tokio-compat-02",
|
||||||
"tokio-tar",
|
"tokio-tar",
|
||||||
]
|
]
|
||||||
@@ -612,7 +612,7 @@ checksum = "3ed85775dcc68644b5c950ac06a2b23768d3bc9390464151aaf27136998dcf9e"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
"libc",
|
"libc",
|
||||||
"redox_syscall",
|
"redox_syscall 0.1.57",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1429,7 +1429,7 @@ dependencies = [
|
|||||||
"cloudabi 0.1.0",
|
"cloudabi 0.1.0",
|
||||||
"instant",
|
"instant",
|
||||||
"libc",
|
"libc",
|
||||||
"redox_syscall",
|
"redox_syscall 0.1.57",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
@@ -1818,6 +1818,15 @@ version = "0.1.57"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
|
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "redox_syscall"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "48b82c2a1e8eb6e1bfde608de2bcbebd4072aa32d056ea48a986990cd5ca0f5a"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_users"
|
name = "redox_users"
|
||||||
version = "0.3.5"
|
version = "0.3.5"
|
||||||
@@ -1825,7 +1834,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d"
|
checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom",
|
"getrandom",
|
||||||
"redox_syscall",
|
"redox_syscall 0.1.57",
|
||||||
"rust-argon2",
|
"rust-argon2",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1995,9 +2004,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.117"
|
version = "1.0.118"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a"
|
checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
@@ -2014,9 +2023,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.117"
|
version = "1.0.118"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e"
|
checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.24",
|
"proc-macro2 1.0.24",
|
||||||
"quote 1.0.7",
|
"quote 1.0.7",
|
||||||
@@ -2138,7 +2147,7 @@ checksum = "2c29947abdee2a218277abeca306f25789c938e500ea5a9d4b12a5a504466902"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"libc",
|
"libc",
|
||||||
"redox_syscall",
|
"redox_syscall 0.1.57",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2208,7 +2217,7 @@ dependencies = [
|
|||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
"libc",
|
"libc",
|
||||||
"rand 0.7.3",
|
"rand 0.7.3",
|
||||||
"redox_syscall",
|
"redox_syscall 0.1.57",
|
||||||
"remove_dir_all",
|
"remove_dir_all",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
@@ -2249,7 +2258,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "c7fbf4c9d56b320106cd64fd024dadfa0be7cb4706725fc44a7d7ce952d820c1"
|
checksum = "c7fbf4c9d56b320106cd64fd024dadfa0be7cb4706725fc44a7d7ce952d820c1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"redox_syscall",
|
"redox_syscall 0.1.57",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2288,9 +2297,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "0.3.4"
|
version = "0.3.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9dfe2523e6fa84ddf5e688151d4e5fddc51678de9752c6512a24714c23818d61"
|
checksum = "a12a3eb39ee2c231be64487f1fcbe726c8f2514876a55480a5ab8559fc374252"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg 1.0.1",
|
"autocfg 1.0.1",
|
||||||
"bytes 0.6.0",
|
"bytes 0.6.0",
|
||||||
@@ -2318,7 +2327,7 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
"pin-project-lite 0.1.11",
|
"pin-project-lite 0.1.11",
|
||||||
"tokio 0.2.22",
|
"tokio 0.2.22",
|
||||||
"tokio 0.3.4",
|
"tokio 0.3.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2334,15 +2343,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-tar"
|
name = "tokio-tar"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/dr-bonez/tokio-tar.git#1ba710f344ddb2a5b4d98bb96c905195c3cd9d43"
|
||||||
checksum = "f3a9e415c93375be93253134543229563114a2be8d46440d6d8f25b2ec62a7fb"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"filetime",
|
"filetime",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"libc",
|
"libc",
|
||||||
"redox_syscall",
|
"redox_syscall 0.2.1",
|
||||||
"tokio 0.2.22",
|
"tokio 0.3.5",
|
||||||
"xattr",
|
"xattr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ rand = "0.7.3"
|
|||||||
regex = "1.4.2"
|
regex = "1.4.2"
|
||||||
reqwest = { version = "0.10.9", features = ["stream", "json"] }
|
reqwest = { version = "0.10.9", features = ["stream", "json"] }
|
||||||
rpassword = "5.0.0"
|
rpassword = "5.0.0"
|
||||||
serde = { version = "1.0.117", features = ["derive", "rc"] }
|
serde = { version = "1.0.118", features = ["derive", "rc"] }
|
||||||
serde_yaml = "0.8.14"
|
serde_yaml = "0.8.14"
|
||||||
serde_cbor = "0.11.1"
|
serde_cbor = "0.11.1"
|
||||||
serde_json = "1.0.59"
|
serde_json = "1.0.59"
|
||||||
simple-logging = "2.0"
|
simple-logging = "2.0"
|
||||||
tokio = { version = "0.3.4", features = ["full"] }
|
tokio = { version = "0.3.5", features = ["full"] }
|
||||||
tokio-compat-02 = "0.1.2"
|
tokio-compat-02 = "0.1.2"
|
||||||
tokio-tar = "0.2.0"
|
tokio-tar = { version = "0.3.0", git = "https://github.com/dr-bonez/tokio-tar.git" }
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ use std::path::Path;
|
|||||||
|
|
||||||
use failure::ResultExt as _;
|
use failure::ResultExt as _;
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
use tokio_compat_02::IoCompat;
|
|
||||||
use tokio_tar as tar;
|
use tokio_tar as tar;
|
||||||
|
|
||||||
use crate::config::{ConfigRuleEntry, ConfigSpec};
|
use crate::config::{ConfigRuleEntry, ConfigSpec};
|
||||||
@@ -49,7 +48,7 @@ pub async fn info_full<P: AsRef<Path>>(
|
|||||||
.with_context(|e| format!("{}: {}", p.display(), e))
|
.with_context(|e| format!("{}: {}", p.display(), e))
|
||||||
.with_code(crate::error::FILESYSTEM_ERROR)?;
|
.with_code(crate::error::FILESYSTEM_ERROR)?;
|
||||||
log::info!("Extracting archive.");
|
log::info!("Extracting archive.");
|
||||||
let mut pkg = tar::Archive::new(IoCompat::new(r));
|
let mut pkg = tar::Archive::new(r);
|
||||||
let mut entries = pkg.entries()?;
|
let mut entries = pkg.entries()?;
|
||||||
log::info!("Opening manifest from archive.");
|
log::info!("Opening manifest from archive.");
|
||||||
let manifest = entries
|
let manifest = entries
|
||||||
@@ -63,7 +62,7 @@ pub async fn info_full<P: AsRef<Path>>(
|
|||||||
"Package File Invalid or Corrupted"
|
"Package File Invalid or Corrupted"
|
||||||
);
|
);
|
||||||
log::trace!("Deserializing manifest.");
|
log::trace!("Deserializing manifest.");
|
||||||
let manifest: Manifest = from_cbor_async_reader(IoCompat::new(manifest)).await?;
|
let manifest: Manifest = from_cbor_async_reader(manifest).await?;
|
||||||
let manifest = manifest.into_latest();
|
let manifest = manifest.into_latest();
|
||||||
crate::ensure_code!(
|
crate::ensure_code!(
|
||||||
crate::version::Current::new()
|
crate::version::Current::new()
|
||||||
@@ -94,7 +93,7 @@ pub async fn info_full<P: AsRef<Path>>(
|
|||||||
"Package File Invalid or Corrupted"
|
"Package File Invalid or Corrupted"
|
||||||
);
|
);
|
||||||
log::trace!("Deserializing config spec.");
|
log::trace!("Deserializing config spec.");
|
||||||
let spec = from_cbor_async_reader(IoCompat::new(spec)).await?;
|
let spec = from_cbor_async_reader(spec).await?;
|
||||||
log::info!("Opening config rules from archive.");
|
log::info!("Opening config rules from archive.");
|
||||||
let rules = entries
|
let rules = entries
|
||||||
.next()
|
.next()
|
||||||
@@ -109,7 +108,7 @@ pub async fn info_full<P: AsRef<Path>>(
|
|||||||
"Package File Invalid or Corrupted"
|
"Package File Invalid or Corrupted"
|
||||||
);
|
);
|
||||||
log::trace!("Deserializing config rules.");
|
log::trace!("Deserializing config rules.");
|
||||||
let rules = from_cbor_async_reader(IoCompat::new(rules)).await?;
|
let rules = from_cbor_async_reader(rules).await?;
|
||||||
Some(AppConfig { spec, rules })
|
Some(AppConfig { spec, rules })
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@@ -125,7 +124,7 @@ pub async fn print_instructions<P: AsRef<Path>>(path: P) -> Result<(), Error> {
|
|||||||
.with_context(|e| format!("{}: {}", p.display(), e))
|
.with_context(|e| format!("{}: {}", p.display(), e))
|
||||||
.with_code(crate::error::FILESYSTEM_ERROR)?;
|
.with_code(crate::error::FILESYSTEM_ERROR)?;
|
||||||
log::info!("Extracting archive.");
|
log::info!("Extracting archive.");
|
||||||
let mut pkg = tar::Archive::new(IoCompat::new(r));
|
let mut pkg = tar::Archive::new(r);
|
||||||
let mut entries = pkg.entries()?;
|
let mut entries = pkg.entries()?;
|
||||||
log::info!("Opening manifest from archive.");
|
log::info!("Opening manifest from archive.");
|
||||||
let manifest = entries
|
let manifest = entries
|
||||||
@@ -139,7 +138,7 @@ pub async fn print_instructions<P: AsRef<Path>>(path: P) -> Result<(), Error> {
|
|||||||
"Package File Invalid or Corrupted"
|
"Package File Invalid or Corrupted"
|
||||||
);
|
);
|
||||||
log::trace!("Deserializing manifest.");
|
log::trace!("Deserializing manifest.");
|
||||||
let manifest: Manifest = from_cbor_async_reader(IoCompat::new(manifest)).await?;
|
let manifest: Manifest = from_cbor_async_reader(manifest).await?;
|
||||||
let manifest = manifest.into_latest();
|
let manifest = manifest.into_latest();
|
||||||
crate::ensure_code!(
|
crate::ensure_code!(
|
||||||
crate::version::Current::new()
|
crate::version::Current::new()
|
||||||
@@ -167,7 +166,7 @@ pub async fn print_instructions<P: AsRef<Path>>(path: P) -> Result<(), Error> {
|
|||||||
if manifest.has_instructions {
|
if manifest.has_instructions {
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
|
|
||||||
let instructions = entries
|
let mut instructions = entries
|
||||||
.next()
|
.next()
|
||||||
.await
|
.await
|
||||||
.ok_or(crate::install::Error::CorruptedPkgFile(
|
.ok_or(crate::install::Error::CorruptedPkgFile(
|
||||||
@@ -176,7 +175,7 @@ pub async fn print_instructions<P: AsRef<Path>>(path: P) -> Result<(), Error> {
|
|||||||
.no_code()??;
|
.no_code()??;
|
||||||
|
|
||||||
let mut stdout = tokio::io::stdout();
|
let mut stdout = tokio::io::stdout();
|
||||||
tokio::io::copy(&mut IoCompat::new(instructions), &mut stdout)
|
tokio::io::copy(&mut instructions, &mut stdout)
|
||||||
.await
|
.await
|
||||||
.with_code(crate::error::FILESYSTEM_ERROR)?;
|
.with_code(crate::error::FILESYSTEM_ERROR)?;
|
||||||
stdout
|
stdout
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use futures::stream::StreamExt;
|
|||||||
use futures::stream::TryStreamExt;
|
use futures::stream::TryStreamExt;
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
use tokio::io::{AsyncRead, ReadBuf};
|
use tokio::io::{AsyncRead, ReadBuf};
|
||||||
use tokio_compat_02::{FutureExt, IoCompat};
|
use tokio_compat_02::FutureExt;
|
||||||
use tokio_tar as tar;
|
use tokio_tar as tar;
|
||||||
|
|
||||||
use crate::config::{ConfigRuleEntry, ConfigSpec};
|
use crate::config::{ConfigRuleEntry, ConfigSpec};
|
||||||
@@ -215,7 +215,7 @@ pub async fn install<R: AsyncRead + Unpin + Send + Sync>(
|
|||||||
name: Option<&str>,
|
name: Option<&str>,
|
||||||
) -> Result<(), crate::Error> {
|
) -> Result<(), crate::Error> {
|
||||||
log::info!("Extracting archive.");
|
log::info!("Extracting archive.");
|
||||||
let mut pkg = tar::Archive::new(IoCompat::new(r));
|
let mut pkg = tar::Archive::new(r);
|
||||||
let mut entries = pkg.entries()?;
|
let mut entries = pkg.entries()?;
|
||||||
log::info!("Opening manifest from archive.");
|
log::info!("Opening manifest from archive.");
|
||||||
let manifest = entries
|
let manifest = entries
|
||||||
@@ -229,9 +229,7 @@ pub async fn install<R: AsyncRead + Unpin + Send + Sync>(
|
|||||||
"Package File Invalid or Corrupted"
|
"Package File Invalid or Corrupted"
|
||||||
);
|
);
|
||||||
log::trace!("Deserializing manifest.");
|
log::trace!("Deserializing manifest.");
|
||||||
let manifest: Manifest = from_cbor_async_reader(IoCompat::new(manifest))
|
let manifest: Manifest = from_cbor_async_reader(manifest).await.no_code()?;
|
||||||
.await
|
|
||||||
.no_code()?;
|
|
||||||
match manifest {
|
match manifest {
|
||||||
Manifest::V0(m) => install_v0(m, entries, name).await?,
|
Manifest::V0(m) => install_v0(m, entries, name).await?,
|
||||||
};
|
};
|
||||||
@@ -240,7 +238,7 @@ pub async fn install<R: AsyncRead + Unpin + Send + Sync>(
|
|||||||
|
|
||||||
pub async fn install_v0<R: AsyncRead + Unpin + Send + Sync>(
|
pub async fn install_v0<R: AsyncRead + Unpin + Send + Sync>(
|
||||||
manifest: ManifestV0,
|
manifest: ManifestV0,
|
||||||
mut entries: tar::Entries<IoCompat<R>>,
|
mut entries: tar::Entries<R>,
|
||||||
name: Option<&str>,
|
name: Option<&str>,
|
||||||
) -> Result<(), crate::Error> {
|
) -> Result<(), crate::Error> {
|
||||||
crate::ensure_code!(
|
crate::ensure_code!(
|
||||||
@@ -295,7 +293,7 @@ pub async fn install_v0<R: AsyncRead + Unpin + Send + Sync>(
|
|||||||
"Package File Invalid or Corrupted"
|
"Package File Invalid or Corrupted"
|
||||||
);
|
);
|
||||||
log::trace!("Deserializing config spec.");
|
log::trace!("Deserializing config spec.");
|
||||||
let config_spec: ConfigSpec = from_cbor_async_reader(IoCompat::new(config_spec)).await?;
|
let config_spec: ConfigSpec = from_cbor_async_reader(config_spec).await?;
|
||||||
log::info!("Saving config spec.");
|
log::info!("Saving config spec.");
|
||||||
let mut config_spec_out = app_dir.join("config_spec.yaml").write(None).await?;
|
let mut config_spec_out = app_dir.join("config_spec.yaml").write(None).await?;
|
||||||
to_yaml_async_writer(&mut *config_spec_out, &config_spec).await?;
|
to_yaml_async_writer(&mut *config_spec_out, &config_spec).await?;
|
||||||
@@ -312,15 +310,14 @@ pub async fn install_v0<R: AsyncRead + Unpin + Send + Sync>(
|
|||||||
"Package File Invalid or Corrupted"
|
"Package File Invalid or Corrupted"
|
||||||
);
|
);
|
||||||
log::trace!("Deserializing config rules.");
|
log::trace!("Deserializing config rules.");
|
||||||
let config_rules: Vec<ConfigRuleEntry> =
|
let config_rules: Vec<ConfigRuleEntry> = from_cbor_async_reader(config_rules).await?;
|
||||||
from_cbor_async_reader(IoCompat::new(config_rules)).await?;
|
|
||||||
log::info!("Saving config rules.");
|
log::info!("Saving config rules.");
|
||||||
let mut config_rules_out = app_dir.join("config_rules.yaml").write(None).await?;
|
let mut config_rules_out = app_dir.join("config_rules.yaml").write(None).await?;
|
||||||
to_yaml_async_writer(&mut *config_rules_out, &config_rules).await?;
|
to_yaml_async_writer(&mut *config_rules_out, &config_rules).await?;
|
||||||
config_rules_out.commit().await?;
|
config_rules_out.commit().await?;
|
||||||
if manifest.has_instructions {
|
if manifest.has_instructions {
|
||||||
log::info!("Opening instructions from archive.");
|
log::info!("Opening instructions from archive.");
|
||||||
let instructions = entries
|
let mut instructions = entries
|
||||||
.next()
|
.next()
|
||||||
.await
|
.await
|
||||||
.ok_or(Error::CorruptedPkgFile("missing config rules"))
|
.ok_or(Error::CorruptedPkgFile("missing config rules"))
|
||||||
@@ -332,7 +329,7 @@ pub async fn install_v0<R: AsyncRead + Unpin + Send + Sync>(
|
|||||||
);
|
);
|
||||||
log::info!("Saving instructions.");
|
log::info!("Saving instructions.");
|
||||||
let mut instructions_out = app_dir.join("instructions.md").write(None).await?;
|
let mut instructions_out = app_dir.join("instructions.md").write(None).await?;
|
||||||
tokio::io::copy(&mut IoCompat::new(instructions), &mut *instructions_out)
|
tokio::io::copy(&mut instructions, &mut *instructions_out)
|
||||||
.await
|
.await
|
||||||
.with_code(crate::error::FILESYSTEM_ERROR)?;
|
.with_code(crate::error::FILESYSTEM_ERROR)?;
|
||||||
instructions_out.commit().await?;
|
instructions_out.commit().await?;
|
||||||
@@ -373,7 +370,7 @@ pub async fn install_v0<R: AsyncRead + Unpin + Send + Sync>(
|
|||||||
.with_code(crate::error::FILESYSTEM_ERROR)?;
|
.with_code(crate::error::FILESYSTEM_ERROR)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
src.unpack_in(&dst_path).compat().await?;
|
src.unpack_in(&dst_path).await?;
|
||||||
if src.header().entry_type().is_dir() {
|
if src.header().entry_type().is_dir() {
|
||||||
loop {
|
loop {
|
||||||
let mut file = entries
|
let mut file = entries
|
||||||
@@ -387,7 +384,7 @@ pub async fn install_v0<R: AsyncRead + Unpin + Send + Sync>(
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
file.unpack_in(&dst_path).compat().await?;
|
file.unpack_in(&dst_path).await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -433,7 +430,7 @@ pub async fn install_v0<R: AsyncRead + Unpin + Send + Sync>(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
log::info!("Opening image.tar from archive.");
|
log::info!("Opening image.tar from archive.");
|
||||||
let image = entries
|
let mut image = entries
|
||||||
.next()
|
.next()
|
||||||
.await
|
.await
|
||||||
.ok_or(Error::CorruptedPkgFile("missing image.tar"))
|
.ok_or(Error::CorruptedPkgFile("missing image.tar"))
|
||||||
@@ -459,7 +456,7 @@ pub async fn install_v0<R: AsyncRead + Unpin + Send + Sync>(
|
|||||||
})
|
})
|
||||||
.spawn()?;
|
.spawn()?;
|
||||||
let mut child_in = child.stdin.take().unwrap();
|
let mut child_in = child.stdin.take().unwrap();
|
||||||
tokio::io::copy(&mut IoCompat::new(image), &mut child_in).await?;
|
tokio::io::copy(&mut image, &mut child_in).await?;
|
||||||
child_in.flush().await?;
|
child_in.flush().await?;
|
||||||
child_in.shutdown().await?;
|
child_in.shutdown().await?;
|
||||||
drop(child_in);
|
drop(child_in);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ use failure::ResultExt;
|
|||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
use linear_map::LinearMap;
|
use linear_map::LinearMap;
|
||||||
use rand::SeedableRng;
|
use rand::SeedableRng;
|
||||||
use tokio_compat_02::IoCompat;
|
|
||||||
use tokio_tar as tar;
|
use tokio_tar as tar;
|
||||||
|
|
||||||
use crate::config::{ConfigRuleEntry, ConfigSpec};
|
use crate::config::{ConfigRuleEntry, ConfigSpec};
|
||||||
@@ -42,7 +41,7 @@ pub async fn pack(path: &str, output: &str) -> Result<(), failure::Error> {
|
|||||||
output.display(),
|
output.display(),
|
||||||
);
|
);
|
||||||
let out_file = tokio::fs::File::create(output).await?;
|
let out_file = tokio::fs::File::create(output).await?;
|
||||||
let mut out = tar::Builder::new(IoCompat::new(out_file));
|
let mut out = tar::Builder::new(out_file);
|
||||||
log::info!("Reading {}/manifest.yaml.", path.display());
|
log::info!("Reading {}/manifest.yaml.", path.display());
|
||||||
let manifest: Manifest = crate::util::from_yaml_async_reader(
|
let manifest: Manifest = crate::util::from_yaml_async_reader(
|
||||||
tokio::fs::File::open(path.join("manifest.yaml"))
|
tokio::fs::File::open(path.join("manifest.yaml"))
|
||||||
@@ -131,7 +130,7 @@ pub async fn pack(path: &str, output: &str) -> Result<(), failure::Error> {
|
|||||||
h.set_size(0);
|
h.set_size(0);
|
||||||
h.set_path(format!("APPMGR_DIR_END:{}", asset.src.display()))?;
|
h.set_path(format!("APPMGR_DIR_END:{}", asset.src.display()))?;
|
||||||
h.set_cksum();
|
h.set_cksum();
|
||||||
out.append(&h, IoCompat::new(tokio::io::empty())).await?;
|
out.append(&h, tokio::io::empty()).await?;
|
||||||
} else {
|
} else {
|
||||||
out.append_path_with_name(&file_path, &asset.src).await?;
|
out.append_path_with_name(&file_path, &asset.src).await?;
|
||||||
}
|
}
|
||||||
@@ -145,8 +144,7 @@ pub async fn pack(path: &str, output: &str) -> Result<(), failure::Error> {
|
|||||||
log::info!("Writing image.tar to archive.");
|
log::info!("Writing image.tar to archive.");
|
||||||
let mut header = tar::Header::new_gnu();
|
let mut header = tar::Header::new_gnu();
|
||||||
header.set_size(image.metadata().await?.len());
|
header.set_size(image.metadata().await?.len());
|
||||||
out.append_data(&mut header, "image.tar", IoCompat::new(image))
|
out.append_data(&mut header, "image.tar", image).await?;
|
||||||
.await?;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out.into_inner().await?;
|
out.into_inner().await?;
|
||||||
@@ -201,7 +199,7 @@ pub async fn verify(path: &str) -> Result<(), failure::Error> {
|
|||||||
.await
|
.await
|
||||||
.with_context(|e| format!("{}: {}", path.display(), e))?;
|
.with_context(|e| format!("{}: {}", path.display(), e))?;
|
||||||
log::info!("Extracting archive.");
|
log::info!("Extracting archive.");
|
||||||
let mut pkg = tar::Archive::new(IoCompat::new(r));
|
let mut pkg = tar::Archive::new(r);
|
||||||
let mut entries = pkg.entries()?;
|
let mut entries = pkg.entries()?;
|
||||||
log::info!("Opening manifest from archive.");
|
log::info!("Opening manifest from archive.");
|
||||||
let manifest = entries
|
let manifest = entries
|
||||||
@@ -214,7 +212,7 @@ pub async fn verify(path: &str) -> Result<(), failure::Error> {
|
|||||||
manifest.path()?.display()
|
manifest.path()?.display()
|
||||||
);
|
);
|
||||||
log::trace!("Deserializing manifest.");
|
log::trace!("Deserializing manifest.");
|
||||||
let manifest: Manifest = from_cbor_async_reader(IoCompat::new(manifest)).await?;
|
let manifest: Manifest = from_cbor_async_reader(manifest).await?;
|
||||||
let manifest = manifest.into_latest();
|
let manifest = manifest.into_latest();
|
||||||
ensure!(
|
ensure!(
|
||||||
crate::version::Current::new()
|
crate::version::Current::new()
|
||||||
@@ -247,7 +245,7 @@ pub async fn verify(path: &str) -> Result<(), failure::Error> {
|
|||||||
config_spec.path()?.display()
|
config_spec.path()?.display()
|
||||||
);
|
);
|
||||||
log::trace!("Deserializing config spec.");
|
log::trace!("Deserializing config spec.");
|
||||||
let config_spec: ConfigSpec = from_cbor_async_reader(IoCompat::new(config_spec)).await?;
|
let config_spec: ConfigSpec = from_cbor_async_reader(config_spec).await?;
|
||||||
log::trace!("Validating config spec.");
|
log::trace!("Validating config spec.");
|
||||||
config_spec.validate(&manifest)?;
|
config_spec.validate(&manifest)?;
|
||||||
let config = config_spec.gen(&mut rand::rngs::StdRng::from_entropy(), &None)?;
|
let config = config_spec.gen(&mut rand::rngs::StdRng::from_entropy(), &None)?;
|
||||||
@@ -263,8 +261,7 @@ pub async fn verify(path: &str) -> Result<(), failure::Error> {
|
|||||||
config_rules.path()?.display()
|
config_rules.path()?.display()
|
||||||
);
|
);
|
||||||
log::trace!("Deserializing config rules.");
|
log::trace!("Deserializing config rules.");
|
||||||
let config_rules: Vec<ConfigRuleEntry> =
|
let config_rules: Vec<ConfigRuleEntry> = from_cbor_async_reader(config_rules).await?;
|
||||||
from_cbor_async_reader(IoCompat::new(config_rules)).await?;
|
|
||||||
log::trace!("Validating config rules against config spec.");
|
log::trace!("Validating config rules against config spec.");
|
||||||
let mut cfgs = LinearMap::new();
|
let mut cfgs = LinearMap::new();
|
||||||
cfgs.insert(name, Cow::Borrowed(&config));
|
cfgs.insert(name, Cow::Borrowed(&config));
|
||||||
@@ -378,7 +375,7 @@ pub async fn verify(path: &str) -> Result<(), failure::Error> {
|
|||||||
.await
|
.await
|
||||||
.ok_or_else(|| format_err!("image.tar is missing manifest.json"))??;
|
.ok_or_else(|| format_err!("image.tar is missing manifest.json"))??;
|
||||||
let image_manifest: Vec<DockerManifest> =
|
let image_manifest: Vec<DockerManifest> =
|
||||||
from_json_async_reader(IoCompat::new(image_manifest)).await?;
|
from_json_async_reader(image_manifest).await?;
|
||||||
image_manifest
|
image_manifest
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flat_map(|a| a.repo_tags)
|
.flat_map(|a| a.repo_tags)
|
||||||
|
|||||||
Reference in New Issue
Block a user