Test::Smoke::Syncer - OO interface for syncing the perl source-tree
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;
At this moment we support three types of syncing the perl source-tree.
This method uses the rsync program with the --delete option to get your perl source-tree up to date.
--delete
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.
rsync --delete
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.
[ Constructor | Public ]
Initialise a new object and check all relevant arguments. It returns an object of the appropriate class Test::Smoke::Syncer::*
[ Accessor | Public ]
config() is an interface to the package lexical %CONFIG, which holds all the default values for the new() arguments.
config()
%CONFIG
new()
[ Method | private-ish ]
_clear_source_tree() removes all files in the source-tree using the File::Path module! (See File::Path for caveats.)
_clear_source_tree()
If $tree_dir is not specified, $self->{ddir} is used.
$tree_dir
$self->{ddir}
[ Method | Private-ish ]
_relocate_tree() uses File::Copy::move() to move the source-tree to its destination ($self->{ddir}).
_relocate_tree()
[ 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).
check_dot_patch()
It returns the patchlevel found or undef.
undef
clean_from_directory() uses File::Find to get the contents of $source_dir and compare these to {ddir} and remove all other files.
clean_from_directory()
$source_dir
The contents of @leave_these should be in "MANIFEST-format".
This handles syncing with the rsync program. It should only be visible from the "parent-package" so no direct user-calls on this.
This crates the new object. Keys for %args:
%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
Do the actual sync.
This handles syncing with the Net::FTP module. It should only be visible from the "parent-package" so no direct user-calls on this.
* 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
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.
/^perl@\d+\.tgz$/
This does the actual ftpsession.
_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.
_extract_snapshot()
_extract_with_Archive_Tar() uses the Archive::Tar and Compress::Zlib modules to extract the snapshot. This tested verry slow on my Linux box!
_extract_with_Archive_Tar()
_extract_with_external() uses $self->{tar} as a sprintf() template to build a command. Yes that might be dangerous!
_extract_with_external()
$self->{tar}
patch_a_snapshot() tries to fetch all the patches between $patch_number and perl-current and apply them. This requires a working patch program.
patch_a_snapshot()
$patch_number
perl-current
You should pass this extra information to Test::Smoke::Syncer::Snapshot->new():
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 )
_get_patches() sets up the FTP connection and gets all patches beyond $patch_number. Remember that patch numbers do not have to be consecutive.
_get_patches()
_apply_patches() calls the patch program to apply the patch and updates .patch accordingly.
_apply_patches()
@patch_list is a list of filenames of these patches.
@patch_list
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
_read_patch() unzips the patch and returns the contents.
_read_patch()
_fix_dot_patch() updates the .patch file with the new patch level.
_fix_dot_patch()
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.
* ddir: destination directory ( ./perl-current ) * cdir: directory to copy from ( undef ) * v: verbose
This uses Test::Smoke::SourceTree to do the actual copying.
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!
Keys for %args:
* ddir: destination directory * hdir: source directory * v: verbose
sync() uses the File::Find module to make the hardlink forest in {ddir}.
sync()
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.
* 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)
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}.
rsync, gzip, tar, Archive::Tar, Compress::Zlib, File::Copy, Test::Smoke::SourceTree
(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.
To install Mail::Sendmail, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mail::Sendmail
CPAN shell
perl -MCPAN -e shell install Mail::Sendmail
For more information on module installation, please visit the detailed CPAN module installation guide.