Skip to content

Instantly share code, notes, and snippets.

@monstermunchkin
Created August 8, 2012 11:44
Show Gist options
  • Save monstermunchkin/3294444 to your computer and use it in GitHub Desktop.
Save monstermunchkin/3294444 to your computer and use it in GitHub Desktop.
Create rooted image from factory image
#!/bin/bash -e
factory_img='soju-jro03e-factory-c9f5a67d.tgz'
su_bin='su-bin-3.1.1-arm-signed.zip'
mkdir -pv ~/custom_rom
cd ~/custom_rom
wget -nc "https://dl.google.com/dl/android/aosp/${factory_img}"
wget -nc "http://downloads.androidsu.com/superuser/${su_bin}"
tar -vxzf "${factory_img}"
cd ${factory_img%-factory*}
yes 'N' | unzip "image-${factory_img%-factory*}.zip"
mv -v "image-${factory_img%-factory*}.zip"{,.orig}
yes 'N' | unzip "../${su_bin}"
simg2img system.img{,.raw} || true
sudo mount -v -o loop system.img.raw /mnt
sudo cp -v system/bin/su /mnt/bin/
sudo chown -v 0:0 /mnt/bin/su
sudo chmod -v 6755 /mnt/bin/su
sync
sudo make_ext4fs -s -l 512M -a system system.img.new /mnt
sudo umount /mnt
sudo chown -v ${USER}:${GROUPS} system.img.new
mv -v system.img{.new,}
zip "image-${factory_img%-factory*}.zip" {boot,recovery,system,userdata}.img android-info.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment