ubuntu 18.04 review board安装及svn设置pre-commit 和post-cmmit

数据库:使用review board默认支持的sqlit

版本管理仓库:svn

 

1 安装依赖包

sudo apt-get install apache2

sudo apt-get install libapache2-mod-python

sudo apt-get install libapache2-mod-wsgi

sudo apt-get install Memcached

sudo apt-get install memcached-dev

sudo apt-get install python-memcache

sudo apt-get install patch

sudo apt-get install subversion

sudo apt-get install python-svn

2 安装review board

sudo pip install --upgrade setuptools

sudo pip install reviewboard

报错:

Collecting PIL (from Djblets<0.8,>=0.7.32->reviewboard)

  ERROR: Could not find a version that satisfies the requirement PIL (from Djblets<0.8,>=0.7.32->reviewboard) (from versions: none)

ERROR: No matching distribution found for PIL (from Djblets<0.8,>=0.7.32->reviewboard)

 

解决方法:

python -m pip install --upgrade pip

下载的是ReviewBoared1.7的配套依赖,因为/usr/local/lib/python2.7/dist-packages下已经有ReviewBoard-1.7.29-py2.7.egg文件夹,将这个文件夹命名为ReviewBoard-1.7.29-py2.7.egg_bk就可以了。

再次执行sudo -H pip install reviewboard

就会下载最新的ReviewBoard.

发现要下载的包太多了,会超时。于是,把pip超时设置为3600秒。

sudo -H pip –timeout 3600 install reviewboard

安装成功,打印下面的语句:

Successfully built django-oauth-toolkit django-multiselectfield mimeparse django-cors-headers pillowfight publicsuffix feedparser oauthlib PyYAML pycparser

Installing collected packages: pytz, markdown, pymdown-extensions, Pygments, Pillow, pillowfight, publicsuffix, futures, django-pipeline, python-dateutil, Django, dnspython, feedparser, Djblets, Whoosh, python-memcached, django-braces, oauthlib, django-oauth-toolkit, pycparser, cffi, pynacl, pyasn1, bcrypt, paramiko, django-evolution, urllib3, certifi, chardet, requests, requests-oauthlib, asana, PyYAML, rbintegrations, django-multiselectfield, mimeparse, django-cors-headers, docutils, django-haystack, reviewboard

Successfully installed Django-1.6.11 Djblets-1.0.11 Pillow-6.0.0 PyYAML-5.1 Pygments-2.4.2 Whoosh-2.7.4 asana-0.8.2 bcrypt-3.1.6 certifi-2019.3.9 cffi-1.12.3 chardet-3.0.4 django-braces-1.13.0 django-cors-headers-1.1.0 django-evolution-0.7.8 django-haystack-2.4.1 django-multiselectfield-0.1.8 django-oauth-toolkit-0.9.0 django-pipeline-1.6.14 dnspython-1.16.0 docutils-0.14 feedparser-5.2.1 futures-3.2.0 markdown-2.6.11 mimeparse-0.1.3 oauthlib-1.0.1 paramiko-2.4.2 pillowfight-0.3 publicsuffix-1.1.0 pyasn1-0.4.5 pycparser-2.19 pymdown-extensions-3.5 pynacl-1.3.0 python-dateutil-2.8.0 python-memcached-1.59 pytz-2019.1 rbintegrations-1.0 requests-2.22.0 requests-oauthlib-0.8.0 reviewboard-3.0.14 urllib3-1.25.3

 

到此,已安装成功review board.

3 配置站点:

sudo rb-site install /var/www/html/reviewboard

在弹出的一系列配置项里配置为以下的值:

Domain =  localhost

Root Path = / (默认)

Database Type = sqlite

Memcached Server = localhost:11211 (默认)

Username = zhangjing

Password = 密码

Confirm Password = 密码

E-mail = [email protected]

Company/Organization = 随意

Allow us to collect support data = n

4 修改目录权限

sudo chown -R www-data /var/www/html/reviewboard/htdocs/media/uploaded/

sudo chown -R www-data /var/www/html/reviewboard/htdocs/media/ext

sudo chown -R www-data /var/www/html/reviewboard/data

5 拷贝配置文件

sudo cd /etc/apache2/sites-available

sudo cp /var/www/html/reviewboard/conf/apache-wsgi.conf reviewboard.conf

sudo cd ../sites-enabled

sudo ln -s ../sites-available/reviewboard.conf .

sudo a2ensite reviewboard

由于apache2服务器配置了mantis,需要让apache2配置2个网站

6 配置网站服务器

Cd /etc/apache2

修改ports.conf,增加Listen 8060:

Listen 8050

Listen 8060

 

<IfModule ssl_module>

      Listen 443

</IfModule>

 

<IfModule mod_gnutls.c>

      Listen 443

</IfModule>

修改/etc/apache2/sites-enabled/000-default.conf,

把reviewboard.conf的内容copy到000-default.conf中:

<VirtualHost *:8050>

      # The ServerName directive sets the request scheme, hostname and port that

      # the server uses to identify itself. This is used when creating

      # redirection URLs. In the context of virtual hosts, the ServerName

      # specifies what hostname must appear in the request's Host: header to

      # match this virtual host. For the default virtual host (this file) this

      # value is not decisive as it is used as a last resort host regardless.

      # However, you must set it for any further virtual host explicitly.

      #ServerName www.example.com

 

      ServerAdmin webmaster@localhost

      DocumentRoot /var/www/html/mantisbt

 

      # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,

      # error, crit, alert, emerg.

      # It is also possible to configure the loglevel for particular

      # modules, e.g.

      #LogLevel info ssl:warn

 

      ErrorLog ${APACHE_LOG_DIR}/error.log

      CustomLog ${APACHE_LOG_DIR}/access.log combined

 

      # For most configuration files from conf-available/, which are

      # enabled or disabled at a global level, it is possible to

      # include a line for only one particular virtual host. For example the

      # following line enables the CGI configuration for this host only

      # after it has been globally disabled with "a2disconf".

      #Include conf-available/serve-cgi-bin.conf

 

 

      ServerName bt.example.com

      ServerAlias www.bt.example.com

      <Directory "/var/www/html/mantisbt/">

      DirectoryIndex index.php index.html

      Options FollowSymLinks

      AllowOverride None

      Require all granted

      Options MultiViews FollowSymlinks

      </Directory>

 

</VirtualHost>

 

<VirtualHost *:8060>

        ServerName localhost

        DocumentRoot "/var/www/html/reviewboard/htdocs"

 

        # Error handlers

        ErrorDocument 500 /errordocs/500.html

 

        WSGIPassAuthorization On

        WSGIScriptAlias "/" "/var/www/html/reviewboard/htdocs/reviewboard.wsgi/"

 

        <Directory "/var/www/html/reviewboard/htdocs">

                AllowOverride All

                Options -Indexes +FollowSymLinks

                Allow from all

        </Directory>

 

        # Prevent the server from processing or allowing the rendering of

        # certain file types.

        <Location "/media/uploaded">

                SetHandler None

                Options None

 

                AddType text/plain .html .htm .shtml .php .php3 .php4 .php5 .phps .asp

                AddType text/plain .pl .py .fcgi .cgi .phtml .phtm .pht .jsp .sh .rb

 

                <IfModule mod_php5.c>

                        php_flag engine off

                </IfModule>

 

                # Force all uploaded media files to download.

                <IfModule mod_headers.c>

                        Header set Content-Disposition "attachment"

                </IfModule>

        </Location>

 

        ErrorLog ${APACHE_LOG_DIR}/error.log

        CustomLog ${APACHE_LOG_DIR}/access.log combined

 

        # Alias static media requests to filesystem

        Alias /media "/var/www/html/reviewboard/htdocs/media"

        Alias /static "/var/www/html/reviewboard/htdocs/static"

        Alias /errordocs "/var/www/html/reviewboard/htdocs/errordocs"

        Alias /favicon.ico "/var/www/html/reviewboard/htdocs/static/rb/images/favicon.png"

</VirtualHost>

重启apache2

sudo systemctl restart apache2

查看端口情况

sudo netstat -apn | grep apache2

 

查看apache2的网页http://ip:8060,报错:

[Wed May 29 17:11:47.363190 2019] [wsgi:crit] [pid 29085] mod_wsgi (pid=29085): The mod_python module can not be used in conjunction with mod_wsgi 4.0+. Remove the mod_python module from the Apache configuration.

AH00016: Configuration Failed

卸载mod-python

sudo apt-get remove --purge libapache2-mod-python

发现卸载的是3.3.3版本的mod_python,推断应该是mod_python 3.3.3不是最新版本。

 

再次访问http://ip:8060网页,报错:

[Wed May 29 10:38:56.424436 2019] [wsgi:error] [pid 4199] [client 192.168.2.40:56319] No handlers could be found for logger "djblets.extensions.manager"

还是需要安装mod_python组件。

https://github.com/grisha/mod_python

clone git上的最新代码,就是mod_python3.5.0版本的。

$ ./configure

$ make

$ sudo make install

装的过程中报错:rely on aspx

Aspx是apache2-dev的一个组件

sudo apt install apache2-dev

都安装好后,访问http://192.168.2.249:8060 报错: the page hints you to run sudo chown -R www-data "/var/www/html/reviewboard/htdocs/static/ext"

赋权限后,再次访问http://192.168.2.249:8060,成功了。

安装好mod_python后,可以正常访问网页了

由于使用的是sqlite数据库,所以运行命令:

sudo apt-get install sqlite

重启apache2

sudo systemctl restart apache2

查看端口情况

sudo netstat -apn | grep apache2

 

7 操作网页

网上有现成的,可以参考网页:

https://wenku.baidu.com/view/90c1ed1a773231126edb6f1aff00bed5b9f37373.html

8 配置svn hooks: pre commit

http://pypi.python.org/pypi/reviewboard-svn-hooks

copy到svn仓库所在的服务器

解压并进入解压后的目录进行安装:

python setup.py install

安装成功之后修改如下文件:

/etc/reviewboard-svn-hooks/conf.ini

修改为:

  GNU nano 2.9.3                                                                                                     /etc/reviewboard-svn-hooks/conf.ini                                                                                                     Modified 

 

[common]

debug=0

 

[reviewboard]

url=http://ip:port

username=zhangjing

password=admin

 

[rule]

min_ship_it_count=2

min_expert_ship_it_count=2

experts=user1,user2

 

review_path=

ignore_path=

 

svn hooks配置

 

pre-commit

修改$REPOS/hooks/下的pri-commit文件内容为

#!/bin/sh

REPOS="$1" 

TXN="$2" 

strict_review $REPOS $TXN 

exit $?

具体使用请参考第7步。

9 配置svn hooks:post-commit

在 review board所在的服务器上安装RBTools,如果不行,再把svn所在的服务器上也安装好RBTools.

sudo pip install RBTools

查看Review board网页上配置的svn仓库参数,最好将name与svn仓库的真实文件夹名称设置为一致的。

设置完成后,点击左侧的repositories-->RBTools Setup

 

 

找一个linux虚拟机,checkout一套代码出来。进入代码目录,运行脚本命令:

rbt setup-repo

既可创建.reviewboardrc。创建过程中根据提示输入配置。

REVIEWBOARD_URL = "http://ip:port/"
REPOSITORY = "svn仓库文件夹名称"
REPOSITORY_TYPE = "svn"
 

文件生成后,在此代码路径下修改并提交代码。

然后登陆review board,点击new review request,选择已存在的历史提交。之后填写Reviewers   people,就可以生成Review request了。

参考:

https://www.cnblogs.com/daniaoge/archive/2011/12/29/6161223.html

https://blog.csdn.net/qq_26709459/article/details/80445375

https://blog.csdn.net/u011771638/article/details/36407971

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章