diff options
author | Andrew Cady <d@jerkface.net> | 2021-02-25 16:42:12 -0500 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2021-02-25 16:42:12 -0500 |
commit | 571f14acc0045f15a69e44557bff601d270726a9 (patch) | |
tree | 3b066b14d13a2bbd20f817ec78d6e9b672c62273 /src/partvi | |
parent | bfc9cd9ebbbb17263c75b8df8fe8abf88cab6078 (diff) |
partvi: eliminate code duplication
Diffstat (limited to 'src/partvi')
-rwxr-xr-x | src/partvi | 69 |
1 files changed, 31 insertions, 38 deletions
@@ -262,11 +262,8 @@ pee_on_table() | |||
262 | start=0 | 262 | start=0 |
263 | iterate_partitions create_ptable_conf | 263 | iterate_partitions create_ptable_conf |
264 | 264 | ||
265 | ( | 265 | loudly $sudo sfdisk --no-tell-kernel "$dev" < "$GPT_TABLE_FILE" || return |
266 | set -x | 266 | loudly $sudo sfdisk --no-tell-kernel -Y dos "$dev" < "$DOS_TABLE_FILE" || return |
267 | $sudo sfdisk --no-tell-kernel "$dev" < "$GPT_TABLE_FILE" || return | ||
268 | $sudo sfdisk --no-tell-kernel -Y dos "$dev" < "$DOS_TABLE_FILE" || return | ||
269 | ) | ||
270 | } | 267 | } |
271 | 268 | ||
272 | check_for_key_only_skip() | 269 | check_for_key_only_skip() |
@@ -343,39 +340,35 @@ $sudo kpartx -su "$whole" | |||
343 | 340 | ||
344 | trap cleanup EXIT | 341 | trap cleanup EXIT |
345 | 342 | ||
346 | for f in part*.conf | 343 | copy_data_to_mounted_target_filesystems() |
347 | do | 344 | { |
348 | [ "$f" != part0.conf ] || continue | 345 | case "$type" in |
349 | notice "Processing $f" | 346 | efi-system-partition|boot|samizdat-keys) ;; |
350 | img=${f%.conf} | 347 | dm-verity-hashes|partition-table|bios-grub) return ;; |
351 | dev=/dev/mapper/${whole#/dev/}p${img#part} | 348 | *) notice "Not mounting $name"; return ;; |
352 | mnt=${f%.conf}.mnt | 349 | esac |
353 | 350 | ||
354 | read_config_file || warn "Received error return from command: read_config_file $img" | 351 | img=${f%.conf} |
355 | require_var name | 352 | dev=/dev/mapper/${whole#/dev/}p${img#part} |
356 | require_var type | 353 | mnt=${f%.conf}.mnt |
357 | case "$type" in | 354 | |
358 | dm-verity-hashes|partition-table|bios-grub) ;; | 355 | mkdir -p "$mnt" |
359 | efi-system-partition|boot|samizdat-keys) | 356 | loudly $sudo mount "$dev" "$mnt" |
360 | mkdir -p "$mnt" | 357 | |
361 | loudly $sudo mount "$dev" "$mnt" | 358 | case "$type" in |
362 | 359 | boot) | |
363 | case "$type" in | 360 | BOOT_DIR=$mnt |
364 | boot) | 361 | install_boot_dir "$mnt" |
365 | BOOT_DIR=$mnt | 362 | ;; |
366 | install_boot_dir "$mnt" | 363 | samizdat-keys) |
367 | ;; | 364 | $sudo rsync -a --info=STATS "$GPG_INPUT_DIR"/ "$mnt"/gnupghome/ |
368 | samizdat-keys) | 365 | ;; |
369 | $sudo rsync -a --info=STATS "$GPG_INPUT_DIR"/ "$mnt"/gnupghome/ | 366 | efi-system-partition) |
370 | ;; | 367 | EFI_DIR=$mnt |
371 | efi-system-partition) | 368 | ;; |
372 | EFI_DIR=$mnt | 369 | esac |
373 | ;; | 370 | } |
374 | esac | 371 | iterate_partitions copy_data_to_mounted_target_filesystems |
375 | ;; | ||
376 | *) notice "Not mounting $name" ;; | ||
377 | esac | ||
378 | done | ||
379 | 372 | ||
380 | loudly $sudo eatmydata -- grub-install --target=i386-pc --recheck --boot-directory="$BOOT_DIR" "$whole" | 373 | loudly $sudo eatmydata -- grub-install --target=i386-pc --recheck --boot-directory="$BOOT_DIR" "$whole" |
381 | loudly $sudo eatmydata -- grub-install --target=x86_64-efi --recheck --removable --efi-directory="$EFI_DIR" "$whole" || true | 374 | loudly $sudo eatmydata -- grub-install --target=x86_64-efi --recheck --removable --efi-directory="$EFI_DIR" "$whole" || true |