Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mirage/mirage
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1f53284302e6
Choose a base ref
...
head repository: mirage/mirage
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e14fbaef0fdc
Choose a head ref
  • 4 commits
  • 1 file changed
  • 2 contributors

Commits on Dec 7, 2016

  1. Copy the full SHA
    b260e94 View commit details
  2. Copy the full SHA
    8d35cad View commit details
  3. Copy the full SHA
    36e3b09 View commit details
  4. Merge pull request #723 from yomimono/ocamlify-fat-name

    ocamlify names used in fat block construction & reference
    yomimono authored Dec 7, 2016
    Copy the full SHA
    e14fbae View commit details
Showing with 12 additions and 5 deletions.
  1. +12 −5 lib/mirage.ml
17 changes: 12 additions & 5 deletions lib/mirage.ml
Original file line number Diff line number Diff line change
@@ -461,15 +461,17 @@ let fat_conf = impl @@ object
let fat ?(io_page=default_io_page) block = fat_conf $ block $ io_page

let fat_block ?(dir=".") ?(regexp="*") () =
let name = Name.create (Fmt.strf "fat%s:%s" dir regexp) ~prefix:"fat_block" in
let name = Name.(ocamlify @@ create (Fmt.strf "fat%s:%s" dir regexp) ~prefix:"fat_block") in
let block_file = name ^ ".img" in
impl @@ object
inherit block_conf block_file as super

method packages = Key.pure [ package ~build:true "fat-filesystem" ]
method packages = Key.map (fun l -> (package ~build:true "fat-filesystem") :: l) super#packages
method build i =
let root = Info.root i in
let file = Printf.sprintf "make-%s-image.sh" name in
let dir = Fpath.of_string dir |> R.error_msg_to_invalid_arg in
Log.info (fun m -> m "Generating block generator script: %s" file);
with_output ~mode:0o755 (Fpath.v file)
(fun oc () ->
let fmt = Format.formatter_of_out_channel oc in
@@ -489,18 +491,20 @@ let fat_block ?(dir=".") ?(regexp="*") () =
Codegen.append fmt "";
Codegen.append fmt "IMG=$(pwd)/%s" block_file;
Codegen.append fmt "rm -f ${IMG}";
Codegen.append fmt "cd %a" Fpath.pp Fpath.(root / dir);
Codegen.append fmt "cd %a" Fpath.pp (Fpath.append root dir);
Codegen.append fmt "SIZE=$(du -s . | cut -f 1)";
Codegen.append fmt "${FAT} create ${IMG} ${SIZE}KiB";
Codegen.append fmt "${FAT} add ${IMG} %s" regexp;
Codegen.append fmt "echo Created '%s'" block_file;
R.ok ())
"fat shell script" >>= fun () ->
Bos.OS.Cmd.run (Bos.Cmd.v ("./make-" ^ name ^ "-image.sh")) >>= fun () ->
Log.info (fun m -> m "Executing block generator script: ./%s" file);
Bos.OS.Cmd.run (Bos.Cmd.v ("./" ^ file)) >>= fun () ->
super#build i

method clean i =
Bos.OS.File.delete (Fpath.v ("make-" ^ name ^ "-image.sh")) >>= fun () ->
let file = Printf.sprintf "make-%s-image.sh" name in
Bos.OS.File.delete (Fpath.v file) >>= fun () ->
Bos.OS.File.delete (Fpath.v block_file) >>= fun () ->
super#clean i
end
@@ -514,6 +518,9 @@ let kv_ro_of_fs_conf = impl @@ object
method name = "kv_ro_of_fs"
method module_name = "Fat.KV_RO.Make"
method packages = Key.pure [ package "fat-filesystem" ]
method connect _ modname = function
| [ fs ] -> Fmt.strf "%s.connect %s" modname fs
| _ -> failwith "The kv_ro_of_fs connect should receive exactly one argument."
end

let kv_ro_of_fs x = kv_ro_of_fs_conf $ x