Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions kinode/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rayon::prelude::*;
use std::{
collections::HashSet,
fs::{self, File},
io::{Cursor, Read, Write},
path::{Path, PathBuf},
Expand All @@ -22,6 +23,24 @@ fn get_features() -> String {
features
}

fn output_reruns(dir: &Path, rerun_files: &HashSet<String>) {
if let Ok(entries) = fs::read_dir(dir) {
for entry in entries.filter_map(|e| e.ok()) {
let path = entry.path();
if path.is_dir() {
// If the entry is a directory, recursively walk it
output_reruns(&path, rerun_files);
} else if let Some(filename) = path.file_name().and_then(|n| n.to_str()) {
// Check if the current file is in our list of interesting files
if rerun_files.contains(filename) {
// If so, print a `cargo:rerun-if-changed=PATH` line for it
println!("cargo:rerun-if-changed={}", path.display());
}
}
}
}
}

fn build_and_zip_package(
entry_path: PathBuf,
parent_pkg_path: &str,
Expand Down Expand Up @@ -76,6 +95,13 @@ fn main() -> anyhow::Result<()> {
.map(|entry| entry.unwrap().path())
.collect();

let rerun_files: HashSet<String> = HashSet::from([
"Cargo.lock".to_string(),
"Cargo.toml".to_string(),
"src/".to_string(),
]);
output_reruns(&parent_dir, &rerun_files);

let features = get_features();

let results: Vec<anyhow::Result<(String, String, Vec<u8>)>> = entries
Expand Down
61 changes: 38 additions & 23 deletions kinode/packages/app_store/app_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,25 +686,35 @@ pub fn handle_install(
))?)
.send()?;

let _bytes_response = Request::to(("our", "vfs", "distro", "sys"))
.body(serde_json::to_vec(&vfs::VfsRequest {
path: wasm_path.clone(),
action: vfs::VfsAction::Read,
})?)
.send_and_await_response(5)??;
if let Ok(vfs::VfsResponse::Err(_)) = serde_json::from_slice(
Request::to(("our", "vfs", "distro", "sys"))
.body(serde_json::to_vec(&vfs::VfsRequest {
path: wasm_path.clone(),
action: vfs::VfsAction::Read,
})?)
.send_and_await_response(5)??
.body(),
) {
return Err(anyhow::anyhow!("failed to read process file"));
};

Request::new()
.target(("our", "kernel", "distro", "sys"))
.body(serde_json::to_vec(&kt::KernelCommand::InitializeProcess {
id: parsed_new_process_id.clone(),
wasm_bytes_handle: wasm_path,
wit_version: None,
on_exit: entry.on_exit.clone(),
initial_capabilities: HashSet::new(),
public: entry.public,
})?)
.inherit(true)
.send_and_await_response(5)??;
let Ok(kt::KernelResponse::InitializedProcess) = serde_json::from_slice(
Request::new()
.target(("our", "kernel", "distro", "sys"))
.body(serde_json::to_vec(&kt::KernelCommand::InitializeProcess {
id: parsed_new_process_id.clone(),
wasm_bytes_handle: wasm_path,
wit_version: None,
on_exit: entry.on_exit.clone(),
initial_capabilities: HashSet::new(),
public: entry.public,
})?)
.inherit(true)
.send_and_await_response(5)??
.body(),
) else {
return Err(anyhow::anyhow!("failed to initialize process"));
};
// build initial caps
let mut requested_capabilities: Vec<kt::Capability> = vec![];
for value in &entry.request_capabilities {
Expand Down Expand Up @@ -829,11 +839,16 @@ pub fn handle_install(
}
}
}
Request::to(("our", "kernel", "distro", "sys"))
.body(serde_json::to_vec(&kt::KernelCommand::RunProcess(
parsed_new_process_id,
))?)
.send_and_await_response(5)??;
let Ok(kt::KernelResponse::StartedProcess) = serde_json::from_slice(
Request::to(("our", "kernel", "distro", "sys"))
.body(serde_json::to_vec(&kt::KernelCommand::RunProcess(
parsed_new_process_id,
))?)
.send_and_await_response(5)??
.body(),
) else {
return Err(anyhow::anyhow!("failed to start process"));
};
}
// finally set the package as installed
state.update_downloaded_package(package_id, |package_state| {
Expand Down