Skip to content
Merged
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
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
astring
(fmt (>= 0.8.9))
logs
cmdliner
(cmdliner (>= 1.1.0))
(tar-unix (>= 2.0.0))
yojson
sexplib
Expand Down
4 changes: 2 additions & 2 deletions example.spec
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
; The result can then be found in /tank/HASH/rootfs/ (where HASH is displayed at the end of the build).

((build dev
((from ocaml/opam@sha256:af617095b1255a61f82ac1873031a850dd29c37865ff5bf691ab5ccd29187679)
((from ocaml/opam@sha256:dca2be63c27c3860560bd70001f94c39c32e8a22fdc270e5e77d297b665c871f)
(workdir /src)
(user (uid 1000) (gid 1000)) ; Build as the "opam" user
(run (shell "sudo chown opam /src"))
(env OPAM_HASH "b33a2146602d62541ce95e5f1f52b63827f076c2") ; Fix the version of opam-repository we want
(env OPAM_HASH "6ed2f3af9af5303f9a037a693e3f4696a4b51fe1") ; Fix the version of opam-repository we want
(run
(network host)
(shell "sudo apt-get --allow-releaseinfo-change update"))
Expand Down
2 changes: 1 addition & 1 deletion lib/runc_sandbox.ml
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ let fast_sync =
Arg.value @@
Arg.flag @@
Arg.info
~doc:"Ignore sync syscalls (requires runc >= 1.0.0-rc92)"
~doc:"Ignore sync syscalls (requires runc >= 1.0.0-rc92)."
["fast-sync"]

let cmdliner : config Term.t =
Expand Down
50 changes: 25 additions & 25 deletions main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,22 @@ let setup_log style_renderer level =
()

let setup_log =
Term.(const setup_log $ Fmt_cli.style_renderer () $ Logs_cli.level ())
let docs = Manpage.s_common_options in
Term.(const setup_log $ Fmt_cli.style_renderer ~docs () $ Logs_cli.level ~docs ())

let spec_file =
Arg.required @@
Arg.opt Arg.(some file) None @@
Arg.info
~doc:"Path of build spec file"
~doc:"Path of build spec file."
~docv:"FILE"
["f"]

let src_dir =
Arg.required @@
Arg.pos 0 Arg.(some dir) None @@
Arg.info
~doc:"Directory containing the source files"
~doc:"Directory containing the source files."
~docv:"DIR"
[]

Expand All @@ -107,61 +108,60 @@ let store =
Arg.required @@
Arg.opt Arg.(some store_t) None @@
Arg.info
~doc:"btrfs:/path or rsync:/path or zfs:pool for build cache"
~doc:"$(b,btrfs:/path) or $(b,rsync:/path) or $(b,zfs:pool) for build cache."
~docv:"STORE"
["store"]

let id =
Arg.required @@
Arg.pos 0 Arg.(some string) None @@
Arg.info
~doc:"The ID of a build within the store"
~doc:"The $(i,ID) of a build within the store."
~docv:"ID"
[]

let secrets =
(Arg.value @@
Arg.(opt_all (pair ~sep:':' string file)) [] @@
Arg.info
~doc:"Provide a secret under the form id:file"
~doc:"Provide a secret under the form $(b,id:file)."
~docv:"SECRET"
["secret"])

let build =
let doc = "Build a spec file." in
Term.(const build $ setup_log $ store $ spec_file $ Sandbox.cmdliner $ src_dir $ secrets),
Term.info "build" ~doc
let info = Cmd.info ~doc "build" in
Cmd.v info
Term.(const build $ setup_log $ store $ spec_file $ Sandbox.cmdliner $ src_dir $ secrets)

let delete =
let doc = "Recursively delete a cached build result." in
Term.(const delete $ setup_log $ store $ Sandbox.cmdliner $ id),
Term.info "delete" ~doc
let info = Cmd.info ~doc "delete" in
Cmd.v info
Term.(const delete $ setup_log $ store $ Sandbox.cmdliner $ id)

let buildkit =
Arg.value @@
Arg.flag @@
Arg.info
~doc:"Output extended BuildKit syntax"
~doc:"Output extended BuildKit syntax."
["buildkit"]

let dockerfile =
let doc = "Convert a spec to Dockerfile format" in
Term.(const dockerfile $ setup_log $ buildkit $ spec_file),
Term.info "dockerfile" ~doc
let doc = "Convert a spec to Dockerfile format." in
let info = Cmd.info ~doc "dockerfile" in
Cmd.v info
Term.(const dockerfile $ setup_log $ buildkit $ spec_file)

let healthcheck =
let doc = "Perform a self-test" in
Term.(const healthcheck $ setup_log $ store $ Sandbox.cmdliner),
Term.info "healthcheck" ~doc
let doc = "Perform a self-test." in
let info = Cmd.info ~doc "healthcheck" in
Cmd.v info
Term.(const healthcheck $ setup_log $ store $ Sandbox.cmdliner)

let cmds = [build; delete; dockerfile; healthcheck]

let default_cmd =
let doc = "a command-line interface for OBuilder" in
Term.(ret (const (`Help (`Pager, None)))),
Term.info "obuilder" ~doc

let term_exit (x : unit Term.result) = Term.exit x

let () =
term_exit @@ Term.eval_choice default_cmd cmds
let doc = "a command-line interface for OBuilder" in
let info = Cmd.info ~doc "obuilder" in
exit (Cmd.eval @@ Cmd.group info cmds)
2 changes: 1 addition & 1 deletion obuilder.opam
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ depends: [
"astring"
"fmt" {>= "0.8.9"}
"logs"
"cmdliner"
"cmdliner" {>= "1.1.0"}
"tar-unix" {>= "2.0.0"}
"yojson"
"sexplib"
Expand Down
12 changes: 6 additions & 6 deletions stress/stress.ml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ module Test(Store : S.STORE) = struct
let ops = ops @ [Spec.run {|[ `cat output` = %S ] || exit 1|} expected] in
let check_log data =
data |> String.split_on_char '\n' |> List.filter_map (fun line ->
match Astring.String.cut ~sep:":" line with
match Astring.String.cut ~sep:":" line with
| Some ("added", x) -> Some x
| _ -> None
)
Expand Down Expand Up @@ -221,8 +221,6 @@ let stress spec conf =

open Cmdliner

let term_exit (x : unit Term.result) = Term.exit x

let store_t =
Arg.conv Obuilder.Store_spec.(of_string, pp)

Expand All @@ -236,11 +234,13 @@ let store =

let cmd =
let doc = "Run stress tests." in
Term.(const stress $ store $ Sandbox.cmdliner),
Term.info "stress" ~doc
let info = Cmd.info ~doc "stress" in
Cmd.v info
Term.(const stress $ store $ Sandbox.cmdliner)


let () =
(* Logs.(set_level (Some Info)); *)
Fmt_tty.setup_std_outputs ();
Logs.set_reporter @@ Logs.format_reporter ();
term_exit @@ Term.eval cmd
exit @@ Cmd.eval cmd