matteomattei / PySquashfsImage

Python library to read Squashfs image files.
GNU General Public License v3.0
50 stars 20 forks source link

Do not support xz compressor. #1

Closed charlesw1234 closed 8 years ago

charlesw1234 commented 10 years ago

I have try to include the decompressor by using python-lzma, but it seems not worked. And then I add a new python function decompress0 by call of lzma_stream_buffer_decode as the xz_wrapper.c in squashfs-tools. But the call of decompress still failed with format error (lzma error code = 7). So I think this may be caused by unsupported new format of squashfs. Can you update PySquashfsImage to support the new squashfs with more stronger compression? The squashfs which I'm using can be provided, and my modification about PySquashfsImage, lzma.c in python-lzma can be provided too.

matteomattei commented 10 years ago

I am sorry but in this moment I don't have enough time to spend on PySquashfsImage development. However if you (or anyone else) will contribute I will be happy to include the change to the main stream of the project. I would suggest to share your code and post a link where everyone can download it.

BotoX commented 8 years ago

Hi, the problem occurs because the fragments are being read incorrectly. Change in def read_fragment_table(self,myfile):

        ofs = 0
        while ofs<len(table) :
            entry = _Squashfs_fragment_entry()
            ofs = entry.fill(table,ofs)
            entry.fragment = self.read_data_block(myfile,entry.start_block,entry.size)
            self.fragment_table.append(entry)

Also added reading and parsing the compression options block (right after superblock). Can make a pull request with my changes (not done yet) if wanted.

After this fix LZMA decompressor can be used just like so:

def uncompress(self, src):
        import lzma
        return lzma.decompress(src)
matteomattei commented 8 years ago

Yes! please make a pull request and I will merge your patches with the lzma support ;-)

probonopd commented 8 years ago

@BotoX would be great if you could send a pull request

probonopd commented 8 years ago

Thanks @matteomattei

matteomattei commented 8 years ago

you are welcome! ;-)