@@ -9,6 +9,8 @@ type t = {
99 fallback_library_path : string ;
1010 (* Scoreboard -- where we keep our symlinks for knowing homedirs for users *)
1111 scoreboard : string ;
12+ (* Should the sandbox mount and unmount the FUSE filesystem *)
13+ no_fuse : bool ;
1214 (* Whether or not the FUSE filesystem is mounted *)
1315 mutable fuse_mounted : bool ;
1416 (* Whether we have chowned/chmoded the data *)
@@ -21,6 +23,7 @@ type config = {
2123 uid : int ;
2224 fallback_library_path : string ;
2325 scoreboard : string ;
26+ no_fuse : bool ;
2427}[@@ deriving sexp ]
2528
2629let run_as ~env ~user ~cmd =
@@ -50,12 +53,12 @@ let copy_to_log ~src ~dst =
5053 and copy back out the result. It's not super efficienct, but is necessary.*)
5154let post_build ~result_dir ~home_dir (t : t ) =
5255 Os. sudo [" rsync" ; " -aHq" ; " --delete" ; home_dir ^ " /" ; result_dir ] >> = fun () ->
53- if not t.fuse_mounted then Lwt. return () else
56+ if not t.fuse_mounted || t.no_fuse then Lwt. return () else
5457 let f = [" umount" ; " -f" ; " /usr/local" ] in
5558 Os. sudo f >> = fun _ -> t.fuse_mounted < - false ; Lwt. return ()
5659
5760(* Using rsync to delete old files seems to be a good deal faster. *)
58- let rec pre_build ~result_dir ~home_dir (t : t ) =
61+ let pre_build ~result_dir ~home_dir (t : t ) =
5962 Os. sudo [ " mkdir" ; " -p" ; " /tmp/obuilder-empty" ] >> = fun () ->
6063 Os. sudo [ " rsync" ; " -aHq" ; " --delete" ; " /tmp/obuilder-empty/" ; home_dir ^ " /" ] >> = fun () ->
6164 Os. sudo [ " rsync" ; " -aHq" ; result_dir ^ " /" ; home_dir ] >> = fun () ->
@@ -64,7 +67,7 @@ let rec pre_build ~result_dir ~home_dir (t : t) =
6467 Os. sudo [ " chmod" ; " -R" ; " g+w" ; home_dir ] >> = fun () ->
6568 Lwt. return (t.chowned < - true )
6669 end) >> = fun () ->
67- if t.fuse_mounted then Lwt. return () else
70+ if t.fuse_mounted || t.no_fuse then Lwt. return () else
6871 let f = [ " obuilderfs" ; t.scoreboard ; " /usr/local" ; " -o" ; " allow_other" ] in
6972 Os. sudo f >> = fun _ -> t.fuse_mounted < - true ; Lwt. return ()
7073
@@ -131,6 +134,7 @@ let create ~state_dir:_ c =
131134 gid = 1000 ;
132135 fallback_library_path = c.fallback_library_path;
133136 scoreboard = c.scoreboard;
137+ no_fuse = c.no_fuse;
134138 fuse_mounted = false ;
135139 chowned = false ;
136140 }
@@ -162,8 +166,17 @@ let scoreboard =
162166 ~docv: " SCOREBOARD"
163167 [" scoreboard" ]
164168
169+ let no_fuse =
170+ Arg. value @@
171+ Arg. flag @@
172+ Arg. info
173+ ~doc: " Whether the macOS sandbox should mount and unmount the FUSE filesystem. \
174+ This is useful for testing."
175+ ~docv: " NO-FUSE"
176+ [" no-fuse" ]
177+
165178let cmdliner : config Term.t =
166- let make uid fallback_library_path scoreboard =
167- { uid; fallback_library_path; scoreboard; }
179+ let make uid fallback_library_path scoreboard no_fuse =
180+ { uid; fallback_library_path; scoreboard; no_fuse }
168181 in
169- Term. (const make $ uid $ fallback_library_path $ scoreboard)
182+ Term. (const make $ uid $ fallback_library_path $ scoreboard $ no_fuse )
0 commit comments