4.4 supdate
注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
请把他存成一般文字档并改变存取权限 chmod a+rx
--------------------------------------------------------------------------------
#!/bin/ksh
# CVS program supdate
# Program to update the file from CVS read/write mode
cmdname=`basename $0`
if [ $# -lt 1 ]; then
print "\nUsage: $cmdname
"
exit
fi
# Check if file already exists....
if [ $# -gt 0 -a -f $1 ]; then
user_perms=" "
group_perms=" "
other_perms=" "
user_perms=`ls -l $1 | awk '{print $1 }' | cut -b3-3 `
group_perms=`ls -l $1 | awk '{print $1 }' | cut -b6-6 `
other_perms=`ls -l $1 | awk '{print $1 }' | cut -b9-9 `
if [ "$user_perms" = "w" -o "$group_perms" = "w" \
-o "$other_perms" = "w" ]; then
while :
do
print "\n$cmdname will backup your working file "
print "$1 to $1.supdate_bak before doing any merges."
print "Are you sure you want the merge the changes from"
print -n "CVS repository to your working file ? [n]: "
read ans
if [ "$ans" = "y" -o "$ans" = "Y" ]; then
if [ -f $1.supdate_bak ]; then
print "\nWarning : File $1.supdate_bak already exists!!"
print "Please examine the file $1.supdate_bak and delete it"
print "and than re-try this $cmdname "
print "Aborting $cmdname ...."
exit
else
cp $1 $1.supdate_bak
break
fi
elif [ "$ans" = "n" -o "$ans" = "N" -o "$ans" = "" -o "$ans" = " " ]; then
exit
fi
done
fi
fi
if [ -d $1 ]; then
print "\nDirectory update is disabled as cvs update"
print "merges the changes from repository to your working directory"
print "So give the filename to update - as shown below: "
print " Usage: $cmdname "
exit
# cvs update
else
cvs update $1
fi
print "\nDone $cmdname. $cmdname successful"
#print "\nTip (Usage): $cmdname \n"
--------------------------------------------------------------------------------
4.5 sunlock
注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
请把他存成一般文字档并改变存取权限 chmod a+rx.
--------------------------------------------------------------------------------
#!/bin/ksh
# CVS program sunlock
# Program to unlock the file to release the lock done by sedit
cmdname=`basename $0`
Usage()
{
print "\nUsage: $cmdname [-r revision_number] "
print " The options -r is optional "
print "For example - "
print " $cmdname -r 1.1 foo.cpp"
print " $cmdname foo.cpp "
print " "
}
# Command getopt will not supported in next major release.
# Use getopts instead.
while getopts r: ii
do
case $ii in
r) FLAG1=$ii; OARG1="$OPTARG";;
?) Usage; exit 2;;
esac
done
shift ` expr $OPTIND - 1 `
if [ $# -lt 1 ]; then
Usage
exit
fi
hme=` echo $HOME | cut -f1 -d' ' `
if [ "$hme" = "" ]; then
print "\nError: \$HOME is not set!!\n"
exit
fi
cur_dir=`pwd`
#echo $cur_dir
len=${#hme}
len=$(($len + 2))
#echo $len
subdir=` echo $cur_dir | cut -b $len-2000 `
#echo $subdir
if [ "$subdir" = "" ]; then
fdname=$1
else
fdname=$subdir"/"$1
fi
# If file is already checked out by another user....
cvs_root=` echo $CVSROOT | cut -f1 -d' ' `
if [ "$cvs_root" = "" ]; then
print "\nError: \$CVSROOT is not set!!\n"
exit
fi
cldir=$CVSROOT/$subdir/Locks
rcsfile=$CVSROOT/$subdir/$1,v
#echo $rcsfile
if [ ! -e $rcsfile ]; then
print "\nError: File $1 does not exist in CVS repository!!\n"
exit
fi
# Get the tip revision number of the file....
# Use tmpfile as the arg cannot be set inside the sub-shell
tmpfile=$hme/sedit-lock.tmp
\rm -f $tmpfile 2>/dev/null
if [ "$FLAG1" = "" ]; then
(
cd $hme
cvs log $fdname | head -6 | grep head: | awk '{print $2}' > $tmpfile
)
OARG1=`cat $tmpfile`
\rm -f $tmpfile 2>/dev/null
fi
lockfile=$cldir/$1-$OARG1
#echo lockfile is : $lockfile
if [ ! -e $lockfile ]; then
print "\nFile $1 revision $OARG1 is NOT locked by anyone"
print " "
exit
fi
ans=""
while :
do
print "\n\n***************************************************"
print "WARNING: $cmdname will release lock and enable other"
print " developers to edit the file. It is advisable"
print " to save your changes with scommit command"
print "***************************************************"
print -n "\nAre you sure you want to unlock the file ? [n]: "
read ans
if [ "$ans" = "" -o "$ans" = " " -o "$ans" = "n" -o "$ans" = "N" ]; then
print "\nAborting $cmdname ...."
exit
fi
if [ "$ans" = "y" -o "$ans" = "Y" ]; then
print "\n\n\n\n\n "
print "CAUTION: You may lose all the changes made to file!!"
print -n "Do you really want to unlock the file ? [n]: "
read ans
if [ "$ans" = "y" -o "$ans" = "Y" ]; then
break
else
exit
fi
else
print "\n\nWrong entry. Try again..."
sleep 1
fi
done
if [ -e $lockfile ]; then
\rm -f $lockfile
print "\nDone $cmdname"
else
print "\nFile $1 is NOT locked by anyone"
print " "
fi
--------------------------------------------------------------------------------
4.6 slist
注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
请把他存成一般文字档并改变存取权限 chmod a+rx
--------------------------------------------------------------------------------
#!/bin/ksh
# CVS program slist
# Program to list all edited source files from CVS
#cmdname=`basename $0`
#echo "no of params : " $#
#echo "all args : " $@
recurse_flag=""
if [ "$1" = "" ]; then
dir=.
recurse_flag=""
else
dir=$@
recurse_flag=" -prune "
fi
FOUT=slist_temporary_file.out
\rm -f $FOUT
find $dir $recurse_flag -type f -exec ls -ltr {} \; \
| grep -v "/CVS/" \
| grep ^\-rw \
| grep -v \\.o \
| grep -v \\.log \
| grep -v \\.out \
| grep -v \\.pid \
| awk '{ if ($NF != "tags") print $0 }' \
| awk '{ if ($NF != "a.out") print $0 }' \
| awk '{ if ($NF != "core") print $0 }' \
| awk '{ print $NF }' > $FOUT
aa=`cat $FOUT`
\rm -f $FOUT
for ii in $aa ; do
ftype=" "
ftype=`file $ii | awk '{print $2 }' `
# find . -type f -exec file {} \;
# 1)ELF 2)commands 3)[nt]roff, 4)c 5)English 6)executable
# 7)ascii 8)current 9)empty
# Binaries are ELF, lib.a are current
#
if [ "$ftype" = "ascii" -o "$ftype" = "commands" \
-o "$ftype" = "[nt]roff," -o "$ftype" = "c" -o "$ftype" = "data" \
-o "$ftype" = "English" -o "$ftype" = "executable" ]; then
pcfile=` echo $ii | cut -d'.' -f1`
pcfile=${pcfile}".pc"
if [ ! -f $pcfile ]; then
ls -l $ii
else
if [ "$ii" = "$pcfile" ]; then
ls -l $ii
fi
fi
fi
done;
#| grep -v ^\-rwx \
#ls -l | grep ^\-rw | grep -v \\.o
#ls -l | grep ^\-rw | grep -v \\.o | awk '{ if ($NF != "tags") print $0 }'
#ls -l | grep ^\-rw | grep -v ^\-rwx | grep -v \\.o | awk '{ if ($NF != "tags") print $0 }' | awk '{ if ($NF != "core") print $0 }'
#print "\nDone $cmdname. $cmdname successful"
#print "\nTip (Usage): $cmdname \n"
--------------------------------------------------------------------------------
4.7 sinfo
注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
请把他存成一般文字档并改变存取权限 chmod a+rx
--------------------------------------------------------------------------------
#!/bin/ksh
# CVS program sinfo
# Program to get the status of files in working directory
cmdname=`basename $0`
if [ $# -lt 1 ]; then
print "\nUsage: $cmdname [file/directory name] "
print "For example - "
print " $cmdname foo.cpp"
print " $cmdname some_directory "
print " "
exit
fi
hme=` echo $HOME | cut -f1 -d' ' `
if [ "$hme" = "" ]; then
print "\nError: \$HOME is not set!!\n"
exit
fi
tmpfile=$hme/cvs_sinfo.tmp
rm -f $tmpfile
cur_dir=`pwd`
#echo $cur_dir
len=${#hme}
len=$(($len + 2))
#echo $len
subdir=` echo $cur_dir | cut -b $len-2000 `
#echo $subdir
if [ "$subdir" = "" ]; then
fdname=$1
else
fdname=$subdir"/"$1
fi
# Create subshell
if [ -f $1 ]; then
(
cd $hme
clear
cvs status $fdname
)
elif [ -d $1 ]; then
(
cd $hme
clear
echo " " >> $tmpfile
echo " ****************************************" >> $tmpfile
echo " Overall Status of Directory" >> $tmpfile
echo " ****************************************" >> $tmpfile
cvs release $fdname 1>>$tmpfile 2>>$tmpfile << EOF
Y
EOF
echo "\n -------------------------------\n" >> $tmpfile
aa=`cat $tmpfile | grep ^"M " | awk '{print $2}' `
for ii in $aa
do
jj="(cd $hme; cvs status $subdir/$ii );"
echo $jj | /bin/sh \
| grep -v Sticky | awk '{if (NF != 0) print $0}' \
1>>$tmpfile 2>>$tmpfile
done
cat $tmpfile | grep -v ^? | grep -v "Are you sure you want to release" \
| less
rm -f $tmpfile
)
else
print "\nArgument $1 if not a file or directory"
exit
fi
--------------------------------------------------------------------------------
4.8 slog
注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
请把他存成一般文字档并改变存取权限 chmod a+rx
--------------------------------------------------------------------------------
#!/bin/ksh
# CVS program slog
# Program to list history of the file in CVS
cmdname=`basename $0`
if [ $# -lt 1 ]; then
print "\nUsage: $cmdname \n"
exit
fi
# Check if file does not exist....
if [ ! -f $1 ]; then
print "\nError: $1 is NOT a file. Aborting $cmdname ......"
exit
fi
cvs log $1 | /usr/local/bin/less
print "\nDone $cmdname. $cmdname successful"
#print "\nTip (Usage): $cmdname \n"
--------------------------------------------------------------------------------
4.9 sdif
注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
请把他存成一般文字档并改变存取权限 chmod a+rx
--------------------------------------------------------------------------------
#!/bin/ksh
# CVS program sdif
# Program to see difference of the working file with CVS copy
cmdname=`basename $0`
Usage()
{
print "\nUsage: $cmdname "
print "$cmdname -r -r \n"
exit
}
FLAG1=""
FLAG2=""
OARG1=""
OARG2=""
# Command getopt will not supported in next major release.
# Use getopts instead.
while getopts r:r: ii
do
case $ii in
r)
if [ "$FLAG1" = "" ]; then
FLAG1=$ii;
OARG1="$OPTARG"
else
FLAG2=$ii;
OARG2="$OPTARG"
fi
;;
?) Usage; exit 2;;
esac
done
shift ` expr $OPTIND - 1 `
if [ "$FLAG2" = "" ]; then
FLAG2=r
OARG2=HEAD
fi
if [ "$FLAG1" = "" ]; then
cvs diff -r HEAD $1 | less
else
cvs diff -$FLAG1 $OARG1 -$FLAG2 $OARG2 $1 | less
fi
--------------------------------------------------------------------------------
4.10 sadd
注意 : Korn shell /bin/ksh 在你从Linux CD-ROM 安装 pdksh*.rpm 时就会产生
请把他存成一般文字档并改变存取权限 chmod a+rx
--------------------------------------------------------------------------------
#!/bin/ksh
# test
# CVS program sadd
# Program to add the file to CVS
cmdname=`basename $0`
if [ $# -lt 1 ]; then
print "\nUsage: $cmdname \n"
exit
fi
# Check if file exists ....
if [ -f $1 ]; then
cvs add $1
exit
fi
if [ ! -d $1 ]; then
&n
5. CVS 的其他文件
在 unix 提示符号下,请打 -
cvs --help
cvs --help-options
cvs --help-commands
cvs -H checkout
cvs -H commit
man cvs
man tkcvs
网站 http://www.cyclic.com
网站 http://www.loria.fr/~molli/cvs-index.html
(译注:或者在 unix 提示符号下打 info cvs 也可得到一样的讯息)
(译注:这篇也不错简单明了) http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/cvs/
tkcvs http://www.tkcvs.org 是 CVS 的 Tcl/Tk GUI 介面。这里也有线上求助。
cd $HOME/src/foo.cpp
tkcvs
在 foo.cpp 上点一下
在 'spectacle Icon' 旁边的 'Revision Log Icon' 点一下。
这将会显示一个 Tree 组织的图在视窗里。然後在文字 '1.3' 上用滑鼠的右键点一下还有 '1.1' 滑鼠的左键点一下,然後再点一下 "Diff" 。这样将会显示两个视窗出来!!
在 "Next" 上点一下将会显示更多版本'1.3' 与 '1.1' 的 diffs。 请按 "Center" 将文字对齐置中。 (译注:这边原文好像有脱误)
这里也有 Windows 95 用的 CVS 喔,叫 WinCVS。 http://www.wincvs.org WinCVS 可以用在 Samba 系统上喔 - http://www.samba.org
基本重要的命令 -
cvs checkout
cvs update
cvs add
cvs remove
cvs commit
cvs status
cvs log
cvs diff -r1.4 -r1.5 这行指令将会输出档案 filename 1.4 版和 1.5 版的差异在哪里。
6. Emacs 编辑器
Emacs 是非常强大的编辑器而且还支援了 CVS/RCS - 尤其是对於改版後的合并和比较。 Emacs的主要网站在 http://www.emacs.org.
7. 问题反应系统 (Problem Reporting System)
伴随著 CVS 的使用,你可能会想要用计划追踪系统(Project Tracking system)或问题反应系统(Problem Reporting System)。每一个软体计划需要问题反应系统来作 bugs 的回报与追踪,并且把相关负责部分,分配给不同的程式设计师。
想知道计划追踪系统(Project Tracking system)请看这个网站 http://www.stonekeep.com。
8. 这份文件的其他档案格式
这份文件用了将近 10 个不同的档案格式来发行 - DVI, Postscript, Latex, LyX, GNU-info, HTML, RTF(Rich Text Format), Plain-text, Unix man pages and SGML。
你可以在下面的 Web 获得单一的 HTML, DVI, Postscript or SGML 型式的 tar.gz 档案, ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO/other-formats/ 或者 ftp://metalab.unc.edu/pub/Linux/docs/HOWTO/other-formats/
Plain text 格式的在: ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO,或者 ftp://metalab.unc.edu/pub/Linux/docs/HOWTO
翻译成其他国家语言像是法文,德文,西班牙文,中文,日文等等可在下面网址找得到。 ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO 或者 ftp://metalab.unc.edu/pub/Linux/docs/HOWTO 对於任何想翻译这份文件到其他语言是都欢迎的。
这份文件是用一种叫 "SGML" 的工具写成的。你可以从下列网址得到 - http://www.xs4all.nl/~cg/sgmltools/ 编译原始码後,你就会得到下列命令,像是
sgml2html cvs-rcs-howto.sgml (产生 html 档案)
sgml2rtf cvs-rcs-howto.sgml (产生 RTF 档案)
sgml2latex cvs-rcs-howto.sgml (产生 latex 档案)
这份文件是位於 -
http://sunsite.unc.edu/LDP/HOWTO/CVS-RCS-HOWTO.html
你也可以在下面映射网站找到这份文件 -
http://www.caldera.com/LDP/HOWTO/CVS-RCS-HOWTO.html
http://www.WGS.com/LDP/HOWTO/CVS-RCS-HOWTO.html
http://www.cc.gatech.edu/linux/LDP/HOWTO/CVS-RCS-HOWTO.html
http://www.redhat.com/linux-info/ldp/HOWTO/CVS-RCS-HOWTO.html
其他比较靠近你的映射网站 http://sunsite.unc.edu/LDP/hmirrors.html 选择其中一个网站并到这个目录 /LDP/HOWTO/CVS-RCS-HOWTO.html
想看 dvi 格式的文件,请用 xdvi 。若原本没安装,可在 Redhat Linux 下的 tetex-xdvi*.rpm 套件中找得到。要不然可以经由桌面上的ControlPanel | Applications | Publishing | TeX menu buttons找到他。
想看 dvi 格式的文件,请下命令 -
xdvi -geometry 80x90 howto.dvi,
并且用滑鼠调整视窗大小。请看 xdvi 的线上求助 man xdvi。
使用方向键, Page Up, Page Down 来检视文件。你也可以用 'f', 'd', 'u', 'c', 'l', 'r', 'p', 'n'来移动。
要关掉专家模式 menu 请按 x 。
你可以用软体 'gv' (ghostview) 或 'ghostscript' 来读 postscript 档案。
在 Redhat Linux 下,ghostscript 在 ghostscript*.rpm 套件里, gv 在 gv*.rpm 套件里,如果你已经装了这个应用程式,可以透过 ControlPanel | Applications | Graphics menu 里找到, gv 是比 ghostscript 更友善使用。Ghostscript 和 gv 也可以在其他作业平台如 OS/2, windows 95 和 NT 下使用。
要读 postscript 文件,请下这个命令 -
gv howto.ps
用 ghostscript 请打 -
ghostscript howto.ps
你可以用 Netscape Navigator, Microsoft Internet explorer, Redhat Baron Web browser 或其他浏览器来读 HTML 格式的文件。
你可以用一个 latex 的 "X-Windows" 介面软体叫做 LyX 的,来读 latex 或 LyX 的输出。
9. 版权
这份文件版权为 GNU GPL,但是请在所有的复制中保留原作者的名字与电子邮件地址。