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?

HelpNeeder
  • 178
  • 1
  • 11

2 Answers2

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
epposan
  • 139
  • 6
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]
HelpNeeder
  • 178
  • 1
  • 11