Skip to content

Instantly share code, notes, and snippets.

@danielml3
Created November 26, 2023 17:55
Show Gist options
  • Save danielml3/89204b770e6841bd848d52c147c3f308 to your computer and use it in GitHub Desktop.
Save danielml3/89204b770e6841bd848d52c147c3f308 to your computer and use it in GitHub Desktop.
Script for diffing two boot images using Git and AIK (Android Image Kitchen)
#!/bin/bash
set -e
ORIGINAL_IMG=$1
NEW_IMG=$2
if [ -z $ORIGINAL_IMG ] || [ -z $NEW_IMG ]; then
echo "usage: ./bootimgdiff.sh <original-img> <new-img>"
exit 1
fi
if [ "$EUID" -ne 0 ]; then
echo "This script must be run as root"
exit 1
fi
IMGNAME=$(basename $ORIGINAL_IMG)
if [ -f $IMGNAME ] || [ -d $IMGNAME ]; then
rm -rf $IMGNAME
fi
mkdir $IMGNAME
# Unpack the original image and move the contents to the img diff directory
./unpackimg.sh $ORIGINAL_IMG
mv ramdisk $IMGNAME
mv split_img $IMGNAME
./cleanup.sh
# Init a git repository and add all files
cd $IMGNAME
git init
git add .
# Remove the files
rm -rf ramdisk
rm -rf split_img
cd ..
# Unpack the new image and move the contents to the img diff directory
./unpackimg.sh $NEW_IMG
mv ramdisk $IMGNAME
mv split_img $IMGNAME
./cleanup.sh
echo "Diff available at: $IMGNAME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment