[tool] ANDROID_IMG_REPACK_TOOLS

A.S._id

Inactive Recognized Developer
Sep 21, 2010
1,211
2,574
153
[tool] ANDROID_IMG_REPACK_TOOLS
&
Android_ROM_IMG_Repacker



android_img_repack_tools is a kit utilites for unpack/repack android ext4 and boot images in LINUX & WINDOWS


includes binaries:
mkbootfs
simg2simg
make_ext4fs
make_ext4fs_def
mkbootimg
ext2simg
simg2img
img2simg
sgs4ext4fs - Chainfire's tool
unpackbootimg - CyanogenMod tool
mkbootimg_tools - xiaolu

Android_ROM_IMG_Repacker




sources used:
https://android.googlesource.com
https://github.com/CyanogenMod/android_system_core.git
https://github.com/Chainfire/sgs4ext4fs





how to make:

Preparation OS:

Code:
sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev build-essential zip curl libncurses5-dev zlib1g-dev valgrind libreadline6-dev gcc-multilib g++-multilib libc6-dev x11proto-core-dev libx11-dev libz-dev gawk texinfo automake libtool cvs libsdl-dev
Dowload repo:

Code:
git clone https://github.com/ASdev/android_img_repack_tools
Choose branch, for example:

Code:
cd android_img_repack_tools
git checkout android-4.4.4_r2.0.1
Building tools:

Code:
chmod +x configure
./configure
will download source from android git repositories

Code:
make
will compille binaries: mkbootfs simg2simg make_ext4fs mkbootimg sgs4ext4fs unpackbootimg ext2simg img2simg simg2img

Code:
make clean
will remove binaries

Code:
make clear

wiil remove sources

credits:
android.googlesource
Chainfire
CyanogenMod


go to the repository

Already have a branch:
android-2.3.7
android-4.0.4
android-4.1.1
android-4.1.2
android-4.2.2
android-4.3
android-4.4.2
android-4.4.3
android-4.4.4
android-5.0.0
android-5.0.2
android-5.1.0
android-5.1.1
android-6.0.0
android-6.0.1


Usage:


Code:
## Converting sparse flashing system.img from flashing android sparse img to ext4 img

$ simg2img system.img system.raw.img
## or all parts of sparse img
$ simg2img system.img* system.raw.img

## Mounting ext4 img for edit

$ mkdir system_mnt
$ mount -t ext4 -o loop system.raw.img system_mnt
Code:
## Creating new android sparse img for flashing (android 2.3.6-4.2)

$ mkuserimg.sh -s system_mnt system_new.img ext4 ./system [size partition MB for example 1024M]
## or
$ make_ext4fs -s -l 1024M system_new.img system_mnt

more

$ mkuserimg.sh -s system system.img ext4 /system [size partition MB for example 1024M] file_contexts
Code:
## Converting ext4 img to sparse img for flashing (android 4.3-etc)

$ ext2simg -v system.raw.img system_new.img
Code:
## Changing sparse img header size from 28bit to 32bit (for Samsung Exynos Octa)

$ sgs4ext4fs --bloat system_new.img system_32bit.img
Code:
## Remove Moto extra header... (for Motorola G-series, making after unsparse img)

$ mv system.raw.img system.moto.img
$ dd if=system.moto.img of=system.raw.img ibs=131072 skip=1





ANDROID_IMG_REPACK_TOOLS_CYGWIN WINDOWS

ANDROID_IMG_REPACK_TOOLS_CYGWIN is a kit utilites for unpack/repack android ext4 and boot images in WINDOWS


mkbootfs.exe
simg2simg.exe
make_ext4fs.exe
mkbootimg.exe
ext2simg.exe
img2simg.exe
simg2img.exe
sgs4ext4fs.exe - Chainfire's tool
unpackbootimg.exe - CyanogenMod tool


Already have a branch:
android-4.1.2
android-5.1.0
android-5.1.1
android-6.0.0
android-6.0.1

Already have a .exe:
WINDOWS REPO






XDA:DevDB Information
android_img_repack_tools, Tool/Utility for the Android General

Contributors
A.S._id

Version Information
Status: Testing

Created 2014-01-06
Last Updated 2016-04-17
 
Last edited:

A.S._id

Inactive Recognized Developer
Sep 21, 2010
1,211
2,574
153
Android ext4fs ROM editor

Android_ROM_IMG_Repacker

It is automatise for android_img_repack_tools for Linux & Windows CYGWIN

Instructions:


credits:
android.googlesource
@Chainfire
@Chenglu
@xpirt

Added v.2.1

* Configure:
Auto choice OS for compilation android_img_repack_tools

* MOUNT ext4 img:
Auto converting sparse to raw img
Auto find magic sparse img and remove vendor extra header
Auto choice OS for mount or extract raw img

* MAKE_EXT4FS - new img ANDROID permission:
Auto extract 'file_contexts' from recovery.img (if exist)

* EXT2SIMG - raw to sparse
Auto choice chunk header (28/32 bytes)

Added v.2.2

* Fixed some bugs
 

Attachments

Last edited:

A.S._id

Inactive Recognized Developer
Sep 21, 2010
1,211
2,574
153

MATPOC

Senior Member
Jun 25, 2010
58
9
28
Some headers missed. I am using Ubintu 12.04 and installed zlib1g-dev for compiling zlib_host. But make_ext4fs don't compiling:

Building make_ext4fs...
extras/ext4_utils/make_ext4fs.c: In function 'build_directory_structure':
extras/ext4_utils/make_ext4fs.c:175:27: error: 'struct stat' has no member named 'st_stat'
extras/ext4_utils/make_ext4fs.c:176:26: error: 'struct stat' has no member named 'st_stat'
extras/ext4_utils/make_ext4fs.c:177:26: error: 'struct stat' has no member named 'st_stat'
make: *** [make_ext4fs] Error 1
 

A.S._id

Inactive Recognized Developer
Sep 21, 2010
1,211
2,574
153
Some headers missed. I am using Ubintu 12.04 and installed zlib1g-dev for compiling zlib_host. But make_ext4fs don't compiling:

Building make_ext4fs...
extras/ext4_utils/make_ext4fs.c: In function 'build_directory_structure':
extras/ext4_utils/make_ext4fs.c:175:27: error: 'struct stat' has no member named 'st_stat'
extras/ext4_utils/make_ext4fs.c:176:26: error: 'struct stat' has no member named 'st_stat'
extras/ext4_utils/make_ext4fs.c:177:26: error: 'struct stat' has no member named 'st_stat'
make: *** [make_ext4fs] Error 1
Well you has two ways:
This http://www.zlib.net/
or
Code:
make clean
make clear
./configure
cd ./zlib/src
./configure
make
sudo make install
cd ../..
make clean
make
 
Last edited:

A.S._id

Inactive Recognized Developer
Sep 21, 2010
1,211
2,574
153
As I said I have compiled zlib_host by installing zlib1g-dev. Compile broken at ext4fs - maybe there are no extra headers for ext4fs, such as for struct stat.
1. zlib1g-dev - не входит в состав zlib
2. у меня установлена Ubuntu 13.10 amd64 gcc 4.8
поэтому - не могу точно ответить по 12.04

gt.
1. zlib1g-dev - not part of zlib
2. I have installed Ubuntu 13.10 amd64 gcc 4.8
so - I can not exactly answer to 12.04
 
Last edited:

alexyuh

Senior Member
Jan 7, 2012
319
515
0
Saint-Peterburg
As I said I have compiled zlib_host by installing zlib1g-dev. Compile broken at ext4fs - maybe there are no extra headers for ext4fs, such as for struct stat.
Assembly must be done on 64 bit OS. Only installing zlib-1.2.8
View attachment zlib-1.2.8.tar.gz
And the following packages
Code:
sudo apt-get update
sudo apt-get install ia32-libs
gcc 4.8 can be set separately
 
Last edited:
  • Like
Reactions: linhbs

desalesouche

Senior Member
Feb 6, 2012
3,651
4,294
0
hi sir. may i ask you to update op with more explanation of what can do your tool?
i understood that it unpack and repack boot.img and compile binaries...
and after that i am wondering what more? what for?
i use kernel tool master to unpack and repack boot.img...
what is the diffeence and the purpose of you tools?
thank you...
i know i miss of knowledge so that is why i ask.
 

alexyuh

Senior Member
Jan 7, 2012
319
515
0
Saint-Peterburg
hi sir. may i ask you to update op with more explanation of what can do your tool?
i understood that it unpack and repack boot.img and compile binaries...
and after that i am wondering what more? what for?
i use kernel tool master to unpack and repack boot.img...
what is the diffeence and the purpose of you tools?
thank you...
i know i miss of knowledge so that is why i ask.
Old binary do not work with newer versions of android
 
  • Like
Reactions: desalesouche

Odysseus1962

Senior Member
Sep 30, 2013
690
562
123
Miami
The way is not into repacking boot image, but different version of android has different parametrs of FS. Example android 4.3 ext4 FS has support SELinux, but 4.1 and older hasn't
I still don't get the purpose of these tools. I've been running Gentoo Linux as my primary OS for a dozen years, all the tools I need to compile kernels, create boot images, ramdisks, initrds, extract and manipulate from already created images, are already installed on my system by default. Why would I need these too? Are these supposed to be time-savers? Shortcuts? I still don't understand.
 

A.S._id

Inactive Recognized Developer
Sep 21, 2010
1,211
2,574
153
I still don't get the purpose of these tools. I've been running Gentoo Linux as my primary OS for a dozen years, all the tools I need to compile kernels, create boot images, ramdisks, initrds, extract and manipulate from already created images, are already installed on my system by default. Why would I need these too? Are these supposed to be time-savers? Shortcuts? I still don't understand.
Well, how I can see, you're HTC user, and maybe this utilities isn't you needs, because htc don't use sparse images, and different header block size in self rom. But samsung, sony, asus and different brands using it...
 
Last edited:

rogerscrack

Senior Member
May 8, 2011
121
12
0
39
Buenos Aires
why is this error?

Building mkbootimg...
core/mkbootimg/mkbootimg.c: In function 'main':
core/mkbootimg/mkbootimg.c:245:9: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [mkbootimg] Error 1
 
  • Like
Reactions: Doctur