[tool] ANDROID-ROM-REPACK-TOOLS

Search This thread

Nightmare_MYS

Member
Oct 29, 2018
20
0
A very important bug

When I used make_ext4fs to successfully make the new system.img,and then upgrade it,when I reboot my phone,I found that the uid and gid permissions of all the files under the system were all changed to root,and have some bug in my phone,I use oero,8.1
 

celhack

Member
Dec 26, 2006
25
0
I have a Nougat Rom, I mount and replaced only one app, them I repack using file_context from boot. and them convert with img2simg. I cant flash this img but I can flash Raw img and phone is in a loop. I have tried without making any change on the system

---------- Post added at 09:55 PM ---------- Previous post was at 09:47 PM ----------

So I have a question system.transfer.list == to system.map???
 
Last edited:

rkhat

Senior Member
Apr 29, 2017
50
69
When I used make_ext4fs to successfully make the new system.img,and then upgrade it,when I reboot my phone,I found that the uid and gid permissions of all the files under the system were all changed to root,and have some bug in my phone,I use oero,8.1

Can you try make_ext4fs_def instead of make_ext4fs in this version. Let me know if this fixes your issue so I can make it official release? Thanks.

I have a Nougat Rom, I mount and replaced only one app, them I repack using file_context from boot. and them convert with img2simg. I cant flash this img but I can flash Raw img and phone is in a loop. I have tried without making any change on the system


---------- Post added at 09:55 PM ---------- Previous post was at 09:47 PM ----------

So I have a question system.transfer.list == to system.map???

system.transfer.list is for lineageOS. You won't find it in other ROMS that are not based on LineageOS. You have to check how the ROM you got was packaged.
 
Last edited:
  • Like
Reactions: celhack

celhack

Member
Dec 26, 2006
25
0
Thanks for your reply. How can I check or determine packer of my rom?
My image is in sparse. When I use simg2img it got converted ro raw and until here I can still flash the image and my phone boots.

If I mount the raw image and repack, even if I don’t make any change my phone doesn’t boot.

Could you take a look in the image Please? Maybe you can find the way to support this type. Thanks for your hard work.
 

rkhat

Senior Member
Apr 29, 2017
50
69
Thanks for your reply. How can I check or determine packer of my rom?
My image is in sparse. When I use simg2img it got converted ro raw and until here I can still flash the image and my phone boots.

If I mount the raw image and repack, even if I don’t make any change my phone doesn’t boot.

Could you take a look in the image Please? Maybe you can find the way to support this type. Thanks for your hard work.

I think you forgot to post the image.

What exact command(s) did you use to repack the image? Also what is the version of the ROM?

Question: Can we compile these binaries into windows PE ?

What do you mean by PE? Preinstalled environment? I have never used that. Unfortunately, there is currently no Windows support.
 

KP@2016

Senior Member
Apr 21, 2016
288
244
Mumbai
kpstvhub.com
I think you forgot to post the image.

What exact command(s) did you use to repack the image? Also what is the version of the ROM?



What do you mean by PE? Preinstalled environment? I have never used that. Unfortunately, there is currently no Windows support.
Windows PE is a portable executable file. Ok I got it, so it means that we do definitely need cygwin in order to run this on Windows
 

N6500

Member
Mar 15, 2016
9
0
Smila
Preparing Ubunru 18.10 for SAMSUNG Firmware

Note:I am sorry I can't post this in the Android development thread because my number of posts is low. Hopefully some mod can move it there.

Introduction
Since this project (Android_IMG_REPACK_TOOLS) is dead for 2 years now (last supported version is Marshmallow). I decided to do a new rom repacker that supports up to Android Oreo.

Supported OS
Linux

Supported Android Versions
android-5 (Lollipop)
android-wear-5
android-6 (Marshmallow)
android-7 (Nougat)
android-8 (Oreo)
android-9 (Pie) beta

Binaries included
append2simg
img2simg
simg2img
simg2simg
make_ext4fs (Google removed it for android 9. I will add a replacement in the future)
mkbootfs
mkbootimg
unpackbootimg (For android-wear-5, you can use the one in android-5)
sefcontext_compile
sefcontext_decompile

Usage
Check this post out for some use case. You'll need img2simg and make_ext4fs from my post.

sefcontext_compile and sefcontext_decompile:
ROMS since Android 7 (Nougat) come with a binary file_contexts but you need a text based file_contexts when you need to repackage the ROM. You'll need it for make_ext4fs. sefcontext_decompile converts the binary file_contexts into text version.


Code:
# file_contexts (human readable text file) -> file_contexts.bin (PCRE formatted binary file)
sefcontext_compile [-o <output_file>]  <text_file>

# file_contexts.bin (PCRE formatted binary file) -> file_contexts (human readable text file)
sefcontext_decompile [-o <output_file>] <binary_file>


Source code
Repository
android-5
android-wear-5
android-6
android-7
android-8
android-9

Download links for Linux
Download page
android-5
android-wear-5
android-6
android-7
android-8
android-9


Change Log:
v3:
  • Added android-5 and android-wear-5 support
  • Added android-9 beta support
v2:
  • Added sefcontext_compile and sefcontext_decompile: converts between file_contexts.bin and file_contexts
  • Static linking to libc++: No need to install 3rd party libraries to use the binaries.
v1:
  • Added append2simg img2simg simg2img simg2simg make_ext4fs mkbootfs mkbootimg unpackbootimg

credits:
@A.S._id
android.googlesource
LineageOS

Created: 2018-03-16
Updated: 2018-08-18

Good day to you
Installed Ubuntu 18.10
Now tell me please HOW TO PREPARE IT FOR SUSPECTING AND ASSEMBLING sysrem.img.ext4.
And even better describe the full instructions how to use the ANDROID-ROM-REPACK-TOOLS for firmware SAMSUNG for only the pre-installed Ubuntu 18.10
 

rkhat

Senior Member
Apr 29, 2017
50
69
Good day to you
Installed Ubuntu 18.10
Now tell me please HOW TO PREPARE IT FOR SUSPECTING AND ASSEMBLING sysrem.img.ext4.
And even better describe the full instructions how to use the ANDROID-ROM-REPACK-TOOLS for firmware SAMSUNG for only the pre-installed Ubuntu 18.10

This tool is made using LineageOS and AOSP source code. It works for LineageOS or AOSP ROMs. It might or might not work with other ROMS. Also I haven't dealt with Samsung ROMs so use the tool at your own risk. Samsung doesn't like third party messing up with their closed source ROMs. They probably make it harder to tamper with them.

I would recommend to rename system.img.ext4 to system.img.

Then follow this guide guide but in step 1 run this instead:

Code:
./simg2img system.img my_new_system.img

and use my_new_system.img for step 2. Then do steps 2 and 3. The output of step 3 is the new system.img you will need (basically skip step 4). Then rename this new system.img to system.img.ext4.

Note: you'll need file_contexts, it is usually in boot.img.
 
  • Like
Reactions: N6500

rkhat

Senior Member
Apr 29, 2017
50
69
what is simg2simg?
and Thanks all of you for the hard work.

simg2simg is for splitting a large sparse image into multiple smaller sparse images. 3rd parameter is to set the max size of the smaller images.

Where to get the updated sgs4ext4fs file for SAMSUNG system.img.ext4 firmware?

I don't work on Samsung ROMs and the developer for this binary sgs4ext4fs hasn't updated his github repository in 6 years. I don't know the specifications for newer Samsung ext4 images to code the binary. Sorry for not being able to help you.
 

dasToshy

Member
Jan 1, 2017
24
1
windows version / port

Sorry. my english is bad.

till now, i use
https://xdaforums.com/showthread.php?t=2600364
old repack tools. i only have androit 4-6.

its nice to see, that you build new versions.

but this is for linux. can you or other member port it to an windows verison?
so i can use "exe"-files on windows!?

thanks and greetings
Toshy
 

Magendanz

Senior Member
Mar 25, 2008
987
1,071
Issaquah, WA
www.Vote4Chad.com
What exactly does make_ext4fs_def do differently than make_ext4fs? I can't seem to find it documented anywhere.

Also, is there anything new we need to do when building sparse images in OREO?

I've been using the same script with make_ext4fs and a decompiled file_contexts.bin from the boot image on Nougat system images with no problems, but running it on an OREO firmware causes a hang during boot. The same images flash and run fine in raw format, but there's something about the conversion to sparse that's causing problems. I was guessing it was a file contexts issue, but I've got one from the latest OREO OTA update. I've noticed that OREO has split the file contexts into separate files (plat_file_contexts, non-plat_file_contexts, etc.). Do I need to merge these into one file for make_ext4fs?

Update: Well, it seems on Project Treble firmware that you do need to merge the two file_contexts (plat_file_contexts & non-plat_file_context) for make_ext4fs. But more importantly, you need to set the label (-L) and android (-a) arguments to "vendor" or "odm", as appropriate. My script had them all as "system". (Still no idea what make_ext4fs_def does differently, though.)
 
Last edited:

rkhat

Senior Member
Apr 29, 2017
50
69
What exactly does make_ext4fs_def do differently than make_ext4fs? I can't seem to find it documented anywhere.

Also, is there anything new we need to do when building sparse images in OREO?

I've been using the same script with make_ext4fs and a decompiled file_contexts.bin from the boot image on Nougat system images with no problems, but running it on an OREO firmware causes a hang during boot. The same images flash and run fine in raw format, but there's something about the conversion to sparse that's causing problems. I was guessing it was a file contexts issue, but I've got one from the latest OREO OTA update. I've noticed that OREO has split the file contexts into separate files (plat_file_contexts, non-plat_file_contexts, etc.). Do I need to merge these into one file for make_ext4fs?

Update: Well, it seems on Project Treble firmware that you do need to merge the two file_contexts (plat_file_contexts & non-plat_file_context) for make_ext4fs. But more importantly, you need to set the label (-L) and android (-a) arguments to "vendor" or "odm", as appropriate. My script had them all as "system". (Still no idea what make_ext4fs_def does differently, though.)


make_ext4fs_def is only working in this version (android 8 version 4). It prevents uid, guid, and permissions from resetting when you flash a ROM with new files.
 
  • Like
Reactions: Magendanz

Ricky Divjakovski

Recognized Developer / Inactive RC
Feb 4, 2013
5,287
7,685
28
Sydney
Thank you.
I tried differents ways but download functions aren't working. I changed cmake file to 3.6 compatibility because cygwin only is updated with cmake 3.6.
I found an updated repo for oreo, here. Now I'm going to test and tell you. Thanks.

Have you found a fix or workaround for this for cygwin?
i found a 3.10 cmake version from here but to compile you need to set USE_SYSTEM_ZLIB to OFF and USE_SYSTEM_CURL to OFF
I still cant get a successful compile of the binaries but im close
 

Top Liked Posts

  • There are no posts matching your filters.
  • 25
    Note:I am sorry I can't post this in the Android development thread because my number of posts is low. Hopefully some mod can move it there.

    Introduction
    Since this project (Android_IMG_REPACK_TOOLS) is dead for 2 years now (last supported version is Marshmallow). I decided to do a new rom repacker that supports up to Android Oreo.

    Supported OS
    Linux

    Supported Android Versions
    android-5 (Lollipop)
    android-wear-5
    android-6 (Marshmallow)
    android-7 (Nougat)
    android-8 (Oreo)
    android-9 (Pie) beta

    Binaries included
    append2simg
    img2simg
    simg2img
    simg2simg
    make_ext4fs (Google removed it for android 9. I will add a replacement in the future)
    mkbootfs
    mkbootimg
    unpackbootimg (For android-wear-5, you can use the one in android-5)
    sefcontext_compile
    sefcontext_decompile

    Usage
    Check this post out for some use case. You'll need img2simg and make_ext4fs from my post.

    sefcontext_compile and sefcontext_decompile:
    ROMS since Android 7 (Nougat) come with a binary file_contexts but you need a text based file_contexts when you need to repackage the ROM. You'll need it for make_ext4fs. sefcontext_decompile converts the binary file_contexts into text version.


    Code:
    # file_contexts (human readable text file) -> file_contexts.bin (PCRE formatted binary file)
    sefcontext_compile [-o <output_file>]  <text_file>
    
    # file_contexts.bin (PCRE formatted binary file) -> file_contexts (human readable text file)
    sefcontext_decompile [-o <output_file>] <binary_file>


    Source code
    Repository
    android-5
    android-wear-5
    android-6
    android-7
    android-8
    android-9

    Download links for Linux
    Download page
    android-5
    android-wear-5
    android-6
    android-7
    android-8
    android-9


    Change Log:
    v3:
    • Added android-5 and android-wear-5 support
    • Added android-9 beta support
    v2:
    • Added sefcontext_compile and sefcontext_decompile: converts between file_contexts.bin and file_contexts
    • Static linking to libc++: No need to install 3rd party libraries to use the binaries.
    v1:
    • Added append2simg img2simg simg2img simg2simg make_ext4fs mkbootfs mkbootimg unpackbootimg

    credits:
    @A.S._id
    android.googlesource
    LineageOS

    Created: 2018-03-16
    Updated: 2018-08-18
    4
    [Placeholder]
    3
    [Placeholder2]
    2
    New version available in Original Post.

    Change log
    v2:
    • Added sefcontext_compile and sefcontext_decompile: converts between file_contexts.bin and file_contexts
    • Static linking to libc++: No need to install 3rd party libraries to use the binaries.
    1
    hi bro i want extract oreo system.new.dat.br and also repack dat to .br in windows
    please help me bro
    and im unable to convert oreo file_context.bin to readable in windows

    please help thanks in advance

    Oreo ROMs come compressed by brotili. You can compile from source to get the executable or you can get the binaries directly from the release page (version 1.0). Use it to extract and repack .br.

    I added a converter from file_context.bin to a readable format in the new version I just uploaded.

    This project only supports Linux as of now. As for using it in Windows, you have 3 options,

    • Use a linux distro in VirtualBox (I currently use this option)
    • Install a linux bash shell in Windows 10
    • Build the project in Cygwin (hopefully someone can make a pull request and share it with the rest)