Skip to content
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

check kernel version and issue warning if necessary #180

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

shrx
Copy link
Contributor

@shrx shrx commented Jun 23, 2015

Fixes #178
for real this time

@popcornmix
Copy link
Collaborator

The problem is the NOTICE.md mechanism is a general purpose scheme for warning about any change that may cause issues - not just for the 4.0 kernel.

The correct solution is for WARNING.md to include a git hash for the first update that requires the warning. E.g. a line like `HASH: abcdef0123456789abcdef``
Call this hash W.
The last rpi-update hash in in /boot/.firmware_revision. Call this U.
The latest hash you are updating to is L.

Then, if U < W && L >= W you display the warning.

@shrx
Copy link
Contributor Author

shrx commented Jun 23, 2015

How to achieve this when hashes are not incremental?

@popcornmix
Copy link
Collaborator

This repo is committed to linearly (without rebases/merges) so the date of the hashes should be in order.
If you run with JUST_CHECK=1 it prints a list of commits since you last updated. Grepping that for the HASH listed in NOTICE.md should say if you are including the WARNING commit.

@shrx
Copy link
Contributor Author

shrx commented Jun 24, 2015

I have updated the script so it can compare commit hashes. Also added HASH to NOTICE.md in rpi-firmware repo.

@popcornmix
Copy link
Collaborator

Looks promising.
Can you handle the case where HASH is not present in NOTICE.md (I think you should get the warning unconditionally)
Can you handle the case where /boot/.firmware_revision is not present (treat LOCAL_HASH date as very old).

@Ruffio
Copy link

Ruffio commented Apr 30, 2016

@shrx any chance you would update this to @popcornmix spec so it can be merged?

@Ruffio
Copy link

Ruffio commented May 18, 2016

@shrx it would be cool if you had the time to make the small changes so this PR could be merged.

@shrx
Copy link
Contributor Author

shrx commented May 18, 2016

Sorry, I completely forgot about this.
Will have a look at what needs to be done.

Handles the case where HASH is not present in NOTICE.md
Handles the case where /boot/.firmware_revision is not present
@shrx
Copy link
Contributor Author

shrx commented May 19, 2016

@Ruffio @popcornmix I think everything is in order now, it should handle the case where HASH is not present in NOTICE.md and where /boot/.firmware_revision is not present.

Improved efficiency logic
@popcornmix
Copy link
Collaborator

Currently we have a dependency on curl but not wget, and this PR adds a dependency on wget.
Is is possible to switch to using curl for get_hash_date?

return
local NOTICE_HASH_HEAD=$(echo "$FULL_NOTICE" | head -1)
if [ $(echo "${NOTICE_HASH_HEAD}" | awk -F: '{print $1}') == "HASH" ]; then
local NOTICE_HASH_EXISTS = true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get local: =': not a valid identifier`. The spaces need removing.

shrx added 2 commits May 19, 2016 18:04
bash doesn't like spaces
switch to curl
@shrx
Copy link
Contributor Author

shrx commented May 19, 2016

@popcornmix can you check now? I removed the offending spaces (hopefully all) and switched to curl.

@popcornmix
Copy link
Collaborator

Should the curl include -L?
I think we needed to add that to all other uses as github sometimes redirects responses.

@shrx
Copy link
Contributor Author

shrx commented May 19, 2016

It can't hurt, I guess.

curl follows redirects
@Ruffio
Copy link

Ruffio commented May 20, 2016

@popcornmix is this good to go?
I guess that the "add -L to curl in all other places" should be performed in another PR?

@popcornmix
Copy link
Collaborator

With the current NOTICE.md file, we discard the first line of the message.
I suspect we want to use NOTICE when NOTICE_HASH_EXISTS=true and FULL_NOTICE when NOTICE_HASH_EXISTS=false.

Don't discard lines if HASH is missing
@Ruffio
Copy link

Ruffio commented Jun 29, 2016

@popcornmix merge?

if ${NOTICE_HASH_EXISTS}; then
local NEW_HASH=${FW_REV}
local LOCAL_lt_NOTICE=$(compare_hashes ${LOCAL_HASH} lt ${NOTICE_HASH})
local NEW_ge_NOTICE=$(compare_hashes ${NEW_HASH} ge ${NOTICE_HASH})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By calling get_hash_date inside compare_hashes, this results in four separate requests to curl.
If you rearranged the logic slightly, and got the hash dates before comparing them, then you'd only need three requests to curl.
I guess there's also no need to call get_hash_date in the case when LOCAL_HASH has been set to 0.
And is it possible that any of LOCAL_HASH, NOTICE_HASH or NEW_HASH could have the same value? That might allow you to (conditionally) eliminate another call to curl.

@Ruffio
Copy link

Ruffio commented Jul 26, 2016

@shrx any chance you would do the last changes so we can get this PR merged? It would be awsome to get it in place. Think about it

changed `compare_hashes` logic to reduce the number of `curl` calls
@Ruffio
Copy link

Ruffio commented Jul 27, 2016

@lurch @popcornmix ready to merge?

@Ruffio
Copy link

Ruffio commented Aug 1, 2016

@popcornmix ready to merge?

1 similar comment
@Ruffio
Copy link

Ruffio commented Aug 17, 2016

@popcornmix ready to merge?

local LOCAL_HASH_DATE=$(get_hash_date ${LOCAL_HASH})
fi
local LOCAL_lt_NOTICE=$(compare_hashes "${LOCAL_HASH_DATE}" lt "${NOTICE_HASH_DATE}")
local NEW_ge_NOTICE=$(compare_hashes "${NEW_HASH_DATE}" ge "${NNOTICE_HASH_DATE}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just spotted that this line has ${NNOTICE_HASH_DATE} (note the two Ns) which I guess is a typo.

@Ruffio
Copy link

Ruffio commented Jan 13, 2017

@shrx any chance you would update this PR?

@shrx
Copy link
Contributor Author

shrx commented Jan 24, 2017

@Ruffio what needs updating?

@Ruffio
Copy link

Ruffio commented Jan 24, 2017

@shrx Have you read @lurch comments and observations? It also looks like there is a conflict to be resolved.

if [ -z "$NOTICE" ]; then
return
fi
local NOTICE_HASH_HEAD=$(echo "$FULL_NOTICE" | head -1)
if [ $(echo "${NOTICE_HASH_HEAD}" | awk -F: '{print $1}') == "HASH" ]; then
local NOTICE_HASH_EXISTS=true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For style-consistency with the rest of the code in this script, you should probably use 1 and 0 instead of true and false, and then change all your conditionals to e.g. if [[ ${NOTICE_HASH_EXISTS} -eq 1 ]]; then

@@ -281,6 +310,19 @@ function noobs_fix {

}

function get_hash_date {
commit_api="https://api.github.com/repos/Hexxeh/rpi-firmware/git/commits/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for style-consistency this should be upper-cased to COMMIT_API, and it should be dynamically calculated from $REPO_URI in the same way that REPO_API is on line 364; in case the user supplies a custom REPO_URI.

In fact, perhaps it makes sense to have REPO_API=${REPO_URI/github.com/api.github.com\/repos} up at the top of the script, and then line 315 could use $REPO_API/git/commits/$1 and line 365 etc. could use $REPO_API/git/refs/heads/${BRANCH}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made this change in #279 🙂

@Ruffio
Copy link

Ruffio commented Dec 25, 2020

@shrx is this still relevant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't display 4.0.y kernel warning if we're already on 4.0.y
4 participants