-
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?
Changes from 8 commits
61b193c
c478341
47f760c
18dea0d
4e5fe1f
986365d
6d43989
9856b77
21b75dd
f5b32bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,10 +115,33 @@ function update_sdk { | |
} | ||
|
||
function show_notice { | ||
local NOTICE=`curl -Lfs https://raw.githubusercontent.com/hexxeh/rpi-firmware/${FW_REV}/NOTICE.md` | ||
local FULL_NOTICE=`curl -Lfs https://raw.githubusercontent.com/hexxeh/rpi-firmware/${FW_REV}/NOTICE.md` | ||
local NOTICE=$(echo "$FULL_NOTICE" | tail -n+2) | ||
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 commentThe 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 |
||
local NOTICE_HASH=$(echo "${NOTICE_HASH_HEAD}" | awk '{print $2}') | ||
else | ||
local NOTICE_HASH_EXISTS=false | ||
fi | ||
if [ -f "$FW_REVFILE" ]; then | ||
local LOCAL_HASH=$(cat "$FW_REVFILE") | ||
else | ||
local LOCAL_HASH=0 | ||
fi | ||
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 commentThe 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 ! ${LOCAL_lt_NOTICE} && ! ${NEW_ge_NOTICE}; then | ||
return | ||
fi | ||
else | ||
NOTICE="$FULL_NOTICE" | ||
fi | ||
echo "$NOTICE" | ||
if ! echo "$NOTICE" | grep -q WARNING; then | ||
return | ||
|
@@ -281,6 +304,21 @@ 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 commentThe reason will be displayed to describe this comment to others. Learn more. I think for style-consistency this should be upper-cased to In fact, perhaps it makes sense to have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've made this change in #279 🙂 |
||
curl -Ls "$commit_api"$1 | grep "date" | head -1 | awk -F\" '{print $4}' | ||
} | ||
|
||
function compare_hashes { | ||
date1=$(get_hash_date $1) | ||
date2=$(get_hash_date $3) | ||
if [ $(date -d "$date1" +%s) -$2 $(date -d "$date2" +%s) ]; then | ||
echo true | ||
else | ||
echo false | ||
fi | ||
} | ||
|
||
if [[ ${EUID} -ne 0 ]]; then | ||
echo " !!! This tool must be run as root" | ||
exit 1 | ||
|
@@ -320,13 +358,13 @@ command -v readelf >/dev/null 2>&1 || { | |
|
||
# ask github for latest version hash | ||
REPO_API=${REPO_URI/github.com/api.github.com\/repos}/git/refs/heads/${BRANCH} | ||
GITREV=$(curl -s ${REPO_API} | awk '{ if ($1 == "\"sha\":") { print substr($2, 2, 40) } }') | ||
GITREV=$(curl -Ls ${REPO_API} | awk '{ if ($1 == "\"sha\":") { print substr($2, 2, 40) } }') | ||
FW_REV=${FW_REV:-${GITREV}} | ||
|
||
if [[ "${FW_REV}" == "" ]]; then | ||
echo " *** No hash received from github: ${REPO_API}" | ||
# run again with errors not suppressed | ||
curl ${REPO_API} | ||
curl -L ${REPO_API} | ||
exit 1 | ||
fi | ||
|
||
|
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 wonder if this should be checking $FULL_NOTICE instead of $NOTICE ?
I think as it is currently, it wouldn't display the NOTICE if it was only one line long?
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.
In fact, I think this line should be
if [ -z "$FULL_NOTICE" ]; then
and thelocal NOTICE=$(echo "$FULL_NOTICE" | tail -n+2)
can probably be moved down to line 138 or so.