-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update RPi OS logic detection #152
base: master
Are you sure you want to change the base?
Conversation
martignoni
commented
Jan 15, 2023
- Fixes Recent RPi OS version aren't correctly detected #151.
Should work with Bookworm (and hopefully later Debian versions). |
rpi-clone
Outdated
if [ -f /etc/os-release ] | ||
rpios=0 | ||
rpios_recent=0 | ||
if [ -f /etc/os-release ] && [ -f /proc/device-tree/model ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I see this test should check whether it's a Raspberry HW. Are you sure /proc/device-tree/model is an unique idetifier for a Raspberry HW? /etc/rpi-issue
exists on Raspberry OS Builds only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm rather sure, but your proposition with /etc/rpi-issue
is cleaner and easier to understand, I'll change.
rpi-clone
Outdated
fi | ||
if ((raspbian)) && [[ "$pretty" == *"buster"* ]] | ||
if ((rpios)) && ((osversion >= 10)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this check for the osversion 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, normally, it should work with later versions of Debian.
- Credits to @framps
hi @martignoni , I was looking to your changes , I've tried them manually and those are the result from my raspberry pi@raspberrypi:~ $ cat /proc/device-tree/model
Raspberry Pi 4 Model B Rev 1.2
pi@raspberrypi:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux bookworm/sid"
NAME="Raspbian GNU/Linux"
VERSION_CODENAME=bookworm
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
pi@raspberrypi:~ $ cat /etc/rpi-issue
Raspberry Pi reference 2019-09-26
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 80d486687ea77d31fc3fc13cf3a2f8b464e129be, stage5 as you can see, the With the original code, at least the "raspbian" variable is set to 1. |
Hi @gpongelli, You'll see that in your case the What you describe is not a problem, since In your case, you've an older release, there's no Recent versions of RPiOS all have a |
Hi @martignoni , I’ve no idea what’s “recent” for you but, as you can see I’m on bookworm, that’s the actual testing release. I’ve tried today to upgrade (again) over testing and the os-release had not changed. |
There is a misunderstanding here: I'm speaking of recent releases of RPiOS images. And my bad: I did not notice that your image was upgraded. For the record, upgrading an RPi image to a new OS version is not recommended and not supported. I assume Side note: Debian testing versions never have a |
Even if it’s not recommended, it can be done (and it worked, waiting for official bookworm), so why rpi-clone shouldn’t also be supported ? |
If you find a way to check for a version number in Debian testing release, I'd be glad to include it in this PR. |
Not sure what's the purpose of this check. Maybe it's worth to remove this check? |
This is needed because as of RPiOS Buster (and later), the boot partition size has changed. See Lines 1348 to 1356 in 07f536e
Lines 1609 to 1624 in 07f536e
|
Hi @martignoni , I've just tested rpi-clone on my rpi and it worked correctly. The only changes I did had been this one here: if ((raspbian)) && [[ "$pretty" == *"buster"* ]]
then
raspbian_buster=1
fi
+ if ((raspbian)) && [[ "$pretty" == *"bookworm"* ]]
+ then
+ raspbian_buster=1
+ fi this because there's no way to get version 11 with any of following methods:
|
Your "fix" would not fix the bug: the problem will occur again when Debian reaches its next version after Bookworm. |
Agree. Then every new Debian version requires a change in rpi-clone. Wouldn't it make sense to test backwards and not forwards? |
I know it is not future-proof, but it’s just to demonstrate that rpi-clone works also on upgraded rpi (even not so pure raspbian, because in the past I’ve mixed it with Debian due to more recent sw version needed). agree with @framps about reversing the detection logic edit: |
I agree. That's the more general approach. But this creates a dependency of rpi-clone on an existing network connection I don't like. |
Not sure I understand, can you elaborate? |
As @gpongelli wrote here he added a new if statement to set raspibian_buster. This will have to be done for every new release. Why don't we just negate the test and assume raspbian_buster is 1 and reset it to zero for older releases. They will not change any more 😉 |
Here are the 32bitPRETTY_NAME="Raspbian GNU/Linux 7 (wheezy)" 64bitPRETTY_NAME="Debian GNU/Linux 10 (buster)" For (unsupported) testing/sid releases, the 32bitPRETTY_NAME="Raspbian GNU/Linux bookworm/sid" 64bitPRETTY_NAME="Debian GNU/Linux bullseye/sid" We can conclude that for the test to work also for unsupported versions, we've to test whether the This (not as elegant as actual PR) bit of code would work. Any comment welcome:
|
I like regex 😄
|
- Works for unsupported RPiOS versions (i.e. RPiOS updated to testing/sid) - Once again, credits to @framps