您的位置:首页 > 编程语言 > Python开发

viewvc 安装配置指南

2006-09-11 15:03 501 查看
<!--[if !supportLists]-->1.<!--[endif]-->概述
viewvc是一个基于web的CVS、SVN代码仓库浏览工具。它最早是从cvsweb发展而来的,cvsweb是用Perl编写的,viewvc原作者Greg Stein发现很难在此基础上扩展新的功能,于是用Python重新实现,并命名为viewcvs。后来又加入了对SVN代码仓库的支持,为反映这一变化viewcvs重命名为viewvc。viewvc可以以独立的程序运行(standalone.py),也可以以cgi方式运行于支持CGI的web服务器,还可以以ASP模式运行于IIS,以mod_python模式运行于Apache。viewvc通过本地文件系统访问代码仓库,所以它必须安装在运行CVS或SVN代码仓库的同一服务器上。运行viewvc需要很多第三方软件,具体需要的依赖软件取决于启用功能和运行平台两大因素。viewvc除了支持CVS代码仓库浏览功能,还支持
1)SVN代码仓库浏览功能
2)代码语法加亮、颜色标注
3)CVS代码修订历史图形显示
4)CVS代码代码提交动作的记录、查询
本文以Windows系统下实现上述1,2,3三个功能为例说明viewvc + Apache CGI的安装配置过程。具体环境是Windows XP SP2,CVSNT 2.5.03,Subversion 1.3.0,viewvc-1.0-dev(r1278)。根据这些功能要求需要以下依赖软件:
1)Python 运行时
2)Subversion及Subversion Python绑定
3)Enscript(http://www.codento.com/people/mtr/genscript/)或者Highlight, code colorizer, 2.4.2及以上版本(http://www.andre-simon.de/)
4)CvsGraph 1.5.0或更高(http://www.akhphd.au.dk/~bertho/cvsgraph/)
在Windows平台上,由于viewvc使用了Python的Win32扩展模块,所以第一项依赖软件包除了安装官方发布的Python外,还需要Python Win32扩展模块(可从从http://starship.python.net/crew/mhammond/win32/下载)。为了省去另行安装的麻烦,可以使用ActiveState提供的Windows版的ActivePython,它包含了Python Win32扩展模块,使得安装更为便捷。第二项依赖软件包可以从Subversion的官方网站获取。Enscript和highlight都可以对代码进行语法加亮、颜色标注,但由于Enscript相对比较旧,支持的语言相对较少,而且本身又有依赖,所以第三项依赖软件包采用功能更丰富、开发相对比较活跃的highlight。
整个安装配置的过程大致是:
1)获取viewvc及其依赖的软件包
2)安装配置viewvc依赖的软件包
3)安装viewvc
4)配置viewvc
5)测试
6)集成到Apache
<!--[if !supportLists]-->2.<!--[endif]-->获取viewvc及其依赖的软件包
<!--[if !supportLists]-->2.1.<!--[endif]-->获取viewvc
获取viewvc可以从http://www.viewvc.org/download.html下载。目前,viewvc的稳定版本是0.94,但该版本对Windows系统的支持有问题,使用它默认的安装方式往往无法成功。而且,功能不及现在1.0-dev版本全面,事实上,很多开源组织(sourceforge.net参见http://svn.sourceforge.net/viewcvs.cgi/vienna-rss/trunk/2.0.0/;apache参见http://svn.apache.org/viewcvs.cgi/)都使用了该版本,所以推荐使用1.0-dev版本。
获得viewvc 1.0-dev版本需要用svn从viewvc的开发网站http://viewvc.tigris.org checkout代码具体命令:
svn co http://viewvc.tigris.org/svn/viewvc/trunk/ viewvc-1.0-dev
E:/>svn co http://viewvc.tigris.org/svn/viewvc/trunk/ viewvc-1.0-de
A viewvc-1.0-dev/www
A viewvc-1.0-dev/www/project_tools.html
A viewvc-1.0-dev/www/index.html
A viewvc-1.0-dev/tparse/tparsemodule.cpp
A viewvc-1.0-dev/tparse/INSTALL
A viewvc-1.0-dev/tparse/Setup.py
A viewvc-1.0-dev/tparse/CHANGES
A viewvc-1.0-dev/tparse/tparsemodule.h
A viewvc-1.0-dev/tparse/.cvsignore
A viewvc-1.0-dev/tparse/README
A viewvc-1.0-dev/templates
A viewvc-1.0-dev/templates/diff.ezt
A viewvc-1.0-dev/templates/docroot
......
A viewvc-1.0-dev/elemx/elx_page.sh
A viewvc-1.0-dev/elemx/elx.h
A viewvc-1.0-dev/viewcvs.conf.dist
取出修订版 1278。
帐号可以用guest,密码可以用guest
<!--[if !supportLists]-->2.2.<!--[endif]-->获取Subversion Python绑定
Subversion Python绑定是一些访问Subversion功能的Python模块,在Subversion的每个主要版本发布时都会发布相应的Python绑定。二进制文件可以从以下链接处获得http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91。目前,官方发布的Subversion 1.3.0的Python绑定是针对Python 2.3的,无法在不同版本Python上使用,比如无法在Python 2.4使用。所以,安装Python时可以使用2.3.x的版本,或则是自己编译Python 2.4的Subversion绑定,具体方法在http://svn.collab.net/repos/svn/trunk/subversion/bindings/swig/INSTALL处说明。当然也可以在网上搜索现成的Python 2.4 Subversion绑定。
<!--[if !supportLists]-->2.3.<!--[endif]-->获取ActivePython
从http://www.activestate.com/Products/ActivePython/处下一个和Subversion Python绑定兼容的版本。
<!--[if !supportLists]-->2.4.<!--[endif]-->获取CvsGraph
为支持CVS代码修订历史图形显示功能,viewvc需要CvsGraph 1.5.0 或以上的版本,可以从http://www.akhphd.au.dk/~bertho/cvsgraph/ 处下载Windows版的cvsgraph-1.5.2-bin.zip,解压缩至某个目录,假定是D:/OSS/cvsgraph-1.5.2。
<!--[if !supportLists]-->2.5.<!--[endif]-->获取Highlight
为支持代码语法加亮功能,viewvc需要Highlight, code colorizer, 2.4.2及以上版本,可以从http://www.andre-simon.de/ 处下载Windows版的highlight-2.4.4.zip。解压缩至某个目录,假定是D:/OSS/highlight-2.4.4。
<!--[if !supportLists]-->3.<!--[endif]-->安装配置viewvc依赖的软件包
<!--[if !supportLists]-->3.1.<!--[endif]-->安装Python
首先,安装Python,假定是ActivePython 2.3.5,运行安装程序,将Python安装到C:/Python23。
<!--[if !supportLists]-->3.2.<!--[endif]-->安装Subversion Python绑定
然后,解开Subversion Perl绑定压缩包svn-win32-1.3.0_py.zip,将其中的两个子目录svn、libsvn拷贝到C:/Python23/Lib目录下。
<!--[if !supportLists]-->3.3.<!--[endif]-->安装CvsGraph
将下载的cvsgraph-1.5.2-bin.zip发行包解压缩至某个目录,假定是D:/OSS/cvsgraph-1.5.2。
<!--[if !supportLists]-->3.4.<!--[endif]-->安装Highlight
将下载的highlight发行包解压缩至某个目录,假定是D:/OSS/highlight-2.4.4。
<!--[if !supportLists]-->4.<!--[endif]-->安装配置viewvc
到viewvc的发行版目录下(本例为E:/viewvc-1.0-dev),运行python viewcvs-install
E:/viewvc-1.0-dev>python viewcvs-install
This is the ViewVC 1.0-dev installer.
It will allow you to choose the install path for ViewVC. You will
now be asked some installation questions.
Defaults are given in square brackets. Just hit [Enter] if a default
is okay.
Installation path [C:/Program Files/viewvc-1.0-dev]: e:/viewvc2
DESTDIR path (generally, only package maintainers will need to change
this) []:
Installing ViewVC to: e:/viewvc2
bin/cgi/viewcvs.cgi
bin/cgi/query.cgi
bin/mod_python/viewcvs.py
bin/mod_python/query.py
bin/mod_python/handler.py
bin/mod_python/.htaccess
bin/standalone.py
......
templates/revision.ezt
templates/roots.ezt
templates/rss.ezt
ViewVC File Installation Complete
Consult INSTALL for detailed information to finish the installation
and configure ViewVC for your system.
Overview of remaining steps:
1) Edit the e:/viewvc2/viewcvs.conf file.
2) Configure an existing web server to run (or copy to cgi-bin)
e:/viewvc2/bin/cgi/viewcvs.cgi.
OR
Run the web server that comes with ViewVC at
e:/viewvc2/standalone.py.
<!--[if !supportLists]-->5.<!--[endif]-->配置viewvc
接下来需要配置viewvc,主要的配置信息有cvs或svn的代码仓库的位置,cvsnt或rcs命令的的位置。这些信息在viewvc安装根目录下的的viewcvs.conf文件中,该文件采用Windows常见的.ini格式,其中的每一个参数都有详尽的解释。在该文件开头的注释部分说明了使viewvc运行起来需要设定的基本参数,以及源代码语法加亮,显示界面客户化等功能需要设定的参数。
<!--[if !supportLists]-->5.1.<!--[endif]-->基本参数
<!--[if !supportLists]-->5.1.1.<!--[endif]-->代码仓库位置参数
使viewvc运行起来需要告诉它cvs或svn的代码仓库的位置,相关参数是cvs_roots,svn_roots,这两个参数使用相同的语法:每指定一个代码仓库需要给其命名,然后指定代码仓库的绝对路径,两者用冒号分隔。如果指定多个代码库用用逗号分隔每个名称:路径字符串。示例如下:
cvs_roots = new technology: C:/cvs_repos/new_tech,
leyacy_code: C:/cvs_repos/leyacy_code,
projectA: C:/cvs_repos/projectA,
projectB: C:/cvs_repos/projectB
svn_roots = new technology: C:/svn_repos/new_tech,
leyacy_code: C:/svn_repos/leyacy_code,
productA: C:/svn_repos/productA,
productB: C:/svn_repos/productB
如果有多个代码仓库需要让viewvc通过web展示,并且这些代码仓库都在同一个目录下,可以使用参数root_parents。所以上述配置可以简写为:
root_parents = C:/svn_repos : svn,
C:/cvs_repos : cvs
<!--[if !supportLists]-->5.1.2.<!--[endif]-->cvs,svn可以执行文件位置
viewvc需要使用cvs或svn的可执行程序访问代码仓库,某些情况下需要显示指定这些可执行程序的位置。CVS的情况稍微复杂一些,如果代码库是CVSNT的,则应当使用cvsnt的cvs客户端可执行程序,以增强对CVSNT扩展特性的支持。对于标准安装的Subversion使用默认的设置即可。相关参数有cvsnt_exe_path,svn_path
cvsnt_exe_path = C:/Program Files/CVSNT/cvs.exe
use_cvsgraph = 1
cvsgraph_path =D:/OSS/cvsgraph
# should we use 'highlight' for syntax coloring?
# NOTE: use_enscript has to be 0 or enscript will be used instead
use_highlight = 1
#
# if the highlight program is not on the path, set this value
#
highlight_path = D:/OSS/highlight-2.4.4/
# what coloring style should highlight use?
highlight_style = emacs
# should we add line numbers?
highlight_line_numbers = 1
# convert tabs to ## spaces (use 0 for no conversion)
highlight_convert_tabs = 2
<!--[if !supportLists]-->5.2.<!--[endif]-->CVS代码修订历史图形显示参数
启用CVS代码修订历史图形显示功能需要将参数use_cvsgraph设为1,如果cvsgraph.exe可执行文件不在环境变量Path中,需要cvsgraph_path参数告诉viewvc cvsgraph.exe的绝对路径。此外,还可以指定cvsgraph的配置文件。以下是和highlight相关的配置示例:
#
# Use CvsGraph. See http://www.akhphd.au.dk/~bertho/cvsgraph/ for
# documentation and download.
#
use_cvsgraph = 1
#
# if the cvsgraph program is not on the path, set this value
#
cvsgraph_path =D:/OSS/cvsgraph
# cvsgraph_path = /usr/local/bin/
#
# Location of the customized cvsgraph configuration file.
# You will need an absolute pathname here:
#
cvsgraph_conf = cvsgraph.conf
<!--[if !supportLists]-->5.3.<!--[endif]-->代码语法加亮参数
启用CVS代码修订历史图形显示功能需要将参数use_highlight设为1,如果highlight.exe可执行文件不在环境变量Path中,需要highlight_path参数告诉viewvc highlight.exe的绝对路径。此外,可以设定代码风格(highlight_style),tab键转换成空格(highlight_convert_tabs)等参数。可选的代码风格可以到highlight安装目录下的themes子目录下查找相应style文件名。
D:/OSS/highlight-2.4.4/themes>dir
驱动器 D 中的卷是 work
卷的序列号是 D8A6-4C1A
D:/OSS/highlight-2.4.4/themes 的目录
2006-03-10 00:44

2006-03-10 00:44

2005-10-19 20:38 573 acid.style
2005-10-19 20:38 665 berries-dark.style
2005-10-19 20:38 671 berries-light.style
2005-10-19 20:38 664 bipolar.style
2005-10-19 20:38 629 blacknblue.style
2005-10-19 20:38 611 bright.style
2005-10-19 20:38 657 contrast.style
2005-10-19 20:38 521 darkblue.style
2005-10-19 20:38 625 darkness.style
2005-10-19 20:38 626 desert.style
2005-10-19 20:38 643 dull.style
2005-10-19 20:38 626 easter.style
2005-10-19 20:38 495 emacs.style
2005-10-19 20:38 626 golden.style
2005-10-19 20:38 620 greenlcd.style
2005-10-19 20:38 602 ide-anjuta.style
2005-10-19 20:38 454 ide-codewarrior.style
2005-10-19 20:38 609 ide-devcpp.style
2005-10-19 20:38 498 ide-eclipse.style
2005-10-19 20:38 605 ide-kdev.style
2005-10-19 20:38 609 ide-msvcpp.style
2005-10-19 20:38 469 kwrite.style
……
从上面的输出可知可选的风格有acid, berries-dark, berries-light, bipolar,ide-anjuta, ide-codewarrior, ide-devcpp, ide-eclipse, ide-kdev, ide-msvcpp等等。以下是和highlight相关的配置示例:
# should we use 'highlight' for syntax coloring?
# NOTE: use_enscript has to be 0 or enscript will be used instead
use_highlight = 1
#
# if the highlight program is not on the path, set this value
#
highlight_path = D:/OSS/highlight-2.4.4/
# what coloring style should highlight use?
highlight_style = emacs
# should we add line numbers?
highlight_line_numbers = 1
# convert tabs to ## spaces (use 0 for no conversion)
highlight_convert_tabs = 2
<!--[if !supportLists]-->5.4.<!--[endif]-->其它参数
通常address参数需要修改,它是一个给管理员发邮件的链接。
address = Tell SCM master if you have troubles in use viewvc
<!--[if !supportLists]-->6.<!--[endif]-->测试配置
配置完成后可以通过运行standalone.py来测试安装配置是否正确。运行e:/viewvc2/bin/standalone.py
E:/viewvc2/bin>standalone.py
server ready at http://localhost:7467/viewvc 打开浏览器输入http://localhost:7467/viewvc查看viewvc是否正常运行。
<!--[if !supportLists]-->7.<!--[endif]-->将viewvc和Apache集成
standalone.py启动的viewvc服务不够稳定,在生产环境通产需要和web服务器集成。viewvc以CGI方式集成到Apache中相当简单。只需要用ScriptAlias指令将viewvc安装目录下的bin/cgi子目录映射到一个URL上去。示例:
ScriptAlias /codeview/ "E:/viewvc/bin/cgi/"
重启Apache,即可通过URL:http://localhost/codeview/viewcvs.cgi访问所配置的代码仓库。
<!--[if !supportLists]-->8.<!--[endif]-->总结
安装配置viewvc涉及到众多依赖软件和参数,如果以Apache CGI方式运行viewvc同时Apache作为Windows Service运行修改配置后可能需要重启Windows才能生效。另外,如果viewvc运行不正常,常见的错误是CVS,SVN的代码仓库位置不正确,或者使用到了highlight,cvsgraph没有制定正确的路径。
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息