Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit a571676

Browse files
committed
Formatting
1 parent d592917 commit a571676

File tree

3 files changed

+64
-68
lines changed

3 files changed

+64
-68
lines changed

src/disk_layout.ml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ type layout_choice =
2020
| Sys_part_plus_boot_plus_maybe_EFI
2121
| Sys_part_plus_usb_drive
2222

23-
type sys_part_enc_choice = [
24-
| `None
23+
type sys_part_enc_choice =
24+
[ `None
2525
| `Passphrase
2626
| `Keyfile
27-
]
27+
]
2828

2929
(* | Lvm_single_disk
3030
* | Lvm_boot_plus_maybe_EFI_plus_pv_s
@@ -242,7 +242,8 @@ let make_boot (pool : Storage_unit.pool) ~enc_params ~encrypt ~path =
242242
let primary_key =
243243
Misc_utils.ask_string_confirm
244244
~is_valid:(fun x -> x <> "")
245-
~no_echo:true "Please enter passphrase for BOOT (/boot) partition encryption"
245+
~no_echo:true
246+
"Please enter passphrase for BOOT (/boot) partition encryption"
246247
in
247248
Storage_unit.L1.make_luks ~primary_key ~add_secondary_key:true
248249
~version:`LuksV1 ~path ~mapper_name:Config.boot_mapper_name enc_params
@@ -253,28 +254,29 @@ let make_boot (pool : Storage_unit.pool) ~enc_params ~encrypt ~path =
253254
(Storage_unit.L4.make ~mount_point:Config.boot_mount_point `Ext4);
254255
Storage_unit.make ~l1_id ~l2_id ~l3_id ~l4_id
255256

256-
let make_root_var_home (pool : Storage_unit.pool) ~enc_params ~(encrypt : sys_part_enc_choice) ~use_lvm
257-
path : Storage_unit.t * Storage_unit.t option * Storage_unit.t option =
257+
let make_root_var_home (pool : Storage_unit.pool) ~enc_params
258+
~(encrypt : sys_part_enc_choice) ~use_lvm path :
259+
Storage_unit.t * Storage_unit.t option * Storage_unit.t option =
258260
(* common components - L1, L2 stuff *)
259261
Hashtbl.add pool.l1_pool Params.Sys.l1_id
260262
(match encrypt with
261263
| `None -> Storage_unit.L1.make_clear ~path
262264
| `Passphrase ->
263265
let primary_key =
264-
Misc_utils.ask_string_confirm
265-
~is_valid:(fun x -> x <> "")
266-
~no_echo:true "Please enter passphrase for ROOT (/) partition encryption"
266+
Misc_utils.ask_string_confirm
267+
~is_valid:(fun x -> x <> "")
268+
~no_echo:true
269+
"Please enter passphrase for ROOT (/) partition encryption"
267270
in
268-
Storage_unit.L1.make_luks ~primary_key ~path ~mapper_name:Config.sys_mapper_name
269-
enc_params
271+
Storage_unit.L1.make_luks ~primary_key ~path
272+
~mapper_name:Config.sys_mapper_name enc_params
270273
| `Keyfile ->
271274
Storage_unit.L1.make_luks ~path ~mapper_name:Config.sys_mapper_name
272-
enc_params
273-
);
274-
(* (if encrypt then
275-
* Storage_unit.L1.make_luks ~path ~mapper_name:Config.sys_mapper_name
276-
* enc_params
277-
* else Storage_unit.L1.make_clear ~path); *)
275+
enc_params);
276+
(* (if encrypt then
277+
* Storage_unit.L1.make_luks ~path ~mapper_name:Config.sys_mapper_name
278+
* enc_params
279+
* else Storage_unit.L1.make_clear ~path); *)
278280
Hashtbl.add pool.l2_pool Params.Sys.l2_id
279281
(if use_lvm then Storage_unit.L2.make_lvm ~vg_name:Config.lvm_vg_name
280282
else Storage_unit.L2.make_none ());
@@ -339,7 +341,8 @@ let make_root_var_home (pool : Storage_unit.pool) ~enc_params ~(encrypt : sys_pa
339341
(root, var, home)
340342

341343
let make_layout ~esp_part_path ~boot_part_path ~boot_part_enc_params
342-
~boot_encrypt ~sys_part_path ~sys_part_enc_params ~(sys_encrypt : sys_part_enc_choice) ~use_lvm =
344+
~boot_encrypt ~sys_part_path ~sys_part_enc_params
345+
~(sys_encrypt : sys_part_enc_choice) ~use_lvm =
343346
let pool = Storage_unit.make_pool () in
344347
let esp = Option.map (fun path -> make_esp pool ~path) esp_part_path in
345348
let boot =

src/mkinitcpio_utils.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
let gen_mkinitcpio_hooks ~(encrypt_sys : Disk_layout.sys_part_enc_choice) ~use_lvm =
1+
let gen_mkinitcpio_hooks ~(encrypt_sys : Disk_layout.sys_part_enc_choice)
2+
~use_lvm =
23
List.filter_map
34
(fun x -> x)
45
[

src/oali.ml

Lines changed: 41 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -219,24 +219,18 @@ User is allowed to continue said setup if they wishes to however
219219
selected to not encrypt root";
220220
confirm_answer_is_correct_end_retry ~ret:encrypt_sys)
221221
in
222-
if encrypt then (
223-
if encrypt_boot then
224-
{ config with encrypt_sys = Some `Keyfile }
222+
if encrypt then
223+
if encrypt_boot then { config with encrypt_sys = Some `Keyfile }
225224
else (
226-
print_endline "Since boot partition is not encrypted, please specify whether system partition should use passphrase or keyfile";
225+
print_endline
226+
"Since boot partition is not encrypted, please specify whether \
227+
system partition should use passphrase or keyfile";
227228
let choices =
228-
[
229-
("passphrase", `Passphrase);
230-
("keyfile", `Keyfile);
231-
]
229+
[ ("passphrase", `Passphrase); ("keyfile", `Keyfile) ]
232230
in
233231
let choice = pick_choice_kv choices in
234-
{ config with encrypt_sys = Some choice }
235-
)
236-
)
237-
else
238-
{ config with encrypt_sys = Some `None }
239-
);
232+
{ config with encrypt_sys = Some choice })
233+
else { config with encrypt_sys = Some `None });
240234
reg ~name:"Adjust cryptsetup parameters for root partition" ~doc:luks_doc
241235
(fun answer_store config ->
242236
if Option.get config.encrypt_sys <> `None then
@@ -663,31 +657,28 @@ if using the USB key disk layout|}
663657
config);
664658
reg ~name:"Install keyfile for /"
665659
~doc:{|Sets up keyfile to be embedded into the initramfs|}
666-
(fun _answer_store config -> (
667-
match Option.get config.encrypt_sys with
668-
| `None | `Passphrase ->
669-
print_endline "Skipped"
670-
| `Keyfile -> (
671-
let disk_layout = Option.get config.disk_layout in
672-
let root = Disk_layout.get_root disk_layout in
673-
match root.l1 with
674-
| Clear _ -> failwith "Expected LUKS"
675-
| Luks { info; _ } ->
676-
let keyfile_path =
677-
concat_file_names
678-
[
679-
Config.root_mount_point;
680-
Config.root_dir;
681-
Config.sys_part_keyfile_name;
682-
]
683-
in
684-
let oc = open_out_bin keyfile_path in
685-
Fun.protect
686-
~finally:(fun () -> close_out oc)
687-
(fun () -> output_string oc info.primary_key);
688-
Unix.chmod keyfile_path 0o000)
689-
)
690-
;
660+
(fun _answer_store config ->
661+
(match Option.get config.encrypt_sys with
662+
| `None | `Passphrase -> print_endline "Skipped"
663+
| `Keyfile -> (
664+
let disk_layout = Option.get config.disk_layout in
665+
let root = Disk_layout.get_root disk_layout in
666+
match root.l1 with
667+
| Clear _ -> failwith "Expected LUKS"
668+
| Luks { info; _ } ->
669+
let keyfile_path =
670+
concat_file_names
671+
[
672+
Config.root_mount_point;
673+
Config.root_dir;
674+
Config.sys_part_keyfile_name;
675+
]
676+
in
677+
let oc = open_out_bin keyfile_path in
678+
Fun.protect
679+
~finally:(fun () -> close_out oc)
680+
(fun () -> output_string oc info.primary_key);
681+
Unix.chmod keyfile_path 0o000));
691682
config);
692683
reg ~name:"Install keyfile for unlocking /boot"
693684
~doc:
@@ -774,15 +765,15 @@ The line is then commented if disk layout uses USB key|}
774765
fun s ->
775766
match Re.matches re s with
776767
| [] -> [ s ]
777-
| _ ->
778-
match encrypt_sys with
779-
| `Keyfile ->
780-
[
781-
Printf.sprintf "FILES=(%s)"
782-
(concat_file_names
783-
[ "/root"; Config.sys_part_keyfile_name ]);
784-
]
785-
| `None | `Passphrase -> [ s ]
768+
| _ -> (
769+
match encrypt_sys with
770+
| `Keyfile ->
771+
[
772+
Printf.sprintf "FILES=(%s)"
773+
(concat_file_names
774+
[ "/root"; Config.sys_part_keyfile_name ]);
775+
]
776+
| `None | `Passphrase -> [ s ])
786777
in
787778
let fill_in_HOOKS =
788779
let re = "^HOOKS" |> Re.Posix.re |> Re.compile in
@@ -793,7 +784,8 @@ The line is then commented if disk layout uses USB key|}
793784
[
794785
Printf.sprintf "HOOKS=(%s)"
795786
(String.concat " "
796-
(Mkinitcpio_utils.gen_mkinitcpio_hooks ~encrypt_sys ~use_lvm));
787+
(Mkinitcpio_utils.gen_mkinitcpio_hooks ~encrypt_sys
788+
~use_lvm));
797789
]
798790
in
799791
File.filter_map_lines ~file fill_in_FILES;

0 commit comments

Comments
 (0)