diff --git a/README.md b/README.md index 0ae805c2..3eb3540a 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ file in your home directory under `~/.shark`. A default is provided from the com ```sh $ shark config -((store (Zfs obuilder-zfs))) +((store (Zfs (() obuilder-zfs false)))) ``` ## Markdown Support diff --git a/docs/zfs.md b/docs/zfs.md new file mode 100644 index 00000000..fae26c55 --- /dev/null +++ b/docs/zfs.md @@ -0,0 +1,26 @@ +# ZFS Setup + +The best store to use as a backend is probably ZFS. A simple setup without +changing your whole system to ZFS might look something like: + + +``` +truncate --size XG zfs.img +sudo zpool create obuilder-zfs $PWD/zfs.img +``` + +And then you can run shark (from source, in a development mode). + +``` +sudo env "PATH=$PATH" dune exec -- shark md specs/shark.md --store=zfs:obuilder-zfs --verbose +``` + +If your system is booted from ZFS, then there might some `` ZFS pool, and you will want +the datasets to be stored under a sub-dataset name for example `shark`. + +``` +sudo env "PATH=$PATH" dune exec -- shark md specs/shark.md --store=zfs::shark --zfs-path-without-pool --verbose +``` + +The files will be available from `/shark/results//rootfs` after this. + diff --git a/src/bin/dune b/src/bin/dune index a6007fc2..6d5c8bac 100644 --- a/src/bin/dune +++ b/src/bin/dune @@ -2,7 +2,7 @@ (name main) (public_name shark) (libraries - eio_main + eio_posix shark shark.server lwt.unix diff --git a/src/bin/main.ml b/src/bin/main.ml index 03294581..082eb6a4 100644 --- a/src/bin/main.ml +++ b/src/bin/main.ml @@ -3,11 +3,7 @@ let ( / ) = Filename.concat module Sandbox = Obuilder.Native_sandbox module Store_spec = Obuilder.Store_spec -let store_of_string = function - | `Rsync path -> `Rsync (path, Obuilder.Rsync_store.Copy) - | (`Zfs _ | `Btrfs _ | `Xfs _ | `Docker _) as v -> v - -let config_path = +let _config_path = match Sys.getenv_opt "SHARK_CONFIG" with | Some config -> config | None -> ( @@ -15,13 +11,12 @@ let config_path = | Some home -> Filename.concat home ".shark" | None -> failwith "No SHARK_CONFIG or HOME environment variables") -let store_or_default v = - match Option.map store_of_string v with - | Some store -> Obuilder.Store_spec.to_store store - | None -> - let config = In_channel.with_open_bin config_path In_channel.input_all in - let config = Shark.Config.t_of_sexp (Sexplib.Sexp.of_string config) in - Obuilder.Store_spec.to_store config.store +(* TODO: Default store config is disabled for now *) +let store_or_default = function store -> store +(* | None -> + let config = In_channel.with_open_bin config_path In_channel.input_all in + let config = Shark.Config.t_of_sexp (Sexplib.Sexp.of_string config) in + Obuilder.Store_spec.to_store config.store *) let run_eventloop ~clock main = Lwt_eio.with_event_loop ~clock @@ fun _ -> main () @@ -198,7 +193,7 @@ let template ~clock ~fs () file directory = Ok () let config () = - let config = Shark.Config.{ store = `Zfs "obuilder-zfs" } in + let config = Shark.Config.{ store = `Zfs (None, "obuilder-zfs", false) } in Fmt.pr "%a" Sexplib.Sexp.pp_hum (Shark.Config.sexp_of_t config); Ok () @@ -246,11 +241,7 @@ let src_dir = @@ Arg.info ~doc:"Directory containing the source files." ~docv:"SRC_DIR" [ "src_dir" ] -let store = - Arg.value - @@ Arg.opt Arg.(some Store_spec.store_t) None - @@ Arg.info ~doc:"Store for shark, defaults to configuration file." - ~docv:"STORE" [ "store" ] +let store = Store_spec.cmdliner let no_run = Arg.value @@ Arg.flag diff --git a/src/test/ci.sh b/src/test/ci.sh index b2ee26c2..49e7d00c 100755 --- a/src/test/ci.sh +++ b/src/test/ci.sh @@ -21,7 +21,7 @@ case "$1" in sudo mkdir /rsync sudo chown "$(whoami)" /rsync - sudo "$GITHUB_WORKSPACE/_build/install/default/bin/shark" md specs/shark.md --store=rsync:/rsync --verbose + sudo "$GITHUB_WORKSPACE/_build/install/default/bin/shark" md specs/shark.md --store=rsync:/rsync --rsync-mode=hardlink --verbose cat ./_shark/gdal.version diff --git a/vendor/obuilder b/vendor/obuilder index 2a9d9d36..efd76cb3 160000 --- a/vendor/obuilder +++ b/vendor/obuilder @@ -1 +1 @@ -Subproject commit 2a9d9d36a1dd6a78e81a01cad6a9c3f0d45d4606 +Subproject commit efd76cb3b5fc2ecf1aa97358c137e8d1bb661a5c