ふにゃるんv2

もとは、http://d.hatena.ne.jp/Wacky/

tarファイルから、Python 2.4.2のRPMファイルを作ろう

先日は、2.4.1のSRPMファイルから、RPMファイルを作った訳ですね。
で、今回は 2.4.2のSRPMファイルから、RPMファイルを作ろうと思った訳ですよ、旦那。
SRPMファイルは、Python 2.4.2から、左側のメニューのLinux RPMsをクリックすると行けるページにある、python24-2.4.2-2.src.rpmをDLすればOK。


早速、rpmbuild。

$ rpmbuild --rebuild python24-2.4.2-2.src.rpm 
python24-2.4.2-2.src.rpm をインストール中
警告: user jafo does not exist - using root
警告: group jafo does not exist - using root
警告: user jafo does not exist - using root
警告: group jafo does not exist - using root
警告: user jafo does not exist - using root
警告: group jafo does not exist - using root
警告: user jafo does not exist - using root
警告: group jafo does not exist - using root
警告: user jafo does not exist - using root
警告: group jafo does not exist - using root
警告: user jafo does not exist - using root
警告: group jafo does not exist - using root
警告: user jafo does not exist - using root
警告: group jafo does not exist - using root
警告: user jafo does not exist - using root
警告: group jafo does not exist - using root
警告: user jafo does not exist - using root
警告: group jafo does not exist - using root
警告: user jafo does not exist - using root
警告: group jafo does not exist - using root
警告: user jafo does not exist - using root
警告: group jafo does not exist - using root
警告: user jafo does not exist - using root
警告: group jafo does not exist - using root
警告: user jafo does not exist - using root
警告: group jafo does not exist - using root
警告: user jafo does not exist - using root
警告: group jafo does not exist - using root
エラー: Failed build dependencies:
        tcl-devel is needed by python24-2.4.2-2
        tk-devel is needed by python24-2.4.2-2
        tix-devel is needed by python24-2.4.2-2
        bzip2-devel is needed by python24-2.4.2-2

Ouch!!
tcl/tkの開発ライブラリを入れろって言ってるよ。
おっかしいなぁ、2.4.1の時にtcl/tkを入れたのに。もしかしてtcl/tkの要求バージョンが上がっているのかなぁ?


で、まぁ、RPM Searchから、Red Hat Linux 9(自分のLinux環境はデフォルトがRH9なのだ)のRPMファイルを落として、片っ端からRPMにかけてみた訳ですな。例えばtcl-8.4.9-1_3.rh9.at.i386.rpmなんてファイルとか。


すると、↓こんな感じのメッセージが出て、conflictじゃボケ〜って出てくる訳ですよ。

# rpm -ivh ./tcl-8.4.9-1_3.rh9.at.i386.rpm
警告: ./tcl-8.4.9-1_3.rh9.at.i386.rpm: V3 DSA signature: NOKEY, key ID 66534c2b
Preparing...                ########################################### [100%]
        file /usr/bin/tclsh from install of tcl-8.4.9-1_3.rh9.at conflicts with file from package tcl-8.3.5-88
        file /usr/share/man/man1/tclsh.1.gz from install of tcl-8.4.9-1_3.rh9.at conflicts with file from package tcl-8.3.5-88

数時間かけて一緒に入れようとしたりしたんだけど、どうも conflict が取れない。"--force"オプションをかける事も考えたけど、何か気に食わないので、それは止めた。


次に、RPMの使い方サイトを眺めていたら、tarファイルでもspecファイルがあれば、RPMファイルが作れるとある。
早速、Python-2.4.2.tgzをダウンロードして、rpmbuildにかけてみた。

# rpmbuild -ta ./Python-2.4.2.tgz
エラー: %changelog not in descending chronological order

何これ?


ぐぐるって見る。…よくわかんねぇ。
とりあえず、specファイルが悪さをしているんだろう。という見当を付けた。
で、次 どうしようかな?と思い、specファイルを弄りながらRPMを作るしかないだろうなぁ、という結論に至った訳ですよ。


で、tarファイルからspecファイルを使って、RPMファイルを作る方法って無いかな?と ぐぐると、以下が一番判り易かった。

ぶっちゃけて言うと、

  1. /usr/src/redhat以下と同じ構造のフォルダを、ホームディレクトリ下に作る
    $ cd ~; mkdir -p ~/redhat/{BUILD,SOURCES,SPECS,RPMS,SRPMS} 
  2. ホームディレクトリに、".rpmmacros"ってファイルを作って、パスを通す。
    %_topdir        /home/test/redhat
  3. SPECSフォルダに、specファイルを作る
    (実は、Pythonには、/misc/RPM下にspecファイルが用意されている)
  4. SOURCESフォルダに、tarファイルを置く
  5. "rpmbuild -ba"で、specファイルを指定してビルドさせる

って順番を踏めば、SRPMにこだわらずにRPMが作れちゃうらしい。


ってんで、早速試してみよう。

必要なブツ。

  • Python-2.4.2.tar.bz2
    ちなみに、何故、tgzじゃなくtar.bz2かと言うと、specファイルが tar.bz2 を前提にしちゃっている模様だから。

1. tar.bz2ファイルから、specファイルを取り出す
まずは、tar.bz2ファイルを開いて、specファイルを取り出す。
specは、tar.bz2ファイルの、Python-2.4/Misc/RPM/python-2.4.spec にある。

2. ホームディレクトリ下に、/usr/src/redhatと同じ構造のフォルダを作る
例えば、以下の感じ。

$ mkdir -p ~/redhat/{BUILD,SOURCES,SPECS,RPMS,SRPMS}
$ ls redhat
BUILD  RPMS  SOURCES  SPECS  SRPMS

3. ホームディレクトリ直下に、".rpmmacros"ファイルを作る
例えば、以下の感じ。

$ vi .rpmmacros
_topdir        /home/wacky/redhat

確認は、"rpm --eval %_topdir"で行うらしい。

$ rpm --eval %_topdir
/home/wacky/redhat

4. SPECSフォルダに、specファイルをコピー
例えば、以下の感じ。

$ cp python-2.4.spec redhat/SPECS/
$ ls redhat/SPECS/
python-2.4.spec

5. SOURCESフォルダに、tar.bz2ファイルを置く
例えば、以下の感じ。

$ cp Python-2.4.2.tar.bz2 redhat/SOURCES/
$ ls redhat/SOURCES/
Python-2.4.2.tar.bz2

6. "rpmbuild -ba"で、specファイルを指定してビルドさせる
例えば、以下の感じ。

$ rpmbuild -ba redhat/SPECS/python-2.4.spec
エラー: %changelog not in descending chronological order

あれ、エラーだ。


これの解決方法なんだけど、わかってしまえば何の事は無かった。

$ vi redhat/SPECS/python-2.4.spec
...
%changelog
* Wed Jan 05 2004 Sean Reifschneider <jafo-rpms@tummy.com> [2.4-3pydotorg]
- Changing the idle wrapper so that it passes arguments to idle.

134行目の"Wed Jan 05 2004"を"Wed Jan 05 2005"に修正するだけ。


んじゃぁ、再ビルド。

$ rpmbuild -ba redhat/SPECS/python-2.4.spec
...
Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/python2.4-2.4.2-root
書き込み中: /home/wacky/redhat/SRPMS/python2.4-2.4.2-1pydotorg.src.rpm
書き込み中: /home/wacky/redhat/RPMS/i386/python2.4-2.4.2-1pydotorg.i386.rpm
書き込み中: /home/wacky/redhat/RPMS/i386/python2.4-devel-2.4.2-1pydotorg.i386.rpm
書き込み中: /home/wacky/redhat/RPMS/i386/python2.4-tkinter-2.4.2-1pydotorg.i386.rpm
書き込み中: /home/wacky/redhat/RPMS/i386/python2.4-tools-2.4.2-1pydotorg.i386.rpm
書き込み中: /home/wacky/redhat/RPMS/i386/python2.4-debuginfo-2.4.2-1pydotorg.i386.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.30668
+ umask 022
+ cd /home/wacky/redhat/BUILD
+ cd Python-2.4.2
+ '[' -n /var/tmp/python2.4-2.4.2-root -a /var/tmp/python2.4-2.4.2-root '!=' / ']'
+ rm -rf /var/tmp/python2.4-2.4.2-root
+ rm -f mainpkg.files tools.files
+ exit 0

出来たよ!


早速インストールしてみよう。

$ rpm -ivh python2.4-2.4.2-1pydotorg.i386.rpm
Preparing...                ########################################### [100%]
   1:python2.4              ########################################### [100%]
$ python2.4 -V
Python 2.4.2

いえふぅ!


しかし、何ですな。
specファイルがあれば、意外と簡単にRPMファイルって作れちゃうもんなんですね。感心したよ。