35. — SVN —
# cvs import [options] directory-name vendor-tag release-tag
# cd /devel # 必须在该目录中来导入
# cvs import myapp Company R1_0 # 修订(release)标签可以为任何单个单词
在添加了一个新目录 "/devel/tools/" 后,也可这么导入。
# cd /devel/tools
# cvs import myapp/tools Company R1_0
签出、更新和提交
# cvs co myapp/tools # 仅会签出 tools 目录
# cvs co -r R1_1 myapp # 签出修订版本为 R1_1 的 myapp (sticky)
# cvs -q -d update -P # 典型的 CVS 更新
# cvs update -A # 重置所有 sticky 标签(或日期、选项)
# cvs add newfile # 添加一个新文件
# cvs add -kb newfile # 添加一个二进制文件
# cvs commit file1 file2 # 仅提交这两个文件
# cvs commit -m "message" # 提交所有更改并为这个更改添加日志消息
创建一个 patch
It is best to create and apply a patch from the working development directory related to the
project, or from within the source directory.
# cd /devel/project
# diff -Naur olddir newdir > patchfile # Create a patch from a directory or a file
# diff -Naur oldfile newfile > patchfile
应用一个 patch
Sometimes it is necessary to strip a directory level from the patch, depending how it was created.
In case of difficulties, simply look at the first lines of the patch and try -p0, -p1 or -p2.
# cd /devel/project
# patch --dry-run -p0 < patchfile # Test the path without applying it
# patch -p0 < patchfile
# patch -p1 < patchfile # strip off the 1st level from the path
13 SVN
Server setup (p35) | SVN+SSH (p36) | SVN over http (p36) | SVN usage (p36)
Subversion (SVN)34 is a version control system designed to be the successor of CVS (Concurrent
Versions System). The concept is similar to CVS, but many shortcomings where improved. See also
the SVN book35.
1 3 . 1 S e r v e r s etup
The initiation of the repository is fairly simple (here for example /home/svn/ must exist):
# svnadmin create --fs-type fsfs /home/svn/project1
Now the access to the repository is made possible with:
• file:// Direct file system access with the svn client with. This requires local permissions
on the file system.
• svn:// or svn+ssh:// Remote access with the svnserve server (also over SSH). This requires
local permissions on the file system.
• http:// Remote access with webdav using apache. No local users are necessary for this
method.
34.http://subversion.tigris.org/
35.http://svnbook.red-bean.com/en/1.4/
35
36. — SVN —
Using the local file system, it is now possible to import and then check out an existing project.
Unlike with CVS it is not necessary to cd into the project directory, simply give the full path:
# svn import /project1/ file:///home/svn/project1/trunk -m 'Initial import'
# svn checkout file:///home/svn/project1
The new directory "trunk" is only a convention, this is not required.
Remote access with ssh
No special setup is required to access the repository via ssh, simply replace file:// with
svn+ssh/hostname. For example:
# svn checkout svn+ssh://hostname/home/svn/project1
As with the local file access, every user needs an ssh access to the server (with a local account)
and also read/write access. This method might be suitable for a small group. All users could
belong to a subversion group which owns the repository, for example:
# groupadd subversion
# groupmod -A user1 subversion
# chown -R root:subversion /home/svn
# chmod -R 770 /home/svn
Remote access with http (apache)
Remote access over http (https) is the only good solution for a larger user group. This method
uses the apache authentication, not the local accounts. This is a typical but small apache
configuration:
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 # Only for access control
<Location /svn>
DAV svn
# any "/svn/foo" URL will map to a repository /home/svn/foo
SVNParentPath /home/svn
AuthType Basic
AuthName "Subversion repository"
AuthzSVNAccessFile /etc/apache2/svn.acl
AuthUserFile /etc/apache2/svn-passwd
Require valid-user
</Location>
The apache server needs full access to the repository:
# chown -R www:www /home/svn
Create a user with htpasswd2:
# htpasswd -c /etc/svn-passwd user1 # -c creates the file
Access control svn.acl example
# Default it read access. "* =" would be default no access
[/]
* = r
[groups]
project1-developers = joe, jack, jane
# Give write access to the developers
[project1:]
@project1-developers = rw
1 3 . 2 S V N c o m m ands and usage
See also the Subversion Quick Reference Card36. Tortoise SVN37 is a nice Windows interface.
36
37. — 实用命令 —
Import
A new project, that is a directory with some files, is imported into the repository with the
import command. Import is also used to add a directory with its content to an existing project.
# svn help import # Get help for any command
# Add a new directory (with content) into the src dir on project1
# svn import /project1/newdir http://host.url/svn/project1/trunk/src -m 'add newdir'
Typical SVN commands
# svn co http://host.url/svn/project1/trunk # Checkout the most recent version
# Tags and branches are created by copying
# svn mkdir http://host.url/svn/project1/tags/ # Create the tags directory
# svn copy -m "Tag rc1 rel." http://host.url/svn/project1/trunk
http://host.url/svn/project1/tags/1.0rc1
# svn status [--verbose] # Check files status into working dir
# svn add src/file.h src/file.cpp # Add two files
# svn commit -m 'Added new class file' # Commit the changes with a message
# svn ls http://host.url/svn/project1/tags/ # List all tags
# svn move foo.c bar.c # Move (rename) files
# svn delete some_old_file # Delete files
14 实用命令
less (p37) | vi (p37) | mail (p38) | tar (p38) | dd (p39) | screen (p40) | find (p40) | 混杂的
(p41)
14.1 less
less 命令用来在控制台中分屏显示文本文档。它在许多发行版中可用。
# less unixtoolbox.xhtml
一些重要指令(^N 代表 [control]-[N]):
h H 显示指令的汇总列表
f ^F ^V SPACE 向前滚动一屏(或者 N 行)
b ^B ESC-v 向后滚动一屏(或者 N 行)
F 向前滚动;类似于"tail -f"
/pattern 向前搜索匹配该模式的行
?pattern 向后搜索匹配该模式的行
n 重复之前的搜索
N 反方向重复之前的搜索
q 退出
14.2 vi
Vi 在任何 Linux/Unix 发行安装版(gentoo 没有?)上都存在。因此,我们有必要了解一些基本的命令。Vi 有两
个模式:命令模式和插入模式。使用 [ESC] 键可进入命令模式,使用 i 键可进入插入模式。如果你迷失了,可
在命令模式下键入 : help。
编辑器 nano 和 pico 通常也都可用,而且更容易(IMHO)使用。
Quit
:w newfilename 保存文件为 newfilename
:wq or :x 保存并退出
:q! 退出但不保存
36.http://www.cs.put.poznan.pl/csobaniec/Papers/svn-refcard.pdf
37.http://tortoisesvn.tigris.org
37
38. — 实用命令 —
移动和查找
/string 向前查找 string
?string 向后查找 string
n 同方向重复上一次搜索命令
N 反方向重复上一次搜索命令
{ 光标移至段落结尾
} 光标移至段落开头
1G 光标移至文件的第一行首
nG 光标移至文件的第 n 行首
G 光标移至文件的最后一行首
:%s/OLD/NEW/g 替换所有查找到的 OLD 为 NEW
删除文本
dd 删除当前行
D 删除光标到当前行末尾的字符
dw 删除单词
x 删除字符
u 回复上一次操作
U 回复所有此行的更改
14.3 mail
mail 命令是一个读取和发送邮件的应用程序,她通常已安装。要发送一封邮件,可以简单的输入 "mail
user@domain"。其第一行为主题,然后是邮件内容。在一个新行中使用单个点(.)来结束并发送邮件。例子:
# mail [email protected]
Subject: Your text is full of typos
"For a moment, nothing happened. Then, after a second or so,
nothing continued to happen."
.
EOT
#
这同样可用于管道:
# echo "This is the mail body" | mail [email protected]
也是测试邮件服务器的简单方法。
14.4 tar
命令 tar (磁带存档) 可以为文件和目录创建档案。归档文件 .tar 是未压缩的,一个压缩过的归档文件的后缀
是 .tgz 或 .tar.gz (zip) 或者 .tbz (bzip2)。不要使用绝对路径建立一个归档文件,你可能要解开这个归档
文件到某个地方。一些常用命令如下:
创建
# cd /
# tar -cf home.tar home/ # 归档整个 /home 目录(c 为创建)
# tar -czf home.tgz home/ # 等同于 zip 压缩
# tar -cjf home.tbz home/ # 等同于 bzip2 压缩
从一个目录树中只包含一个(或2个)目录,并保持相对目录结构。举个例子,/usr/local/etc 和 /usr/local/
www,它们在归档文件中的第一层目录是 local/。
# tar -C /usr -czf local.tgz local/etc local/www
# tar -C /usr -xzf local.tgz # 释放 local 目录到 /usr
# cd /usr; tar -xzf local.tgz # 同上面一样
38