Monday, November 03, 2008

MEGA 4 LE安装手记

前言

MEGA(Molecular Evolutionary Genetics Analysis)以其友好的界面,简单的操作,强大的功能,当然还有免费的授权方式,成为分子进化领域最为常用的软件之一,现在版本号已经更新到了4.0。但长久以来,MEGA都是只能在Windows系统下运行的,直到最近才有了基于Linux操作系统的MEGA 4 Linux Edition(LE)。但这个LE版并不完善,它其实就是个绿色软件包,还是要借助Wine做平台,所以要在Linux系统上安装MEGA,就先得安装Wine。还有一个不完善的地方是这个LE版的安装说明过于简略,只有寥寥几行,忽略了安装过程中很可能遇到的一个问题,反正照着那个安装说明我是没有装成功的而且迷茫了好久-_-!。既然如此,还是有写篇手记的必要的:)

正文

1)Wine的安装和设置

从Wine的官网上下载最新的Wine源码包,下载地址为http://www.winehq.org/site/download,现在的最新稳定版版本号为1.0.1。然后解压到本地任意文件夹
$ tar jxvf wine-1.0.1.tar.bz2

切换到解压后的目录
$ cd wine-1.0.1

为了图省事,我这里用wine自带的安装程序配置和安装的,方法如下
切换到下级目录tools
$ cd tools

运行其中的wineinstall程序
$ wineinstall

该程序会自动运行./configure,然后显示:“We need to install wine as root user, do you want us to build wine,'su root' and install Wine? Enter 'no' to continue without installing(yes/no)”,键入yes,继续安装

安装过程耗时比较长,中间会提示让输入root的密码,照办就是。
待屏幕上出现:Installation complete for now. If you have problems with Wine, please read the documentation first,as many kinds of potential problems are explained there. 表示安装成功了。

这时wine已经可以用了,可以用wine自带的写字板做检验,在任意目录下,终端中键入
$ wine wordpad
就会看到和Windows下熟悉的写字板,亲切吧,嘿嘿,试试各项功能,一切正常。

这样就算安装结束了,在终端键入
$ winecfg
就会看到一个设置面板,可以在里面按照自己的需要设置一下,如果只为用MEGA是不用改动默认设置的。

2)MEGA 4 LE的安装

首先从MEGA官网上下载最新的MEGA LE 4.0.2的rpm包,放在本地任意目录 ,下载地址为http://www.megasoftware.net/mega_linux.html

然后就要开始安装了,下面是MEGA官网上的安装说明,似乎很简单

Installation Instruction
The installation of MEGA 4 LE depends on the X kernel that you use. Most of the time, the installation will start automatically after clicking the Submit and Download button on this page. Generally, the download window will open with two options:

Option 1: Open with Software Installer
By choosing this option, the package manager will guide you through the installation.
1. You will be asked to enter your root password
2. The Installing Packages window will be open: click the Apply button to start the installation
3. The installer will check the MEGA dependencies. If the Dependencies Added window opens, then click Continue or Install Anyway to install the necessary dependencies.

Option 2: Save to disk
If you choose this option, you can install MEGA manually.
1. Login as super user or root
2. Make sure that you have RPM installed. If you don't, then key in the following command to install it:
yum install rpm
3. If you don't have WINE installed, you will need to install Wine by yum install wine
4. After you get RPM, you can install MEGA 4 LE by typing:
rpm -i MEGA-4-01.i386.rpm
or:
rpm -Uvh MEGA-4-01.i386.rpm

但实际操作起来,可就没这么轻松了,我每次我尝试用 rpm -i MEGA-4-01.i386.rpm 安装mega,都会被提示缺少wine支持,可我明明装wine了啊,问题出在哪呢?我查遍baidu, google和wiki,也没找到答案,可能是使用人群过少的缘故吧,那MEGA官网上的用户论坛中总该有人碰到过相似问题吧,结果一点告我 The User Discussion Forum is currently under development and will become available shortly. 简直ft死了...那还是自己动手,丰衣足食吧。

既然没法直接安装rpm包,那先想办法看看其中的内容吧,在网上找到一个很牛的命令,顺利将rpm包解压。终端中键入:
$ rpm2cpio MEGA-4-01.i386.rpm | cpio -idmv
这样就会看到解压出usr和var两个子文件夹

另外还得看看默认安装的话MEGA会被装到那里,运行
$ rpm -qipl MEGA-4-01.i386.rpm
就会看到rpm包中各部分文件应被安装到的目录,发现基本上都在/usr/local/bin或者/var/下面

这样就好办了,照这列出来的安装目录,把我们刚解压出的/usr和/var下面对应目录的文件拷过去了事,具体操作如下。
在root下,将刚解压出的usr文件夹中/local/bin/下的MEGA文件夹和一个名为mega的文件拷到系统目录/usr/local/bin/下。再将解压出的var文件夹中的/log/下的mega文件拷到系统目录/var/log/下。

然后再在终端中敲入
$ mega
依然会提示不能运行,但这次列出了问题所在,提示在/usr/bin/下找不到wine支持,这是当然的,因为我们的Wine默认安装在了/usr/local/bin/下面嘛,呵呵。

知道了问题出在哪里,解决起来也就容易了。找到刚才拷过去的/usr/local/bin下的那个mega文件,其实就是一个bash脚本,用文本编辑器打开。
将其中的“if [ -e /usr/bin/wine ]”一行改为“if [ -e /usr/local/bin/wine ]”,然后保存

退出root,在普通账户下,再试试,终端中输入:
$ mega
会看到弹出一个安装Mozilla ActiveX control 插件的对话框,和Windows下的对话框一样,点击安装就行了。安装完毕后会自动启动MEGA LE,现在MEGA LE已经可以正常使用了。

为了支持多用户使用,还需要把拷到/usr/local/bin下的那个MEGA文件夹及其下面所有目录和文件的权限用chmod命令改为777。
$ chmod 777 文件或目录名

对于系统的每一个独立用户,直接在终端中敲入$ mega即可运行,首次运行时会弹出安装Mozilla ActiveX control 的对话框,照办安装即可。

至此全部安装结束:)

后记

这个安装过程比昨天写的那个hmmpfam的过程要复杂一些,还是希望MEGA能早日开发出不依赖于Wine的Linux版本,也省的我们再去这样折腾了,呵呵。

BTW:
本次安装所使用的OS平台为:Redhat Enterprise Linux Server Release 5.2 (Tikanga)

No comments: