NAME
Test::Smoke::Syncer - OO interface for syncing the perl source-tree
SYNOPSIS
use Test::Smoke::Syncer;
my $type = 'rsync'; # or 'snapshot' or 'copy'
my $syncer = Test::Smoke::Syncer->new( $type => %sync_config );
my $patch_level = $syncer->sync;
DESCRIPTION
At this moment we support three types of syncing the perl source-tree.
- rsync
-
This method uses the rsync program with the
--delete
option to get your perl source-tree up to date. - snapshot
-
This method uses the Net::FTP module to get the latest snapshot. To emulate the
rsync --delete
effect, the current source-tree is removed. The snapshot tarball is handled by either tar/gzip or Archive::Tar/Compress::Zlib. - copy
-
This method uses the File::Copy module to copy an existing source-tree from somewhere on the system (in case rsync doesn't work), this also removes the current source-tree first.
METHODS
- Test::Smoke::Syncer->new( $type, %sync_config )
-
[ Constructor | Public ]
Initialise a new object and check all relevant arguments. It returns an object of the appropriate class Test::Smoke::Syncer::*
- Test::Smoke::Syncer->config( $key[, $value] )
-
[ Accessor | Public ]
config()
is an interface to the package lexical%CONFIG
, which holds all the default values for thenew()
arguments. - $syncer->_clear_souce_tree( $tree_dir )
-
[ Method | private-ish ]
_clear_source_tree()
removes all files in the source-tree using the File::Path module! (See File::Path for caveats.)If
$tree_dir
is not specified,$self->{ddir}
is used. - $syncer->_relocate_tree( $source_dir )
-
[ Method | Private-ish ]
_relocate_tree()
uses File::Copy::move() to move the source-tree to its destination ($self->{ddir}
). - $syncer->check_dot_patch( )
-
[ Method | Private ]
check_dot_patch()
checks if there is a '.patch' file in the source-tree. It will try to create one if it is not there (this is the case for snapshots).It returns the patchlevel found or
undef
. - $syncer->clean_from_directory( $source_dir[, @leave_these] )
-
clean_from_directory()
uses File::Find to get the contents of$source_dir
and compare these to {ddir} and remove all other files.The contents of @leave_these should be in "MANIFEST-format".
Test::Smoke::Syncer::Rsync
This handles syncing with the rsync program. It should only be visible from the "parent-package" so no direct user-calls on this.
- Test::Smoke::Syncer::Rsync->new( %args )
-
This crates the new object. Keys for
%args
:* ddir: destination directory ( ./perl-current ) * source: the rsync source ( ftp.linux.activestate.com::perl-current ) * opts: the options for rsync ( -az --delete ) * rsync: the full path to the rsync program ( rsync ) * v: verbose
- $object->sync( )
-
Do the actual sync.
Test::Smoke::Syncer::Snapshot
This handles syncing with the Net::FTP module. It should only be visible from the "parent-package" so no direct user-calls on this.
- Test::Smoke::Syncer::Snapshot->new( %args )
-
This crates the new object. Keys for
%args
:* ddir: destination directory ( ./perl-current ) * server: the server to get the snapshot from ( ftp.funet.fi ) * sdir: server directory ( /pub/languages/perl/snap ) * snapext: the extension used for snapdhots ( tgz ) * tar: howto untar ( Archive::Tar or 'gzip -d -c %s | tar x -' ) * v: verbose
- $syncer->sync( )
-
Make a connection to the ftp server, change to the {sdir} directory. Get the list of snapshots (
/^perl@\d+\.tgz$/
) and determin the highest patchlevel. Fetch this file. Remove the current source-tree and extract the snapshot. - $syncer->_fetch_snapshot( )
-
This does the actual ftpsession.
- $syncer->_extract_snapshot( )
-
_extract_snapshot()
checks the tar attribute to find out how to extract the snapshot. This could be an external command or the Archive::Tar/Comperss::Zlib modules. - $syncer->_extract_with_Archive_Tar( )
-
_extract_with_Archive_Tar()
uses the Archive::Tar and Compress::Zlib modules to extract the snapshot. This tested verry slow on my Linux box! - $syncer->_extract_with_external( )
-
_extract_with_external()
uses$self->{tar}
as a sprintf() template to build a command. Yes that might be dangerous! - $syncer->patch_a_snapshot( $patch_number )
-
patch_a_snapshot()
tries to fetch all the patches between$patch_number
andperl-current
and apply them. This requires a working patch program.You should pass this extra information to
Test::Smoke::Syncer::Snapshot->new()
:* patchup: should we do this? ( 0 ) * pserver: which FTP server? ( ftp2.activestate.com ) * pdir: directory ( /pub/staff/gsar/APC/perl-current-diffs ) * unzip: ( gzip ) [ Compress::Zlib ] * patch: ( patch ) * cleanup: remove patches after applied? ( 1 )
- $syncer->_get_patches( [$patch_number] )
-
_get_patches()
sets up the FTP connection and gets all patches beyond$patch_number
. Remember that patch numbers do not have to be consecutive. - $syncer->_apply_patches( @patch_list )
-
_apply_patches()
calls the patch program to apply the patch and updates .patch accordingly.@patch_list
is a list of filenames of these patches.Check the unzip attribute to find out how to unzip the patch and call the patch program.
* $patch = <FH> * open PATCH, "| $self->{patch} -u -p1" * print PATCH $patch
- $syncer->_read_patch( $file )
-
_read_patch()
unzips the patch and returns the contents. - $syncer->_fix_dot_patch( $new_level );
-
_fix_dot_patch()
updates the .patch file with the new patch level.
Test::Smoke::Syncer::Copy
This handles syncing with the File::Copy module from a local directory. It uses the MANIFEST file is the source directory to determine which fiels to copy. The current source-tree removed before the actual copying.
- Test::Smoke::Syncer::Copy->new( %args )
-
This crates the new object. Keys for
%args
:* ddir: destination directory ( ./perl-current ) * cdir: directory to copy from ( undef ) * v: verbose
- $syncer->sync( )
-
This uses Test::Smoke::SourceTree to do the actual copying.
Test::Smoke::Syncer::Hardlink
This handles syncing by copying the source-tree from a local directory using the link function. This can be used as an alternative for make distclean.
Thanks to Nicholas Clark for donating this suggestion!
- Test::Smoke::Syncer::Hardlink->new( %args )
-
Keys for
%args
:* ddir: destination directory * hdir: source directory * v: verbose
- $syncer->sync( )
-
sync()
uses the File::Find module to make the hardlink forest in {ddir}.
Test::Smoke::Syncer::Forest
This handles syncing by setting up a master directory that is in sync with either a snapshot or the repository. Then it creates a copy of this master directory as a hardlink forest and the regenheaders.pl script is run (if found). Now the source-tree should be up to date and ready to be copied as a hardlink forest again, to its final destination.
Thanks to Nicholas Clark for donating this idea.
- Test::Smoke::Syncer::Forest->new( %args )
-
Keys for
%args
:* All keys from the other methods (depending on {fsync}) * fsync: which master sync method is to be used * mdir: master directory * fdir: intermediate directory (first hardlink forest)
- $syncer->sync( )
-
sync()
starts with a "traditional" sync according to {ftype} in {mdir}. It then creates a copy of {mdir} in {fdir} with hardlinks an tries to run the regen_headers.pl script in {fdir}. This directory should now contain an up to date (working) source-tree wich again using hardlinks is copied to the destination directory {ddir}.
SEE ALSO
rsync, gzip, tar, Archive::Tar, Compress::Zlib, File::Copy, Test::Smoke::SourceTree
COPYRIGHT
(c) 2002, All rights reserved.
* Abe Timmerman <abeltje@cpan.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.