|
@ -1,12 +1,13 @@ |
|
|
#!/bin/bash |
|
|
#!/bin/bash |
|
|
# SPDX-License-Identifier: GPL-3.0+ |
|
|
# SPDX-License-Identifier: GPL-3.0+ |
|
|
# Copyright (C) 2018, Martin Kepplinger <martink@posteo.de> |
|
|
|
|
|
|
|
|
# Copyright (C) 2019, Martin Kepplinger <martink@posteo.de> |
|
|
|
|
|
|
|
|
set -e |
|
|
set -e |
|
|
|
|
|
|
|
|
source functions.sh |
|
|
source functions.sh |
|
|
|
|
|
|
|
|
have_input_image=0 |
|
|
have_input_image=0 |
|
|
|
|
|
request_update=0 |
|
|
|
|
|
|
|
|
usage() |
|
|
usage() |
|
|
{ |
|
|
{ |
|
@ -16,13 +17,14 @@ usage() |
|
|
echo " This flashes the BIOS with the given image." |
|
|
echo " This flashes the BIOS with the given image." |
|
|
echo " Make sure you booted Linux with iomem=relaxed" |
|
|
echo " Make sure you booted Linux with iomem=relaxed" |
|
|
echo "" |
|
|
echo "" |
|
|
echo "Usage: $0 [-i <4mb_top_image>.rom] [-h]" |
|
|
|
|
|
|
|
|
echo "Usage: $0 [-i <4mb_top_image>.rom] [-U] [-h]" |
|
|
echo "Options:" |
|
|
echo "Options:" |
|
|
echo " -i path to the image to flash" |
|
|
echo " -i path to the image to flash" |
|
|
|
|
|
echo " -U update: check for a new Skulls package online" |
|
|
echo " -h print this help text" |
|
|
echo " -h print this help text" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
args=$(getopt -o i:h -- "$@") |
|
|
|
|
|
|
|
|
args=$(getopt -o i:hU -- "$@") |
|
|
if [ $? -ne 0 ] ; then |
|
|
if [ $? -ne 0 ] ; then |
|
|
usage |
|
|
usage |
|
|
exit 1 |
|
|
exit 1 |
|
@ -41,6 +43,9 @@ do |
|
|
usage |
|
|
usage |
|
|
exit 1 |
|
|
exit 1 |
|
|
;; |
|
|
;; |
|
|
|
|
|
-U) |
|
|
|
|
|
request_update=1 |
|
|
|
|
|
;; |
|
|
--) |
|
|
--) |
|
|
shift |
|
|
shift |
|
|
break |
|
|
break |
|
@ -53,6 +58,57 @@ do |
|
|
shift |
|
|
shift |
|
|
done |
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
if [ "$request_update" -gt 0 ] ; then |
|
|
|
|
|
warn_not_root |
|
|
|
|
|
|
|
|
|
|
|
command -v curl >/dev/null 2>&1 || { echo -e >&2 "${RED}Please install curl.${NC}"; exit 1; } |
|
|
|
|
|
|
|
|
|
|
|
CURRENT_VERSION=$(head -2 NEWS | egrep -o "([0-9]{1,}\.)+[0-9]{1,}") |
|
|
|
|
|
|
|
|
|
|
|
UPSTREAM_FILE=$(curl -s https://api.github.com/repos/merge/skulls/releases/latest | grep browser_download_url | cut -d'"' -f4 | cut -d'/' -f9 | head -n 1) |
|
|
|
|
|
|
|
|
|
|
|
UPSTREAM_VERSION=$(curl -s https://api.github.com/repos/merge/skulls/releases/latest | grep browser_download_url | cut -d'"' -f4 | cut -d'/' -f9 | head -n 1 | egrep -o "([0-9]{1,}\.)+[0-9]{1,}") |
|
|
|
|
|
|
|
|
|
|
|
UPSTREAM_X230=$(echo ${UPSTREAM_FILE} | grep x230) |
|
|
|
|
|
if [[ -z "$UPSTREAM_X230" ]] ; then |
|
|
|
|
|
echo "The latest release didn't include the X230" |
|
|
|
|
|
exit 0 |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if [[ $verbose -gt 0 ]] ; then |
|
|
|
|
|
echo "This is v$CURRENT_VERSION and latest is v$UPSTREAM_VERSION" |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if [[ "$CURRENT_VERSION" = "$UPSTREAM_VERSION" ]] ; then |
|
|
|
|
|
echo -e "${GREEN}You are using the latest version of Skulls for the X230${NC}" |
|
|
|
|
|
exit 0 |
|
|
|
|
|
elif [[ "$CURRENT_VERSION" < "$UPSTREAM_VERSION" ]] ; then |
|
|
|
|
|
echo -e "${RED}You have ${CURRENT_VERSION} but there is version ${UPSTREAM_VERSION} available for the X230. Please update.${NC}" |
|
|
|
|
|
read -r -p "Download it to the parent directory now? [y/N] " response |
|
|
|
|
|
case "$response" in |
|
|
|
|
|
[yY][eE][sS]|[yY]) |
|
|
|
|
|
UPSTREAM_URL=$(curl -s https://api.github.com/repos/merge/skulls/releases/latest | grep browser_download_url | cut -d'"' -f4 | head -n 1) |
|
|
|
|
|
UPSTREAM_URL_SHA256=$(curl -s https://api.github.com/repos/merge/skulls/releases/latest | grep browser_download_url | cut -d'"' -f4 | head -n 3 | tail -n 1) |
|
|
|
|
|
cd .. |
|
|
|
|
|
curl -LO ${UPSTREAM_URL} |
|
|
|
|
|
curl -LO ${UPSTREAM_URL_SHA256} |
|
|
|
|
|
sha256sum -c ${UPSTREAM_FILE}.sha256 |
|
|
|
|
|
mkdir skulls-x230-${UPSTREAM_VERSION} |
|
|
|
|
|
tar -xf ${UPSTREAM_FILE} -C skulls-x230-${UPSTREAM_VERSION}/ |
|
|
|
|
|
echo "Version ${UPSTREAM_VERSION} extracted to ../skulls-x230-${UPSTREAM_VERSION}/" |
|
|
|
|
|
echo "Please continue in the new directory." |
|
|
|
|
|
;; |
|
|
|
|
|
*) |
|
|
|
|
|
exit 0 |
|
|
|
|
|
;; |
|
|
|
|
|
esac |
|
|
|
|
|
else |
|
|
|
|
|
echo "You seem to use a development version. Please use release package skulls-x230 ${UPSTREAM_VERSION} for flashing." |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
exit 0 |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
force_x230_and_root |
|
|
force_x230_and_root |
|
|
|
|
|
|
|
|
BIOS_VENDOR=$(dmidecode -t bios | grep Vendor | cut -d':' -f2) |
|
|
BIOS_VENDOR=$(dmidecode -t bios | grep Vendor | cut -d':' -f2) |
|
|