xz icon indicating copy to clipboard operation
xz copied to clipboard

How do you decompress tar.xz files?

Open fire opened this issue 10 years ago • 3 comments

Trying to discover how to extract tar.xz files. Is this possible?

fire avatar Jan 31 '15 08:01 fire

First, decompress the *.tar.xz to a *.tar, either to memory or a temporary file. Then use a tar decompressor (i.e., import "archive/tar") on that.

A working xz decompressor is needed first; and this seems to be alpha software currently.

skull-squadron avatar Feb 05 '15 12:02 skull-squadron

Many thanks for the interest in my code. The code is not even alpha right now. Currently the software contains working code for the LZMA method. This is the core compression method used by xz file format. But actually xz is using LZMA2 that contains chunks of LZMA compressed data. So I'm working currently on LZMA2.

When the code will be complete, I will provide examples on how to create and decompress tar files in Go.

ulikunitz avatar Feb 26 '15 20:02 ulikunitz

Easy: https://github.com/mholt/archiver/blob/cdc68dd1f170b8dfc1a0d2231b5bb0967ed67006/tarxz.go#L53-L66

(Opening the .tar file is the "hard" part, but the xz decompression just gets layered on underneath it as you can see.)

mholt avatar Nov 30 '16 23:11 mholt