Simple utility to tinker with OPlus images

Overview

OPlus image utilities

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 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

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.

Comments
  • While using product-merge.sh

    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'

    opened by ApexLegend007 5
  • What about of erofsUnpackKt?

    What about of erofsUnpackKt?

    In my opinion, as much as the process takes a little longer, the EROFS image can be converted to EXT4 properly and correctly.

    Here the erofsUnpackKt binary: https://github.com/xiaoxindada/SGSI-build-tool/blob/12/tool_bin/erofsUnpackKt

    opened by Velosh 2
  • mount failed

    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

    opened by vpolinov 2
  • Fix invalid literal for int() with base 10.

    Fix invalid literal for int() with base 10.

    This was made to prevent errors when the calculated image size is big or still has a floating point. EDIT: Source of the fix: https://stackoverflow.com/questions/1841565/valueerror-invalid-literal-for-int-with-base-10

    opened by AhmadMoemen 0
  • Image rebuilding (erofs -> ext4) doesn't work for small partitions

    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

    opened by Ctapchuk 3
Owner
Wiley Lau
Tears are gonna fall, rolling in the deep.
Wiley Lau
Command line utility for converting images to seamless tiles

img2texture Command line utility for converting images to seamless tiles. The resulting tiles can be used as textures in games, compositing and 3D mod

Artёm IG 24 Dec 26, 2022
missing-pixel-filler is a python package that, given images that may contain missing data regions (like satellite imagery with swath gaps), returns these images with the regions filled.

Missing Pixel Filler This is the official code repository for the Missing Pixel Filler by SpaceML. missing-pixel-filler is a python package that, give

SpaceML 11 Jul 19, 2022
📷 Python package and CLI utility to create photo mosaics.

?? Python package and CLI utility to create photo mosaics.

Loic Coyle 7 Oct 29, 2022
A simple programming language for manipulating images.

f-stop A simple programming language for manipulating images. Examples OPEN "image.png" AS image RESIZE image (300, 300) SAVE image "out.jpg" CLOSE im

F-Stop 6 Oct 27, 2022
A simple Streamlit Component to compare images in Streamlit apps. It integrates Knightlab's JuxtaposeJS

streamlit-image-juxtapose A simple Streamlit Component to compare images in Streamlit apps using Knightlab's JuxtaposeJS. The images are saved to the

Robin 30 Dec 31, 2022
Simple Python / ImageMagick script to package images into WAD3s for use as GoldSrc textures.

WADs Out For [The] Ladies Simple Python / ImageMagick script to package images into WAD3s for use as GoldSrc textures. Development mostly focused on L

null 5 Apr 9, 2022
A simple image-level annotation tool supporting multi-channel images for napari.

napari-labelimg4classification A simple image-level annotation tool supporting multi-channel images for napari. This napari plugin was generated with

null 4 May 16, 2022
A simple plugin to view APR images in napari

napari-apr-viewer A simple plugin to view APR images in napari This napari plugin was generated with Cookiecutter using @napari's cookiecutter-napari-

null 5 Jan 24, 2022
Rembg is a tool to remove images background.

Rembg is a tool to remove images background.

Daniel Gatis 7.8k Jan 5, 2023
A large-scale dataset of both raw MRI measurements and clinical MRI images

fastMRI is a collaborative research project from Facebook AI Research (FAIR) and NYU Langone Health to investigate the use of AI to make MRI scans faster. NYU Langone Health has released fully anonymized knee and brain MRI datasets that can be downloaded from the fastMRI dataset page. Publications associated with the fastMRI project can be found at the end of this README.

Facebook Research 907 Jan 4, 2023
Fixes 500+ mislabeled MURA images

In this repository, new csv files are provided that fixes 500+ mislabeled MURA x-rays for all categories. The mislabeled x-rays mainly had hardware in them. This project only fixes the false negatives for now.

Pieter Zeilstra 4 May 18, 2022
HtmlWebShot - A python3 package which Can Create Images From url, Html-CSS, Svg and from any readable file and texts with many setup features.

A python3 package which Can Create Images From url, Html-CSS, Svg and from any readable file and texts with many setup features

Danish 24 Dec 14, 2022
pix2tex: Using a ViT to convert images of equations into LaTeX code.

The goal of this project is to create a learning based system that takes an image of a math formula and returns corresponding LaTeX code.

Lukas Blecher 2.6k Dec 30, 2022
A scalable implementation of WobblyStitcher for 3D microscopy images

WobblyStitcher Introduction A scalable implementation of WobblyStitcher Dependencies $ python -m pip install numpy scikit-image Visualization ImageJ

CSE Lab, ETH Zurich 7 Jul 25, 2022
Glyphtracer is an app for converting images of letters to a font

Glyphtracer takes an image that contains pictures of several letters. It recognizes all them and lets the user tag each letter to a Unicode code point. It then converts the images to vector form and writes them to a FontForge's data format. The font can then be finalized with FontForge.

Jussi Pakkanen 38 Dec 24, 2022
Django helper application to easily and non-destructively crop arbitrarily large images in admin and frontend.

django-image-cropping django-image-cropping is an app for cropping uploaded images via Django's admin backend using Jcrop. Screenshot: django-image-cr

Jonas und der Wolf GmbH 546 Jan 3, 2023
A drop-in replacement for django's ImageField that provides a flexible, intuitive and easily-extensible interface for quickly creating new images from the one assigned to the field.

django-versatileimagefield A drop-in replacement for django's ImageField that provides a flexible, intuitive and easily-extensible interface for creat

Jonathan Ellenberger 490 Dec 13, 2022
Fast batch image resizer and rotator for JPEG and PNG images.

imgp is a command line image resizer and rotator for JPEG and PNG images.

Terminator X 921 Dec 25, 2022
Python Image Morpher (PIM) is a program that can take two images and blend them to whatever extent or precision that you like

Python Image Morpher (PIM) is a program that can take two images and blend them to whatever extent or precision that you like! It is designed to emulate some of Python's OpenCV image processing from scratch without reference.

David Dowd 108 Dec 19, 2022