Created
August 6, 2017 04:34
-
-
Save erfanoabdi/7ff14d614f4919fee5159fccd7885370 to your computer and use it in GitHub Desktop.
sparseChunks to image Convertor for motorola images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#SparseChunks to image Convertor for motorola images by Erfan Abdi | |
#special thanks to superR for header removal script | |
#make sure you have only one image with sparse chunks (system or oem) | |
echo "Converting all SparseChunks to Raw Image" | |
./simg2img *chunk* system.img.raw | |
echo "Removing Moto Header" | |
offset=$(LANG=C grep -aobP -m1 '\x53\xEF' system.img.raw | head -1 | gawk '{print $1 - 1080}') | |
dd if=system.img.raw of=system_moto.img ibs=$offset skip=1 2>&1 | |
echo "Removing Raw Image" | |
rm -rf system.img.raw | |
echo "Removing Moto Footer" | |
head -c $(( 4*1024*-1 )) system_moto.img > system.img | |
echo "Removing moto Image" | |
rm -rf system_moto.img | |
echo "system.img is ready" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment