Skip to content

Commit a26aaff

Browse files
Ignore missing files in fixup_device_references_in_file
Since this is called for fstab on unmounted partitions now, without checking if the file exists, just silently do nothing if the file does not exist.
1 parent d610218 commit a26aaff

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

rpi-clone

+24-20
Original file line numberDiff line numberDiff line change
@@ -685,28 +685,32 @@ fixup_device_references_in_file() {
685685
partition=$1
686686
dst_mount=$2
687687
file=$3
688-
if grep -q "${src_disk_ID}" "${dst_mount}${file}"
689-
then
690-
qecho " Editing $partition$file PARTUUID to use $dst_disk_ID"
691-
sed -i "s/${src_disk_ID}/${dst_disk_ID}/g" "${dst_mount}${file}"
692-
elif grep -q UUID= "${dst_mount}${file}"
693-
then
694-
for ((p = 1; p <= n_src_parts; p++))
695-
do
696-
old_fsuuid=${src_fsuuid[p]}
697-
new_fsuuid=${dst_fsuuid[p]}
698-
if [ "$old_fsuuid" == "" -o "$new_fsuuid" == "" ] || ! grep -q "$old_fsuuid" "${dst_mount}${file}";
699-
then
700-
continue
701-
fi
702688

703-
qecho " Editing $partition$file UUID to use $new_fsuuid for partition $p"
704-
sed -i "s/$old_fsuuid/${new_fsuuid}/" "${dst_mount}${file}"
705-
done
706-
elif [ "$edit_fstab_name" != "" ] && grep -q ${src_part_base} "${dst_mount}${file}"
689+
if [ -f "${dst_mount}${file}" ]
707690
then
708-
qecho " Editing $partition$file references from $src_part_base to $edit_fstab_name"
709-
sed -i "s/${src_part_base}/${edit_fstab_name}/" "${dst_mount}${file}"
691+
if grep -q "${src_disk_ID}" "${dst_mount}${file}"
692+
then
693+
qecho " Editing $partition$file PARTUUID to use $dst_disk_ID"
694+
sed -i "s/${src_disk_ID}/${dst_disk_ID}/g" "${dst_mount}${file}"
695+
elif grep -q UUID= "${dst_mount}${file}"
696+
then
697+
for ((p = 1; p <= n_src_parts; p++))
698+
do
699+
old_fsuuid=${src_fsuuid[p]}
700+
new_fsuuid=${dst_fsuuid[p]}
701+
if [ "$old_fsuuid" == "" -o "$new_fsuuid" == "" ] || ! grep -q "$old_fsuuid" "${dst_mount}${file}";
702+
then
703+
continue
704+
fi
705+
706+
qecho " Editing $partition$file UUID to use $new_fsuuid for partition $p"
707+
sed -i "s/$old_fsuuid/${new_fsuuid}/" "${dst_mount}${file}"
708+
done
709+
elif [ "$edit_fstab_name" != "" ] && grep -q ${src_part_base} "${dst_mount}${file}"
710+
then
711+
qecho " Editing $partition$file references from $src_part_base to $edit_fstab_name"
712+
sed -i "s/${src_part_base}/${edit_fstab_name}/" "${dst_mount}${file}"
713+
fi
710714
fi
711715
}
712716

0 commit comments

Comments
 (0)