Commit 91f92b8a authored by Seb Mondet's avatar Seb Mondet

Build with development version of Genspio

parent 842e47fd
......@@ -29,7 +29,7 @@ module Shell_script = struct
let on_stdin_lines ~body =
let fresh =
sprintf "var_%d_%s" Random.(int 10_000)
(Genspio.Language.to_one_liner (body (string "bouh"))
(Genspio.Compile.to_one_liner (body (string "bouh"))
|> Digest.string |> Digest.to_hex) in
loop_while (exec ["read"; "-r"; fresh] |> succeeds)
~body:(seq [
......@@ -57,7 +57,7 @@ module Shell_script = struct
write_output ~stdout:dev_null ~stderr:dev_null u
let seq_succeeds_or
?dependencies ?(silent = true) ~name ?(clean_up = [fail]) cmds =
?dependencies ?(silent = true) ~name ?(clean_up = [fail "seq_succeeds_or"]) cmds =
let content =
let stdout i =
ksprintf string "/tmp/cmd-%s-stdout-%d" (sanitize_name name) i in
......@@ -111,7 +111,7 @@ module Shell_script = struct
"# Script %s";
"# Generated by Habust";
sprintf "echo 'Habust: %s (%s)'" name filename;
Genspio.Language.to_many_lines content;
Genspio.Compile.to_many_lines content;
])
:: List.concat_map dep_scripts ~f:(fun c -> c.files);
call = call s;
......@@ -225,7 +225,7 @@ module Prepare_environment = struct
]
~e:[
sayl (strf "Command %d failed !" index) [];
fail
fail "command failed"
])
|> seq in
script_over_ssh ?root_password ~ssh_port ~name begin
......@@ -242,7 +242,7 @@ module Prepare_environment = struct
]
~e:[
sayl "Condition not ensured by build" [];
fail
fail "condition not ensured"
]
]
]
......@@ -333,7 +333,7 @@ module Prepare_environment = struct
let wget =
let open Shell_script in
let open Genspio.EDSL in
seq_succeeds_or ~name:(sprintf "WGetting %s" url) ~clean_up:[fail] [
seq_succeeds_or ~name:(sprintf "WGetting %s" url) ~clean_up:[fail "make_files"] [
exec ["mkdir"; "-p"; "_cache"];
exec ["wget"; url; "--output-document"; tmp_name_of_url url];
exec ["mv"; "-f"; tmp_name_of_url url; base];
......@@ -372,8 +372,8 @@ module Prepare_environment = struct
let kill_qemu_vm (Qemu_ssh _) =
let open Shell_script in
let open Genspio.EDSL in
let pid = output_as_string (exec ["cat"; "qemu.pid"]) in
seq_succeeds_or ~name:(sprintf "Killing Qemu VM") ~clean_up:[fail] [
let pid = get_stdout (exec ["cat"; "qemu.pid"]) |> Byte_array.to_c in
seq_succeeds_or ~name:(sprintf "Killing Qemu VM") ~clean_up:[fail "kill_qemu_vm"] [
if_seq (file_exists (string "qemu.pid"))
~t:[
if_seq (call [string "kill"; pid] |> succeeds)
......@@ -382,7 +382,7 @@ module Prepare_environment = struct
]
~e:[
sayl "PID file here (PID: %s) but Kill failed, \
deleting `qemu.pid`" [pid];
deleting `qemu.pid`" [ pid];
exec ["rm"; "qemu.pid"];
return_false
]
......@@ -400,23 +400,23 @@ module Prepare_environment = struct
let there_was_a_failure = tmp_file "bool-failure" in
let cmds =
[
report#set (string "Configuration Report\n\
report#set (byte_array "Configuration Report\n\
====================\n\n");
there_was_a_failure#set (bool false |> Bool.to_string);
there_was_a_failure#set_c (bool false |> Bool.to_string);
] @ List.map local_dependencies ~f:begin function
| `Command name ->
if_seq (exec ["which"; name] |> silently |> succeeds)
~t:[
report#append (ksprintf string "* `%s`: found.\n" name);
report#append (ksprintf byte_array "* `%s`: found.\n" name);
]
~e:[
report#append (ksprintf string "* `%s`: NOT FOUND!\n" name);
there_was_a_failure#set (bool true |> Bool.to_string);
report#append (ksprintf byte_array "* `%s`: NOT FOUND!\n" name);
there_was_a_failure#set_c (bool true |> Bool.to_string);
]
end
@ [
call [string "cat"; report#path];
if_seq (there_was_a_failure#get |> Bool.of_string)
if_seq (there_was_a_failure#get_c |> Bool.of_string)
~t:[
exec ["printf"; "\\nThere were *failures* :(\\n"];
return_false
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment