SE街道まっしぐら このページをアンテナに追加 RSSフィード

2012-02-05

[] PHPソース解析用の便利な検証ツール導入 17:48

概要

PHPでの開発は行なっているけどソース品質を向上させるためのアプローチがけっこう停滞している。

ウノウラボ by Zynga Japan: PHPで利用出来るテストと開発に便利なツールを参考にさせてもらって

そのためのソースに対して解析を行えるツールを試しに利用してみる。

環境

試した環境は、さくらVPS

OSは、CentOS v5.5。

phpは、v5.3.8。

Apacheは、 v2.2.21。

導入してみたツール

phpcpd

sebastianbergmann/phpcpd - GitHub

コードの中でコピー&ペースト記述されている部分の検出してくれるツール。

phpdcd

sebastianbergmann/phpdcd - GitHub

どこからもコールされていないファンクションが無いかをチェックするためのツール

phploc

sebastianbergmann/phploc - GitHub

phpファイル構成を調べてくれるツール

phpmd

PHPMD - PHP Mess Detector

バグの可能性になりそうなコード最適化できそうなコード、複雑すぎる記述になっているコード、使われていないファンクションパラメータ、を検出してくれるツール。Jenkinsのpluginとしても動作できる。(Javafindbugsのような位置付け)


インストール方法・実行方法などなど

  • phpcpd

さっそくインストールしてみる。インストール方法PEAR経由で簡単にできる。

[naoki@www22404u ~]$ php -v
PHP 5.3.8 (cli) (built: Sep 30 2011 20:07:13) 
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
    with Xdebug v2.1.1, Copyright (c) 2002-2011, by Derick Rethans

[naoki@www22404u ~]$ sudo pear config-set auto_discover 1
config-set succeeded

[naoki@www22404u ~]$ sudo pear install pear.phpunit.de/phpcpd
Attempting to discover channel "pear.phpunit.de"...
downloading channel.xml ...
Starting to download channel.xml (804 bytes)
....done: 804 bytes
Auto-discovered channel "pear.phpunit.de", alias "phpunit", adding to registry
Attempting to discover channel "components.ez.no"...
downloading channel.xml ...
Starting to download channel.xml (591 bytes)
...done: 591 bytes
Auto-discovered channel "components.ez.no", alias "ezc", adding to registry
phpunit/phpcpd requires PEAR Installer (version >= 1.9.4), installed version is 1.9.2
downloading File_Iterator-1.3.1.tgz ...
Starting to download File_Iterator-1.3.1.tgz (5,157 bytes)
...done: 5,157 bytes
downloading PHP_Timer-1.0.2.tgz ...
Starting to download PHP_Timer-1.0.2.tgz (3,686 bytes)
...done: 3,686 bytes
downloading ConsoleTools-1.6.1.tgz ...
Starting to download ConsoleTools-1.6.1.tgz (869,994 bytes)
...done: 869,994 bytes
downloading Base-1.8.tgz ...
Starting to download Base-1.8.tgz (236,357 bytes)
...done: 236,357 bytes
install ok: channel://pear.phpunit.de/File_Iterator-1.3.1
install ok: channel://pear.phpunit.de/PHP_Timer-1.0.2
install ok: channel://components.ez.no/Base-1.8
install ok: channel://components.ez.no/ConsoleTools-1.6.1

pear のバージョンがv1.9.4より古かったので、pear自体のupgradeを実施。

[naoki@www22404u ~]$ sudo pear upgrade pear
WARNING: channel "pear.php.net" has updated its protocols, use "pear channel-update pear.php.net" to update
downloading PEAR-1.9.4.tgz ...
Starting to download PEAR-1.9.4.tgz (296,332 bytes)
.............................................................done: 296,332 bytes
downloading Archive_Tar-1.3.8.tgz ...
Starting to download Archive_Tar-1.3.8.tgz (17,995 bytes)
...done: 17,995 bytes
upgrade ok: channel://pear.php.net/Archive_Tar-1.3.8
upgrade ok: channel://pear.php.net/PEAR-1.9.4
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)
PEAR: To install optional features use "pear install pear/PEAR#featurename"

[naoki@www22404u ~]$ sudo pear config-set auto_discover 1
config-set succeeded

[naoki@www22404u ~]$ sudo pear install pear.phpunit.de/phpcpd
downloading phpcpd-1.3.5.tgz ...
Starting to download phpcpd-1.3.5.tgz (8,746 bytes)
.....done: 8,746 bytes
install ok: channel://pear.phpunit.de/phpcpd-1.3.5 ※今度は、phpcpd v1.3.5のインストールできた。

利用方法は phpcpd [directory/path]。

今回は、index.phpという全く同じ記述をしたソースファイルを、index_cp.phpとして用意した。

[naoki@www22404u php_sandbox]$ ll /home/naoki/src/php_sandbox/
 -rw-rw-r-- 1 naoki naoki 3599 11月 27 04:24 index.php
 -rw-rw-r-- 1 naoki naoki 3599  2月  5 14:29 index_cp.php

[naoki@www22404u php_sandbox]$ phpcpd /home/naoki/src/php_sandbox/
phpcpd 1.3.5 by Sebastian Bergmann.

Found 1 exact clones with 15 duplicated lines in 2 files:

  - /index.php:67-82
    /index_cp.php:67-82

3.62% duplicated lines out of 414 total lines of code.

Time: 0 seconds, Memory: 2.50Mb

  • phpdcd

インストール方法pear経由。

[naoki@www22404u ~]$ sudo pear config-set auto_discover 1
config-set succeeded

[naoki@www22404u ~]$ sudo pear install pear.phpunit.de/phpdcd
Failed to download phpunit/phpdcd within preferred state "stable", latest release is version 0.9.3, stability "beta", use "channel://pear.phpunit.de/phpdcd-0.9.3" to install
install failed

最新だとstableじゃないからダメだって。stable版のv.0.9.3を利用してみる。

[naoki@www22404u ~]$ sudo pear install pear.phpunit.de/phpdcd-0.9.3
downloading phpdcd-0.9.3.tgz ...
Starting to download phpdcd-0.9.3.tgz (5,827 bytes)
.....done: 5,827 bytes
downloading PHP_TokenStream-1.1.2.tgz ...
Starting to download PHP_TokenStream-1.1.2.tgz (9,797 bytes)
...done: 9,797 bytes
install ok: channel://pear.phpunit.de/PHP_TokenStream-1.1.2
install ok: channel://pear.phpunit.de/phpdcd-0.9.3

これで準備完了。

利用方法は、第1引数に対象のソースがおいてあるディレクトリを指定してあげるだけ。

実行結果はこんな感じ。isIncluderメソッドがどこからもコールされていないことが分かる。

[naoki@www22404u ~]$ ll /home/naoki/src/php_sandbox/
 -rw-rw-r-- 1 naoki naoki 1239 11月 27 04:24 geoIndex.php
 -rw-rw-r-- 1 naoki naoki 2375 11月 27 04:24 geoSample2.php
 -rw-rw-r-- 1 naoki naoki  691 11月 27 04:24 googleMaps.php
 -rw-rw-r-- 1 naoki naoki 3599 11月 27 04:24 index.php
 -rw-rw-r-- 1 naoki naoki 3599  2月  5 14:29 index_cp.php
 -rw-rw-r-- 1 naoki naoki  609 10月 29 17:20 test.php
 -rw-rw-r-- 1 naoki naoki 1857 11月 27 04:24 tweet.php

[naoki@www22404u ~]$ phpdcd /home/naoki/src/php_sandbox/
phpdcd 0.9.3 by Sebastian Bergmann.

  - isIncludedUrl()
    declared in /tweet.php:53

Time: 0 seconds, Memory: 4.50Mb


  • phploc

インストールpear経由で。ほんと簡単。

[naoki@www22404u ~]$ sudo pear config-set auto_discover 1
config-set succeeded

[naoki@www22404u ~]$ sudo pear install pear.phpunit.de/phploc
phpunit/phploc can optionally use PHP extension "bytekit"
downloading phploc-1.6.4.tgz ...
Starting to download phploc-1.6.4.tgz (8,481 bytes)
.....done: 8,481 bytes
install ok: channel://pear.phpunit.de/phploc-1.6.4

実行方法は、上のツールと同じ。

実行すると、php内部の構成が解析されて数値として確認することができる。

[naoki@www22404u ~]$ ll /home/naoki/src/php_sandbox/
 -rw-rw-r-- 1 naoki naoki 1239 11月 27 04:24 geoIndex.php
 -rw-rw-r-- 1 naoki naoki 2375 11月 27 04:24 geoSample2.php
 -rw-rw-r-- 1 naoki naoki  691 11月 27 04:24 googleMaps.php
 -rw-rw-r-- 1 naoki naoki 3599 11月 27 04:24 index.php
 -rw-rw-r-- 1 naoki naoki 3599  2月  5 14:29 index_cp.php
 -rw-rw-r-- 1 naoki naoki  609 10月 29 17:20 test.php
 -rw-rw-r-- 1 naoki naoki 1857 11月 27 04:24 tweet.php

[naoki@www22404u ~]$ phploc /home/naoki/src/php_sandbox/
phploc 1.6.4 by Sebastian Bergmann.

Lines of Code (LOC):                                414
  Cyclomatic Complexity / Lines of Code:           0.04
Comment Lines of Code (CLOC):                         4
Non-Comment Lines of Code (NCLOC):                  410

Namespaces:                                           0
Interfaces:                                           0
Classes:                                              1
  Abstract:                                           0 (0.00%)
  Concrete:                                           1 (100.00%)
  Average Class Length (NCLOC):                      33
Methods:                                              2
  Scope:
    Non-Static:                                       2 (100.00%)
    Static:                                           0 (0.00%)
  Visibility:
    Public:                                           1 (50.00%)
    Non-Public:                                       1 (50.00%)
  Average Method Length (NCLOC):                     16
  Cyclomatic Complexity / Number of Methods:       3.50

Anonymous Functions:                                  0
Functions:                                            3

Constants:                                            0
  Global constants:                                   0
  Class constants:                                    0

  • phpmd

インストールは、pear経由でこれもOK。

[naoki@www22404u ~]$ sudo  pear channel-discover pear.phpmd.org
Adding Channel "pear.phpmd.org" succeeded
Discovery of channel "pear.phpmd.org" succeeded

[naoki@www22404u ~]$ sudo pear channel-discover pear.pdepend.org
Adding Channel "pear.pdepend.org" succeeded
Discovery of channel "pear.pdepend.org" succeeded

[naoki@www22404u ~]$ sudo pear install --alldeps phpmd/PHP_PMD
downloading PHP_PMD-1.3.0.tgz ...
Starting to download PHP_PMD-1.3.0.tgz (45,722 bytes)
.............done: 45,722 bytes
downloading PHP_Depend-1.0.0.tgz ...
Starting to download PHP_Depend-1.0.0.tgz (180,666 bytes)
...done: 180,666 bytes
downloading imagick-3.0.1.tgz ...
Starting to download imagick-3.0.1.tgz (93,920 bytes)
...done: 93,920 bytes
install ok: channel://pear.pdepend.org/PHP_Depend-1.0.0
13 source files, building
running: phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
Please provide the prefix of Imagemagick installation [autodetect] : y
building in /var/tmp/pear-build-rootIOlddC/imagick-3.0.1
running: /var/tmp/imagick/configure --with-imagick=y
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ANSI C... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-redhat-linux-gnu
checking host system type... x86_64-redhat-linux-gnu
checking target system type... x86_64-redhat-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib
checking for PHP extension directory... /usr/lib64/php/modules
checking for PHP installed headers prefix... /usr/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking whether to enable the imagick extension... yes, shared
checking whether to enable the imagick GraphicsMagick backend... no
checking ImageMagick MagickWand API configuration program... configure: error: not found. Please provide a path to MagickWand-config or Wand-config program.
ERROR: `/var/tmp/imagick/configure --with-imagick=y' failed
install ok: channel://pear.phpmd.org/PHP_PMD-1.3.0

早速、実行してみる。実行方法は、

> phpmd [filename|directory] [report format] [ruleset file], i.e:

ルールセットは、カスタマイズ可能だが、今回はもともと用意されてあるルールセットで

解析を実行してみた。codesize, unusedcode,namingを指定。

まずはtext形式で実行してみる。

[naoki@www22404u ~]$ phpmd /home/naoki/src/php_sandbox/ text codesize,unusedcode,naming

/home/naoki/src/php_sandbox/geoIndex.php:33	Avoid variables with short names like $i. Configured minimum length is 3.

実行結果としては、変数$iが短すぎるよって解析結果が、text形式かxml形式で出力される。

結構効率よく、コードの静的な解析ができて便利!!

xml形式に指定も可能。

[naoki@www22404u ~]$ phpmd /home/naoki/src/php_sandbox/ xml codesize,unusedcode,naming

<pmd version="1.3.0" timestamp="2012-02-05T17:37:53+09:00">
  <file name="/home/naoki/src/php_sandbox/geoIndex.php">
    <violation beginline="33" endline="33" rule="ShortVariable" ruleset="Naming Rules" externalInfoUrl="http://phpmd.org/rules/naming.html#shortvariable" priority="3">
      Avoid variables with short names like $i. Configured minimum length is 3.
    </violation>
  </file>
</pmd>

まとめ

これらのツールを活用してコードの中身をもっと、リファクタリングしていったり、

品質あげるアプローチをしていきたいと思う。

phpunitについては、まだ未導入であるため、今度はphpunitを利用してあわせて

リファクタリングTDDの導入をやっていきたいところ。

参考URL

ウノウラボ by Zynga Japan: PHPで利用出来るテストと開発に便利なツール

Manual :: Installation of a local PEAR copy on a shared host

トラックバック - http://d.hatena.ne.jp/n-sega/20120205

2011-05-06

[] 性能・負荷を把握するためのコマンドについて 01:48

Linuxで性能・負荷を把握するための方法を覚えたいなと思って、まずはそのためにもボトルネックを見極める作業をベースに性の方法とそのためのコマンドを整理しておきたい、と思ったので書いておく。


ボトルネック見極め作業の基本的な流れ

ロードアベレージを見る

CPUI/Oのいずれがボトルネックかを探る

  • ロードアベレージが高い場合、CPUI/Oのどちらかに原因があるかを探る。
  • sar, vmstatを利用することで、時間経過とCPU使用率I/O待ち率の推移を確認することができる。この結果を参考にして、CPUI/Oの当たりを付ける。

CPU負荷が高い場合

I/O負荷が高い場合


性能、負荷計測に利用するコマンド(OS)

top

ある瞬間のOSの状態のスナップショットを表示する。


ps

ps(Report Process Status)は、プロセスが持つ情報を出力するツール。

よく使うpsコマンドの例。

$ ps aux | sort -nr -k2 | head -5 #CPU使用率の高い順5件を表示
$ ps aux | sort -nr -k3 | head -5 #Memory使用率の高い順5件を表示

sar

sar(System Activity Reporter)は、OSが報告する各種指標を参照するツール。

2つの用途がある。

sarが利用出来るように、sysstatパッケージに含まれているため、sysstatパッケージをインストール

$ sudo yum install sysstat

よく使うsarのオプションとその内容。

コマンドオプション内容
sar -uCPU使用率を見る
sar -qロードアベレージを見る
sar -rメモリの利用状況を見る
sar -Wスワップ発生状況を見る

vmstat

vmstat(Report Virtual Memory Statistics)は、仮想メモリ関連情報を参照するツール。


参考URL

UNIX的なアレ:gihyo.jp出張所:第2回 知っておきたいスケールアウトの基礎知識 その1|gihyo.jp … 技術評論社


参考書籍

トラックバック - http://d.hatena.ne.jp/n-sega/20110506

2011-04-11

[] DevLOVE Beautiful Development( #devlove, #devlove0409, #DDDjp ) に参加しました。 02:24

2011/4/9(土)にオラクル青山センターにて、DevLOVE Beautiful Developmentに参加してきた。なにげにDevLOVEは、初めての参加。

このイベントは、JavaEE勉強会所属id:digitalsoulさんが翻訳を行ったDDD本が出版されて、QCONの前夜祭というの位置づけの認識。定員は90名。

アジェンダは、こんな感じ。

  • 13:00-13:30 オープニング
    • 和智右桂 氏, papanda 氏
  • 13:40-14:20 第一枠
    • 陽の巻 都元ダイスケ 氏
    • 陰の巻 じゅんいち☆かとう 氏
  • 14:30-15:10 第二枠
  • 15:10-15:40 長休憩
  • 15:40-16:20 第三枠
    • 陽の巻 和田卓人 氏
    • 陰の巻 綿引琢磨
  • 16:30-17:10 第四枠
  • 17:20-18:10 キーノート
    • 和智右桂 氏
  • 18:30-20:30 ビアバッシュ

自分はいちおうJavaEE勉強会所属の身と自負していて、発表される方々は、ほとんどJavaEE勉強会に参加したことのある人達だったので、これは自分も行くしかないと思い、参加してみた。DDDについて、陽と陰と2コマで分けられていて、初めての人は陽へ、初めてでなく裏話とか聞きたい人は陰へ、ということでした。


自分は、陰にしか参加しないということをやったら、どうやら全て陰にしか参加しないということをする人はほとんどいなかった。 まあ全然気にしてはいないw


感想は、参加費が無料だというのに、面白い内容の発表ばかりで充実していた。参加してよかったと思う。


本題のQCONには残念なことに参加することはできないが、これを機にDDDの敷居が下がるようなきっかけになったらいいなーって思えた。こういう前を向いたエンジニアの人たちと触れ合えるってのは、ほんとに良い!!

トラックバック - http://d.hatena.ne.jp/n-sega/20110411

2011-04-10

[][] symfonyを使ってみる 02:00

symfony学習

PHP勉強するにあたり、なにかしらのフレームワークを利用してみたいという気持ちが

強かったので、symfony勉強しようと思った。ということでまずは環境の構築をせねば

と、そのときの覚書を残しておく。


Webで調べながらだと個人的には体系的にサクサク進めないかなー、と思い、

以下の書籍を利用してみた。環境は、さくらVPS環境(CentOS 5.5)で。

symfony 1.4によるWebアプリケーション開発―オープンソース徹底活用


symfonyの関連ソフトインストール

symfonyインストールにあたり必要なソフトインストールする。

$ yum install --enablerepo="remi" php php-pear php-devel php-pdo php-xml
php-mbstring php-process php-pecl-apc mysql-server subversion
$ chkconfig httpd on
$ chkconfig mysqld on
$ /etc/init.d/mysqld restart
$ /etc/init.d/httpd restart

ソフトの動作確認として以下の作業を実施した。

  • PHPのバージョン確認
  • mod_rewriteが有効になっているかの確認
  • AllowOverrideが有効になっているかの確認
  • APCが有効になっているかの確認

php.ini に以下の内容を追記。デフォルトタイムゾーンを設定しないため、

Warningが発生してしまっていたため。

date.timezone = Asia/Tokyo

symfonyインストール

インストール方法は、これ以外にリリースパッケージsubversionリポジトリ、からの

インストールを行うことができる。

$ cd /var/www/html
$ wget http://www.symfony-project.org/get/sf_sandbox_1_4.tgz
$ tar zxvf sf_sandbox_1_4.tgz
$ mv sf_sandbox_1_4 sf14
$ rm sf_sandbox_1_4.tgz

$ cd /var/www/html/sf14
$ php symfony -V
symfony version 1.4.11 (/var/www/html/sf14/lib/vendor/symfony/lib)

/var/www/html/sf14/webディレクトリにある.htaccessに以下のような修正を行う。

RewtireBase /sf14/web/

雛形として作成されるサイト画像などを適切に表示するためにシンボリックリンクを作成する。

$ ln -s /var/www/html/sf14/lib/vendor/symfony/data/web/sf /var/www/html/sf14/web

http://(DomainName)/sf14/web/frontend_dev.php

アクセスすると「Symfony Project Created」が表示されれば

インストール成功。

localhostからではなく、リモートでアクセスする場合は、

frontend_dev.php記述でリモートアクセスを禁止している

記述があるため、その箇所をコメントアウトする必要がある。

//if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1')))
//{
//  die('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
//}

さあ、これで環境が整ったので、symfony使ったアプリ作りをやってみるか。


参考URL

You are not allowed to access this file. Check frontend_dev.php for more information. - tech tech -テクテクブログ-

date関数で”Asia/Tokyo・・”なんかのエラーが出る件:PHP5.1.0以降

innx_hidenoriinnx_hidenori 2011/04/11 17:19 初めまして。symfony本の著者の1人の後藤です。
書籍がお役に立てたら幸いです。不明なことなどございましたら、お気軽にtwitter(#sf14book)とうでつぶやいてください!

ところで、次の日の日記に書かれているDDDカンファレンス、私も参加したかったです。
(私はQConの方へ参加します)
DDDの方面では私はまだまだ勉強しないといけませんので、もし今後お会いできる機会があれば、是非いろいろ教えてください!

shishishishi 2011/04/17 05:15 インストール編を担当したものです。ローカルでのインストールを想定していたもので、リモート環境にインストールする場合は少し書き加えておけば良かったなと反省しています。また感想を頂ければ嬉しいです!

n-segan-sega 2011/05/06 02:03 >innx_hidenori さん
初めまして。情報ありがとうございます。この本のhashtagがあったんですね。知りませんでした。

QConに参加されたんですね。私はそちらには都合がつかず参加できなかっただけに残念でした。私もまだ勉強している身なので教えるというよりは一緒に勉強していきたく思ってます!もしお会いできるときがありましたらその際はよろしくお願いします。

n-segan-sega 2011/05/06 02:07 >shishi さん
初めまして。こんなつたない内容にも関わらず、フィードバックいただきありがとうございます。symfony初心者なので四苦八苦しながら勉強することになると思いますが、なるべく情報を公開したいと思います。その際はまた教えていただければと思ってます。

トラックバック - http://d.hatena.ne.jp/n-sega/20110410

2011-04-06

[][][] CentOSPHP開発環境の設定 00:17

Xdebugインストール

$ sudo pecl install xdebug

設定ファイルの作成。

最後にiniに以下のように書く、zend_extension。

extension=xdebug.so

Config File Scan Dirxdebug.ini ファイルを作成する。

/etc/php.d/xdebug.ini

に、以下の内容を記述する。

zend_extension=/usr/lib64/php/modules/xdebug.so

なおzend_extensionには絶対パスを書かなければいけないので、

分からない場合は pear config-show のext_dirを確認して、

絶対パスを/usr/lib64/php/modulesとした。

pearのconfig-showで設定内容を確認した。

$ pear config-show
:
:

参考URL

ウノウラボ by Zynga Japan: EclipseでPHP開発

「Eclipse+PDT」でPHP開発 ?環境構築と使用方法(1/4):CodeZine

モダンなPHPの開発環境の構築方法 - 肉とご飯と甘いもの @ sotarok

[][] CentOSgitの設定をする 00:13

さくらVPSCentOSを利用しているが、

ここで開発もまとめてやってしまいたいと思っているので、

githubを利用出来るように環境設定を行う。

yumではgitリストにないため、インストールできない。

$ sudo yum install git
:
Setting up Install Process
No package git available.
Nothing to do

yumリポジトリgitを含むものを追加

yumリポジトリgitを含むリポジトリを追加する。

今回は2つのファイルを作成する。

/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

wgetpython-hashlib のrpmを取得して、rpmインストール

インストールする理由は、yum updateでError performing checksum失敗してしまうため。

$ wget http://skvidal.fedorapeople.org/hashlib/python-hashlib-20081119-2.x86_64.rpm
$ sudo rpm -ivh python-hashlib-20081119-2.i386.rpm
$ rpm -qa | grep python-hashlib
python-hashlib-20081119-2

yum updateで、gitリポジトリを追加する。

$ yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
git                                                                                                                updates                                                                                               | 1.9 
:
updates/primary_db                                                                                    | 1.1 
:
Setting up Update Process
No Packages marked for Update

結果的にgitインストールでまた違うエラーが発生してしまい、インストールは完了できなかった。

依存関係のあるモジュールが不足しているため、発生しているみたい。

ちょっと一旦、ここで打ち切って違うタイミングで解決させておきたい。

$sudo yum install git
:
:
--> Processing Dependency: libexpat.so.1()(64bit) for package: git
--> Processing Dependency: libcrypto.so.10()(64bit) for package: git
---> Package perl-Git.x86_64 0:1.7.4.3-1.fc13 set to be updated
--> Processing Dependency: perl(:MODULE_COMPAT_5.10.1) for package: perl-Git
--> Finished Dependency Resolution
git-1.7.4.3-1.fc13.x86_64 from git has depsolving problems
  --> Missing Dependency: libcurl.so.4()(64bit) is needed by package git-1.7.4.3-1.fc13.x86_64 (git)
perl-Git-1.7.4.3-1.fc13.x86_64 from git has depsolving problems
  --> Missing Dependency: perl(:MODULE_COMPAT_5.10.1) is needed by package perl-Git-1.7.4.3-1.fc13.x86_64 (git)
git-1.7.4.3-1.fc13.x86_64 from git has depsolving problems
  --> Missing Dependency: libexpat.so.1()(64bit) is needed by package git-1.7.4.3-1.fc13.x86_64 (git)
git-1.7.4.3-1.fc13.x86_64 from git has depsolving problems
  --> Missing Dependency: libc.so.6(GLIBC_2.7)(64bit) is needed by package git-1.7.4.3-1.fc13.x86_64 (git)
git-1.7.4.3-1.fc13.x86_64 from git has depsolving problems
  --> Missing Dependency: libssl.so.10()(64bit) is needed by package git-1.7.4.3-1.fc13.x86_64 (git)
git-1.7.4.3-1.fc13.x86_64 from git has depsolving problems
  --> Missing Dependency: libcrypto.so.10()(64bit) is needed by package git-1.7.4.3-1.fc13.x86_64 (git)
Error: Missing Dependency: libcrypto.so.10()(64bit) is needed by package git-1.7.4.3-1.fc13.x86_64 (git)
Error: Missing Dependency: libc.so.6(GLIBC_2.7)(64bit) is needed by package git-1.7.4.3-1.fc13.x86_64 (git)
Error: Missing Dependency: libcurl.so.4()(64bit) is needed by package git-1.7.4.3-1.fc13.x86_64 (git)
Error: Missing Dependency: libexpat.so.1()(64bit) is needed by package git-1.7.4.3-1.fc13.x86_64 (git)
Error: Missing Dependency: libssl.so.10()(64bit) is needed by package git-1.7.4.3-1.fc13.x86_64 (git)
Error: Missing Dependency: perl(:MODULE_COMPAT_5.10.1) is needed by package perl-Git-1.7.4.3-1.fc13.x86_64 (git)
 You could try using --skip-broken to work around the problem
 You could try running: package-cleanup --problems
                        package-cleanup --dupes
                        rpm -Va --nofiles --nodigest
The program package-cleanup is found in the yum-utils package.

参考URL

Help.GitHub - Set Up Git

CentOS5.5にgitをインストールする(yumを使用) - hogehoge foobar Blog Style5

yum 実行時に「Error performing checksum」エラー - miauの避難所

トラックバック - http://d.hatena.ne.jp/n-sega/20110406