diff --git a/bootpkg/src/main.rs b/bootpkg/src/main.rs index f59cf01..8853c9b 100644 --- a/bootpkg/src/main.rs +++ b/bootpkg/src/main.rs @@ -1,13 +1,15 @@ -use crate::args::{Args, Command}; -use pkgfile::PKGFile; use std::env; use std::env::temp_dir; -use std::fs::{create_dir, create_dir_all, File}; +use std::fs::{create_dir_all, File, remove_dir_all}; use std::io::Write; -use std::path::PathBuf; use std::process::exit; + use uuid::Uuid; +use pkgfile::PKGFile; + +use crate::args::{Args, Command}; + mod args; mod prelude; @@ -30,6 +32,7 @@ fn main() { .expect("Could not turn file into bytes.") .to_vec() } else { + println!("** reading data..."); if let Ok(d) = std::fs::read(uri) { d } else { @@ -38,6 +41,7 @@ fn main() { } }; + println!("** parsing pkgfile..."); let pkg = match PKGFile::try_from(data) { Ok(p) => p, Err(_) => { @@ -48,7 +52,10 @@ fn main() { let mani = prelude::mani_from_str(&pkg.manifest); - println!("!! Package: {}", &mani.package.name); + println!("-- Package: {}", &mani.package.name); + println!("-- Description: {}", &mani.package.description); + println!("-- Version: {}", &mani.package.version); + println!("-- Tags: {}", &mani.package.tags.join(", ")); if !mani.valid() { println!("!!! Manifest is not valid."); @@ -61,16 +68,22 @@ fn main() { .expect("Could not create tmp dir."); { - let mut file = File::create(format!("{}/pkgtar", tmp_dir.to_str().unwrap())) + println!("** writing tar to tmp file..."); + let mut file = File::create(format!("{}/pkgtar", tmp_dir.to_str().unwrap_or("/tmp"))) .expect("Could not create tmp pkgtar file"); file.write(&pkg.data) .expect("Could not write pkgtar to tmp file"); } + // TODO: untar // TODO: cd into pkg // TODO: run bootstrap commands + + println!("** removing temporary directory..."); + remove_dir_all(&tmp_dir) + .expect(&*format!("Could not remove tmp dir: {}", &tmp_dir.to_str().unwrap())); } Command::Unpack => {} _ => { diff --git a/bootpkg/src/prelude.rs b/bootpkg/src/prelude.rs index b62eda1..13a9936 100644 --- a/bootpkg/src/prelude.rs +++ b/bootpkg/src/prelude.rs @@ -1,8 +1,10 @@ -use manifest::{self, Manifest}; +use std::str::FromStr; + use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, str::FromStr}; use toml; +use manifest::{self, Manifest}; + #[derive(Serialize, Deserialize)] pub struct PKGR { pub bootstrap: Option, diff --git a/manifest/src/bin.rs b/manifest/src/bin.rs index e8b48a3..a7af0e7 100644 --- a/manifest/src/bin.rs +++ b/manifest/src/bin.rs @@ -1,5 +1,6 @@ use std::collections::HashMap; -use serde::{Serialize, Deserialize}; + +use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] pub struct Bin { diff --git a/manifest/src/build.rs b/manifest/src/build.rs index 0ad59ec..a727d49 100644 --- a/manifest/src/build.rs +++ b/manifest/src/build.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] pub struct Build { diff --git a/manifest/src/lib.rs b/manifest/src/lib.rs index 71efe31..c894ec5 100644 --- a/manifest/src/lib.rs +++ b/manifest/src/lib.rs @@ -1,6 +1,7 @@ -use serde::{Deserialize, Serialize}; use std::{collections::HashMap, str::FromStr}; +use serde::{Deserialize, Serialize}; + pub mod package; pub mod fs; pub mod bin; diff --git a/manifest/src/package.rs b/manifest/src/package.rs index 3fa1626..528aa29 100644 --- a/manifest/src/package.rs +++ b/manifest/src/package.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] pub enum PackageType { diff --git a/manifest/src/pkgr.rs b/manifest/src/pkgr.rs index 2ca5fd4..8c4ce55 100644 --- a/manifest/src/pkgr.rs +++ b/manifest/src/pkgr.rs @@ -1,4 +1,4 @@ -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] pub struct PKGR {} \ No newline at end of file diff --git a/mock-pkg.py b/mock-pkg.py index 57ee008..70ba501 100644 --- a/mock-pkg.py +++ b/mock-pkg.py @@ -1,4 +1,5 @@ -import tarfile, os +import os +import tarfile with open("./package.toml", mode='r') as mani: data = mani.read()