Update RPi OS logic detection #152
Reference in New Issue
Block a user
Delete Branch "martignoni/151-rpios"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Should work with Bookworm (and hopefully later Debian versions).
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-issueexists on Raspberry OS Builds only.I like this check for the osversion 👍
Thanks, normally, it should work with later versions of Debian.
I'm rather sure, but your proposition with
/etc/rpi-issueis cleaner and easier to understand, I'll change.hi @martignoni , I was looking to your changes , I've tried them manually and
osversionin my case is empty.those are the result from my raspberry
as you can see, the
/etc/os-versionmisses theVERSION_IDfield .With the original code, at least the "raspbian" variable is set to 1.
Hi @gpongelli,
You'll see that in your case the
rpiosvariable (which replaces variableraspbian) is correctly set to1.What you describe is not a problem, since
osversionis only used to detect recent versions of RPiOS.In your case, you've an older release, there's no
VERSION_IDin your/etc/os-release, soosversionis empty; the comparison on line 38 evaluates tofalse, sorpios_recent=0and your older release is adequately detected.Recent versions of RPiOS all have a
VERSION_IDin their/etc/os-release, so in this case the comparison on line 38 evaluates correctly totrue.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
rpi-clonetoo is not supported in these cases.Side note: Debian testing versions never have a
VERSION_IDdefined.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
07f536e9d9/rpi-clone (L1348-L1356)and07f536e9d9/rpi-clone (L1609-L1624).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:
this because there's no way to get version 11 with any of following methods:
lsb_release -acat /etc/os-releasehostnamectlYour "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:
To address future boot changes other than the one already in place (or any os changes that impacts rpi-clone), a more correct check could be done parsing history/release table in webpages like this one or this one through an external script.
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
PRETTY_NAMEs for all Raspbian/RPiOS supported releases:32bit
PRETTY_NAME="Raspbian GNU/Linux 7 (wheezy)"
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
64bit
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
For (unsupported) testing/sid releases, the
PRETTY_NAMEdoes not have any number and noVERSION_ID, as already said before. A few examples (we cannot exclude that some adventurousrpi-cloneuser has updated their official RPiOS buster version to a testing bullseye one):32bit
PRETTY_NAME="Raspbian GNU/Linux bookworm/sid"
PRETTY_NAME="Raspbian GNU/Linux bullseye/sid"
64bit
PRETTY_NAME="Debian GNU/Linux bullseye/sid"
PRETTY_NAME="Debian GNU/Linux bookworm/sid"
We can conclude that for the test to work also for unsupported versions, we've to test whether the
PRETTY_NAMEcontains either "wheezy", "jessie" or "stretch", and conclude that in this case this is not a recent version.This (not as elegant as actual PR) bit of code would work. Any comment welcome:
bashis not my first language 😊I like regex 😄
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.