Fix race condition in partition script
This commit is contained in:
parent
6d6b93fb64
commit
70964072b6
|
@ -91,9 +91,14 @@ let
|
|||
type);
|
||||
|
||||
fdiskCommand = arguments: "sudo sfdisk ${arguments}";
|
||||
fdiskScript = script: append: "echo ${script} | ${fdiskCommand "${if append then "--append" else ""} ${diskVar}"}";
|
||||
wipeScript = script: fdiskScript script false;
|
||||
appendScript = script: fdiskScript script true;
|
||||
fdiskScript = script: args: append:
|
||||
"echo ${script} | ${
|
||||
fdiskCommand "${builtins.concatStringsSep " " args} ${
|
||||
if append then "--append" else ""
|
||||
} ${diskVar}"
|
||||
}";
|
||||
wipeScript = script: fdiskScript script [] false;
|
||||
appendScript = index: script: fdiskScript script ["-N" (builtins.toString index)] true;
|
||||
|
||||
cleanup = lib.strings.concatLines (builtins.map
|
||||
(partition: "${fdiskCommand "--delete ${diskVar} ${toString partition.index}"} || true")
|
||||
|
@ -130,7 +135,7 @@ let
|
|||
};
|
||||
|
||||
create = lib.strings.concatLines [
|
||||
(appendScript ''${toString index}: "$(${sizeOption})" type=${mkType type}'')
|
||||
(appendScript index ''${toString index}: "$(${sizeOption})" type=${mkType type}'')
|
||||
probeScript
|
||||
"sudo ${formatScripts.${format}}"
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue