#native_company# #native_desc#

The Power of CVS Page 3

By Tim Perdue
on July 30, 2000

Now I want to blow out my local directory and start checking out from the tree (back up first).

[[email protected] www.phpbuilder.com] $ cd ..

[[email protected] docs] $ rm -rf www.phpbuilder.com

[[email protected] docs] $ cvs -d :pserver:[email protected]:/fireball/cvs checkout www.phpbuilder.com

Now the tree is recreated on my local drive and I can begin editing and committing changes. I want to
create a 1.0 version of the entire site and commit that to the tree. I no longer have to use the -d
option, since the server info is stored within my local tree.

[[email protected] docs] $ cd www.phpbuilder.com

[[email protected] www.phpbuilder.com] $ cvs update   #not really necessary here

[[email protected] www.phpbuilder.com] $ cvs commit -r 1.0

Now if you make changes, commit them, and then regret it, you can always come back to version 1.0.

[[email protected] www.phpbuilder.com] $ cvs update -r 1.0 #or use "cvs checkout -r 1.0"

How’s that for cool? You’re all set up, and you even have the building blocks to allow multiple
developers to work safely against the same cvs tree.
Updating the web server
Now what if you want to automate the updating of your website? I wrote a script that does this.
Once you have committed all of your code and you’re confident that everything works fine, you
can run a script to automate the process.
First, of course you need to know where the DOCUMENT_ROOT of your server is. Mine is at:
/fireball/share/phpbuilder.com/. I then created a directory next to share, called share-update.
I keep a checked-out version of my site in that directory.

[[email protected] www.phpbuilder.com] $ mkdir /fireball/share-update/

[[email protected] www.phpbuilder.com] $ cd /fireball/share-update/

[[email protected] share-update] $ cvs -d /fireball/cvs checkout www.phpbuilder.com

So now I have a directory on my webserver that is similar to my “real” web server directory,
and I can update it using CVS, then move it over to the live server directory.



#    go to the update directory


cd /fireball/share-update/phpbuilder.com/


#    use CVS to update that directory with the latest code


cvs update


#    clear out the "real" web server directory


rm -rf /fireball/share/phpbuilder.com/*


#    move the updated files over to the "real" web server directory


cp -R /fireball/share-update/phpbuilder.com/* /fireball/share/phpbuilder.com/


#    go to the live web server directory


cd /fireball/share/phpbuilder.com/


#    recursively delete all the directories called CVS


find . -type d -name CVS -exec rm -fr {} ;


#    make sure it's all readable by the server


chmod -R 755 *