-
Notifications
You must be signed in to change notification settings - Fork 232
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
base: master
Are you sure you want to change the base?
Conversation
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`` Then, if U < W && L >= W you display the warning. |
How to achieve this when hashes are not incremental? |
This repo is committed to linearly (without rebases/merges) so the date of the hashes should be in order. |
now with smart hash comparison
I have updated the script so it can compare commit hashes. Also added |
Looks promising. |
@shrx any chance you would update this to @popcornmix spec so it can be merged? |
@shrx it would be cool if you had the time to make the small changes so this PR could be merged. |
Sorry, I completely forgot about this. |
Handles the case where HASH is not present in NOTICE.md Handles the case where /boot/.firmware_revision is not present
@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
Currently we have a dependency on curl but not wget, and this PR adds a dependency on wget. |
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 |
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 get local:
=': not a valid identifier`. The spaces need removing.
bash doesn't like spaces
switch to curl
@popcornmix can you check now? I removed the offending spaces (hopefully all) and switched to curl. |
Should the curl include |
It can't hurt, I guess. |
curl follows redirects
@popcornmix is this good to go? |
With the current NOTICE.md file, we discard the first line of the message. |
Don't discard lines if HASH is missing
@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}) |
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.
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.
@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
@lurch @popcornmix ready to merge? |
@popcornmix ready to merge? |
1 similar comment
@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}") |
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.
Just spotted that this line has ${NNOTICE_HASH_DATE}
(note the two Ns) which I guess is a typo.
@shrx any chance you would update this PR? |
@Ruffio what needs updating? |
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 |
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.
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/" |
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 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}
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've made this change in #279 🙂
@shrx is this still relevant? |
Fixes #178
for real this time