牵牛散步
仗剑走天涯

一、安装

1 linux 安装好后已经装好了 cvs ,可用 rpm -qa|grep cvs 查看。

如果没有安装你可以在 Redhat 2 张光盘上找到,另外你也可以在网上下载到最新的 rpm 包。很容易找,其实不存在什么 linux 版本。

 

2 、创建 cvs 使用的目录: mkdir /home/mycvstest

 

3 、创建 cvs 使用的用户和组

groupadd cvs

useradd -g cvs -G cvs –d /home/mycvstest cvs

passwd cvs

 

4 、修改 mycvstest 的用户: chown -R cvs:cvs /home/mycvstest

                        chmod 755 /home/mycvstest

 

5 、切换用户: su cvs

 

6 、创建源码仓库: mkdir /home/mycvstest/drcls drclgw

 

7 、初始化源码仓库: cvs -d /home/mycvstest/drcls init

                   cvs -d /home/mycvstest/drclgw init

                   chmod 755 /home/mycvstest/drcls drclgw

初始化后可以在目录下见到新增加的 CVSROOT 目录, cvs 所有的控制信息都在这个目录里。

 

8 、退回到 root 用户,建立 CVS 服务启动文件, CVS 使用 xinetd 方式启动。  

 

vi /etc/xinetd.d/cvspserver

 

service cvspserver

{

disable = no

flags = REUSE

socket_type = stream

wait = no

user = root

server= /usr/bin/cvs

server_args= -f --allow-root=/home/mycvstest/drcls

--allow-root=/home/mycvstest/drclgw pserver

log_on_failure += USERID

}

 

注:红色的参数很重要,由于 xinetd server_args 长度限制 , 当你想运行很多的单个仓库的时候 ( 就是有很多个模块时,比如 drcrgw), 但在 server_args 中无法输入这么多单个的仓库, 可以采取以下方式解决(现在实验室 90 上就用的这种方式):

 

#> vi cvspserver

 

service cvspserver

{

        disable = no

        socket_type = stream

        wait = no

        user = root

        server = /usr/bin/cvs.run

        server_args =""

}

编写 cvs.run 脚本

vi /cvsroot/cvs.run

#!/bin/bash

/usr/bin/cvs -f

--allow-root=/home/mycvstest/drcls

--allow-root= /home/mycvstest/drclgw

pserver

 

chmod a+x cvs.run

 

9 、加入 cvs 服务:

 

#>vi /etc/services

 

cvspserver 2401/tcp #pserver cvs service

cvspserver 2401/udp #pserver cvs service

 

10 、启动 cvs 服务:

 

#> service xinetd restart

 

11 、检查 cvspserver 服务是否已经启动:

 

#> netstat -l |grep cvspserver

应该有如下结果:

tcp 0 0 *:cvspserver *:* LISTEN

 

 

二、使用和管理

1 、创建 cvs 用户:

cd /home/mycvstest/drcls/CVSROOT

htpasswd –c passwd zhangcan (htpasswd 命令要安装 apache 后才有,此命令创建一个 passwd 文件,里面内容为新建 cvs 用户的用户名和密码 )

vi passwd ( 在新建的用户后手工加入用户属于的组 cvs)

例如: zhangcan:dgeagasdgasdr:cvs  蓝色字符串表示加密后的密码。

 

2 、赋予用户读写权限

手工在 CVSROOT 目录中建立 readers writers 文件。 Readers 文件中的用户只有读权限, writers 中的用户具有读写权限,一行只写一个用户名。

 

3 、登录 cvs

在客户机 Linux 下面用命令:

export CVSROOT=:pserver:zhangcan@192.168.100.197:/home/mycvstest/drcls

cvs login

 

4 、向源码仓库中导入源码

首先进入你本机上安装源码的目录,然后使用以下命令:

cvs import –m “this is my soure code” drcls NISEC test start

-m 表示在 cvs 历史文件显示的消息, drclst 为你指定的源码目录名, NISEC 为供应商标签, test 为发行标签(这两项可以不要), start 必须要。

 

5 checkout 出需要修改的源代码

cvs co drcls  在你的当前目录下会发现多了一个 drcls 目录,要修改的源码都在里面

co checkout 的简写

 

6 、提交修改

假设刚才对 readme 文件进行了修改,现在提交

cvs commit –m “modify a few of wrong words”  readme

命令执行后会提示版本已经改为 1.2

 

7 checkout 出以前的版本

如果想检出以前的版本可以用以下命令:

cvs co –r 1.1 drcls/readme 或者 cvs –D yesterday drcls/readme

 

8 、删除文件

若想从源码仓库中删除 readme 文件,首先应把客户机工作目录中的 readme 文件删除,然后使用 cvs 的删除命令,最后提交删除,流程如下:

rm readme

cvs rm readme

cvs commit –m “ 现在不需要这个 readme 文件   readme

如果系统类似错误: cannot remove file `INSTALL' which has a numeric sticky tag of `1.1'

可以用命令 cvs update –A readme 后再删除文件。


以上为火山哥提供的,以下是我添加的部份:
1.在reader和writes文件中添加使用用户时要注意,当在reader中添加了某一只读用户后就不要在writers中添加此用户,如果在两个文件中都添加同一用户的话,在使用cvs时,CVS服务器会把此用户当做只读用户看待,当使用一些命令如import时会产生权限问题,以下是linux关于此问题的说明:
/* This command has the potential to modify the repository, so
   * we check if the user have permission to do that.
   *
   * (Only relevant for remote users -- local users can do
   * whatever normal Unix file permissions allow them to do.)
   *
   * The decision method:
   *
   *    If $CVSROOT/CVSADMROOT_READERS exists and user is listed
   *    in it, then read-only access for user.
   *
   *    Or if $CVSROOT/CVSADMROOT_WRITERS exists and user NOT
   *    listed in it, then also read-only access for user.
   *
   *    Else read-write access for user.
   */

posted on 2006-11-28 16:18 牵牛散步 阅读(1938) 评论(3)  编辑 收藏 引用 所属分类: C++学习资料
Comments
  • # re: CVS服务器的相关配置及使用[ Server of CVS Configure and Usage for linux]
    canyon
    Posted @ 2006-11-29 11:46
    写的太好了,不顶不行啊!  回复  更多评论   
  • # re: CVS服务器的相关配置及使用[ Server of CVS Configure and Usage for linux]---注,此教程是"火山哥"提供的:-)[未登录]
    牵牛散步
    Posted @ 2007-07-09 13:14
    项目中添加二进制文件进CVS仓库需要注意:
    添加文件 创建好新文件后,比如:touch new_file cvs add new_file 注意:对于图片,Word文档等非纯文本的项目,需要使用cvs add -kb选项按2进制文件方式导入(k表示扩展选项,b表示binary),否则有可能出现文件被破坏的情况 比如: cvs add -kb new_file.gif cvs add -kb readme.doc  回复  更多评论   
  • # re: CVS服务器的相关配置及使用[ Server of CVS Configure and Usage for linux]---注,此教程是"火山哥"提供的:-)[未登录]
    猪猪
    Posted @ 2007-10-15 11:26
    谢谢,刚好遇到了下面这个问题,很受用。
    如果系统类似错误: cannot remove file `INSTALL' which has a numeric sticky tag of `1.1'   回复  更多评论   

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理