2008年2月4日 星期一

Linux Service - cvs setup server

CVS Server 利用xinetd dispatch

1. 設定xinetd 的相關步驟, 如果是使用ssh(ext mode)access CVS Server, 應該可以不用, 似乎是使用pserver才需要

首先在/etc/xinetd.d/ 增加cvspserver 檔案
內容如下
service cvspserver
{
disable = no ==> enable the service
port = 2401 ==> cvs listen port
socket_type = stream
protocol = tcp
wait = no
user = root
passenv = PATH
server = /usr/bin/cvs
env = HOME=/var/cvs
server_args = -f --allow-root=/home/cvs/CVSROOT pserver ==> /home/cvs/CVSROOT 為CVS repository directory
bind = 127.0.0.1 ==> cvs listen address
}

注意必須包含有 /etc/xinetd.conf, 如下

#
## Simple configuration file for xinetd
##
## Some defaults, and include /etc/xinetd.d/

defaults
{
instances = 60
log_type = SYSLOG authpriv
log_on_success = HOST PID
log_on_failure = HOST
cps = 25 30
}
includedir /etc/xinetd.d

2. 重新啟動xinetd (由於我在安裝時系統沒有xinetd, 所以我去重新下載了xinetd, 編譯過後, copy contrib/xinetd /etc/rc.d/init.d/ 下成為service script)
/etc/rc.d/init.d/xinetd restart
正在停止 xinetd: [ 確定 ]
正在啟動 xinetd: [ 確定 ]


/home/cvs 的結構如下

ls -la /home/cvs/
drwxrwxrwx 3 root wheel 4096 2008-02-05 13:15 CVSROOT
drwxrwxr-x 6 username username 4096 2008-02-05 13:15 test
drwxrwxr-x 3 username username 4096 2008-02-05 20:42 test2

CVSROOT 目錄必須要讓所有人都可以有寫的權限, 因為cvs server 必須要記錄user 的cvs 行為在CVSROOT 目錄內的檔案中

如何控管CVS Server 的個別權限 (READERS, WRITERS,PASSWD...)
設定Anonymous 的權限
有空再來測試
We can manage the CVS permission by using the Linux file system permission mechanism. For example, you can group some user into a specified group. And only this group can access a cvs project which group id is the same with that user group. So we can simply use the user/group/other file permission to manage the CVS access control.

e.g.
Set the user1, user2 belong in the "cvs"(id: 501) group
# cat /etc/passwd
[omit]
user1:x:500:501:User1:/home/user1:/bin/bash
cvs:x:501:501::/home/cvs:/bin/bash
user2:x:502:501::/home/user2:/bin/bash

// Make user1 and user2 in the cvs group
# cat /etc/group
[omit]
cvs:x:501:user1,user2




3. 如何import 檔案到剛建立好的CVS Server
我的經驗是從其他CVS import 檔案進來, 首先先把原有的目錄中的 CVS/ 子目錄先刪掉(這些檔案是CVS Server 在maintain cvs 的系統檔案, 我們不用把它們upload到新的project當中)

# cd project
project/# find ./* -name CVS -exec "rm -rf {}" \;

cvs import -m "initial" test3 vendor-name main ==> 其中test3是CVS project name, vendor-name 是 branch tag, main (release tag) 是main trunk tag

cvs import -kb -m "initial files" projectName vendorName main ==> import binary files (add -kb will inform the cvs server that all the uploaded files are binary files)

import 過程的log如下
I test3/filename.o ==> ignored files (*.o, *.a..)
N test3/filename.c ==> newAdded files
[omit]


之後再來cvs client 檢查就會發現如下
# cvs st -v Makefile
username@IP-address's password:
===================================================================
File: Makefile Status: Up-to-date

Working revision: 1.1.1.1
Repository revision: 1.1.1.1 /home/cvs/test3/Makefile,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)

Existing Tags:
main (revision: 1.1.1.1)
vendor-name (branch: 1.1.1)


之後就可以利用client CVS 來執行checkouot 該project 來work了

Note:
We can configure the /CVSROOT/cvswrappers as the following setting to separate different file expansion as binary or text file (default configuration)

*.vsd -k 'b' -m 'COPY'
*.CLASS -k 'b' -m 'COPY'
*.DOC -k 'b' -m 'COPY'

In the real CVS data file, like "file.doc,v", will contain the expand tag to record the kflag type. like following examples
head 1.1;
branch 1.1.1;
access ;
symbols main:1.1.1.1 vendor-name:1.1.1;
locks ; strict;
comment @# @;
expand @b@; ==> "b" indicate "binary"



The method of changing the kflag
$ echo '$Id$' > kotest
$ cvs add -kb -m"A test file" kotest
$ cvs ci -m"First checkin; contains a keyword" kotest

If a file accidentally gets added without '-kb', one can use the cvs admin command to recover. For example:

$ echo '$Id$' > kotest
$ cvs add -m"A test file" kotest
$ cvs ci -m"First checkin; contains a keyword" kotest
$ cvs admin -kb kotest
$ cvs update -A kotest
# For non-unix systems:
# Copy in a good copy of the file from outside CVS
$ cvs commit -m "make it binary" kotest

沒有留言: