赞
踩
Xz 软件包包含文件压缩和解压缩工具,它能够处理 lzma 和新的 xz 压缩文件格式。使用 xz 压缩文本文件,可以得到比传统的 gzip 或 bzip2 更好的压缩比。
在使用 linux 下 tar 命令时,可能会出现以下问题
tar (child): xz: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
这种情况实际上是由于缺少 xz
导致 tar
执行出错
可以用包管理器安装 xz 解决
sudo apt install -y xz-utils
sudo yum install -y xz
下载
wget https://tukaani.org/xz/xz-5.2.6.tar.gz
解压
tar xvf xz-5.2.6.tar.gz
进入文件夹
cd xz-5.2.6
安装 GCC
Make
Ubuntu
sudo apt install gcc make
Centos
sudo yum install gcc make
执行配置,生成 Makefile
./configure
应出现类似如下的提示:
config.status: creating po/Makefile.in config.status: creating lib/Makefile config.status: creating src/Makefile config.status: creating src/liblzma/Makefile config.status: creating src/liblzma/api/Makefile config.status: creating src/xz/Makefile config.status: creating src/xzdec/Makefile config.status: creating src/lzmainfo/Makefile config.status: creating src/scripts/Makefile config.status: creating tests/Makefile config.status: creating debug/Makefile config.status: creating src/scripts/xzdiff config.status: creating src/scripts/xzgrep config.status: creating src/scripts/xzmore config.status: creating src/scripts/xzless config.status: creating config.h config.status: config.h is unchanged config.status: executing depfiles commands config.status: executing libtool commands config.status: executing po-directories commands config.status: creating po/POTFILES config.status: creating po/Makefile
执行 make
进行编译
make
应看到类似如下提示:
make[3]: Entering directory '/root/xz-5.2.6/src'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/root/xz-5.2.6/src'
make[2]: Leaving directory '/root/xz-5.2.6/src'
Making all in po
make[2]: Entering directory '/root/xz-5.2.6/po'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/root/xz-5.2.6/po'
Making all in tests
make[2]: Entering directory '/root/xz-5.2.6/tests'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/root/xz-5.2.6/tests'
make[2]: Entering directory '/root/xz-5.2.6'
make[2]: Leaving directory '/root/xz-5.2.6'
make[1]: Leaving directory '/root/xz-5.2.6'
安装
sudo make install
看到类似以下提示证明成功
make[2]: Entering directory '/root/xz-5.2.6'
make[2]: Nothing to be done for 'install-exec-am'.
/usr/bin/mkdir -p '/usr/local/share/doc/xz'
/usr/bin/install -c -m 644 AUTHORS COPYING COPYING.GPLv2 NEWS README THANKS TODO doc/faq.txt doc/history.txt doc/xz-file-format.txt doc/lzma-file-format.txt '/usr/local/share/doc/xz'
/usr/bin/mkdir -p '/usr/local/share/doc/xz/examples'
/usr/bin/install -c -m 644 doc/examples/00_README.txt doc/examples/01_compress_easy.c doc/examples/02_decompress.c doc/examples/03_compress_custom.c doc/examples/04_compress_easy_mt.c doc/examples/Makefile '/usr/local/share/doc/xz/examples'
/usr/bin/mkdir -p '/usr/local/share/doc/xz/examples_old'
/usr/bin/install -c -m 644 doc/examples_old/xz_pipe_comp.c doc/examples_old/xz_pipe_decomp.c '/usr/local/share/doc/xz/examples_old'
make[2]: Leaving directory '/root/xz-5.2.6'
make[1]: Leaving directory '/root/xz-5.2.6'
验证查看 XZ
版本
xz -V
看到以下提示证明安装成功
xz (XZ Utils) 5.2.6
liblzma 5.2.4
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。