Skip to content

Commit 4335917

Browse files
authored
Merge pull request billw2#2 from framps/master
Fixes #1 - Make things work with Bookworm, sync with framps
2 parents 4e71a28 + cc684c0 commit 4335917

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

rpi-clone

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,15 @@ then
2727
exit 1
2828
fi
2929

30-
raspbian=0
31-
raspbian_buster=0
32-
if [ -f /etc/os-release ]
33-
then
34-
pretty=`cat /etc/os-release | grep PRETTY`
35-
if [[ "$pretty" == *"Raspbian"* ]]
36-
then
37-
raspbian=1
30+
rpios=0
31+
rpios_recent=0
32+
if [ -f /etc/os-release ]; then
33+
if [[ -e /etc/rpi-issue ]]; then
34+
rpios=1
3835
fi
39-
if ((raspbian)) && [[ "$pretty" == *"buster"* ]]
40-
then
41-
raspbian_buster=1
36+
pretty="$(cat /etc/os-release | grep PRETTY)"
37+
if ((rpios)) && [[ ! "$pretty" =~ wheezy|jessie|stretch ]]; then
38+
rpios_recent=1
4239
fi
4340
fi
4441

@@ -224,7 +221,7 @@ qecho()
224221
echo "$@"
225222
fi
226223
}
227-
224+
228225
qprintf()
229226
{
230227
if ((!quiet))
@@ -971,7 +968,7 @@ then
971968
cp $fstab_tmp $fstab
972969
printf "Your original fstab is backed up to $fstab_save\n"
973970

974-
cmdline_txt=/boot/cmdline.txt
971+
cmdline_txt=$(realpath /boot/cmdline.txt)
975972
cmdline_save=$cmdline_txt.${PGM}-save
976973
if [ -f $cmdline_txt ] && grep -q "$src_root_dev" $cmdline_txt
977974
then
@@ -1320,7 +1317,7 @@ Use -U for unattended even if initializing.
13201317
then
13211318
printf "%-22s : %s\n" " " \
13221319
"Possible options:"
1323-
if ((raspbian))
1320+
if ((rpios))
13241321
then
13251322
printf "%-22s : %s\n" " " \
13261323
" Use -f2 to force a two partition initialize clone."
@@ -1338,14 +1335,14 @@ Use -U for unattended even if initializing.
13381335

13391336
readable_MiB $((last_part_sectors + 7812)) "512" image_space_readable
13401337

1341-
echo "== Initialize: IMAGE partition table - $reason =="
1338+
echo "== Initialize: IMAGE partition table - $reason =="
13421339
print_image_actions
13431340
print_options
13441341

13451342
printf "%-22s : %s\n" "** WARNING **" \
13461343
"All destination disk $dst_disk data will be overwritten!"
13471344

1348-
if ((raspbian_buster && p1_size_new == 0 && src_size_sectors[1] < 400000))
1345+
if ((rpios_recent && p1_size_new == 0 && src_size_sectors[1] < 400000))
13491346
then
13501347
printf "%-22s : %s\n" "** WARNING **" \
13511348
"Your source /boot partition is smaller than the"
@@ -1530,7 +1527,7 @@ Use -U for unattended even if initializing.
15301527
else
15311528
src_sync_part[p]=1
15321529
fi
1533-
fi
1530+
fi
15341531
else
15351532
printf " => dd if=${src_device[$p]} of=$dst_dev bs=1M ..."
15361533
dd if=${src_device[$p]} of=$dst_dev bs=1M &>> /tmp/$PGM-output
@@ -1606,7 +1603,7 @@ else
16061603
exit 1
16071604
fi
16081605

1609-
if ((raspbian_buster && dst_size_sectors[1] < 500000))
1606+
if ((rpios_recent && dst_size_sectors[1] < 500000))
16101607
then
16111608
qprintf "%-22s : %s\n" "** WARNING **" \
16121609
"Your destination /boot partition is smaller than the"
@@ -1730,7 +1727,7 @@ qecho ""
17301727
# Fix PARTUUID or device name references in cmdline.txt and fstab
17311728
#
17321729
fstab=${clone}/etc/fstab
1733-
cmdline_txt=${clone}/boot/cmdline.txt
1730+
cmdline_txt=${clone}$(realpath /boot/cmdline.txt)
17341731

17351732
if [ -f $cmdline_txt ]
17361733
then
@@ -1814,7 +1811,7 @@ qprintf " Start - %s End - %s Elapsed Time - %d:%02d\n" \
18141811
if ((!unattended))
18151812
then
18161813
echo -n $"
1817-
Cloned partitions are mounted on $clone for inspection or customizing.
1814+
Cloned partitions are mounted on $clone for inspection or customizing.
18181815
18191816
Hit Enter when ready to unmount the /dev/$dst_disk partitions ..."
18201817

0 commit comments

Comments
 (0)