Programmers' Canvas Toolkit Home

CVSWebSync for Windows

SourceForge.net Logo

2004-07-26 10:26:36 AM -0500

License
Wiki
Support
Search

Installing CVS on Windows

FileTools
Globals.XML
Package.XML
CVS LogInfo, TagInfo, and Notify Scripts

Open Source Development with CVSCvs Pocket ReferenceEssential CVS


License

See here


CVSNTUpd Synchronizes CVS to any Filesystem Folder - Automatically


CVSWebSync Commits Web Sites (or any other directory structure) to CVS

Sometimes forcing website authors to use CVS is unrealistic.  FrontPage Extensions make it easy to modify content but at the risk of losing change history.  With CVSWebSync, you can commit content from your website into CVS at whatever interval you choose. 

Caveats:

  • This program only works if your computer has filesystem access (at least read access) to the web site's files, either locally or via a network share.  In other words, if the website files are only accessible via FTP, you can still use CVSWebSync but you have to script the FTP download yourself, which is usually unrealistic due to FTP timeouts over the Internet.
  • CVS commits only occur when you invoke CVSWebSync.  If someone modifies a file twice between invocations, CVSWebSync will only save the last revision to CVS.
  • CVSWebSync is unable to keep track of who modified which files.  CVSWebSync commits all changes using the same CVS user account.
  • CVSWebSync doesn't yet remove deleted files from your web server from CVS

Given these caveats, CVSWebSync may not be for you.  Or, CVSWebSync may be better than having no revision history of your website.

Instructions:

  1. Download FileTools 1.8.1.5 or later
    • For Windows, get the latest FILETOOLS_*.TAR.GZ (1.8.1.5 or later)
    • If you want to use the Perl source code option:
      • Install Perl
      • Extract FILETOOLSPERL_*.TAR.GZ to a location in your PATH
      • Extract FILETOOLSPERL_LIB_*.TAR.GZ to the Perl lib directory e.g., c:/perl/site/lib (keep the root directory for the archive which is cfgmgmt)
      • Install the Clone module
        ppm
        install Clone
      • Please note that if you use the Perl source code, you must invoke scripts as scriptname.pl or perl -S scriptname.pl rather than as scriptname
  2. Create a dummy CVS repository for testing
    1. Create a new directory, e.g., c:/cvs/cvswebsync
    2. Enter the following command:
      cvs -d :local:c:/cvs/cvswebsync init
    3. Create the web module:
      mkdir c:\cvs\cvswebsync\web
    4. Create a sandbox and check out CVS
      c:
      cd \
      mkdir sandbox
      cd sandbox
      cvs -d :local:c:/cvs/cvswebsync co CVSROOT
      cd CVSROOT
    5. Modify the cvswrappers file in the CVSROOT directory in your sandbox.  This file lists all binary file extensions that appear in your website.  Here is a recommended file.
    6. Run the following commands from the command line:
      c:
      cd \sandbox\CVSROOT
      cvs -d :local:c:/cvs/cvswebsync commit
  3. Create a new directory, e.g., c:/cvswebsync
  4. Add the following XML file to that directory.  See the description of this XML file.  Save the file as package.XML

<Package-Doc>

<CVS>
<CVSModule>web</CVSModule>
<CVSROOT>:local:c:/cvs/cvswebsync</CVSROOT>
<CommitMessage>Committing Files</CommitMessage>
<Tag></Tag>
</CVS>

<DeleteDir>CVS</DeleteDir>
<DeleteDir>_vti_cnf</DeleteDir>
<DeleteDir>_vti_log</DeleteDir>
<DeleteDir>_reqdis</DeleteDir>
<DeleteDir>_private</DeleteDir>
<DeleteDir>_vti_script</DeleteDir>
<DeleteDir>_vti_pvt</DeleteDir>
<DeleteDir>_vti_text</DeleteDir>
<DeleteDir>_vti_txt</DeleteDir>
<DeleteDir>_derived</DeleteDir>
<DeleteDir>Copy of _vti_cnf</DeleteDir>
<DeleteDir>Copy of _vti_log</DeleteDir>
<DeleteDir>Copy of _borders</DeleteDir>
<DeleteDir>Copy of _reqdis</DeleteDir>
<DeleteDir>Copy of _private</DeleteDir>
<DeleteDir>Copy of _vti_script</DeleteDir>
<DeleteDir>Copy of _vti_pvt</DeleteDir>
<DeleteDir>Copy of _vti_text</DeleteDir>
<DeleteDir>Copy of _vti_txt</DeleteDir>
<DeleteDir>Copy of _derived</DeleteDir>
<Delete>_vti_inf.*<Recursive>1</Recursive></Delete>

<Source>
<CVS>1</CVS>
</Source>

<Source>

<Filespec>*</Filespec>

<Filespec>images/<Recursive>1</Recursive>
<KeepDirectoryStructure>1</KeepDirectoryStructure>
</Filespec>

<Filespec>eng/docs/<Recursive>1</Recursive>
<KeepDirectoryStructure>1</KeepDirectoryStructure>
</Filespec>

<Destination>web/</Destination>

</Source>

</Package-Doc>

  1. Modify the <Filespec> tags, delete them, and/or add new ones.  These specify the files and directories in your web site that you want to check into CVS.  If you specify a directory name, either make sure you end the directory name with a slash or use foo/* as the filespec.
  2. Run the following commands:
    c:
    cd \cvswebsync
    dgprune c:/cvs/cvswebsync/web
    dgprune sandbox
    dgpackage -s [[websitepath]] -d sandbox . package.xml

    Where [[websitepath]] is the full path of the root of your website, e.g., c:/inetpub/wwwroot

    Note:  There is a period between sandbox and package.xml
     

  3. This above commands perform the following actions:
    1. Remove the contents of the c:\cvs\cvswebsync\web directory (which is your local throw-away CVS repository only used for testing)
    2. Delete the contents of the c:\cvswebsync\sandbox directory
    3. Check out the "web" module from CVS to c:\cvs\sandbox
    4. Copy the website contents to the c:\cvs\sandbox\web directory, using only the files and directories that are specified in the package.xml file
    5. Remove IIS administrative directories from the sandbox (vti_text, etc.)
    6. Add new files and folders under c:\sandbox\web which have not been committed to CVS yet
    7. Commit new and changed files in c:\sandbox\web to CVS
  4. Test until it works to your satisfaction
  5. When you're ready to put the script into production,
    1. Change <CVSROOT>, <CVSModule>, and <Destination> in package.xml to work with your "real" CVS server (<CVSModule> and <Destination> should not be altered)
    2. Ensure that the current user has CVS access; i.e., do "cvs login" if necessary.  If SSH is used, make sure pageant is running and has your key loaded.
    3. Create a batch file c:\cvswebsync\webcopy.bat with the following commands
      c:
      cd \cvswebsync
      dgprune sandbox
      dgpackage -q -s [[websitepath]] -d sandbox . package.xml

      Note:  There is a period between sandbox and package.xml
    4. Run the batch program when you want to post your website to CVS

Emailing Notification of CVSWebSync Execution Success or Failure

The CVSWebSync program (dgpackage) returns 0 if it succeeds and 1 if it fails.  If you run CVSWebSync in an automated fashion, you can use another DevGuy FileTool, dgscript, to receive failure or success notifications via email.  dgscript is also included in the Programmers' Canvas Toolkit (pctk).

  1. Modify the file globals.xml in your Program Files/DevGuy/FileTools folder
  2. Change the <SMTPServer> element to contain the name of your SMTP server
  3. Globals.xml is described more here
  4. Add the following XML file to c:\cvswebsync -- save it as script.xml

<Script>

<!-- These are the commands to run
-->
<Do>
<Step name="CVSWebSync">
<Run
command="c:\cvswebsync\webcopy.bat"
checkExitCode="true" />

<!-- Use condition="fail" to only receive emails
     on failure
-->
<Notify condition="end">

<!-- Send Email
All values for email addresses can be comma
or semicolon delimited lists
-->
<NotifySMTP to="yourname@yourdomain.com"/>


</Notify>

</Step>
</Do>
</Script>

  1. Change the to attribute in <NotifySMTP> to your email address
  2. Run the "script" as:
    dgscript c:/cvswebsync/script.xml
  3. If you would like to use the Perl source code, you must also install the XML::Simple module
    ppm
    install Clone
    install XML::Simple
  4. There are two situations which result in new revisions being committed when modifications have not occurred:
    1. File contains CVS keywords ($HEADER$, etc.)
      • Run the following command for each file that contains CVS keywords:
        cvs admin -ko filename
    2. UNICODE (UCS2, not UTF-8)
      • Run the following command for each UCS2 file:
        cvs admin -ku filename