debian lenny のbackportsでxz-utilsとxzdecの導入

※題名を変更(debian lennyにgnu tar 1.22を導入する。)
 「■まとめ」まで飛ばしてOKですw。。。

■tarは影響範囲が大きいので、「$HOME」で既存のtarとは分けてテスト。

$ wget http://ftp.gnu.org/gnu/tar/tar-1.22.tar.gz
$ tar zxvf tar-1.22.tar.gz
$ cd tar-1.22/
$ ./configure --prefix=$HOME
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking how to create a ustar tar archive... gnutar
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
■「no」が出てるところをもう一度引っ掛ける。

$ ./configure --prefix=$HOME | grep no
checking for gawk... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
■gccとgawkをインストール

$ sudo apt-get install gawk gcc

■で続き。

$ ./configure --prefix=$HOME
$ make
$ make install

■バージョンチェック

$HOME/bin/tar --version
tar (GNU tar) 1.22
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

作者: John Gilmore, Jay Fenlason.

$ tar --version
tar (GNU tar) 1.20
Copyright (C) 2008 Free Software Foundation, Inc.
使用許諾 GPLv3+: GNU GPL version 3 またはそれ以降 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

[参考訳]
これはフリーソフトウェアです: 変更と再配布は自由です.
法律で認められる範囲で「無保証」です.

作者: John Gilmore, Jay Fenlason.

■これでシステムのtarとは別に、ログインユーザが使えるtarコマンドが出来た。
 階層構造は以下のようになる。

$ find bin libexec
bin
bin/tar
libexec
libexec/rmt

$ find share/info/
share/info/
share/info/tar.info
share/info/tar.info-1
share/info/tar.info-2

$ find share/locale/ja/
share/locale/ja/
share/locale/ja/LC_MESSAGES
share/locale/ja/LC_MESSAGES/tar.mo

■階層構造がきれいじゃないので。

$ ./configure --help | grep -i prefix
--prefix=PREFIX install architecture-independent files in PREFIX
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--program-prefix=PREFIX prepend PREFIX to installed program names
--with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib
--without-libiconv-prefix don't search for libiconv in includedir and libdir
--with-libintl-prefix[=DIR] search for libintl in DIR/include and DIR/lib
--without-libintl-prefix don't search for libintl in includedir and libdir
■確かにPREFIXは「/usr/local」になっている。

$ grep PREFIX lib/configmake.h
#define PREFIX "/usr/local"
#define EXEC_PREFIX "/usr/local"

■既存のtarを上書きしないことを確認してもう一度。
 今度は「make install」にroot権限が必要な点に注意。

$ whereis tar
tar: /bin/tar /usr/local/bin/tar /usr/include/tar.h /usr/share/man/man1/tar.1.gz

$ ./configure
$ make
$ sudo make install

$ ls /usr/local/bin/tar
/usr/local/bin/tar

$ ls /usr/local/libexec/rmt
/usr/local/libexec/rmt

$ ls /usr/local/share/info/tar.info*
/usr/local/share/info/tar.info /usr/local/share/info/tar.info-2
/usr/local/share/info/tar.info-1

$ find /usr/local/share/locale/ja/
/usr/local/share/locale/ja/
/usr/local/share/locale/ja/LC_MESSAGES
/usr/local/share/locale/ja/LC_MESSAGES/tar.mo

■システムのtarは変わっていないことを確認。

$ whereis tar
tar: /bin/tar /usr/local/bin/tar /usr/include/tar.h /usr/share/man/man1/tar.1.gz

$ tar --version | head -1
tar (GNU tar) 1.20

$ /usr/local/bin/tar --version | head -1
tar (GNU tar) 1.22

これでシステムとは別のgnu tar 1.22が使えるようになった。

□【追記】実際にやってみると。。。

$ tar -Jxvf
tar: xz: exec 不能: そのようなファイルやディレクトリはありません
tar: エラーを回復できません: 直ちに終了します
tar: Child returned status 2
tar: 前のエラーにより失敗ステータスで終了します

■xzが別に要る?

$ strings /usr/local/bin/tar | grep xz
filter the archive through xz

■xzって無いけど?

$ apt-cache search xz
xzoom - リアルタイム更新機能付き X ディスプレイの部分拡大鏡
xzip - Infocom フォーマットによるストーリーファイルのインタプリタ
zblast-x11 - X11 版スペースシューティングゲーム zblast
nexuiz-server - Nexzui 用のスタンドアロンなサーバ
xzgv - サムネイルベースのセレクタが付いた X 用写真ビューア
makexvpics - コマンドラインから .xvpics サムネイルを更新

■じゃ、コンパイル

$ wget http://tukaani.org/xz/xz-5.0.3.tar.gz
$ tar zxvf xz-5.0.3.tar.gz
$ cd xz-5.0.3/
$ ./configure --prefix=/usr/local
$ make
$ sudo make install

■パスは通ってるよね?

$ echo "$PATH" | sed s/":"/"\n"/g | grep /usr/local
/usr/local/bin

$ whereis xzcat
xzcat: /usr/local/bin/xzcat

$ ls /usr/local/bin
lzcat lzegrep lzless lzmainfo unlzma xzcat xzdiff xzgrep
lzcmp lzfgrep lzma lzmore unxz xzcmp xzegrep xzless
lzdiff lzgrep lzmadec tar xz xzdec xzfgrep xzmore

■liblzmaが見つからない?

$ /usr/local/bin/xzdec Free*
/usr/local/bin/xzdec: error while loading shared libraries: liblzma.so.5: 
cannot open shared object file: No such file or directory

$ whereis liblzma
liblzma: /usr/local/lib/liblzma.la /usr/local/lib/liblzma.so /usr/local/lib/liblzma.a

■コピーしてしまおう。

$ sudo cp -pir /usr/local/lib/* /usr/lib/

■とりあえずxzが使えた。

$ xz --decompress FreeBSD-8.2-RELEASE-i386-dvd1.iso.xz

遊び用だからいいけど、もう少し整理しないと駄目だな。。。

■更に追記(2011/10/09)

「xz-utils」はbackportsで管理されています。
 tarにパイプするなり別処理にするなりすればこれだけで充分です。

http://packages.debian.org/ja/lenny-backports/xz-utils
http://packages.debian.org/ja/lenny-backports/amd64/xz-utils/download

■backportsって何?についてはこちら。

http://www.debian.org/News/2010/20100905.ja.html

■sources.listの編集、apt-getで更新。

$ grep backports /etc/apt/sources.list
deb http://backports.debian.org/debian-backports lenny-backports main
deb-src http://backports.debian.org/debian-backports lenny-backports main

$ sudo apt-get update

■依存関係を確認。libc6も絡んでます。「xz-lzma」にご注意を。

$ apt-cache search xz-utils
xz-lzma - XZ-format compression utilities - compatibility commands
xz-utils - XZ-format compression utilities
xzdec - XZ-format compression utilities - tiny decompressors

$ sudo apt-cache showpkg xz-utils | grep Dependencies: -A 1 | \
sed s/" "/"\n"/g | sort | uniq | grep ^[a-z]
libc6
liblzma2
xz-lzma

$ sudo apt-cache showpkg xzdec | grep Dependencies: -A 1 | \
sed s/" "/"\n"/g | sort | uniq | grep ^[a-z]
libc6
xz-lzma
xz-utils


■liblzma2 xz-utils がインストール、xz-lzma が提案されます。
 ※ただし、lzma が削除されますので、xz-lzma は使用しません。

$ sudo apt-get install xz-utils
$ sudo apt-get install xzdec

■以下のようなコマンドが出来ます。

$ ls /usr/bin/ | grep "xz\|lz" | column
lzcat unlzma xzcmp xzfgrep
lzma unxz xzdec xzgrep
lzmadec xz xzdiff xzless
lzmainfo xzcat xzegrep xzmore


■マニュアルもあります。

$ ls /usr/bin/ | grep "xz\|lz" | for list in `xargs`;do apropos ^${list}\$;done
lzcat (1) - LZMA compression and decompression tool
lzma (1) - LZMA compression and decompression tool
lzmadec (1) - Small .xz and .lzma decompressors
lzmainfo (1) - show information stored in the .lzma file header
unlzma (1) - LZMA compression and decompression tool
unxz (1) - Compress or decompress .xz and .lzma files
xz (1) - Compress or decompress .xz and .lzma files
xzcat (1) - Compress or decompress .xz and .lzma files
xzcmp (1) - compare compressed files
xzdec (1) - Small .xz and .lzma decompressors
xzdiff (1) - compare compressed files
xzegrep (1) - search compressed files for a regular expression
xzfgrep (1) - search compressed files for a regular expression
xzgrep (1) - search compressed files for a regular expression
xzless (1) - view xz or lzma compressed (text) files
xzmore (1) - view xz or lzma compressed (text) files

■lzmaには「~bpo50+1」がありません。

$ dpkg -l | grep "xz\|lz" | awk '{print $2 " " $3}'
liblzma2 5.0.0-2~bpo50+1
lzma 4.43-14
xz-utils 5.0.0-2~bpo50+1
xzdec 5.0.0-2~bpo50+1

■lzmaのコマンドは以下の通り。

$ dpkg -L lzma | grep bin/
/usr/bin/lzma
/usr/bin/unlzma
/usr/bin/lzcat

■xz-utilsのコマンド。

$ dpkg -L xz-utils | grep bin/ | column
/usr/bin/xzdiff /usr/bin/lzmainfo /usr/bin/xzcmp
/usr/bin/xzgrep /usr/bin/xzless /usr/bin/xzegrep
/usr/bin/xz /usr/bin/xzfgrep /usr/bin/xzcat
/usr/bin/xzmore /usr/bin/unxz

■xzdecのコマンド

$ dpkg -L xzdec | grep bin/ | column
/usr/bin/xzdec /usr/bin/lzmadec

■lzmadecの依存関係が気になります。

$ lzmadec --version
lzmadec (XZ Utils) 5.0.0
liblzma 5.0.0

■「liblzma.so.2」です。

$ find /usr/lib | grep lz | xargs ls -l | cut -c 48-
/usr/lib/apt/methods/lzma
/usr/lib/liblzma.so.2 -> liblzma.so.2.0.0
/usr/lib/liblzma.so.2.0.0

■ソースをダウンロード。

$ sudo apt-get source --download-only xzdec
$ shasum xz*
96e49ed409f9de6d7610ae538f310cd499a74352 xz-utils_5.0.0-2~bpo50+1.debian.tar.gz
542f01429c2263ff1d9159be30d7f53f16abaf3d xz-utils_5.0.0-2~bpo50+1.dsc
bcce697d7f09584f0feb21e35b13a15ba7417a1f xz-utils_5.0.0.orig.tar.gz

$ less xz*.dsc | grep -i Sha1 -A 2
Checksums-Sha1:
bcce697d7f09584f0feb21e35b13a15ba7417a1f 1232154 xz-utils_5.0.0.orig.tar.gz
96e49ed409f9de6d7610ae538f310cd499a74352 117716 xz-utils_5.0.0-2~bpo50+1.debian.tar.gz

■中身を拝見。「This package includes the shared library.」と言っているので、
 解凍に限れば不要のようですね。


$ tar zxvf xz-utils_5.0.0.orig.tar.gz
$ cd xz-5.0.0
$ grep liblzma: -A 18 PACKAGERS
liblzma:

Library for XZ and LZMA compressed files

liblzma is a general purpose data compression library with
an API similar to that of zlib. liblzma supports multiple
algorithms, of which LZMA2 is currently the primary algorithm.
The native file format is .xz, but also the legacy .lzma
format and raw streams (no headers at all) are supported.

This package includes the shared library.

liblzma-devel:

Library for XZ and LZMA compressed files

This package includes the API headers, static library, and
other development files related to liblzma.

■試してみる。

$ wget http://tukaani.org/lzma/lzma-4.32.7.tar.lzma
$ lzmadec -d lzma-4.32.7.tar.lzma | tar xvf -
$ ls lzma-4.32.7
AUTHORS INSTALL THANKS configure ltmain.sh
COPYING.GPLv2 Makefile.am aclocal.m4 configure.ac m4
COPYING.GPLv3 Makefile.in config.guess depcomp missing
COPYING.LGPLv2.1 NEWS config.h.in extra src
ChangeLog README config.sub install-sh tests

■まとめ

★sources.listにbackportsの設定をして。。。

# cp -pi /etc/apt/sources.list /etc/apt/sources.list.org
# grep backports /etc/apt/sources.list || \
  echo -e 'deb http://backports.debian.org/debian-backports lenny-backports main\n
deb-src http://backports.debian.org/debian-backports lenny-backports main' >> /etc/apt/sources.list

★「xz-utils」と「xzdec」をインストールするだけ。

$ sudo apt-get update && sudo apt-get install xz-utils xzdec

ほんのちょっとした事を大げさにやってただけでした。。。

■おまけ
 backportsで入れたパッケージを一覧する。


$ dpkg -l | grep ~bpo | grep ^i | awk '{print $2}'
liblzma2
xz-utils
xzdec