0

I'm trying to to retrieve most recent master version from the Hexxeh/rpi-firmware which is used by Ubuntu Mate 16.04.

The rpi-update update script exist on this page but I'm unable to fishout how they check if their version is newer than my local one.

What repo file, or what CLI/Bash command cold I use to get the newest available version online?

EDIT:

I could do sudo JUST_CHECK=1 rpi-update but is there cleaner way?

  • They don't. It uses git – Milliways Jan 12 '17 at 4:23
1

There is a /boot/.firmware_revision file created by the installation process.

The following bash script (extracted from Hexxeh's actual rpi-update script) could be used to extract the required info:

#!/bin/bash

set -o nounset
set -o errexit

REPO_URI=${REPO_URI:-"https://github.com/Hexxeh/rpi-firmware"}

BRANCH=${BRANCH:-"master"}
ROOT_PATH=${ROOT_PATH:-"/"}
BOOT_PATH=${BOOT_PATH:-"/boot"}
FW_PATH="${BOOT_PATH}"
FW_REV=${1:-""}
FW_REVFILE="${FW_PATH}/.firmware_revision"

# ask github for latest version hash
REPO_API=${REPO_URI/github.com/api.github.com\/repos}/git/refs/heads/${BRANCH}
FW_REV=$(curl -Ls ${REPO_API} | awk '{ if ($1 == "\"sha\":") { print substr($2, 2, 40) } }')
if [[ "${FW_REV}" == "" ]]; then
        echo " *** No hash received from github: ${REPO_API}"
        # run again with errors not suppressed
        curl -L ${REPO_API}
        exit 1
else
        echo "latest version: $FW_REV"
fi

# display local version hash
if [ -f "$FW_REVFILE" ]; then
        LOCAL_HASH=$(cat "$FW_REVFILE")
        echo " local version: $LOCAL_HASH"
else
        LOCAL_HASH=0
        echo " local version: unkown"
fi
  • this gives you a version which is installed, not the most recent version that is available for download. Also, without first running rpi-upgrade, this file does not exist. – HelpNeeder Jan 12 '17 at 18:13
  • I have updated the answer with an example script (containing a subset of the lines of Hexxeh's rpi-update script) to display the required information. – epposan Jan 13 '17 at 21:03
  • This is what I've been looking at. As the code points, I have run the CURL for the Github subversion API which gives me some information. The HEXX repo does specify the version number in their commit descriptions pretty much every time so this is what I'll be using. – HelpNeeder Jan 17 '17 at 15:21
  • Which of the two answers is what you've been looking for? From your comment it looks like this answer, however you have accepted the other answer as the best one... – epposan Jan 23 '17 at 21:18
  • Well, you just pasted piece of code letting me know 'might be somewhere there'. And you pointed out things I have already knew and prior to your answer was already scripting the answer. – HelpNeeder Jan 24 '17 at 2:44
0

This is a rough idea how I could achieve this due to the fact that the author states the kernel 'bump to' on commit comment:

#!/usr/bin/python

import urllib, json

json_url = 'https://api.github.com/repos/Hexxeh/rpi-firmware/commits'
json_response = urllib.urlopen(json_url)
json_data = json.loads(json_response.read())

count = 0
for json_entry in json_data:
    count += 1

    for property, content in json_entry.iteritems():
        if property == 'commit' and isinstance(content, dict):
            if content['message'].find("Bump to") != -1:
                print count, ": " , property, ": ", content['message'][0:22]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.