有段時間沒有來園子了,今天從 www.kernel.org 上面下載了一個 2.6.32.2 內核壓縮包,下載
下來后發現是一個 .xz 結尾的文件,一看與通常的 .gz、.bz2等格式不一樣,感覺可能利用系統現有
的壓縮和解壓縮工具可能不能解壓,測試后果然不能通過gzip、bzip呼和bzip2等工具解壓。
就在Internet上撈了一下,知道整個這個格式是 LZMA 格式的壓縮文件,就是說是利用LZMA壓縮
算法生成的,而前面的壓縮和解壓縮工具不支持這個算法。於是就又撈了一把,說是可以用7zip工具來
解壓,也可以用 XZ Utils工具進行解壓。 於是就逛了一圈 XZ Utils的官網:http://tukaani.org/xz/
下載了一個xz-5.0.1.tar.gz 的源碼包。解壓后如下所示:
[root@localhost setup_file]# cd xz-5.0.1 [root@localhost xz-5.0.1]# ls ABOUT-NLS config.h COPYING dos lib NEWS tests aclocal.m4 config.h.in COPYING.GPLv2 Doxyfile libtool PACKAGERS THANKS AUTHORS config.log COPYING.GPLv3 Doxyfile.in m4 po TODO autogen.sh config.status COPYING.LGPLv2.1 extra Makefile README windows build-aux configure debug INSTALL Makefile.am src ChangeLog configure.ac doc INSTALL.generic Makefile.in stamp-h1
里面有一個README文檔,打開后查看里面的內容:
156 157 2. Compile XZ Utils with debugging code using configure switches 158 --enable-debug and, if possible, --disable-shared. If you are 159 using GCC, use CFLAGS='-O0 -ggdb3'. Don't strip the resulting 160 binaries.
這地方說,如果你需要編譯帶調試信息的代碼,那么就需要在執行 ./configure 的時候帶上 --enable-debug 選項。
不過一般不需要。
然后接着往下看:
166 4. Try to reproduce the suspected bug. If you get "assertion failed" 167 message, be sure to include the complete message in your bug 168 report. If the application leaves a coredump, get a backtrace 169 using gdb: 170 $ gdb /path/to/app-binary # Load the app to the debugger. 171 (gdb) core core # Open the coredump. 172 (gdb) bt # Print the backtrace. Copy & paste to bug report. 173 (gdb) quit # Quit gdb.
這個地方說,如果在make 或者 make install 的時候遇到 中斷錯誤,那么就可以執行下面的命令來
檢查出錯的原因。 一般編譯的時候,不會出錯,這一步也能省略。
然后接着往下看:
191 4. Translating the xz tool 192 -------------------------- 193 194 The messages from the xz tool have been translated into a few 195 languages. Before starting to translate into a new language, ask 196 the author that someone else hasn't already started working on it. 197 198 Test your translation. Testing includes comparing the translated 199 output to the original English version by running the same commands 200 in both your target locale and with LC_ALL=C. Ask someone to 201 proof-read and test the translation. 202 203 Testing can be done e.g. by installing xz into a temporary directory: 204 205 ./configure --disable-shared --prefix=/tmp/xz-test 206 # <Edit the .po file in the po directory.> 207 make -C po update-po 208 make install 209 bash debug/translations.bash | less 210 bash debug/translations.bash | less -S # For --list outputs
這個地方到了正題: 編譯和安裝 xz 工具。
1、這里提到了一句,與 LC_ALL 區域的相關的問題,一般情況下,這個變量不需要修改,就算
不設置為 LC_ALL=C 也沒有關系。一般情況下這個變量的值為空。
2、編譯第一步:執行 ./configure 文件
./configure --disable-shared --prefix=/tmp/xz-test
這一句用來配置編譯過程, --disable-shared 的意思是禁止共享,
--prefix=/tmp/xz-test 表示編譯后將xz安裝到 /tmp/xz-test 目錄下。
3、更新po文件,
make -C po update-po
這個命令的意思,沒啥好解釋的 -C po 指定Makefile的搜索路徑, update-po 表示執行這個目標
4、編譯和安裝
make install
執行這個命令后,就將xz工具編譯后,並安裝到 /tmp/xz-test 目錄下。
我就是這么做的,所以執行 /test/xz-test/bin/xz --help 后顯示如下:
[root@localhost linux-2.6.32.61]# /tmp/xz-test/bin/xz --help Usage: /tmp/xz-test/bin/xz [OPTION]... [FILE]... Compress or decompress FILEs in the .xz format. -z, --compress force compression -d, --decompress force decompression -t, --test test compressed file integrity -l, --list list information about .xz files -k, --keep keep (don't delete) input files -f, --force force overwrite of output file and (de)compress links -c, --stdout write to standard output and don't delete input files -0 ... -9 compression preset; default is 6; take compressor *and* decompressor memory usage into account before using 7-9! -e, --extreme try to improve compression ratio by using more CPU time; does not affect decompressor memory requirements -q, --quiet suppress warnings; specify twice to suppress errors too -v, --verbose be verbose; specify twice for even more verbose -h, --help display this short help and exit -H, --long-help display the long help (lists also the advanced options) -V, --version display the version number and exit With no FILE, or when FILE is -, read standard input. Report bugs to <lasse.collin@tukaani.org> (in English or Finnish). XZ Utils home page: <http://tukaani.org/xz/>
如果你覺得麻煩,可以將路徑: /tmp/xz-test/bin 添加到環境變量 PATH 中,或者臨時導出一下也行。
-d: 解壓縮
-z: 壓縮文件
-t: 測試文件的一致性
-l: 列出文件的信息
命令如下執行:
/tmp/xz-test/bin/xz -d linux-2.6.32.2.xz
就可以解壓你的xz文件了。
今天這個話題就說到這,希望能給你的系統使用帶來方便。