Skip to content

Commit 31ec209

Browse files
Simplify fixup_cmdline_txt()
This applied largely the same operations to cmdline.txt as fixup_device_references_in_file did to fstab, so this can just call the latter. This should work the same, except that the PARTUUID is not replaced with the g flag (all occurences instead of just one), all filesystem UUIDs are replaced (instead of just the root partition), and progress output messages are slightly different. Also, fstab UUID= replacements are now done anywhere in the file, instead of just at the start of a line.
1 parent 0c23cb2 commit 31ec209

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

rpi-clone

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -665,20 +665,9 @@ fixup_cmdline_txt()
665665
cp "${dst_mount}${cmdline_txt}" "${dst_mount}${cmdline_boot}"
666666
cmdline_txt=${cmdline_boot}
667667
fi
668-
if grep -q "$src_disk_ID" "${dst_mount}${cmdline_txt}"
669-
then
670-
qecho "Editing $cmdline_txt PARTUUID to use $dst_disk_ID"
671-
sed -i "s/${src_disk_ID}/${dst_disk_ID}/" "${dst_mount}${cmdline_txt}"
672-
elif [ "${src_fsuuid[root_part_num]}" != "" ] && grep -q "${src_fsuuid[root_part_num]}" "${dst_mount}${cmdline_txt}"
673-
then
674-
new_fsuuid=${dst_fsuuid[root_part_num]}
675-
qecho "Editing $cmdline_txt UUID to use $new_fsuuid"
676-
sed -i "s/${src_fsuuid[root_part_num]}/${new_fsuuid}/" "${dst_mount}${cmdline_txt}"
677-
elif [ "$edit_fstab_name" != "" ] && grep -q "${src_part_base}" "${dst_mount}${cmdline_txt}"
678-
then
679-
qecho "Editing $cmdline_txt references from $src_part_base to $edit_fstab_name"
680-
sed -i "s/${src_part_base}/$edit_fstab_name/" "${dst_mount}${cmdline_txt}"
681-
fi
668+
669+
fixup_device_references_in_file "${dst_mount}${cmdline_txt}"
670+
682671
if ((leave_sd_usb_boot && SD_slot_boot))
683672
then
684673
qecho "Copying USB cmdline.txt to SD card to set up USB boot."
@@ -696,7 +685,7 @@ fixup_device_references_in_file() {
696685
then
697686
qecho "Editing $file PARTUUID to use $dst_disk_ID"
698687
sed -i "s/${src_disk_ID}/${dst_disk_ID}/g" "$file"
699-
elif grep -q ^UUID= $file
688+
elif grep -q UUID= $file
700689
then
701690
for ((p = 1; p <= n_src_parts; p++))
702691
do

0 commit comments

Comments
 (0)