CVS exercises
APRICOT 2008


1. Install cvs

	# apt-get install cvs


2. Init a new CVS ROOT:

	*NOTE* Do this exercise as the normal user, NOT ROOT!!!

	- First, set the environment variable "CVSROOT" to the path
	- Where your CVS repository will be created:

	> CVSROOT=/home/MYHOMEDIRECTORY/cvs
	> export CVSROOT

	- Now create the directory

	> mkdir $CVSROOT
	> cvs init

	- Check that it was created correctly!

	> ls -l /home/MYHOMEDIRECTORY/cvs

	- You should see a directory called "CVSROOT"
	- Look at the contents of the directory.

3. Let's create a project in CVS for the configuration files on your system
   and import these files into the CVS!

	> mkdir /home/MYHOMEDIRECTORY/temp
	> cp /etc/smokeping/config /home/mysername/temp/config.smokeping

	- Now we need to import these files into CVS:
	- Let's make a new project called "configs"

	> cd /home/MYHOMEDIRECTORY/temp
	> cvs import configs before_cvs start

	(Note: the "before_cvs" and "start" are just labels to say that
	we are importing from "before we used CVS, and this is the start")

	- When you see this:

CVS: ----------------------------------------------------------------------
CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically
CVS:
CVS: ----------------------------------------------------------------------

	... just enter a message saying what you did, for example:

	This is a first import of our config files

	... Then save the file + quit.

	You should see something like this:

File /tmp/cvsh3EOVw saved
N configs/config.smokeping
^
(new file)

No conflicts created by this import

3b. Look at the contents of /home/MYHOMEDIRECTORY/cvs/configs

	> ls -l /home/MYHOMEDIRECTORY/cvs/configs
	total 36
	-r--r--r--   1 regnauld  wheel    799 Aug 31 17:26 config,v


4. Now we can remove our temp directory, and check out the
   configs/ project from CVS!

	> cd /home/MYHOMEDIRECTORY
	> rm -rf temp

	- Let's now check out from cvs :

	> cvs -d /home/MYHOMEDIRECTORY/cvs co configs

	- You should see something like:

cvs checkout: Updating configs
U configs/config.smokeping

	> ls -l /home/MYHOMEDIRECTORY/configs/

	- Notice the CVS directory in /home/MYHOMEDIRECTORY/configs/

	*NOTE* remember, never modify the CVS/ directory by hand!!
	It is only for experienced CVS users...

5. Let's modify the files, add another one, and check things in again:

	> cd /home/mysername/configs
	> vi config.smokeping

	... add something to it, for example a new configuration for
	a new host, then save and quit.

	- Add the APT sources.list file to the directory:

	> cp /etc/apt/sources.list .

	- Tell cvs to show us the status:

	> cvs status

	- Add it to the CVS:

	> cvs add sources.list

	- You should see this:

cvs add: scheduling file `sources.list' for addition
cvs add: use `cvs commit' to add this file permanently

	- You are now ready to commit!

	> cvs commit

	- If all goes well, you should have this in your editor window:

CVS: ----------------------------------------------------------------------
CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically
CVS:
CVS: Committing in .
CVS:
CVS: Modified Files:
CVS:    config.smokeping
CVS: Added Files:
CVS:    sources.list
CVS: ----------------------------------------------------------------------





	... add a message:

	Importing APT sources.list, and modifying smokeping config

	... then save + quit

	You should see this:

File /tmp/cvs3CyXND saved
/home/inst/cvs/configs/config.smokeping,v  <--  config.smokeping
new revision: 1.2; previous revision: 1.1
/home/inst/cvs/configs/sources.list,v  <--  sources.list
initial revision: 1.1


6. Let's see the history for the config.smokeping file:

	> cvs log config.smokeping

	... notice the output

	- Finally, let's try and see the difference between two
	  versions of the config.smokeping file:

	> cvs diff -r 1.1 -r 1.2 config.smokeping

	- What do you notice ?

