Skip to content

Instantly share code, notes, and snippets.

@schnatterer
Last active January 4, 2023 21:03
Show Gist options
  • Save schnatterer/ad7033bf476587aa43a37f3232feeb71 to your computer and use it in GitHub Desktop.
Save schnatterer/ad7033bf476587aa43a37f3232feeb71 to your computer and use it in GitHub Desktop.
Download CalyxOS boot.img for more convenient rooting
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
# Download lastest Calyx factory image and extract boot.img to be patched via magisk
# See here for device names: https://calyxos.org/install/
DEVICE=oriole
CHANNEL=stable4
DEST_DIR=/storage/emulated/0/Download
VERSION=$(curl -s https://release.calyxinstitute.org/$DEVICE-$CHANNEL | cut -d ' ' -f1)
TMPDIR=$(mktemp -d)
(
cd $TMPDIR
# See also updater app # https://gitlab.com/CalyxOS/platform_packages_apps_Updater/-/blob/android13/src/app/seamlessupdate/client/Service.java#L263
curl -o release.zip https://release.calyxinstitute.org/oriole-factory-$VERSION.zip
curl -o release.zip.minisig https://release.calyxinstitute.org/oriole-factory-$VERSION.zip.minisig # Download the public key
curl -o minisign.pub https://release.calyxinstitute.org/minisign.pub
minisign -Vm release.zip -p minisign.pub
#unzip -l e.g. 967 2023-01-04 19:05 something/some.zip
ZIP_PATH=$(unzip -l release.zip | grep .zip | awk '{print $4}')
unzip -j release.zip $ZIP_PATH
rm release.zip release.zip.minisig
FINAL_ZIP=$(find . -iname '*.zip')
# Note that there is a vendor_boot.img
BOOT_IMG_PATH=$(unzip -l $FINAL_ZIP | grep ' boot.img' | awk '{print $4}')
unzip -j $FINAL_ZIP $BOOT_IMG_PATH
)
mv $TMPDIR/boot.img $DEST_DIR/$DEVICE-$VERSION-boot.img
rm -rf $TMPDIR
echo Wrote $DEST_DIR/$DEVICE-$VERSION-boot.img
# Patch img right away?
# https://github.com/affggh/Magisk_patcher/blob/ttkbootstrap/README_EN.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment