@@ -45,32 +45,39 @@ fn main() {
4545 }
4646 } ;
4747
48- let supervisor_path = env:: var_os ( "CARGO_BIN_FILE_OPENSHELL_SANDBOX" )
49- . or_else ( || env:: var_os ( "CARGO_BIN_FILE_OPENSHELL_SANDBOX_openshell-sandbox" ) )
50- . expect ( "CARGO_BIN_FILE_OPENSHELL_SANDBOX not set" ) ;
51- let supervisor_path = PathBuf :: from ( supervisor_path) ;
52- println ! ( "cargo:rerun-if-changed={}" , supervisor_path. display( ) ) ;
53-
54- let mut supervisor = File :: open ( & supervisor_path)
55- . unwrap_or_else ( |e| panic ! ( "Failed to open {}: {e}" , supervisor_path. display( ) ) ) ;
56- let dst_path = out_dir. join ( "openshell-sandbox.zst" ) ;
57- let mut dst = File :: create ( & dst_path)
58- . unwrap_or_else ( |e| panic ! ( "Failed to create {}: {e}" , dst_path. display( ) ) ) ;
59- zstd:: stream:: copy_encode ( & mut supervisor, & mut dst, 1 ) . unwrap_or_else ( |e| {
60- panic ! (
61- "Failed to compress {} to {}: {e}" ,
62- supervisor_path. display( ) ,
63- dst_path. display( )
64- )
65- } ) ;
66- let size = fs:: metadata ( & dst_path) . map_or ( 0 , |m| m. len ( ) ) ;
67- println ! ( "cargo:warning=Embedded openshell-sandbox.zst: {size} bytes" ) ;
48+ let supervisor_artifact = env:: var_os ( "CARGO_BIN_FILE_OPENSHELL_SANDBOX" )
49+ . or_else ( || env:: var_os ( "CARGO_BIN_FILE_OPENSHELL_SANDBOX_openshell-sandbox" ) ) ;
50+ let supervisor_embedded = supervisor_artifact. is_some ( ) ;
51+ if let Some ( supervisor_path) = supervisor_artifact {
52+ let supervisor_path = PathBuf :: from ( supervisor_path) ;
53+ println ! ( "cargo:rerun-if-changed={}" , supervisor_path. display( ) ) ;
54+
55+ let mut supervisor = File :: open ( & supervisor_path)
56+ . unwrap_or_else ( |e| panic ! ( "Failed to open {}: {e}" , supervisor_path. display( ) ) ) ;
57+ let dst_path = out_dir. join ( "openshell-sandbox.zst" ) ;
58+ let mut dst = File :: create ( & dst_path)
59+ . unwrap_or_else ( |e| panic ! ( "Failed to create {}: {e}" , dst_path. display( ) ) ) ;
60+ zstd:: stream:: copy_encode ( & mut supervisor, & mut dst, 1 ) . unwrap_or_else ( |e| {
61+ panic ! (
62+ "Failed to compress {} to {}: {e}" ,
63+ supervisor_path. display( ) ,
64+ dst_path. display( )
65+ )
66+ } ) ;
67+ let size = fs:: metadata ( & dst_path) . map_or ( 0 , |m| m. len ( ) ) ;
68+ println ! ( "cargo:warning=Embedded openshell-sandbox.zst: {size} bytes" ) ;
69+ }
70+ let setup_hint = if supervisor_embedded {
71+ "Run: mise run vm:setup"
72+ } else {
73+ "Run: mise run vm:setup && mise run vm:supervisor"
74+ } ;
6875
6976 let compressed_dir = if let Ok ( dir) = env:: var ( "OPENSHELL_VM_RUNTIME_COMPRESSED_DIR" ) {
7077 PathBuf :: from ( dir)
7178 } else {
7279 println ! ( "cargo:warning=OPENSHELL_VM_RUNTIME_COMPRESSED_DIR not set" ) ;
73- println ! ( "cargo:warning=Run: mise run vm:setup && mise run vm:supervisor " ) ;
80+ println ! ( "cargo:warning={setup_hint} " ) ;
7481 generate_stub_resources (
7582 & out_dir,
7683 & [
@@ -89,7 +96,7 @@ fn main() {
8996 "cargo:warning=Compressed runtime dir not found: {}" ,
9097 compressed_dir. display( )
9198 ) ;
92- println ! ( "cargo:warning=Run: mise run vm:setup && mise run vm:supervisor " ) ;
99+ println ! ( "cargo:warning={setup_hint} " ) ;
93100 generate_stub_resources (
94101 & out_dir,
95102 & [
@@ -110,11 +117,19 @@ fn main() {
110117 format ! ( "{libkrunfw_name}.zst" ) ,
111118 ) ,
112119 ( "gvproxy.zst" . to_string ( ) , "gvproxy.zst" . to_string ( ) ) ,
120+ (
121+ "openshell-sandbox.zst" . to_string ( ) ,
122+ "openshell-sandbox.zst" . to_string ( ) ,
123+ ) ,
113124 ( "umoci.zst" . to_string ( ) , "umoci.zst" . to_string ( ) ) ,
114125 ] ;
115126
116127 let mut all_found = true ;
117128 for ( src_name, dst_name) in & files {
129+ if supervisor_embedded && src_name == "openshell-sandbox.zst" {
130+ continue ;
131+ }
132+
118133 let src_path = compressed_dir. join ( src_name) ;
119134 let dst_path = out_dir. join ( dst_name) ;
120135
@@ -143,9 +158,7 @@ fn main() {
143158 }
144159
145160 if !all_found {
146- println ! (
147- "cargo:warning=Some artifacts missing. Run: mise run vm:setup && mise run vm:supervisor"
148- ) ;
161+ println ! ( "cargo:warning=Some artifacts missing. {setup_hint}" ) ;
149162 generate_stub_resources (
150163 & out_dir,
151164 & [
0 commit comments