源码自动化管理系列一: Mercurial + Apache配置

    

      这段时间一直想配置一套自动化的源码管理服务器,包括:源码版本管理,持续集成,自动进行编译、单元测试、源码测试覆盖率统计,文档生成,基本的冒烟测试和测试目标的发布等等。

      基于当前工作,首先选择了Mercurial分布式版本管理工具,Apache Http服务器,Buildbot持续集成工具搭建源码管理服务器,自动编译、单元测试、源码覆盖率等放在后续过程中。

     本文主要简单介绍基于Apache实现Mercurial版本库的Http发布配置方法。


     一、Mercurial安装

            建议下载源码进行安装(源码包中会包含hgweb.cgi,稍后配置http时需要):

                   http://mercurial.selenic.com/release/

                   http://mercurial.selenic.com/wiki/Download


            当前最新稳定版为1.9,可以通过下面的方式安装:

                   $ wget http://mercurial.selenic.com/release/mercurial-1.9.tar.gz

                   $ tar -zxvf mercurial-1.9.tar.gz

mercurial-1.9

                   $ make  or make all

                   $ make install

            如果安装过程报错:

                   python runrst hgmanpage  --halt warning \
                      --strip-elements-with-class htmlonly hg.1.txt hg.1
                   abort: couldn't generate documentation: docutils module is missing

           需要先安装docutils
                $ wget http://prdownloads.sourceforge.net/docutils/docutils-0.7.tar.gz?download
                   $ tar -zxf docutils-0.7.tar.gz
                   $ cd docutils-0.7
                   $ python setup.py install

            其它缺少模块的错误,请自行安装相应的模块。


            $ make debuginstall                     # 测试安装情况

           如果出现以下错误:
                Checking username...
                no username supplied (see "hg help config")
                (specify a username in your .hgrc file)
               1 problems detected, please check your install!
           说明配置有问题,源码中contrib文件夹下提供了一个sample.hgrc,可以拷贝过来修改:

           找到这行:# username = xxx <xxxx @example.com>
           去掉前面的#号,修改名称为你自己的,然后保存退出。

         

            如果出现:No problems detected表示Mercurial可以使用了。

         详细安装过程参照:http://mercurial.selenic.com/wiki/UnixInstall


   二、Mercurial配置

         Mercurial的使用方法本文不作介绍,请查阅其它文档。

         1. 创建源码库:

             $ cd /usr/local/generic_libraries/repo                     # 目录apache必须能够访问

             $ hg init

             $ cat .hg/hgrc

                [ui]
                username = xxx<xxx@xxx.com>

                [web]
                contact = xxxx <xxx@xxx.com>                      
                description = general strings functions library      
                #name = repo # alias name                            
                allow_archive = gz, zip, bz2                             
                push_ssl = false                                            
                allow_push = *                                             

         2. hgweb.cgi文件

             在源码包中找到hgweb.cgi文件,拷贝到/usr/local/apache2/htdocs/hgweb/(其它目录也可以,注意访问权限,本文中使用此目录)   

              修改hgweb.cgi文件:

                     config = "hgweb.config"  # 当前目录下的hgweb.config文件

         3. hgweb.config文件

              创建hgweb.config文件,内容如下:

              $ cat /usr/local/apache2/htdocs/hgweb/hgweb.config

                [paths]
                repo = /usr/local/generic_libraries/repo                          # 源码库位置

                   others = /usr/local/generic_libraries/others_repo

       

   三、Apache配置

        Apache安装本文不作介绍,请查阅相关文档。

         ScriptAliasMatch ^/hg/(.*)  /usr/local/apache2/htdocs/hgweb/hgweb.cgi/$1

         <Directory /usr/local/apache2/htdocs/hgweb/>
              Options ExecCGI FollowSymLinks
              AllowOverride None
          </Directory>

        本文将cgi脚本放入apache安装目录,是为了httpd.conf的设置方便,配置过程中,存在的主要问题是hgweb.cgi和源码库的访问权限问题,这个需要自行设置。


          启动/重启Apache,访问主页http://localhost/hg/,应该可以看到源码库了,通过hg clone http://localhost/hg/repo也能够访问。

    

   本文只是简单的配置过程,适合新手练习,开始考虑加入权限控制,后来发现apache没有包含相应的模块,而且也是apache的基本配置,作为练习,此处最后也没有加入。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值