summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@cryptonomic.net>2020-11-17 14:18:41 -0500
committerAndrew Cady <d@cryptonomic.net>2020-11-17 14:18:41 -0500
commita89cade4eb531fa0da04007c16fd651d002907f3 (patch)
treea8ed3d543d8a2e1e12a5e57cad63787390fb8d05
parent56b8ba1c8198bce8eef9a2eb23b10cf115d91133 (diff)
partvi: fail better
-rwxr-xr-xsrc/partvi18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/partvi b/src/partvi
index b50b918..57a3dba 100755
--- a/src/partvi
+++ b/src/partvi
@@ -53,11 +53,23 @@ get_root_hash()
53 sed -ne 's/^Root hash:[ \t]*//p' "$1" 53 sed -ne 's/^Root hash:[ \t]*//p' "$1"
54} 54}
55 55
56require_exists()
57{
58 local f
59 for f
60 do
61 [ -f "$f" ] || die "Not a file: $f"
62 done
63}
64
65set -e
66
56builddir=_build 67builddir=_build
57mkdir -p "$builddir" 68mkdir -p "$builddir"
58 69
59for f in part*.conf 70for f in part*.conf
60do 71do
72 notice "Processing $f"
61 img=${f%.conf} 73 img=${f%.conf}
62 74
63 read_config_file "$img" || warn "Received error return from command: read_config_file $img" 75 read_config_file "$img" || warn "Received error return from command: read_config_file $img"
@@ -92,9 +104,7 @@ do
92 case "$type" in 104 case "$type" in
93 dm-verity-hashes|dm-verity-data) 105 dm-verity-hashes|dm-verity-data)
94 require_var data_path 106 require_var data_path
95 [ -f "$data_path" ] 107 require_exists "$data_path" "$data_path".verity "$data_path".verity.log
96 [ -f "$data_path".verity ]
97 [ -f "$data_path".verity.log ]
98 root_hash=$(get_root_hash "$data_path".verity.log) 108 root_hash=$(get_root_hash "$data_path".verity.log)
99 [ ${#root_hash} = 64 ] 109 [ ${#root_hash} = 64 ]
100 ;; 110 ;;
@@ -108,7 +118,7 @@ do
108 case "$type" in 118 case "$type" in
109 efi-system-partition) mkfs.vfat "$tmp" || die "mkfs.vfat failed" ;; 119 efi-system-partition) mkfs.vfat "$tmp" || die "mkfs.vfat failed" ;;
110 bios-grub) mkfs.vfat "$tmp" || die "mkfs.vfat failed" ;; 120 bios-grub) mkfs.vfat "$tmp" || die "mkfs.vfat failed" ;;
111 samizdat-keys) mkfs.btrfs "$tmp" || die "mkfs.btrfs failed" ;; 121 samizdat-keys) mkfs.btrfs -q "$tmp" || die "mkfs.btrfs failed" ;;
112 dm-verity-data) 122 dm-verity-data)
113 partuuid=${root_hash:0:32} 123 partuuid=${root_hash:0:32}
114 cp -f -T --reflink "$data_path" "$builddir"/"$partuuid" 124 cp -f -T --reflink "$data_path" "$builddir"/"$partuuid"