summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2021-02-25 16:42:12 -0500
committerAndrew Cady <d@jerkface.net>2021-02-25 16:42:12 -0500
commit571f14acc0045f15a69e44557bff601d270726a9 (patch)
tree3b066b14d13a2bbd20f817ec78d6e9b672c62273
parentbfc9cd9ebbbb17263c75b8df8fe8abf88cab6078 (diff)
partvi: eliminate code duplication
-rwxr-xr-xsrc/partvi69
1 files changed, 31 insertions, 38 deletions
diff --git a/src/partvi b/src/partvi
index 8ae793d..5963ff6 100755
--- a/src/partvi
+++ b/src/partvi
@@ -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
272check_for_key_only_skip() 269check_for_key_only_skip()
@@ -343,39 +340,35 @@ $sudo kpartx -su "$whole"
343 340
344trap cleanup EXIT 341trap cleanup EXIT
345 342
346for f in part*.conf 343copy_data_to_mounted_target_filesystems()
347do 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 371iterate_partitions copy_data_to_mounted_target_filesystems
375 ;;
376 *) notice "Not mounting $name" ;;
377 esac
378done
379 372
380loudly $sudo eatmydata -- grub-install --target=i386-pc --recheck --boot-directory="$BOOT_DIR" "$whole" 373loudly $sudo eatmydata -- grub-install --target=i386-pc --recheck --boot-directory="$BOOT_DIR" "$whole"
381loudly $sudo eatmydata -- grub-install --target=x86_64-efi --recheck --removable --efi-directory="$EFI_DIR" "$whole" || true 374loudly $sudo eatmydata -- grub-install --target=x86_64-efi --recheck --removable --efi-directory="$EFI_DIR" "$whole" || true