Browse Source

x230: move the upgrade.sh into x230_skulls.sh

pull/102/head
Martin Kepplinger 5 years ago
parent
commit
69eabbf9fc
4 changed files with 61 additions and 99 deletions
  1. +1
    -1
      x230/README.md
  2. +1
    -1
      x230/functions.sh
  3. +0
    -94
      x230/upgrade.sh
  4. +59
    -3
      x230/x230_skulls.sh

+ 1
- 1
x230/README.md View File

@ -50,7 +50,7 @@ branch is _not_ meant to be stable. Use it for testing only.
Before starting, run Linux on your X230, install `dmidecode` and run
`sudo ./x230_skulls.sh`. It simply prints system information and
helps you to be up to date.
Also make sure you have the latest skulls-x230 package release by running `./upgrade.sh`.
Also make sure you have the latest skulls-x230 package release by running `./x230_skulls.sh -U`.
#### original BIOS update / EC firmware (optional)
Before flashing coreboot, consider doing one original Lenovo upgrade process


+ 1
- 1
x230/functions.sh View File

@ -45,6 +45,6 @@ check_battery() {
warn_not_root() {
if [[ $EUID -eq 0 ]]; then
echo -e "${RED}This script should not be run as root!${NC}"
echo -e "${YELLOW}WARNING:${NC} This should not be executed as root!"
fi
}

+ 0
- 94
x230/upgrade.sh View File

@ -1,94 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0+
# Copyright (C) 2018, Martin Kepplinger <martink@posteo.de>
set -e
source functions.sh
usage()
{
echo "Skulls for the X230"
echo ""
echo " This script checks if there's a newer"
echo " release of the X230 Skulls package available."
echo ""
echo "Usage: $0 [-v]"
}
args=$(getopt -o hv -- "$@")
if [ $? -ne 0 ] ; then
usage
exit 1
fi
verbose=0
eval set -- "$args"
while [ $# -gt 0 ]
do
case "$1" in
-v)
verbose=1
;;
-h)
usage
exit 1
;;
--)
shift
break
;;
*)
echo "Invalid option: $1"
exit 1
;;
esac
shift
done
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}/"
;;
*)
exit 0
;;
esac
else
echo "You seem to use a development version. Please use release package skulls-x230 ${UPSTREAM_VERSION} for flashing."
fi

+ 59
- 3
x230/x230_skulls.sh View File

@ -1,12 +1,13 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0+
# Copyright (C) 2018, Martin Kepplinger <martink@posteo.de>
# Copyright (C) 2019, Martin Kepplinger <martink@posteo.de>
set -e
source functions.sh
have_input_image=0
request_update=0
usage()
{
@ -16,13 +17,14 @@ usage()
echo " This flashes the BIOS with the given image."
echo " Make sure you booted Linux with iomem=relaxed"
echo ""
echo "Usage: $0 [-i <4mb_top_image>.rom] [-h]"
echo "Usage: $0 [-i <4mb_top_image>.rom] [-U] [-h]"
echo "Options:"
echo " -i path to the image to flash"
echo " -U update: check for a new Skulls package online"
echo " -h print this help text"
}
args=$(getopt -o i:h -- "$@")
args=$(getopt -o i:hU -- "$@")
if [ $? -ne 0 ] ; then
usage
exit 1
@ -41,6 +43,9 @@ do
usage
exit 1
;;
-U)
request_update=1
;;
--)
shift
break
@ -53,6 +58,57 @@ do
shift
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
BIOS_VENDOR=$(dmidecode -t bios | grep Vendor | cut -d':' -f2)


Loading…
Cancel
Save