[REF] Unpacking and repacking stock rom .img files

http://forum.xda-developers.com/galaxy-s2/general/ref-unpacking-repacking-stock-rom-img-t1081239


备注:每次发给工厂的image分为两种,一种是fastboot可以直接更新的image package;另外一种,是copymachine image package.

一般情况下,脚本build的image是sparse image(一种特殊压缩的文件格式),但是build copymachine image, 则需要un-sparse image; 这种情况下,只需要下面的命令,即可以把sparse image转换成un-sparse image,

./simg2img factoryfs.img output.img


As most of you are aware, the stock rom tarball is comprised of several .img files which don't seem to be of any file system format and it is difficult at first to see what is inside these files without flashing via Odin.

Well, thanks to fguy, this thread  http://forum.xda-developers.com/show....php?t=1054836 provided me the necessary inspiration to investigate just exactly what are these img made of.

Hopefully, this will allow easy removal of all the  Samsung junk, deodexing, rooting etc etc without going through adb.

As it turns out, they are simply sparse ext4 images, and the AOSP source tree already contains the necessary utilities to both unpack and repack these img files via "ext4_utils" in system/extras ( https://android.googlesource.com/pla...system/extras/)

For your convenience, I have provided a repackage of the source code for ext4_utils with a simple Makefile, for keen developers to make the necessary tools for unpacking and repacking the stock img files. Making these tools requires a linux development environment, which is beyond the scope of this topic.

To make the tools, simple extract the attached source code and type "make".

To unpack the .img file:
Code:
./simg2img factoryfs.img output.img
To view the contents of .img file:
Code:
mkdir tempdir; mount -o loop output.img tempdir
To repack .img file:
Code:
./mkuserimg.sh -s /some/directory/with/files ./factoryfs_custom.img ext4 ./temp 512M
As I do not have Odin at the moment, I am not able to test the repacked files can be reflashed successfully. I will test this shortly.


UPDATE
I have just tested repacking the stock factoryfs.img. It so happens that the original ext4_utils does not properly preserve permissions on the new ext4 image. I have made a slight modification to the source and reuploaded the zip.

You can now successfully unpack, remove and change the stock apps, root and modify the stock image using instructions above!!

I hope this will help people create their own custom roms.


UPDATE 27th MAY FOR GALAXY S4 TESTING (i9500 i9505)
A few people have messaged me asking why these tools do not work for the new Galaxy S4. Unfortunately I do not have a Galaxy S4 so I can not test any of these utilities.  HOWEVER, it seems there has been quite a bit of updates by Google in the ext4_utils package. I have updated the sources according to 4.2.2 which is the latest version of the tools. I must stress that  I DO NOT HAVE A GALAXY S4 TO TEST so don't be expecting miracles. In any case I have uploaded the new code now. As it was before, I have provided a MAKEFILE and you simply type "make" in order to build the tools. They are contained in ext4_utils_ new.zip.

Thanks for your support guys. And I do apologize for replying late to my inbox...

Update 9th November 2014
Thanks to qwerty_7564 for providing the fixes for cygwin compilation. 
Ext4 utils new still missing link arguments to compile. Investigating. I will update the sources to that of the 4.3 branch later.

Update 3rd December 2014
I have updated the tools to 4.3 branch. Note that no attempts has been made to make this compatible with cygwin as I have no cygwin to test.
As I have mentioned earlier, I do not have a newer samsung device to test any of these files, use at your own discretion. The new files are in ext4_utils_r4.3.tar.gz and is based on the jb release 2.0.0 branch.
Attached Files
File Type: zipext4_utils_cygwin_fixed.zip - [Click for QR Code] (59.8 KB, 12680 views)
File Type: gzext4_utils_new_cygwin_fixed.tar.gz - [Click for QR Code] (64.9 KB, 9687 views)
File Type: gzext4_utils_r4.3.tar.gz - [Click for QR Code] (110.0 KB, 17888 views)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值