Skip to content

Commit ddda68d

Browse files
committed
Update RPi OS logic detection
- Fixes https://github.com/billw2/rpi-clone/issues.
1 parent 07f536e commit ddda68d

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

rpi-clone

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

30-
raspbian=0
31-
raspbian_buster=0
32-
if [ -f /etc/os-release ]
30+
rpios=0
31+
rpios_recent=0
32+
if [ -f /etc/os-release ] && [ -f /proc/device-tree/model ]
3333
then
3434
pretty=`cat /etc/os-release | grep PRETTY`
35-
if [[ "$pretty" == *"Raspbian"* ]]
35+
osversion=`cat /etc/os-release | grep VERSION_ID | cut -d'"' -f2`
36+
model=`tr -d '\0' < /proc/device-tree/model`
37+
if [[ "$pretty" == *"Raspbian"* || ("$model" == *"Raspberry"* && "$pretty" == *"Debian"*) ]]
3638
then
37-
raspbian=1
39+
rpios=1
3840
fi
39-
if ((raspbian)) && [[ "$pretty" == *"buster"* ]]
41+
if ((rpios)) && ((osversion >= 10))
4042
then
41-
raspbian_buster=1
43+
rpios_recent=1
4244
fi
4345
fi
4446

@@ -224,7 +226,7 @@ qecho()
224226
echo "$@"
225227
fi
226228
}
227-
229+
228230
qprintf()
229231
{
230232
if ((!quiet))
@@ -1320,7 +1322,7 @@ Use -U for unattended even if initializing.
13201322
then
13211323
printf "%-22s : %s\n" " " \
13221324
"Possible options:"
1323-
if ((raspbian))
1325+
if ((rpios))
13241326
then
13251327
printf "%-22s : %s\n" " " \
13261328
" Use -f2 to force a two partition initialize clone."
@@ -1338,14 +1340,14 @@ Use -U for unattended even if initializing.
13381340

13391341
readable_MiB $((last_part_sectors + 7812)) "512" image_space_readable
13401342

1341-
echo "== Initialize: IMAGE partition table - $reason =="
1343+
echo "== Initialize: IMAGE partition table - $reason =="
13421344
print_image_actions
13431345
print_options
13441346

13451347
printf "%-22s : %s\n" "** WARNING **" \
13461348
"All destination disk $dst_disk data will be overwritten!"
13471349

1348-
if ((raspbian_buster && p1_size_new == 0 && src_size_sectors[1] < 400000))
1350+
if ((rpios_recent && p1_size_new == 0 && src_size_sectors[1] < 400000))
13491351
then
13501352
printf "%-22s : %s\n" "** WARNING **" \
13511353
"Your source /boot partition is smaller than the"
@@ -1530,7 +1532,7 @@ Use -U for unattended even if initializing.
15301532
else
15311533
src_sync_part[p]=1
15321534
fi
1533-
fi
1535+
fi
15341536
else
15351537
printf " => dd if=${src_device[$p]} of=$dst_dev bs=1M ..."
15361538
dd if=${src_device[$p]} of=$dst_dev bs=1M &>> /tmp/$PGM-output
@@ -1606,7 +1608,7 @@ else
16061608
exit 1
16071609
fi
16081610

1609-
if ((raspbian_buster && dst_size_sectors[1] < 500000))
1611+
if ((rpios_recent && dst_size_sectors[1] < 500000))
16101612
then
16111613
qprintf "%-22s : %s\n" "** WARNING **" \
16121614
"Your destination /boot partition is smaller than the"
@@ -1814,7 +1816,7 @@ qprintf " Start - %s End - %s Elapsed Time - %d:%02d\n" \
18141816
if ((!unattended))
18151817
then
18161818
echo -n $"
1817-
Cloned partitions are mounted on $clone for inspection or customizing.
1819+
Cloned partitions are mounted on $clone for inspection or customizing.
18181820
18191821
Hit Enter when ready to unmount the /dev/$dst_disk partitions ..."
18201822

0 commit comments

Comments
 (0)