Saturday, August 9, 2008

Installing and configuring Lock and RCS scritp

  • Install RCS package form Sun freeware. “rcs-5.7-sol10-sparc-local”
  • Install following pkg’s
    • libgcc-3.4.6-sol10-sparc-local
    • tcl-8.5.3-sol10-sparc-local
    • libgcc-3.3-sol10-sparc-local
    • expect-5.43.0-sol10-sparc-local
copy lock, lock.exc, lockadm under /usr/bin
chown bin:bin /usr/bin/lock*
# cd /var/etc/
# mkdir RCS
// Put make.conf under revision control
# ci -i make.conf
RCS/make.conf,v <-- make.conf
enter description, terminated with single '.' or end of file:
NOTE: This is NOT the log message!
>> make.conf - custom settings for portage
>> .
initial revision: 1.1
done
// The file is now in RCS, so put it back in /etc for reading
# co make.conf
Notice that make.conf is now under revision control and is read-only. To edit the file, you need to perform the following steps:
Code Listing 2: Editing a file under revision control
// Checkout the file with locking enabled
# co -l make.conf
RCS/make.conf,v --> make.conf
revision 1.1 (locked)
done
// Edit the file
# ${EDITOR} make.conf
// Check the file back in and unlock it.
# ci -u make.conf ( some time we use this command to unlock the file locked by root)
RCS/make.conf,v <-- make.conf
new revision: 1.2; previous revision: 1.1
enter log message, terminated with single '.' or end of file:
>> changed DISTDIR to use a drive with more space
>> . done
ci(1) and co(1)
ci(1) and co(1) are the commands used to check files in and out of their RCS archives. The ci(1) command may also be used to a check a file both in and out of an archive. In their simplest forms, ci(1) and co(1) take only the name of the working file.
ci name_of_work_file
and
co name_of_work_file
The command form
ci -l name_of_work_file
checks in the file with locking enabled, and
co -l name_of_work_file
is performed automatically. That is, ci -l checks the file out again with locking enabled.
ci -u name_of_work_file
checks the file into the archive, and checks it out again with locking disabled. In all cases, the user is prompted for a log message.
ci(1) will also create a RCS archive if one does not exist already.
bash-3.00# /usr/local/bin/rlog aliases
RCS file: RCS/aliases,v
Working file: aliases
head: 1.6
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 6; selected revisions: 6
description:
Aliases file
----------------------------
revision 1.6
date: 2008/07/16 21:00:44; author: tsaini; state: Exp; lines: +0 -1
Removed the entry for tsaini
----------------------------
revision 1.5
date: 2008/07/16 15:29:31; author: tsaini; state: Exp; lines: +1 -1
*** empty log message ***
----------------------------
revision 1.4
date: 2008/07/15 21:50:58; author: hbanwait; state: Exp; lines: +1 -1
*** empty log message ***
=============================================================================
bash-3.00#

Viewing Previous Versions of a File

RCS keeps track of all revisions of a file. You can view a previous version, say version 1.6, of a file (named FILE) by checking out the old version and redirecting it to standard output.
bash-3.00# /usr/local/bin/co -p -r1.5 RCS/aliases,v
You can see the differences between revisions with the rcsdiff command. This example shows the differences between version 1.5 and 1.6.
bash-3.00# /usr/local/bin/rcsdiff -r1.6 -r1.5 RCS/aliases,v
===================================================================
RCS file: RCS/aliases,v
retrieving revision 1.6
retrieving revision 1.5
diff -r1.6 -r1.5
3833a3834
> riskmapper: tsaini
bash-3.00#

Now we can use Lock script to lock the file and edit it. Lock script is customized script to work with rcs.
Lockadm to mange the files.
bash-3.00# lockadm -f ypservers -a -u tsaini
RCS file: RCS/ypservers,v
done
bash-3.00# lockadm -f ypservers -l
The following users are on the access list for ypservers:
tsaini
bash-3.00# lockadm -f ypservers –l
or if you do # lock filename it will ask you to put that file in RCS

1 comment:

Unknown said...

very nice job. Please put more and more notes here so I don't need to search googlge but instead of using your notes.

JRE