一、安裝
1
、
linux
安裝好后已經(jīng)裝好了
cvs
,可用
rpm -qa|grep cvs
查看。
如果沒(méi)有安裝你可以在
Redhat
第
2
張光盤上找到,另外你也可以在網(wǎng)上下載到最新的
rpm
包。很容易找,其實(shí)不存在什么
linux
版本。
?
2
、創(chuàng)建
cvs
使用的目錄:
mkdir /home/mycvstest
?
3
、創(chuàng)建
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
、創(chuàng)建源碼倉(cāng)庫(kù):
mkdir /home/mycvstest/drcls drclgw
?
7
、初始化源碼倉(cāng)庫(kù):
cvs -d /home/mycvstest/drcls init
?????????????????? cvs -d /home/mycvstest/drclgw init
???????????????
???chmod 755 /home/mycvstest/drcls drclgw
初始化后可以在目錄下見到新增加的
CVSROOT
目錄,
cvs
所有的控制信息都在這個(gè)目錄里。
?
8
、退回到
root
用戶,建立
CVS
服務(wù)啟動(dòng)文件,
CVS
使用
xinetd
方式啟動(dòng)。
?
?
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
}
?
注:紅色的參數(shù)很重要,由于
xinetd
的
server_args
長(zhǎng)度限制
,
當(dāng)你想運(yùn)行很多的單個(gè)倉(cāng)庫(kù)的時(shí)候
(
就是有很多個(gè)模塊時(shí),比如
drcrgw),
但在
server_args
中無(wú)法輸入這么多單個(gè)的倉(cāng)庫(kù),
可以采取以下方式解決(現(xiàn)在實(shí)驗(yàn)室
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
服務(wù):
?
#>vi /etc/services
?
cvspserver 2401/tcp #pserver cvs service
cvspserver 2401/udp #pserver cvs service
?
10
、啟動(dòng)
cvs
服務(wù):
?
#> service xinetd restart
?
11
、檢查
cvspserver
服務(wù)是否已經(jīng)啟動(dòng):
?
#> netstat -l |grep cvspserver
應(yīng)該有如下結(jié)果:
tcp 0 0 *:cvspserver *:* LISTEN
?
?
二、使用和管理
1
、創(chuàng)建
cvs
用戶:
cd /home/mycvstest/drcls/CVSROOT
htpasswd –c passwd zhangcan (htpasswd
命令要安裝
apache
后才有,此命令創(chuàng)建一個(gè)
passwd
文件,里面內(nèi)容為新建
cvs
用戶的用戶名和密碼
)
vi passwd (
在新建的用戶后手工加入用戶屬于的組
cvs)
例如:
zhangcan:dgeagasdgasdr:cvs?
藍(lán)色字符串表示加密后的密碼。
?
2
、賦予用戶讀寫權(quán)限
手工在
CVSROOT
目錄中建立
readers
和
writers
文件。
Readers
文件中的用戶只有讀權(quán)限,
writers
中的用戶具有讀寫權(quán)限,一行只寫一個(gè)用戶名。
?
3
、登錄
cvs
在客戶機(jī)
Linux
下面用命令:
export CVSROOT=:pserver:zhangcan@192.168.100.197:/home/mycvstest/drcls
cvs login
?
4
、向源碼倉(cāng)庫(kù)中導(dǎo)入源碼
首先進(jìn)入你本機(jī)上安裝源碼的目錄,然后使用以下命令:
cvs import –m “this is my soure code” drcls NISEC test start
-m
表示在
cvs
歷史文件顯示的消息,
drclst
為你指定的源碼目錄名,
NISEC
為供應(yīng)商標(biāo)簽,
test
為發(fā)行標(biāo)簽(這兩項(xiàng)可以不要),
start
必須要。
?
5
、
checkout
出需要修改的源代碼
cvs co drcls?
在你的當(dāng)前目錄下會(huì)發(fā)現(xiàn)多了一個(gè)
drcls
目錄,要修改的源碼都在里面
co
為
checkout
的簡(jiǎn)寫
?
6
、提交修改
假設(shè)剛才對(duì)
readme
文件進(jìn)行了修改,現(xiàn)在提交
cvs commit –m “modify a few of wrong words”? readme
命令執(zhí)行后會(huì)提示版本已經(jīng)改為
1.2
。
?
7
、
checkout
出以前的版本
如果想檢出以前的版本可以用以下命令:
cvs co –r 1.1 drcls/readme
或者
cvs –D yesterday drcls/readme
?
8
、刪除文件
若想從源碼倉(cāng)庫(kù)中刪除
readme
文件,首先應(yīng)把客戶機(jī)工作目錄中的
readme
文件刪除,然后使用
cvs
的刪除命令,最后提交刪除,流程如下:
rm readme
cvs rm readme
cvs commit –m “
現(xiàn)在不需要這個(gè)
readme
文件
”? readme
如果系統(tǒng)類似錯(cuò)誤:
cannot remove file `INSTALL' which has a numeric sticky tag of `1.1'
可以用命令
cvs update –A readme
后再刪除文件。
以上為火山哥提供的,以下是我添加的部份:
1.在reader和writes文件中添加使用用戶時(shí)要注意,當(dāng)在reader中添加了某一只讀用戶后就不要在writers中添加此用戶,如果在兩個(gè)文件中都添加同一用戶的話,在使用cvs時(shí),CVS服務(wù)器會(huì)把此用戶當(dāng)做只讀用戶看待,當(dāng)使用一些命令如import時(shí)會(huì)產(chǎn)生權(quán)限問(wèn)題,以下是linux關(guān)于此問(wèn)題的說(shuō)明:
/* 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.
? ?*/