Changelog

2022-03-10

  • switched to wget in place of curl

About

Lakka's release cycle is considerably slow and many users prefer to update RetroArch to nightly such that platforms that do not get frequent updates and are stuck with stable might need to manually update to the latest Lakka. Furthermore, the built-in Lakka updater will update only to the stable branch of Lakka such that no update can be performed via the RetroArch menus. In order to address these issues a script can be written that will update Lakka to the latest nightly release on Lakka startup and is supposed to ensure that users are running on the very latest Lakka nightly release.

Design

The procedure involves checking the Lakka nightly website for the latest available image, comparing the latest Lakka image to the currently installed image by comparing the release hash and then downloading the latest image to the Lakka update directory and rebooting Lakka to perform the update. The script goes out of its way to check the hashes and the downloaded file to ensure that the download completed successfully.

Filesystem Overview

The following is a filesystem overview showing where the various files should be placed:

+-/storage/
      +
      |
      +---+ .config
      |        +
      |        |
      |        +---+ autostart.sh
      |
      +---+ .local
      |        +
      |        |
      |        +---+ usr
      |               +
      |               |
      |               +---+ sbin
      |                      +
      |                      |
      |                      +---+ lakka-update.sh
      +---+ .update               
  • /storage/.config/autostart.sh is the default Lakka script that will be executed when Lakka starts up; if it does not exist, it will have to be created,
  • /storage/.local/usr/bin/lakka-update.sh is the updater script provided in the code section,
  • ./storage/.update is the directory where the image file will be placed in order to Lakka to update the system on reboot.

Setup

With the files arranged as per the previous section, the /storage/.config/autostart.sh script should either be created or amended in order to contain the following lines at the top:

#!/usr/bin/sh
 
# update Lakka
/storage/.local/usr/sbin/lakka-update.sh

Code

As commented within the script, the ARCH parameter must be changed under the CONFIGURATION section in order to allow the script to download the correct image file.

#!/usr/bin/env bash
###########################################################################
##  Copyright (C) Wizardry and Steamworks 2021 - License: GNU GPLv3      ##
###########################################################################
# This script is meant to update Lakka to the last nightly and designed   #
# to run when Lakka starts up. The script should be placed in:            #
#                                                                         #
# /storage/local/usr/sbin                                                 #
#                                                                         #
# and then executed from the /storage/.config/autostart.sh script. In     #
# other words copy this file to /storage/.local/usr/sbin/lakka-update.sh  #
# and then edit /storage/.config/autostart.sh to include the line:        #
#                                                                         #
# /storage/.local/usr/sbin/lakka-update.sh                                #
#                                                                         #
###########################################################################
 
###########################################################################
#                             CONFIGURATION                               #
###########################################################################
 
# The architecture to update. A list of available Lakka architectures are
# available at https://nightly.builds.lakka.tv/by_devices/
ARCH=RPi4.arm
 
###########################################################################
#                              INTERNALS                                  #
###########################################################################
 
echo "Checking for updates..."
 
CURRENT_IMAGE_HASH=`cat /etc/os-release | grep VERSION= | awk -F'=' '{ print $2 }' | awk -F'"' '{ print $2 }' | awk -F'-' '{ print $3 }'`
LATEST_IMAGE=`wget -q -O - "https://nightly.builds.lakka.tv/.updater/$ARCH/" | grep -o  "\"Lakka-$ARCH-nightly-.*.img.gz\"" | awk -F'"' '{ print $2 }' | tail -n 1`
LATEST_IMAGE_HASH_FILE=$LATEST_IMAGE".sha256"
UPDATE_URL="https://nightly.builds.lakka.tv/.updater/$ARCH/"$LATEST_IMAGE
LATEST_IMAGE_HASH=`echo $LATEST_IMAGE |  awk -F'[\.\-]' '{ print $6 }'`
 
 
if [ "$LATEST_IMAGE_HASH" = "$CURRENT_IMAGE_HASH" ]; then
    echo "No update necessary."
    exit 0
fi
 
echo "Updating to latest image..."
echo "Downloading latest image: "$UPDATE_URL
wget -c -q -O "/storage/.update/$LATEST_IMAGE" "$UPDATE_URL"
 
# Compre downloaded image SHA256 with SHA256 provided by Lakka
LR=`wget -q -O -  "https://nightly.builds.lakka.tv/.updater/$ARCH/$LATEST_IMAGE_HASH_FILE" | awk '{ print $1 }'`
RR=`sha256sum "/storage/.update/$LATEST_IMAGE" | awk '{ print $1 }'`
 
if [ "$LR" != "$RR" ]; then
    echo "File hashes do not match, aborting..."
    rm "/storage/.update/$LATEST_IMAGE"
    exit 1
fi
 
echo "Rebooting in 10s..."
sleep 10
reboot

lakka/autoupdate_to_nightly.txt ยท Last modified: 2022/04/27 17:51 by office

Wizardry and Steamworks

© 2025 Wizardry and Steamworks

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.