cfig / Android_boot_image_editor

Parsing and re-packing Android boot.img/vbmeta.img/payload.bin, supporting Android 15
Apache License 2.0
1.04k stars 232 forks source link

can u support oem.img unpack/reapck #92

Closed Liberations closed 9 months ago

Liberations commented 2 years ago

https://share.weiyun.com/xknPvylq

oem.img

it is transfer from oem.new.dat.br by rom tools.

oem_PD2049_CN-ZH_FULL_SC_CT-BMW.zip

it is office update zip

oem_unpack.zip

it is adb pull from system root /oem

wen@ubuntu:~/dev/bootdev$ ./gradlew unpack

> Task :unpack FAILED
10:43:38.054 [main] WARN  cfig.packable.PackableLauncher - [system.img] will be handled by [SparseImgParser]
10:43:38.115 [main] WARN  cfig.packable.PackableLauncher - 'unpack' sequence initialized
10:43:38.117 [main] INFO  cfig.packable.IPackable - deleting build/unzip_boot/ ...
10:43:38.120 [main] INFO  Helper - deleting uiderrors
10:43:38.122 [main] INFO  cfig.utils.SparseImgParser - parsing Android sparse image system.img ...
10:43:38.126 [main] INFO  Helper - CMD: [./aosp/libsparse/simg2img/build/install/main/release/linux/simg2img, system.img, system.img.unsparse], workDir: null
Invalid sparse file format at header magic
Failed to read sparse file
10:43:38.137 [main] ERROR Helper - org.apache.commons.exec.ExecuteException: Process exited with an error: 255 (Exit value: 255): can not exec command
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at kotlin.reflect.jvm.internal.calls.CallerImpl$Method.callMethod(CallerImpl.kt:97)
        at kotlin.reflect.jvm.internal.calls.CallerImpl$Method$Instance.call(CallerImpl.kt:113)
        at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:108)
        at cfig.packable.PackableLauncherKt.main(PackableLauncher.kt:108)
Caused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 255 (Exit value: 255)
        at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:153)
        at cfig.helper.Helper$Companion.check_call(Helper.kt:181)
        at cfig.helper.Helper$Companion.check_call$default(Helper.kt:172)
        at cfig.utils.SparseImgParser.simg2img(SparseImgParser.kt:70)
        at cfig.utils.SparseImgParser.unpack(SparseImgParser.kt:44)
        ... 8 more

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':unpack'.
> Process 'command '/usr/lib/jvm/java-11-openjdk-amd64/bin/java'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 14s
22 actionable tasks: 13 executed, 9 up-to-date
cfig commented 2 years ago

unpack/view: oem.img may be sparse ext4 image, or raw ext4 image. If it's sparse image, we can convert it to raw ext4 image, and then view the contents by mounting the contents to some directory. If it's raw ext4 image, we can directly mount it without using this tool.

pack: While creating the (sparse) ext4 image should include external ext4 mkfs/tunefs tools. Let me have a think ...

cfig commented 2 years ago

view oem.img contents:

  1. (optional) simg2img
  2. mount
    $ udisksctl loop-setup --file oem.img
    Mapped file oem.img as /dev/loop0.
    $ udisksctl mount -b /dev/loop0
    Mounted /dev/loop0 at /media/guest/oem

    But this ext4 image has exactly the size of its contents, no spare space for extra new data poured in.

  3. umount
    $ udisksctl unmount -b /dev/loop0
    Unmounted /dev/loop0.
    $ udisksctl loop-delete -b /dev/loop0
cfig commented 2 years ago

From latest AOSP, we see Google may use EROFS instead of ext4 from Android 13. if you're really interested in unpacking/packing oem.img, please refer to AOSP code, there are tools to make the images. Thanks.

cfig commented 9 months ago

Latest code supports ext4 now

VenomousSteam81 commented 2 months ago

Really late here but @cfig you can run resize2fs -l (size in G,M,K,etc) (img file).img to resize the image!