有关的详细信息可使用lynx
查阅/usr/share/doc/cvs/html-cvsclient
,/usr/share/doc/cvs/html-info
,/usr/share/doc/cvsbook
或执行info
cvs及man cvs。
以下步骤配置的服务器,仅允许“src”用户组的成员访问CVS容器,并且仅“staff”用户组的成员才可管理CVS,这样做可以降低管理者不小心犯错的机率。
# cd /var/lib; umask 002 ; sudo mkdir cvs # [Woody] FSH # apt-get install cvs cvs-doc cvsbook # export CVSROOT=/var/lib/cvs # cd $CVSROOT # chown root:src . # 设置为"staff"可加强对新建项目行为的限制 # chmod 3775 . # 如果上面的赋值为"staff",则使用2775 # cvs -d /var/lib/cvs init # 在此明确地指定-d更安全 # cd CVSROOT # chown -R root:staff . # chmod 2775 . # touch val-tags # chmod 664 history val-tags # chown root:src history val-tags
下面我们来设置shell环境以便访问CVS容器。
只读远程访问:
$ export CVSROOT=:pserver:[email protected]:/cvsroot/qref $ cvs login $ cvs -z3 co qref
通过同一台机器上的shell进行本地访问:
$ export CVSROOT=/var/lib/cvs
非SSH(在cvs
中使用RSH协议)远程访问:
$ export CVSROOT=:pserver:[email protected]:/var/lib/cvs $ cvs login
易受窍听攻击。
ssh
使用远程CVS通过SSH进行远程访问:
$ export CVSROOT=:ext:[email protected]:/var/lib/cvs
或连接Sourceforge:
$ export CVSROOT=:ext:[email protected]:/cvsroot/qref
亦可使用RSA认证(用更少的密码建立连接, 第 9.5.3 节),它不需要密码提示。
要建立如下的档案,
ITEM VALUE MEANING source tree: ~/project-x All source codes Project name: project-x Name for this project Vendor Tag: Main-branch Tag for the entire branch Release Tag: Release-original Tag for a specific release
则,
$ cd ~/project-x # 进源码目录 ... 创建源码树 ... $ cvs import -m "Start project-x" project-x Main-branch Release-initial $ cd ..; rm -R ~/project-x
使用本地CVS容器来为project-x工作:
$ cd # 转到工作域 $ cvs co project-x # 从CVS下载源码到本地 $ cd project-x ... 修改源码内容 ... $ cvs diff -u # 相当于diff -u repository/ local/ $ cvs up -C modified_file # 撤消对文件地修改 $ cvs ci -m "Describe change" # 保存本地源码到CVS $ vi newfile_added $ cvs add newfile_added $ cvs ci -m "Added newfile_added" $ cvs up # 从CVS合并最新版本 ... watch out for lines starting with "C filename" ... unmodified code is moved to `.#filename.version'. ... Search "<<<<<<<" and ">>>>>>>" in filename. $ cvs tag Release-1 # 添加release tag ... edit further ... $ cvs tag -d Release-1 # 移除release tag $ cvs ci -m "more comments" $ cvs tag Release-1 # 重新添加release tag $ cd # 返回工作域 $ cvs co -r Release-initial -d old project-x ... get original version to old directory $ cd old $ cvs tag -b Release-initial-bugfixes # 创建branch (-b) tag ... Now you can work on the old version (Tag=sticky) $ cvs update ... Source tree now has sticky tag "Release-initial-bugfixes" ... Work on this branch $ cvs up # sync with files modified by others on this branch $ cvs ci -m "check into this branch" $ cvs update -kk -A ... Remove sticky tag and forget contents ... Update from main trunk without keyword expansion $ cvs update -kk -j Release-initial-bugfixes ... Merge from Release-initial-bugfixes branch into the main ... trunk without keyword expansion. Fix conflicts with editor. $ cvs ci -m "merge Release-initial-bugfixes" $ cd $ tar -cvzf old-project-x.tar.gz old # make archive, -j for bz2 $ cvs release -d old # 删除本地源码(可选)
应该记住的几个选项(用作cvs
命令行的第一个参数):
-n dry run, no effect -t display messages showing steps of cvs activity
要从CVS获得最新版本,用“tomorrow”:
$ cvs ex -D tomorrow module_name
为项目添加别名(本地服务器):
$ su - admin # staff用户组成员 $ export CVSROOT=/var/lib/cvs $ cvs co CVSROOT/modules $ cd CVSROOT $ echo "px -a project-x" >>modules $ cvs ci -m "Now px is an alias for project-x" $ cvs release -d . $ exit # 按control-D从su返回 $ cvs co -d project px ... check out project-x (alias:px) from CVS to directory project $ cd project ... make changes to the content ...
CVS不会覆盖当前容器中的文件,而是用另一个文件替换它。因此,对容器目录的写权限是很危险的权限。所以在新建容器时,请运行下面的命令,确保权限合适。
# cd /var/lib/cvs # chown -R root:src repository # chmod -R ug+rwX repository # chmod 2775 repository # if needed, this and subdirectory
当文件被别人取走后会保留执行标记,任何时候你遇到外出文件存在执行权限问题,可用下面的命令在CVS容器中修改文件权限。
# chmod ugo-x filename
这儿是一些CVS命令的用法简介。
{add|ad|new} [-k kflag] [-m 'message'] files... {admin|adm|rcs} [rcs-options] files... {annotate|ann} [options] [files...] {checkout|co|get} [options] modules... {commit|ci|com} [-lnR] [-m 'log_message' | -f file] \ [-r revision] [files...] {diff|di|dif} [-kl] [rcsdiff_options] [[-r rev1 | -D date1] \ [-r rev2 | -D date2]] [files...] {export|ex|exp} [-flNn] -r rev|-D date [-d dir] [-k kflag] module... {history|hi|his} [-report] [-flags] [-options args] [files...] {import|im|imp} [-options] repository vendortag releasetag... {login|logon|lgn} {log|lo|rlog} [-l] rlog-options [files...] {rdiff|patch|pa} [-flags] [-V vn] [-r t|-D d [-r t2|-D d2]] modules... {release|re|rel} [-d] directories... {remove|rm|delete} [-lR] [files...] {rtag|rt|rfreeze} [-falnR] [-b] [-d] [-r tag | -D date] \ symbolic_tag modules... {status|st|stat} [-lR] [-v] [files...] {tag|ta|freeze} [-lR] [-F] [-b] [-d] [-r tag | -D date] [-f] \ symbolic_tag [files...] {update|up|upd} [-AdflPpR] [-d] [-r tag|-D date] files...
Subversion是下一代版本控制系统,它将替代CVS。当前开发者称它还处于“alpha”阶段,但对大多数用户而言它已足够稳定了。到本文档写作之时,Subversion仅在Debian unstable版中可用。
The subversion-server
meta-package依赖一些关联包(libapache2-dav-svn
和subversion-tools
)来配置服务器。
当前,subversion
软件包无法创建容器,所以用户需要手工创建它们。通常可在/var/local/repos
下创建容器。
创建目录:
# mkdir -p /var/local/repos
创建容器数据库:
# svnadmin create /var/local/repos
将容器的写权限赋给www server:
# chown -R www-data:www-data /var/local/repos
通过用户认证授权访问容器,添加(或去掉注释符)下列内容到/etc/apache2/mods-available/dav_svn.conf
:
<Location /repos> DAV svn SVNPath /var/local/repos AuthType Basic AuthName "Subversion repository" AuthUserFile /etc/subversion/passwd <LimitExcept GET PROPFIND OPTIONS REPORT> Require valid-user </LimitExcept> </Location>
接着,使用下面的命令创建用户认证文件:
htpasswd2 -c /etc/subversion/passwd some-username
重启Apache2,就可以使用URLhttp://hostname/repos来访问新的subversion容器了。
下面的小节将教你如何在subversion下使用各种命令。
创建新的subversion档案,输入下面的命令:
$ cd ~/your-project # 进你的源码目录 $ svn import http://localhost/repos your-project \ project-name -m "initial project import"
这将在你的subversion容器下创建一个名为project-name的目录,用来存放你的项目文件。查看http://localhost/repos/它是否在那儿?
用subversion来管理project-y:
$ cd # 转到工作域 $ svn co http://localhost/repos/project-y # 提取源码 $ cd project-y ... 完成一些工作 ... $ svn diff # 相当于diff -u repository/ local/ $ svn revert modified_file # 撤消对文件所做的修改 $ svn ci -m "Describe changes" # 将你做的修改保存到容器中 $ vi newfile_added $ svn add newfile_added $ svn add new_dir # 将所有的文件嵌套式地加到new_dir $ svn add -N new_dir2 # 非嵌套式地添加目录 $ svn ci -m "Added newfile_added, new_dir, new_dir2" $ svn up # 从容器中合并最新的版本 $ svn log # 显示所有修改记录 $ svn copy http://localhost/repos/project-y \ http://localhost/repos/project-y-branch \ -m "creating my branch of project-y" # branching project-y $ svn copy http://localhost/repos/project-y \ http://localhost/repos/proj-y_release1.0 \ -m "project-y 1.0 release" # added release tag ... note that branching and tagging are the same. The only difference ... is that branches get committed whereas tags do not. ... make changes to branch ... $ # merge branched copy back to main copy $ svn merge http://localhost/repos/project-y \ http://localhost/repos/project-y-branch $ svn co -r 4 http://localhost/repos/project-y # get revision 4
Debian 参考手册
CVS, 星期二 八月 17 00:35:13 UTC 2004[email protected]
[email protected]