CentOS6.3にgitをコンパイル、インストール

ようやくサーバーがそれなりになったので、本来の目的である開発用の環境を作っていきます。

Linux初心者なので色々と間違っている可能性が高いので注意!

gitとは?

まずはお勉強です。ここのサイトが解りやすかったです。

イラストでわかる!git入門の入門

大体わかったら次行きます。

gitをインストール

CentOS6.3にインストールしてみます。

(参考)
CentOS5.5にgitをインストールする(yumを使用)

いつも通りyumでインストール、と行きたいですがリポジトリにgitが登録されていないらしくそのままではダメです。

参考サイトを見ながらとりあえずやってみます。

リポジトリの追加

/etc/yum.repos.d/git.repo を新規作成します。

[git]
name=Base git repository
baseurl=http://www.kernel.org/pub/software/scm/git/RPMS/$basearch
enabled=1
gpgcheck=0

/etc/yum.repos.d/rpmforge.repo も新規作成します。

[rpmforge]
name = Red Hat Enterprise $releasever – RPMforge.net – dag
mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
enabled = 0
gpgcheck = 0

アップデートします。

# yum update
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: ftp.nara.wide.ad.jp
* epel: ftp.tsukuba.wide.ad.jp
* extras: ftp.nara.wide.ad.jp
* updates: ftp.nara.wide.ad.jp
http://www.kernel.org/pub/software/scm/git/RPMS/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 – “The requested URL returned error: 404″
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: git. Please verify its path and try again

おぉぅ、またこの手の奴ですか。見つからないとは、これいかに?

確かに、URLの場所には何もありません。
調べて見ると、どうやら2011年9月にハッキングを受けたみたいですねぇ、知りませんでした。
ハッキング後、セキュリティ対策で何か変更したんでしょうね。
英語で何か書いてありますが、よくわからないので別の方法にしてみます。

注意!

上記2ファイルは削除するなりして無かった事にしておきます。

ソースからのインストール

ここからソースが取得できるようなので、ソースから行ってみます。

https://code.google.com/p/git-core/

まずはディレクトリ移動してダウンロードします。

# cd /usr/local/src
# wget https://git-core.googlecode.com/files/git-1.7.12.1.tar.gz

※2012年9月28日時点での最新ファイルなので注意してください。

解凍・コンパイル

# tar zxvf git-1.7.12.1.tar.gz
# cd git-1.7.12.1
# sh configure
# makeCC credential-store.o
credential-store.c:1 から include されたファイル中:
cache.h:19:18: 警告: zlib.h: そのようなファイルやディレクトリはありません
In file included from credential-store.c:1:
cache.h:21: error: expected specifier-qualifier-list before ‘z_stream’
make: *** [credential-store.o] エラー 1

ぬ、ぬぬぅ・・。やはりダメですか。予想はしてましたけどね。

どうやら zlib.h が見つからないようです。
インストールしたいのですが、どうすればいいのでしょう?
とりあえず、yum search してみます。

# yum search zlib
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: ftp.nara.wide.ad.jp
* epel: ftp.tsukuba.wide.ad.jp
* extras: ftp.nara.wide.ad.jp
* updates: ftp.nara.wide.ad.jp
============================== N/S Matched: zlib ===============================
jzlib.x86_64 : JZlib re-implementation of zlib in pure Java
jzlib-demo.x86_64 : Examples for jzlib
jzlib-javadoc.x86_64 : Javadoc for jzlib
mingw32-zlib.noarch : MinGW Windows zlib compression library
mingw32-zlib-static.noarch : Static libraries for mingw32-zlib development.
perl-Compress-Raw-Zlib.x86_64 : Low-Level Interface to the zlib compression
: library
perl-Compress-Zlib.x86_64 : A module providing Perl interfaces to the zlib
: compression library
perl-IO-Zlib.x86_64 : Perl IO:: style interface to Compress::Zlib
zlib.i686 : The zlib compression and decompression library
zlib.x86_64 : The zlib compression and decompression library
zlib-devel.i686 : Header files and libraries for Zlib development
zlib-devel.x86_64 : Header files and libraries for Zlib development
zlib-static.x86_64 : Static libraries for Zlib development
zlibrary-devel.i686 : Development files for zlibrary
zlibrary-devel.x86_64 : Development files for zlibrary
zlibrary-ui-gtk.x86_64 : GTK+ interface module for ZLibrary
zlibrary-ui-qt.x86_64 : Qt4 interface module for ZLibrary
ghc-zlib.x86_64 : Haskell compression and decompression library
ghc-zlib-devel.x86_64 : Haskell compression and decompression library
: development files
perl-IO-Compress-Zlib.x86_64 : Perl interface to allow reading and writing of
: gzip and zip data
python-gzipstream.noarch : Streaming zlib (gzip) support for python
zlibrary.i686 : Cross-platform GUI library
zlibrary.x86_64 : Cross-platform GUI libraryName and summary matches only, use “search all” for everything.

なにやら大量にヒットしましたが、欲しいのはヘッダーファイルなので、多分これでしょう。

zlib-devel.x86_64 : Header files and libraries for Zlib development

ということで、インストールして再度コンパイルしてみます。

# yum install zlib-devel.x86_64
# make

コンパイルは通ったっぽいのに、リンクでエラーになってしまいました・・・。orz

LINK git-credential-store
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../libz.so when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/libz.so when searching for -lz
/usr/bin/ld: cannot find -lz
collect2: ld はステータス 1 で終了しました
make: *** [git-credential-store] エラー 1

くじけそうです。面倒になってきました。

今度は /usr/lib/libz.so がダメみたいです。
/usr/lib/libz.so の存在チェックをしたら存在しませんでした。
しかし、/lib64/libz.so.1 と /lib64/libz.so.1.2.3 はあります。
とりあえず /lib64/libz.so.1.2.3 より /lib64/libz.so をコピーし

# cp /lib64/libz.so.1.2.3 /lib64/libz.so

再コンパイルしてみました。

/usr/bin/perl Makefile.PL PREFIX=’/usr/local’ INSTALL_BASE=” –localedir=’/usr/local/share/locale’
Can’t locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 3.
BEGIN failed–compilation aborted at Makefile.PL line 3.
make[1]: *** エラー 2
make: *** エラー 2

またぁ・・・。今度はperlですか?
はいはい、インストールしてmake、っと・・・。

# yum install perl-ExtUtils-MakeMaker
# make

ようやくコンパイル完了です。長かった。

インストール

インストールする前に、念のためにすでにインストールされていないかチェック。

# rpm -q git
git-1.7.1-2.el6_0.1.x86_64

ほっ、ほぅ・・・。インストール済みですね、これは。orz

2012/09/30 ダメです。消したら面倒になります。

ま、まぁ、バージョン低いし、アップデートってやつですよ、うふふ。

とりあえず、こんな物は消します。目障りです!!

# yum remove git-1.7.1-2.el6_0.1.x86_64

そしてついにインストールです。

# ./configure –prefix=/usr
# make install

入りました。
今度はようやく設定ですね。

>> centos6-3-gitの設定(その1)やりなおし