Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Android sparse image (simg) tools #8

Closed
wants to merge 1 commit into from
Closed

Build Android sparse image (simg) tools #8

wants to merge 1 commit into from

Conversation

stephan-gh
Copy link
Contributor

@stephan-gh stephan-gh commented Aug 27, 2019

libsparse is already built for fastboot, so building the simg tools only requires a few build rules to link the executables.

Adds the following tools:

  • simgtoimg
  • img2simg
  • append2simg

These tools are used to convert partition images to the sparse format (saving some space), and back.

@nmeum
Copy link
Owner

nmeum commented Sep 5, 2019

Hey, thanks for the PR. I am somewhat busy at the moment but currently working on an upgrade to platform-tools-29.0.2 which isn't entirely finished yet and currently requires gcc >= 9.X. I would like to finish this upgrade first before merging this PR.

@stephan-gh
Copy link
Contributor Author

@nmeum That's fine. Take all the time you need! :)

@nmeum
Copy link
Owner

nmeum commented Sep 17, 2019

I merged the upgrade to platform-tools-29.0.2 into the master branch yesterday. Still want to make some tests before doing a new release. If you want to, you can rebase your branch against master now and check that everything still works as expected.

Let me know if you run into any issues.

@stephan-gh
Copy link
Contributor Author

@nmeum Done. (FYI, there seems to be platform-tools-29.0.3 now...)

libsparse is already built for fastboot, so building the simg
tools only requires a few build rules to link the executables.

Adds the following tools:
  - simgtoimg
  - img2simg
  - append2simg
@stephan-gh
Copy link
Contributor Author

stephan-gh commented Sep 18, 2019

Rebased on 29.0.3, seems like it is working fine without conflicts/changes this time.
Btw, did you forget to update ANDROID_VERSION?

set(ANDROID_VERSION 29.0.2)

@nmeum
Copy link
Owner

nmeum commented Sep 18, 2019

Btw, did you forget to update ANDROID_VERSION?

Yep, indeed. Thanks for rebasing and pointing that out. Will fix that, do some more tests, merge your PR and then release a new tarball.

Speaking of testing: Is there any easy way to test the utilities added by your PR?

@stephan-gh
Copy link
Contributor Author

stephan-gh commented Sep 18, 2019

Speaking of testing: Is there any easy way to test the utilities added by your PR?

Yes. The easiest way is to obtain a raw image file of a partition (e.g. using dd or by creating one with a loop device). Then convert it to sparse format and back, e.g.

# dd if=/dev/sda1 of=test.img
$ img2simg test.img test-sparse.img
$ simg2img test-sparse.img test2.img

test-sparse.img should be slightly smaller than test.img (for example it combines space that is filled with zeros), test2.img should be identical to test.img again.

A real usage example would be downloading a factory image for an Android device (e.g. for one of the Google devices). The system image (system.img) is usually in sparse format, so simg2img allows you to convert them to a mountable ext4 image.

Not sure about append2simg, I have never used it to be honest.

@nmeum
Copy link
Owner

nmeum commented Sep 21, 2019

Merged in db84fde. Thanks for the contribution and sorry that it took a while.

@nmeum nmeum closed this Sep 21, 2019
z3ntu pushed a commit to z3ntu/pmbootstrap that referenced this pull request Oct 13, 2019
The sparse image tools (simg2img, img2simg, append2simg) are now
part of Alpine's android-tools where they are continously updated.
(See nmeum/android-tools#8)

Therefore, "libsparse" now conflicts with "android-tools", which
causes the fastboot flasher to fail if "libsparse" is already
installed.

Install "android-tools" instead of "libsparse" before generating
a sparse image to avoid this problem.
LibrePhone pushed a commit to LibrePhone/pmaports that referenced this pull request Jan 6, 2020
The sparse image tools (img2simg, simg2img, append2simg) are now
part of Alpine's android-tools package where they are continously
updated. (See nmeum/android-tools#8)

Remove "libsparse" as depends from all packages because it is either:

 - installed automatically by pmbootstrap when needed for
   deviceinfo_flash_sparse="true"
    (device-chuwi-hi10plus, device-htc-flounder, device-lg-bullhead,
     device-semc-anzu, device-xiaomi-kenzo)

 - seemingly unused(?)
    (device-asus-z00t, linux-motorola-falcon, linux-motorola-peregrine)

[ci:skip-build]: already built successfully in CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants