在CentOS 5/Redhat 5上安装和配置TortoiseHg和kdiff3

作者:聂勇 欢迎转载,请保留作者信息并说明文章来源!

这是两年前写的一篇文章(已经有同学转载在CSDN上),当时身边的一些同学在安装TortoiseHg和kdiff3时碰到了不少软件的版本和依赖问题,导致无法顺利安装下去。因此,特分享我安装这些软件的完整过程,希望对大家有帮助。

Mercurial(HG)的安装和使用入门可参考我的另一篇文章”在CentOS 5/Redhat 5上安装Mercurial(HG)”。

一、环境和准备工作

1、操作系统:Redhat5 / Centos5
2、需要准备的软件及其版本(都是通过源代码编译进行安装):

  • Python2.7 (Redhat5和Centos5上默认安装的Python为2.4版本,请升级至2.7。升级Python后,重新编译安装mercurial-1.9)
  • qt-4.7.3
  • kdiff3-0.9.95
  • QScintilla-gpl-2.5.1
  • iniparse-0.4
  • sip-4.12.4
  • PyQt-x11-gpl-4.8.5
  • tortoisehg-2.1

它们的依赖关系如下图所示:
组件依赖关系

二、安装QT4

1、下载源代码:

1
wget http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.3.tar.gz

2、解压源代码包:

1
tar -zxvf qt-everywhere-opensource-src-4.7.3.tar.gz

3、编译安装三步曲:
进入解压后的目录,分别按顺序执行如下命令:

1
2
3
./configure -prefix /home/nieyong/local/qt-4.7.3 # 需根据本机环境修改
gmake
gmake install

注:此步骤执行的时间比较久,在我的机器上执行了约2.5小时。

三、安装kdiff3

1、下载源代码

1
wget http://nchc.dl.sourceforge.net/project/kdiff3/kdiff3/0.9.95/kdiff3-0.9.95.tar.gzgmake

2、解压源代码

1
tar -zxvf kdiff3-0.9.95.tar.gz

3、配置环境变量
1)编辑当前用户目录下的.bash_profile文件

1
vi ~/.bash_profile

加入如下配置:

1
2
3
4
5
6
7
8
QTDIR=$HOME/local/qt-4.7.3 # 需根据本机环境修改
export QTDIR
PATH=$QTDIR/bin:$PATH
export PATH
LD_LIBRARY_PATH=$HOME/local/qt-4.7.3/lib:$LD_LIBRARY_PATH # 需根据本机环境修改
export LD_LIBRARY_PATH

2)使环境变量配置生效

1
source ~/.bash_profile

4、安装kdiff3
进入kdiff3-0.9.95.tar.gz解压后的目录,执行如下命令进行安装:

1
./configure qt4

四、配置kdiff3

1、编辑当前用户目录下的.hgrc文件,执行如下命令:

1
vi ~/.hgrc

增加如下配置:

1
2
3
4
5
6
7
8
[extensions]
hgext.extdiff=
[extdiff]
cmd.kdiff3=
[merge-tools]
kdiff3.args=$base $local $other -o $output

五、安装iniparse

1、下载源代码

1
wget http://iniparse.googlecode.com/files/iniparse-0.4.tar.gz

2、解压源代码包

1
tar -zxvf iniparse-0.4.tar.gz

3、安装
进入iniparse-0.4解压后的目录,执行如下命令进行安装:

1
2
python setup.py build
python setup.py install # 需要以root身份执行

六、安装 sip

1、下载源代码

1
wget http://www.riverbankcomputing.co.uk/static/Downloads/sip4/sip-4.12.4.tar.gz

2、解压源代码包

1
tar -zxvf sip-4.12.4.tar.gz

3、编译安装sip
进入sip-4.12.4的解压目录,执行如下三个命令:

1
2
3
python ./configure.py
make
make install # 需要以root身份执行

七、安装PyQt4

1、下载源代码

1
wget http://www.riverbankcomputing.co.uk/static/Downloads/PyQt4/PyQt-x11-gpl-4.8.5.tar.gz

2、解压源代码包

1
tar -zxvf PyQt-x11-gpl-4.8.5.tar.gz

3、安装PyQt4
进入PyQt解压后的目录,按顺序执行如下三个命令安装:

1
python configure.py

然后会显示如下的协议信息:

Determining the layout of your Qt installation…
This is the GPL version of PyQt 4.8.5 (licensed under the GNU General Public
License) for Python 2.7.2 on linux2.

Type ‘2’ to view the GPL v2 license.
Type ‘3’ to view the GPL v3 license.
Type ‘yes’ to accept the terms of the license.
Type ‘no’ to decline the terms of the license.

Do you accept the terms of the license? # 在此输入yes并按回车表示同意协议并继续后面的安装步骤

最后再分别执行:

1
2
make
make install # 需要以root身份执行

八、安装QScintilla

1、下载源代码

1
wget http://www.riverbankcomputing.co.uk/static/Downloads/QScintilla2/QScintilla-gpl-2.5.1.tar.gz

2、解压源代码包

1
tar -zxvf QScintilla-gpl-2.5.1.tar.gz

3、编译安装QScintilla
1)进入QScintilla解压后目录下的Qt4目录,顺序执行如下三个命令:

1
2
3
qmake qscintilla.pro
make
make install

2)进入QScintilla解压后目录下的Python目录,顺序执行如下三个命令:

1
2
3
python ./configure.py
make
make install # 需要以root身份执行

九、安装TortoiseHg

说明:mercurial-1.9对应的tortoisehg的版本是2.1,安装其他版本会有问题。
1、下载源代码

1
wget https://bitbucket.org/tortoisehg/targz/downloads/tortoisehg-2.1.tar.gz

2、解压源代码包

1
tar -zxvf tortoisehg-2.1.tar.gz

3、安装TortoiseHg
进入tortoisehg-2.1的解压目录,顺序执行如下两个命令安装:

1
2
python setup.py build
python setup.py install (需要以root身份执行)

注意:请按照上述过程安装,否则会碰到许多的问题。