(rootfs: &Path)
| 812 | } |
| 813 | |
| 814 | fn ensure_supervisor_binary(rootfs: &Path) -> Result<(), String> { |
| 815 | let path = rootfs.join(SANDBOX_SUPERVISOR_PATH.trim_start_matches('/')); |
| 816 | if SUPERVISOR.is_empty() { |
| 817 | if !path.exists() { |
| 818 | return Err( |
| 819 | "sandbox supervisor not embedded. Build openshell-driver-vm with OPENSHELL_VM_RUNTIME_COMPRESSED_DIR set and run `mise run vm:setup && mise run vm:supervisor` first" |
| 820 | .to_string(), |
| 821 | ); |
| 822 | } |
| 823 | } else { |
| 824 | if let Some(parent) = path.parent() { |
| 825 | fs::create_dir_all(parent).map_err(|e| format!("create {}: {e}", parent.display()))?; |
| 826 | } |
| 827 | |
| 828 | let supervisor = zstd::decode_all(Cursor::new(SUPERVISOR)) |
| 829 | .map_err(|e| format!("decompress supervisor: {e}"))?; |
| 830 | fs::write(&path, supervisor).map_err(|e| format!("write {}: {e}", path.display()))?; |
| 831 | } |
| 832 | |
| 833 | #[cfg(unix)] |
| 834 | { |
| 835 | use std::os::unix::fs::PermissionsExt as _; |
| 836 | |
| 837 | fs::set_permissions(&path, fs::Permissions::from_mode(0o755)) |
| 838 | .map_err(|e| format!("chmod {}: {e}", path.display()))?; |
| 839 | } |
| 840 | |
| 841 | Ok(()) |
| 842 | } |
| 843 | |
| 844 | fn ensure_umoci_binary(rootfs: &Path) -> Result<(), String> { |
| 845 | let path = rootfs.join(SANDBOX_UMOCI_PATH.trim_start_matches('/')); |
no test coverage detected