热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

第6章Subversion

目录6.1.InvokingtheServer6.1.1.Installing6.1.1.1.Ubuntu6.1.1.2.CentOS56.1.1.2.1.classicUnix-

目录

6.1. Invoking the Server
6.1.1. Installing
6.1.1.1. Ubuntu6.1.1.2. CentOS 5
6.1.1.2.1. classic Unix-like xinetd daemon6.1.1.2.2. WebDav6.1.1.2.3. 项目目录结构
6.1.1.3. CentOS 6
6.1.2. standalone “daemon” process
6.1.2.1. starting subversion for debian/ubuntu6.1.2.2. starting subversion daemon script for CentOS/Radhat
6.1.3. classic Unix-like inetd daemon6.1.4. hooks
6.1.4.1. post-commit
6.1.5. WebDav
6.1.5.1. davfs2 - mount a WebDAV resource as a regular file system
6.2. repository 管理
6.2.1. create repository6.2.2. user admin6.2.3. authz6.2.4. dump
6.3. 使用Subversion
6.3.1. Initialized empty subversion repository for project6.3.2. ignore6.3.3. 关键字替换6.3.4. lock 加锁/ unlock 解锁6.3.5. import6.3.6. export 指定版本6.3.7. 修订版本关键字6.3.8. 恢复旧版本
6.4. branch
6.4.1. create6.4.2. remove6.4.3. switch6.4.4. merge6.4.5. relocate
6.5. FAQ
6.5.1. 递归添加文件6.5.2. 清除项目里的所有.svn目录6.5.3. color diff6.5.4. cvs2svn6.5.5. Macromedia Dreamweaver MX 2004 + WebDAV +Subversion6.5.6. 指定用户名与密码

6.1. Invoking the Server

配置开发环境版本控制Subversion

Squid + Subversion 请参考Squid一节

6.1.1. Installing

6.1.1.1. Ubuntu

过程 6.1. subversion

  1. installation

    $ sudo apt-get install subversion

    $ sudo apt-get install subversion

  2. create svn group and svnroot user

    $ sudo groupadd svn
    $ sudo adduser svnroot --ingroup svn

  3. create repository

    $ svnadmin create /home/svnroot/test

  4. testing

    svnroot@netkiller:~$ svnserve -d --foreground -r /home/svnroot/

    check out

    neo@netkiller:/tmp$ svn list svn://localhost/test

    you may see some file and directory

    neo@netkiller:/tmp$ ls test/.svn/
    entries format prop-base props text-base tmp

  5. configure

    $ vim repositories/conf/svnserve.conf

    [general]
    anon-access = read
    auth-access = write
    password-db = passwd
    # authz-db = authz
    # realm = My First Repository

    $ vim repositories/conf/passwd

    [users]
    # harry = harryssecret
    # sally = sallyssecret
    neo = chen

    如果不允许匿名用户checkout代码,配置文件这样写anon-access = none

    [general]
    anon-access = none
    auth-access = write

  6. firewall

    $ sudo ufw allow svn

6.1.1.2. CentOS 5


[root@development ~]# yum -y install subversion

6.1.1.2.1. classic Unix-like xinetd daemon


[root@development ~]# vim /etc/xinetd.d/subversion
service subversion
{disable = noport = 3690socket_type = streamprotocol = tcpwait = nouser = svnrootserver = /usr/bin/svnserveserver_args = -i -r /home/svnroot
}

firewall


iptables -A INPUT -p tcp -m tcp --sport 3690 -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 3690 -j ACCEPT

6.1.1.2.2. WebDav

install webdav module


[root@development ~]# yum install mod_dav_svn

create directory


mkdir /var/www/repository
svnadmin create /var/www/repository

subversion.conf


[root@development ~]# vim /etc/httpd/conf.d/subversion.conf
LoadModule dav_module modules/mod_dav.so
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

vhost.conf



DAV svn
SVNPath /var/www/repository
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/subversion/svn-auth-file
Require valid-user

auth file


[root@development ~]# htpasswd -c /etc/subversion/svn-auth-file my_user_name

6.1.1.2.3. 项目目录结构

–trunk #存放主线

–branches #存放分支,可修改

–tags #存放标记,不可修改

6.1.1.3. CentOS 6

CentOS 6 默认没有安装xinetd

# yum install xinetd
# yum install subversion# mkdir -p /opt/svnroot

xinetd 配置

# vim /etc/xinetd.d/svn
service svn
{disable = noport = 3690socket_type = streamprotocol = tcpwait = nouser = svnrootserver = /usr/bin/svnserveserver_args = -i -r /opt/svnroot
}# /etc/init.d/xinetd restart
Stopping xinetd: [FAILED]
Starting xinetd: [ OK ]# tail /var/log/messages | grep xinetd
May 5 18:57:20 SZVM42-C1-02 yum: Installed: 2:xinetd-2.3.14-16.el5.i386
May 5 18:59:22 SZVM42-C1-02 xinetd[4558]: Unknown user: svnroot [file=/etc/xinetd.d/svn] [line=8]
May 5 18:59:22 SZVM42-C1-02 xinetd[4558]: Error parsing attribute user - DISABLING SERVICE[file=/etc/xinetd.d/svn] [line=8]
May 5 18:59:22 SZVM42-C1-02 xinetd[4558]: xinetd Version 2.3.14 started with libwrap loadavg labeled-networkingoptions compiled in.
May 5 18:59:22 SZVM42-C1-02 xinetd[4558]: Started working: 0 available services

service 名字必须与 /etc/services中定义的名字相同,否则将不能启动,同时在/var/log/message中会提示如下

May 4 14:33:08 www xinetd[5656]: service/protocol combination not in /etc/services: subversion/tcp
May 4 14:33:08 www xinetd[5656]: xinetd Version 2.3.14 started with libwrap loadavg labeled-networking options compiled in.
May 4 14:33:08 www xinetd[5656]: Started working: 0 available services
May 4 14:33:33 www pulseaudio[21913]: sink-input.c: Failed to create sink input: too many inputs per sink.
May 4 14:33:33 www pulseaudio[21913]: sink-input.c: Failed to create sink input: too many inputs per sink.
May 4 14:33:33 www pulseaudio[21913]: sink-input.c: Failed to create sink input: too many inputs per sink.
May 4 14:33:33 www pulseaudio[21913]: sink-input.c: Failed to create sink input: too many inputs per sink.
May 4 14:33:33 www pulseaudio[21913]: sink-input.c: Failed to create sink input: too many inputs per sink.
May 4 14:33:33 www pulseaudio[21913]: sink-input.c: Failed to create sink input: too many inputs per sink.
May 4 14:33:33 www pulseaudio[21913]: sink-input.c: Failed to create sink input: too many inputs per sink.
May 4 14:33:33 www pulseaudio[21913]: sink-input.c: Failed to create sink input: too many inputs per sink.
May 4 14:33:41 www xinetd[5656]: Exiting...
May 4 14:33:41 www xinetd[5676]: xinetd Version 2.3.14 started with libwrap loadavg labeled-networking options compiled in.
May 4 14:33:41 www xinetd[5676]: Started working: 1 available service

6.1.2. standalone “daemon” process

svn daemon

$ svnserve --daemon --root /home/svnroot

6.1.2.1. starting subversion for debian/ubuntu

/etc/init.d/subversion for debian/ubuntu


debian:/etc/init.d# cat subversion
#!/bin/sh
### BEGIN INIT INFO
# Provides: subversion
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Should-Start: fam
# Should-Stop: fam
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the subversion subversion server.
### END INIT INFO#########################
# Author: Neo
#########################PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/svnserve
NAME=subversion
DESC="subversion server"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
SVNROOT=/srv/svnroot
DAEMON_OPTS="-d -T -r $SVNROOT --pid-file $PIDFILE"test -x $DAEMON || exit 0set -e. /lib/lsb/init-functionscase "$1" instart)log_daemon_msg "Starting $DESC" $NAMEecho$DAEMON $DAEMON_OPTSecho `pgrep -o $NAME` > $PIDFILE > /dev/null 2> /dev/null;;stop)log_daemon_msg "Stopping $DESC" $NAMEechokillall `basename $DAEMON` > /dev/null 2> /dev/nullrm -rf $PIDFILE;;restart)$0 stop$0 start;;status)ps ax | grep $NAME;;*)echo "Usage: $SCRIPTNAME {start|stop|restart|status}" >&2exit 1;;
esacexit 0

6.1.2.2. starting subversion daemon script for CentOS/Radhat


#!/bin/bash
#
# /etc/rc.d/init.d/subversion
#
# Starts the Subversion Daemon
#
# chkconfig: 345 90 10
#
# description: Subversion Daemon# processname: svnservesource /etc/rc.d/init.d/functions[ -x /usr/bin/svnserve ] || exit 1### Default variables
SYSCONFIG="/etc/sysconfig/subversion"### Read configuration
[ -r "$SYSCONFIG" ] && source "$SYSCONFIG"RETVAL=0
USER="svnroot"
prog="svnserve"
desc="Subversion Daemon"start() {echo -n $"Starting $desc ($prog): "daemon --user $USER $prog -d $OPTIONSRETVAL=$?[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$progecho
}stop() {echo -n $"Shutting down $desc ($prog): "killproc $progRETVAL=$?[ $RETVAL -eq 0 ] && success || failureecho[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$progreturn $RETVAL
}case "$1" instart)start;;stop)stop;;restart)stopstartRETVAL=$?;;condrestart)[ -e /var/lock/subsys/$prog ] && restartRETVAL=$?;;*)echo $"Usage: $0 {start|stop|restart|condrestart}"RETVAL=1
esacexit $RETVAL

/etc/sysconfig/subversion

# Configuration file for the Subversion service#
# To pass additional options (for instace, -r root of directory to server) to
# the svnserve binary at startup, set OPTIONS here.
#
#OPTIONS=
OPTIONS="--threads --root /srv/svnroot"

6.1.3. classic Unix-like inetd daemon

/etc/inetd.conf

svn stream tcp nowait svn /usr/bin/svnserve svnserve -i -r /home/svnroot/repositories

xinetd.d

/etc/xinetd.d/subversion

$ sudo apt-get install xinetd
$ sudo vim /etc/xinetd.d/subversionservice subversion
{disable = noport = 3690socket_type = streamprotocol = tcpwait = nouser = svnrootserver = /usr/bin/svnserveserver_args = -i -r /home/svnroot
}

restart xinetd

$ sudo /etc/init.d/xinetd restart

6.1.4. hooks

$ sudo apt-get install subversion-tools

6.1.4.1. post-commit

install SVN::Notify

perl -MCPAN -e 'install SVN::Notify'


$ sudo cp post-commit.tmpl post-commit
$ sudo chown svnroot:svn post-commit
$ sudo vim post-commitREPOS="$1"
REV="$2"#/usr/share/subversion/hook-scripts/commit-email.pl "$REPOS" "$REV" openunix@163.com
/usr/share/subversion/hook-scripts/commit-email.pl "$1" "$2" --from neo@netkiller.8800.org -h localhost -s "[SVN]" --diff y openunix@163.com openx@163.com

另一种方法


#!/bin/shREPOS="$1"
REV="$2"/usr/local/bin/svnnotify \--repos-path "$REPOS" \--revision "$REV" \--subject-cx \--with-diff \--handler HTML::ColorDiff \--to \--from

/usr/bin/svnnotify --repos-path "$REPOS" --revision "$REV" \
--from neo@netkiller.8800.org --to openunix@163.com --smtp localhost \
--handler "HTML::ColorDiff" --with-diff --charset zh_CN:GB2312 -g zh_CN --svnlook /usr/bin/svnlook --subject-prefix '[SVN]'

如果你没有安装邮件服务器,你可以使用服务商的SMTP如163.com

/usr/bin/svnnotify --repos-path "$REPOS" --revision "$REV" \
--from openx@163.com --to openunix@163.com --smtp smtp.163.com --smtp-user openunix --smtp-pass ****** \
--handler "HTML::ColorDiff" --with-diff --charset UTF-8 --language zh_CN --svnlook /usr/bin/svnlook --subject-prefix '[SVN]'

Charset

REPOS="$1"
REV="$2"svnnotify --repos-path "$REPOS" --revision "$REV" \--subject-cx \--from neo.chen@example.com \--to group@example.com,manager@example.com \--with-diff \--svnlook /usr/bin/svnlook \--subject-prefix '[SVN]' \--charset UTF-8 --language zh_CN

6.1.5. WebDav

Apache SVN

$ sudo apt-get install libapache2-svn

netkiller@neo:/etc/apache2$ sudo apt-get install libapache2-svn

vhost


ServerName svn.netkiller.8800.orgDocumentRoot /var/svnDAV svnSVNPath /var/svnAuthType BasicAuthName "Subversion Repository"AuthUserFile /etc/apache2/svn.passwdRequire valid-user

建立密码文件

建立第一个用户需要加-c参数

netkiller@neo:/etc/apache2$ sudo htpasswd2 -c /etc/apache2/svn.passwd svn
New password:
Re-type new password:
Adding password for user svn

输入两次密码

建立其他用户

sudo htpasswd2 /etc/apache2/svn.passwd otheruser

6.1.5.1. davfs2 - mount a WebDAV resource as a regular file system

install

$ sudo apt-get install davfs2

mount a webdav to directory

$ sudo mount.davfs https://opensvn.csie.org/netkiller /mnt/davfs/
Please enter the username to authenticate with server
https://opensvn.csie.org/netkiller or hit enter for none.
Username: svn
Please enter the password to authenticate user svn with server
https://opensvn.csie.org/netkiller or hit enter for none.
Password:
mount.davfs: the server certificate is not trustedissuer: CSIE.org, CSIE.org, Taipei, Taiwan, TWsubject: CSIE.org, CSIE.org, Taipei, TWidentity: *.csie.orgfingerprint: e6:05:eb:fb:69:5d:25:4e:11:3c:83:e8:7c:44:ee:bf:a9:85:a3:64
You only should accept this certificate, if you can
verify the fingerprint! The server might be faked
or there might be a man-in-the-middle-attack.
Accept certificate for this session? [y,N] y

test

$ ls davfs/
branches lost+found tags trunk





原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。



推荐阅读
  • 如何在服务器主机上实现文件共享的方法和工具
    本文介绍了在服务器主机上实现文件共享的方法和工具,包括Linux主机和Windows主机的文件传输方式,Web运维和FTP/SFTP客户端运维两种方式,以及使用WinSCP工具将文件上传至Linux云服务器的操作方法。此外,还介绍了在迁移过程中需要安装迁移Agent并输入目的端服务器所在华为云的AK/SK,以及主机迁移服务会收集的源端服务器信息。 ... [详细]
  • 本文介绍了使用cacti监控mssql 2005运行资源情况的操作步骤,包括安装必要的工具和驱动,测试mssql的连接,配置监控脚本等。通过php连接mssql来获取SQL 2005性能计算器的值,实现对mssql的监控。详细的操作步骤和代码请参考附件。 ... [详细]
  • LVS实现负载均衡的原理LVS负载均衡负载均衡集群是LoadBalance集群。是一种将网络上的访问流量分布于各个节点,以降低服务器压力,更好的向客户端 ... [详细]
  • Python已成为全球最受欢迎的编程语言之一,然而Python程序的安全运行存在一定的风险。本文介绍了Python程序安全运行需要满足的三个条件,即系统路径上的每个条目都处于安全的位置、"主脚本"所在的目录始终位于系统路径中、若python命令使用-c和-m选项,调用程序的目录也必须是安全的。同时,文章还提出了一些预防措施,如避免将下载文件夹作为当前工作目录、使用pip所在路径而不是直接使用python命令等。对于初学Python的读者来说,这些内容将有所帮助。 ... [详细]
  • python3.7 安装pip3_python3的pip3安装
    ---恢复内容开始---pip3的安装需要对应一整套python的编译工具库,所以安装好的pip3是这个样子:inearAi:~$pip3-Vpi ... [详细]
  • 系统安装Debian系统的安装方式和Ubuntu系统的安装方式几乎是一样的,毕竟Ubuntu系统是基于Debian的,就如同CentOS基于Redhat ... [详细]
  • 本文介绍了在rhel5.5操作系统下搭建网关+LAMP+postfix+dhcp的步骤和配置方法。通过配置dhcp自动分配ip、实现外网访问公司网站、内网收发邮件、内网上网以及SNAT转换等功能。详细介绍了安装dhcp和配置相关文件的步骤,并提供了相关的命令和配置示例。 ... [详细]
  • Python实现变声器功能(萝莉音御姐音)的方法及步骤
    本文介绍了使用Python实现变声器功能(萝莉音御姐音)的方法及步骤。首先登录百度AL开发平台,选择语音合成,创建应用并填写应用信息,获取Appid、API Key和Secret Key。然后安装pythonsdk,可以通过pip install baidu-aip或python setup.py install进行安装。最后,书写代码实现变声器功能,使用AipSpeech库进行语音合成,可以设置音量等参数。 ... [详细]
  • 本文介绍了在CentOS上安装Python2.7.2的详细步骤,包括下载、解压、编译和安装等操作。同时提供了一些注意事项,以及测试安装是否成功的方法。 ... [详细]
  • 网络请求模块选择——axios框架的基本使用和封装
    本文介绍了选择网络请求模块axios的原因,以及axios框架的基本使用和封装方法。包括发送并发请求的演示,全局配置的设置,创建axios实例的方法,拦截器的使用,以及如何封装和请求响应劫持等内容。 ... [详细]
  • 树莓派语音控制的配置方法和步骤
    本文介绍了在树莓派上实现语音控制的配置方法和步骤。首先感谢博主Eoman的帮助,文章参考了他的内容。树莓派的配置需要通过sudo raspi-config进行,然后使用Eoman的控制方法,即安装wiringPi库并编写控制引脚的脚本。具体的安装步骤和脚本编写方法在文章中详细介绍。 ... [详细]
  • Linux下安装依赖包版本高解决方法
    本文介绍了在Linux系统下,当已安装的依赖包版本高于需要安装的依赖包版本时,解决方法包括欺骗安装程序和修改相关配置文件等操作。针对不同情况,提供了不同的解决方案。 ... [详细]
  • centos安装Mysql的方法及步骤详解
    本文介绍了centos安装Mysql的两种方式:rpm方式和绿色方式安装,详细介绍了安装所需的软件包以及安装过程中的注意事项,包括检查是否安装成功的方法。通过本文,读者可以了解到在centos系统上如何正确安装Mysql。 ... [详细]
  • Centos下安装memcached+memcached教程
    本文介绍了在Centos下安装memcached和使用memcached的教程,详细解释了memcached的工作原理,包括缓存数据和对象、减少数据库读取次数、提高网站速度等。同时,还对memcached的快速和高效率进行了解释,与传统的文件型数据库相比,memcached作为一个内存型数据库,具有更高的读取速度。 ... [详细]
  • Hello,Imaintainawebcluster,withDebiani386andDebianAMD64nodes(itwa ... [详细]
author-avatar
妖泪蓝夕_746
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有