diff --git a/src/artifact/arch.rs b/src/artifact/arch.rs index 6fedf1f..ef08e44 100644 --- a/src/artifact/arch.rs +++ b/src/artifact/arch.rs @@ -4,6 +4,7 @@ use eyre::Result; use regex::Regex; use tokio::fs::File; use tokio_stream::StreamExt; +use tracing::*; use crate::fs::MemFS; use crate::util::config::Injection; @@ -191,6 +192,7 @@ impl ArtifactProducer for ArchProducer { let size = get_artifact_size(previous).await?; let builddate = util::get_current_time()?; + info!("generating .PKGINFO..."); let content = indoc::formatdoc! {r#" # generated by peckish pkgname = {name} @@ -212,6 +214,7 @@ impl ArtifactProducer for ArchProducer { arch = self.package_arch, }; + info!("creating package..."); let mut new_injections = self.injections.clone(); new_injections.push(Injection::Create { path: PathBuf::from(".PKGINFO"), diff --git a/src/artifact/deb.rs b/src/artifact/deb.rs index d016b53..f746e76 100644 --- a/src/artifact/deb.rs +++ b/src/artifact/deb.rs @@ -72,6 +72,7 @@ impl DebArtifact { let mut archive = { let path = self.path.clone(); tokio::task::spawn_blocking(move || { + debug!("decompressing deb into memory..."); let mut decompressed = vec![]; // Decompress deb into memory let mut file = std::fs::File::open(path).unwrap(); @@ -90,6 +91,7 @@ impl DebArtifact { let mut ar_entry = entry?; let path = String::from_utf8_lossy(ar_entry.header().identifier()).to_string(); if path.starts_with("data.tar") { + debug!("found data.dar!"); let ar_buf = { use std::io::Read; let mut b = vec![]; @@ -102,6 +104,7 @@ impl DebArtifact { let decompressed_tarball = produce_from_tmp.path_view().join("decompressed.tar"); let output_tmp = TempDir::new().await?; + debug!("extracting to {}", produce_from_tarball.display()); // Write ar_buf to produce_from_tmp let mut ar_file = File::create(&produce_from_tarball).await?; ar_file.write_all(&ar_buf).await?; @@ -127,6 +130,7 @@ impl DebArtifact { .produce_from(&decompressed_artifact) .await?; + debug!("copying data artifact to memfs..."); // Copy decompressed_data_artifact to fs fs.copy_files_from_paths( &vec![output_tmp.path_view()], @@ -304,6 +308,7 @@ impl ArtifactProducer for DebProducer { let tmp = TempDir::new().await?; // Create data.tar from previous artifact in tmp using TarballProducer + info!("packaging data files..."); debug!("producing data.tar from previous artifact..."); let data_tar = tmp.path_view().join("data.tar"); let _tar_artifact = TarballProducer { @@ -316,6 +321,7 @@ impl ArtifactProducer for DebProducer { .await?; // Create control.tar from control file in tmp + info!("packaging metadata files..."); debug!("producing control.tar..."); let control_tar = tmp.path_view().join("control.tar"); let mut control_tar_builder = tokio_tar::Builder::new(File::create(&control_tar).await?); @@ -361,6 +367,7 @@ impl ArtifactProducer for DebProducer { debug!("wrote postinst file {} to control.tar", postinst.display()); } + info!("computing checksums..."); // Compute the md5sums of every file in the memfs let mut md5sums = vec![]; let memfs = previous.extract().await?; @@ -412,7 +419,7 @@ impl ArtifactProducer for DebProducer { } // Create .deb ar archive from debian-binary, control.tar, and data.tar - debug!("building final .deb..."); + info!("building final .deb..."); let mut deb_builder = ar::Builder::new(std::fs::File::create(&self.path)?); deb_builder.append_path(&debian_binary)?; diff --git a/src/artifact/docker.rs b/src/artifact/docker.rs index b8f0148..77d0645 100644 --- a/src/artifact/docker.rs +++ b/src/artifact/docker.rs @@ -43,6 +43,7 @@ impl Artifact for DockerArtifact { let docker = Docker::connect_with_local_defaults()?; let (image, tag) = split_image_name_into_repo_and_tag(&self.image); + info!("attempting to pull {}...", self.image); // Attempt to download the image let mut pull = docker.create_image( Some(CreateImageOptions { @@ -61,8 +62,9 @@ impl Artifact for DockerArtifact { // Export image to a TAR file let tmp = TempDir::new().await?; + info!("exporting to tarball..."); let mut export = docker.export_image(&self.image); - let export_name = format!("{}.tar", self.name); + let export_name = format!("{}.tar", self.name.replace(['/', ':', ' '], "_")); let export_path = tmp.path_view().join(&export_name); tokio::fs::create_dir_all(export_path.parent().unwrap()) .await @@ -88,6 +90,7 @@ impl Artifact for DockerArtifact { tokio::fs::remove_dir_all(&tmp).await?; // Collect layers + info!("gathering docker layers..."); let mut manifest = basic_tar_fs.open_file("/manifest.json").await?; let mut buf = String::new(); manifest.read_to_string(&mut buf).await?; @@ -105,6 +108,7 @@ impl Artifact for DockerArtifact { .map(|v| v.as_str().unwrap()) .collect(); + info!("extracting docker layers into memfs..."); let tmp = TempDir::new().await?; for layer in layers { // For each layer, extract it into the tmp directory. diff --git a/src/artifact/rpm.rs b/src/artifact/rpm.rs index 9068c47..1664cad 100644 --- a/src/artifact/rpm.rs +++ b/src/artifact/rpm.rs @@ -31,7 +31,7 @@ impl Artifact for RpmArtifact { async fn extract(&self) -> Result { use tokio::io::{AsyncReadExt, AsyncWriteExt}; - debug!("reading rpm: {}", &self.path.display()); + info!("extracting {}...", &self.path.display()); let mut rpm_file = tokio::fs::File::open(&self.path).await?; let metadata = rpm_file.metadata().await?; let size = metadata.len(); @@ -187,6 +187,7 @@ impl ArtifactProducer for RpmProducer { /// Produce a new artifact, given a previous artifact. async fn produce_from(&self, previous: &dyn Artifact) -> Result { + info!("producing {}", self.path.display()); debug!("extracting previous artifact to tmpdir"); let tmp = TempDir::new().await?; let file_artifact = FileProducer { @@ -225,7 +226,7 @@ impl ArtifactProducer for RpmProducer { pkg = pkg.requires(rpm::Dependency::any(dep)); } - debug!("building package!"); + info!("building final rpm..."); let pkg = pkg.build().unwrap(); let path_clone = self.path.clone(); let join_handle = tokio::task::spawn_blocking(move || { diff --git a/src/artifact/tarball.rs b/src/artifact/tarball.rs index 913a8de..fe54255 100644 --- a/src/artifact/tarball.rs +++ b/src/artifact/tarball.rs @@ -37,7 +37,7 @@ impl Artifact for TarballArtifact { // filesystem. // This is sadly necessary because Rust's tar libraries don't allow for // in-memory manipulation. - debug!("unpacking tarball to {:?}", self.path); + info!("unpacking {}", self.path.display()); let decompress_tmpdir = TempDir::new().await?; let decompressed_tarball = decompress_tmpdir.path_view().join("decompressed.tar"); @@ -99,7 +99,7 @@ impl SelfValidation for TarballArtifact { } if !errors.is_empty() { - return Err(eyre!("Tarball artifact not valid:\n{}", errors.join("\n"))); + return Err(eyre!("tarball artifact not valid:\n{}", errors.join("\n"))); } Ok(()) @@ -159,6 +159,7 @@ impl ArtifactProducer for TarballProducer { } async fn produce_from(&self, previous: &dyn Artifact) -> Result { + info!("producing {}", self.path.display()); let memfs = previous.extract().await?; let memfs = self.inject(&memfs).await?; let paths = traverse_memfs(memfs, &PathBuf::from("/"), Some(true)).await?; diff --git a/src/pipeline/mod.rs b/src/pipeline/mod.rs index f7eac57..27933c8 100644 --- a/src/pipeline/mod.rs +++ b/src/pipeline/mod.rs @@ -38,7 +38,7 @@ impl Pipeline { let mut output_artifacts: Vec> = vec![]; for (i, producer) in config.output.iter().enumerate() { - info!("step {}: {}", i + 1, producer.name()); + info!("* step {}: {}", i + 1, producer.name()); let next_artifact: Box = match producer { ConfiguredProducer::File(producer) => { producer.validate().await?; @@ -77,7 +77,7 @@ impl Pipeline { input_artifact = next_artifact.try_clone()?; } - info!("created artifact: {}", next_artifact.name()); + info!("* created artifact: {}", next_artifact.name()); output_artifacts.push(next_artifact); }