Giter Club home page Giter Club logo

erofs's Introduction

OPlus image utilities

Discontinued for now due to various reasons, do NOT use!

Prerequisites

  • Linux running kernel 5.4 or up (check with uname -r)

Image rebuilding

  • Used to rebuild read-only erofs images into EXT4 mountable images. Usage: sudo ./erofs.sh <path to original image> <image partition name> For example, if I'm trying to make system_ext image ext4, I'll use the following command: sudo ./erofs.sh system_ext.img system_ext

  • IF you're running into issues like "not enough space to setup filesystem", specify filesystem size by adding the size (I recommend 64MB) after $2.

Product image rebuilding

  • OPlus (previously oppo) has been being a jerk and adding a butt ton of useless so-called "optimizations" (porting killers). This is one of them.
  • In Android 12 (OxygenOS 12 at least), OPlus has added OPLUS_FEATURE_OVERLAY_MOUNT to "mount product partition from existing my_* partitions" (to save image space? idk). With this going on, the product image shipped with OTAs is a dummy image that could not be mounted.
  • Non-OPlus devices does NOT have OPLUS_FEATURE_OVERLAY_MOUNT implementation (and it is highly unrecommended to use it, as someone has bricked their devices before after implementing it). However, product image should NOT be empty (there is a system symlink pointing to /product). Therefore, this script is written to merge the my_* partitions into a single product image to replicate the /product behavior on OPlus devices.

Usage: sudo ./product-merge.sh

OPlus custom partition merging

  • We will still have to merge my_* partitions after building the product image (as not all files exist in product image). The script will automatically merge the my_* partitions into system.

Usage: sudo ./oplus-merge.sh

Notes

  • All images (especially system) must be the dir that the script is ran.

To-Do

  • Remove dependency of system file_contexts to build all images (we currently cat system filecontexts to the working file contexts to make the image resign properly)
  • Run checks on mounting image (It is reported by Velosh that sometimes mounting erofs images without -o loop -t erofs does not work. However it works on my PC, that's why I introduced this commit. Will work on checks for it later.)

Credits and Thanks

Amack

Erfan Abdi

Velosh

Piraterex

Xiaoxindada

And all those I forgot to mention.

erofs's People

Contributors

erfanoabdi avatar piraterex avatar velosh avatar wileylau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

erofs's Issues

mount failed

root@LMINT:/home/me/erofs-master# ./erofs.sh my_manifest.img my_manifest
[INFO] Mounting my_manifest...
mount: /home/me/erofs-master/my_manifest: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
[INFO] Rebuilding my_manifest as ext4 image...
mount: /home/me/erofs-master/system: special device ./system.img does not exist.
cat: /home/me/erofs-master/system/system/etc/selinux/plat_file_contexts: No such file or directory
umount: /home/me/erofs-master/system: not mounted.
/usr/bin/env: ‘python2’: No such file or directory
umount: /home/me/erofs-master/my_manifest: not mounted.
[INFO] Done

Image rebuilding (erofs -> ext4) doesn't work for small partitions

I'm using latest verion of this tool and have an issue.
Small my_partitions like my_carrier and my_manifest failed to repack on mke2fs. All other bigger partitions rebuilding well.
Partitions size <1 MB (see the attached files below)
log:
sudo ./erofs.sh my_carrier.00011011.img my_carrier
[INFO] Mounting my_carrier...
[INFO] Rebuilding my_carrier as ext4 image...
ERROR:root:mke2fs 1.45.4 (23-Sep-2019)
my_carrier-ext4.img: Not enough space to build proposed filesystem while setting up superblock

[INFO] Done

my_partitions.zip

Liscense?

Not a code issue, but could you please specify a license for this project? (ie GPL, apache, MIT, etc)

We can't use this script unless it is licensed appropriately.

Preserving file context.

Is there any way to preserve file context of origin EROFS image or somehow parse it and apply to a new image instead of using vendor_file_context and plat_file_context?

While using product-merge.sh

siddhant@siddhant-HP-Pavilion-x360-Convertible-14-dh1xxx:~/Desktop/oplus-utils$ sudo ./product-merge.sh
[sudo] password for siddhant:
[INFO] Cleaning up existing build residue
[INFO] Merging my_product into product.img
[INFO] Merging my_engineering into product.img
[INFO] Merging my_company into product.img
[INFO] Merging my_carrier into product.img
[INFO] Merging my_region into product.img
[INFO] Merging my_heytap into product.img
[INFO] Merging my_stock into product.img
[INFO] Merging my_preload into product.img
[INFO] Merging my_bigball into product.img
[INFO] Merging my_manifest into product.img
[INFO] Cleaning product image
[INFO] Grabbing file contexts
[INFO] Setting image size
[INFO] Rebuilding Product image
Traceback (most recent call last):
File "/home/siddhant/Desktop/oplus-utils/tools/mkuserimg_mke2fs.py", line 214, in
main(sys.argv[1:])
File "/home/siddhant/Desktop/oplus-utils/tools/mkuserimg_mke2fs.py", line 184, in main
mke2fs_cmd, e2fsdroid_cmd = ConstructE2fsCommands(args)
File "/home/siddhant/Desktop/oplus-utils/tools/mkuserimg_mke2fs.py", line 165, in ConstructE2fsCommands
blocks = int(args.fs_size) / BLOCKSIZE
ValueError: invalid literal for int() with base 10: '3.04907e+09'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.