}
\ No newline at end of file
diff --git a/manifest/src/lib.rs b/manifest/src/lib.rs
index fdc8cbc..71efe31 100644
--- a/manifest/src/lib.rs
+++ b/manifest/src/lib.rs
@@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize};
-use std::collections::HashMap;
+use std::{collections::HashMap, str::FromStr};
pub mod package;
pub mod fs;
@@ -18,6 +18,22 @@ pub struct Manifest> {
pub pkgr: P
}
+impl Manifest {
+ pub fn valid(&self) -> bool {
+ if self.bin.is_none() && self.build.is_none() {
+ return false
+ }
+ true
+ }
+}
+
+impl FromStr for Manifest {
+ type Err = toml::de::Error;
+ fn from_str(s: &str) -> Result {
+ toml::from_str(s)
+ }
+}
+
impl Default for Manifest {
fn default() -> Self {
Manifest {
diff --git a/mock-pkg.py b/mock-pkg.py
new file mode 100644
index 0000000..57ee008
--- /dev/null
+++ b/mock-pkg.py
@@ -0,0 +1,22 @@
+import tarfile, os
+
+with open("./package.toml", mode='r') as mani:
+ data = mani.read()
+ with open("./mock.pkg", mode='wb') as pkg:
+ print("building header...")
+ pkg.write(bytes([0x01, (len(data) >> 8) & 0xFF, len(data) & 0xFF]))
+ print("writing manifest into pkg...")
+ pkg.write(data.encode("utf-8"))
+ with tarfile.TarFile("/tmp/pkgtar", 'w') as pkgtar:
+ for root, dirs, files in os.walk("."):
+ for file in files:
+ print(f"\33[2Kadd: {file}", end="\r", flush=True)
+ pkgtar.add(os.path.join(root, file))
+ with open("/tmp/pkgtar", 'rb') as pkgtar:
+ print("appending pkgtar to pkg...")
+ pkg.write(pkgtar.read())
+ print("deleting /tmp/pkgtar...")
+ os.unlink("/tmp/pkgtar")
+ print("closing write stream")
+ pkg.close()
+
\ No newline at end of file
diff --git a/package.toml b/package.toml
index fbc4070..54d55b5 100644
--- a/package.toml
+++ b/package.toml
@@ -18,10 +18,7 @@ version = 1 # this can automatically be incremented when publishing by running `
# previous version will lose this tag
# - oldest
# assigned to the first version.
-tags = [
- "prod",
- "pkgr-spec-1"
-]
+tags = [ "prod", "pkgr-spec-1" ]
## package.type
# Supported types:
@@ -39,7 +36,7 @@ arch = "x86_64" # this is automatically filled by `pkgr publish ...`
# you may use the following syntax
# "" or ",,..."
[dependencies]
-example = { arch = "x86_64", tags = [ "stable" ], version = "v1" }
+#example = { arch = "x86_64", tags = [ "stable" ], version = "v1" }
exnmbr2 = "v1,stable"
## fs
@@ -97,14 +94,12 @@ base = "latest,stable" # selected by default
# This exists so that packager is easy to install on anything!
# and only 1 release channel for pkgr
[pkgr.bootstrap]
-# any non-zero = installed
-check_installed_commands = [
- "/scripts/check_installed"
-]
+## any non-zero = installed
+check_installed_commands = [ "/scripts/check_installed" ]
# any non-zero = fail
commands = [
- "/scripts/bootstrap/download_latest @version /tmp/pkgr.pkg",
- "/scripts/bootstrap/dirty_install /tmp/pkgr.pkg",
- "/scripts/bootstrap/check_install"
+ "/scripts/bootstrap/download_latest @version /tmp/pkgr.pkg",
+ "/scripts/bootstrap/dirty_install /tmp/pkgr.pkg",
+ "/scripts/bootstrap/check_install"
]
diff --git a/pkg/scripts/bootstrap/download_latest b/pkg/scripts/bootstrap/download_latest
new file mode 100644
index 0000000..229aaa2
--- /dev/null
+++ b/pkg/scripts/bootstrap/download_latest
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+fetch_latest_version() {
+}
+
+download_file() {
+}
\ No newline at end of file
diff --git a/pkgfile/src/lib.rs b/pkgfile/src/lib.rs
index a6b1d5e..6025cd5 100644
--- a/pkgfile/src/lib.rs
+++ b/pkgfile/src/lib.rs
@@ -20,17 +20,29 @@ impl TryFrom> for PKGFile {
Ok(PKGFile {
manifest: match String::from_utf8(
value[
- 3..(manifest_size as usize)
+ 3..(manifest_size as usize + 3)
].to_vec()
)
{
Ok(s) => s,
_ => return Err(())
},
- data: value[(manifest_size as usize)..].to_vec(),
+ data: value[(manifest_size as usize + 3)..].to_vec(),
})
}
_ => Err(())
}
}
}
+
+impl Into> for PKGFile {
+ fn into(self) -> Vec {
+ let mut bytes = vec![0x01];
+ let manifest_bytes = self.manifest.into_bytes();
+ bytes.push((manifest_bytes.len() >> 8) as u8);
+ bytes.push((manifest_bytes.len() | 0xFF) as u8);
+ bytes.extend(manifest_bytes);
+ bytes.extend(self.data);
+ bytes
+ }
+}
\ No newline at end of file