xpirt / img2sdat

Convert sparse EXT4 image to sparse Android data image
MIT License
153 stars 98 forks source link

No python 3.x support #10

Closed TiceRex closed 6 years ago

TiceRex commented 6 years ago

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]$
xpirt commented 6 years ago

Confirmed.

Will investigate as soon as I have some free time, in the meanwhile you can use Python 2.x.

xpirt commented 6 years ago

Fixed (22cd4cef454b473cc0886ab0ed423d9df3f03867).

ghost commented 6 years ago

I tried using 2.7 on my android phone.I used sdat2img.py and unpacked system.new.DAT but couldn't repack it using img2sdat.py.

On Jan 5, 2018 8:10 PM, "Andrei Conache" notifications@github.com wrote:

Fixed (22cd4ce https://github.com/xpirt/img2sdat/commit/22cd4cef454b473cc0886ab0ed423d9df3f03867 ).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/xpirt/img2sdat/issues/10#issuecomment-355566484, or mute the thread https://github.com/notifications/unsubscribe-auth/AZluWd2WP1hx_6G6JnHtol-kv3NB_8Rhks5tHjDJgaJpZM4QHo_E .