xpirt / img2sdat Goto Github PK
View Code? Open in Web Editor NEWConvert sparse EXT4 image to sparse Android data image
License: MIT License
Convert sparse EXT4 image to sparse Android data image
License: MIT License
I've tried to debug the flash errors & I've noticed that
img2sdat/common.py
is not making a compatible transfer.list for Android 10 & Android 11 devices. I always get some errors when I try to remove those lines...
erasing 93285 blocks
package_extract_file from system_ext.transfer.list to memory took 00s.BLKDISCARD ioctl failed: Invalid argument
failed to execute command [erase 8,88590,97792,98833,130561,131594,163328,164385,185006]
new data receiver is still available after executing all commands.
script aborted: E2001: Failed to flash system_ext_a partition.
E2001: Failed to flash system_ext_a partition.error: 2001
Updater process ended with ERROR: 1
I:Install took 0 second(s).
Error installing zip file '/sdcard/crDroidAndroid-11.0-20210614-mojito-v7.6.zip'
When I try to remove that line, I get another set of following errors:
writing 512 blocks of new data
writing 512 blocks of new data
writing 512 blocks of new data
writing 512 blocks of new data
writing 512 blocks of new data
writing 1 blocks of new data
writing 512 blocks of new data
writing 457 blocks of new data
lseek64 failed: Invalid argument
Failed to write 23442 bytes.
missing 1871872 bytes of new data
failed to execute command [new 4,188006,188462,188513,188514]
script aborted: E2001: Failed to flash system_ext_a partition.
E2001: Failed to flash system_ext_a partition.error: 2001
cause: 103
Updater process ended with ERROR: 1
I:Install took 7 second(s).
Error installing zip file '/sdcard/crDroidAndroid-11.0-20210611-mojito-v7.6.zip'
lseek64() couldn't able to parse the transfer.list
The other issue (#9) has been closed, so I open a new one to report other errors caused by the differences between python 2 and 3.
[grbadmin@granitgeo test]$ python3 sdat2img/img2sdat.py system.sdat ua 4
img2sdat binary - version: 1.5
Total of 215040 4096-byte output blocks in 4921 input chunks.
Finding transfers...
Generating digraph...
Finding vertex sequence...
Reversing backward edges...
0/0 dependencies (0.00%) were violated; 0 source blocks stashed.
Improving vertex order...
Traceback (most recent call last):
File "sdat2img/img2sdat.py", line 89, in
main(sys.argv)
File "sdat2img/img2sdat.py", line 83, in main
b.Compute(outdir)
File "/home/grbadmin/test/sdat2img/blockimgdiff.py", line 342, in Compute
self.AssertSequenceGood()
File "/home/grbadmin/test/sdat2img/blockimgdiff.py", line 814, in AssertSequenceGood
touched = array.array("B", "\0" * self.tgt.total_blocks)
TypeError: cannot use a str to initialize an array with typecode 'B'
[grbadmin@granitgeo test]$
The error above can be easily eliminated by changing blockimgdiff.py line 814 from
touched = array.array("B", "\0" * self.tgt.total_blocks)
to
touched = array.array("B", b"\0" * self.tgt.total_blocks)
But then another error happens, while creating the new dat file:
...
2097152 2097152 (100.00%) new __NONZERO-249 127489-128000
2097152 2097152 (100.00%) new __NONZERO-346 177153-177664
2097152 2097152 (100.00%) new __NONZERO-299 153089-153600
2097152 2097152 (100.00%) new __NONZERO-391 200193-200704
Traceback (most recent call last):
File "sdat2img/img2sdat.py", line 89, in
main(sys.argv)
File "sdat2img/img2sdat.py", line 83, in main
b.Compute(outdir)
File "/home/grbadmin/test/sdat2img/blockimgdiff.py", line 345, in Compute
self.WriteTransfers(prefix)
File "/home/grbadmin/test/sdat2img/blockimgdiff.py", line 417, in WriteTransfers
src_str.insert(1, unstashed_src_ranges.to_string_raw())
File "/home/grbadmin/test/sdat2img/rangelib.py", line 139, in to_string_raw
assert self.data
AssertionError
[grbadmin@granitgeo test]$
Error:
img2sdat system.new.dat2 111
Total of 215040 4096-byte output blocks in 428 input chunks.
Traceback (most recent call last):
File "/usr/share/img2sdat/img2sdat.py", line 33, in <module>
main(sysimg, outdir)
File "/usr/share/img2sdat/img2sdat.py", line 13, in main
bif.Compute('system', outdir)
TypeError: Compute() takes exactly 2 arguments (3 given)
Fix is to change:
bif.Compute('system', outdir)
to:
bif.Compute(outdir)
While converting 5.1 image it gives ValueError: Magic should be 0xED26FF3A but is 0x00000000
The new tool generates errors for older versions.
For example, Android 5.1 had to be level 2 instead has been compiled as a level 4 as attached files.
new system.transfer.list-->http://pastebin.com/g8hRTvn6
original system.transfer.list-->http://pastebin.com/1D7Ce6G4
ValueError: Magic should be 0xED26FF3A but is 0x00000000
Ubuntu 16.04 LTS, all software installed.
alex_mercer@MacBookPro:~/UNPACK/AKITCHEN$
./img2sdat.py system_sparse.img
Traceback (most recent call last):
File "./img2sdat.py", line 10, in <module>
import common, blockimgdiff, sparse_img
ImportError: No module named common
alex_mercer@MacBookPro:~/UNPACK/AKITCHEN$
there are two kinds of img file , for raw image file and sparse image file。
what kind of image file is the input file?
File "/home/grbadmin/test/sdat_utils/common.py", line 112
print "running: ", " ".join(args)
^
SyntaxError: invalid syntax
Please help. What to do (running on python 3.4.5)?
A small mistake with the img2sdat
It works only on the image which is named "system", and doesn't work on vendor, product, etc...
I had to rename them to system, apply the script, get the dat files, then rename them again to their original names, which is a painfully slower task...
Can you update the script so that it works for any file name?
Also you might consider updating other scripts that have the same code.
The tool does not support conversion to vendor.new.dat, if I run the command:
python img2dat.py vendor.img folderoutput 4
I always create system.new.dat, system.transfer.list and system.patch.dat, can you fix this problem kindly?
./img2sdat.py system.img
img2sdat binary - version: 1.6
1. Android Lollipop 5.0
2. Android Lollipop 5.1
3. Android Marshmallow 6.0
4. Android Nougat 7.0/7.1/8.0
Choose system version: 4
Traceback (most recent call last):
File "./img2sdat.py", line 89, in
main(sys.argv)
File "./img2sdat.py", line 79, in main
image = sparse_img.SparseImage(INPUT_IMAGE, tempfile.mkstemp()[1], '0')
File "/home/123/Desktop/unpack/pack/sparse_img.py", line 52, in init
raise ValueError("Magic should be 0xED26FF3A but is 0x%08X" % (magic,))
ValueError: Magic should be 0xED26FF3A but is 0x00000000
But this system.img is not corrupted(can be mounted) and it was generated by sdat2img.py which is your work. It was just extracted from lineage-14.1's system.new.dat and has nothing special things like encryption or something.
Why this 'magic value' thing happens?
Y U NU SUPPORT 5.1?
if len(sys.argv) < 3:
outdir = os.path.realpath(os.path.dirname(sys.argv[1])) + os.sep + os.path.basename(sys.argv[1]).split('.')[0]
#outdir = './system'
else:
# outdir = sys.argv[2] + '/system'
outdir = sys.argv[2] + os.sep + os.path.basename(sys.argv[1]).split('.')[0]
if not os.path.exists(sys.argv[2]):
os.makedirs(sys.argv[2])
Now some ROMs have become ext2 format img files, hope to add support
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.