|
From: Chris W. <la...@us...> - 2001-11-26 13:13:25
|
Update of /cvsroot/openinteract/OpenInteract/OpenInteract
In directory usw-pr-cvs1:/tmp/cvs-serv5862
Modified Files:
Package.pm
Log Message:
make copying of many types of files conditional, depending on the
contents of the .no_overwrite file in the directory
Index: Package.pm
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract/OpenInteract/Package.pm,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** Package.pm 2001/10/11 03:15:26 1.25
--- Package.pm 2001/11/26 13:13:21 1.26
***************
*** 17,24 ****
use SPOPS::HashFile ();
use SPOPS::Utility ();
! @OpenInteract::Package::ISA = qw();
$OpenInteract::Package::VERSION = sprintf("%d.%02d", q$Revision$ =~ /(\d+)\.(\d+)/);
# Define the subdirectories present in a package
--- 17,28 ----
use SPOPS::HashFile ();
use SPOPS::Utility ();
+ require Exporter;
! @OpenInteract::Package::ISA = qw( Exporter );
$OpenInteract::Package::VERSION = sprintf("%d.%02d", q$Revision$ =~ /(\d+)\.(\d+)/);
+ @OpenInteract::Package::EXPORT_OK = qw( READONLY_FILE );
+ use constant READONLY_FILE => '.no_overwrite';
+
# Define the subdirectories present in a package
***************
*** 1130,1148 ****
sub _copy_action_config_file {
my ( $class, $info, $CONFIG ) = @_;
! my $interact_pkg_dir = join( '/', $info->{base_dir}, $info->{package_dir} );
! my $website_pkg_dir = join( '/', $info->{website_dir}, $info->{package_dir} );
! DEBUG && _w( 1, "Coping action info from ($interact_pkg_dir) to ($website_pkg_dir)" );
my $action_conf = 'conf/action.perl';
my $base_config_file = "$interact_pkg_dir/$action_conf";
! my $action_base = eval { SPOPS::HashFile->new({ filename => $base_config_file }) };
if ( $@ ) {
! DEBUG && _w( 1, "No action info for $info->{name}-$info->{version} (generally ok: $@)" );
return undef;
}
my $new_config_file = "$website_pkg_dir/$action_conf";
! my $action_pkg = eval { SPOPS::HashFile->new({ filename => $new_config_file,
! perm => 'new' }) };
# Go through all of the actions and all of the keys and copy them
--- 1134,1158 ----
sub _copy_action_config_file {
my ( $class, $info, $CONFIG ) = @_;
! my $interact_pkg_dir = join( '/', $info->{base_dir},
! $info->{package_dir} );
! my $website_pkg_dir = join( '/', $info->{website_dir},
! $info->{package_dir} );
! DEBUG && _w( 1, "Coping action info from ($interact_pkg_dir)",
! "to ($website_pkg_dir)" );
my $action_conf = 'conf/action.perl';
my $base_config_file = "$interact_pkg_dir/$action_conf";
! my $action_base = eval { SPOPS::HashFile->new({
! filename => $base_config_file }) };
if ( $@ ) {
! DEBUG && _w( 1, "No action info for $info->{name}-$info->{version}",
! "(generally ok: $@)" );
return undef;
}
my $new_config_file = "$website_pkg_dir/$action_conf";
! my $action_pkg = eval { SPOPS::HashFile->new({
! filename => $new_config_file,
! perm => 'new' }) };
# Go through all of the actions and all of the keys and copy them
***************
*** 1174,1177 ****
--- 1184,1188 ----
my ( $class, $root_dir, $sub_dir, $file_list ) = @_;
my @copy_file_list = grep /^$sub_dir/, @{ $file_list };
+ my %no_copy = map { $_ => 1 } $class->read_readonly_file( $root_dir );
foreach my $sub_dir_file ( @copy_file_list ) {
***************
*** 1179,1182 ****
--- 1190,1194 ----
$just_filename =~ s|^$sub_dir/||;
my $new_name = join( '/', $root_dir, $just_filename );
+ next if ( $no_copy{ $just_filename } );
eval { $class->_create_full_path( $new_name ) };
if ( $@ ) { die "Cannot create path to file ($new_name): $@" }
***************
*** 1193,1196 ****
--- 1205,1228 ----
+ sub read_readonly_file {
+ my ( $class, $dir ) = @_;
+ my $overwrite_check_file = join( '/', $dir, READONLY_FILE );
+ return () unless ( -f $overwrite_check_file );
+ my ( @no_write );
+ if ( open( NOWRITE, $overwrite_check_file ) ) {
+ while ( <NOWRITE> ) {
+ chomp;
+ next if ( /^\s*$/ );
+ next if ( /^\s*\#/ );
+ s/^\s+//;
+ s/\s+$//;
+ push @no_write, $_;
+ }
+ close( NOWRITE );
+ }
+ return @no_write;
+ }
+
+
# Copy handlers from the base installation to the website directory,
# putting class names into the namespace of the website
***************
*** 1198,1207 ****
sub _copy_handler_files {
my ( $class, $info, $base_files ) = @_;
! my $website_pkg_dir = join( '/', $info->{website_dir}, $info->{package_dir} );
# We're only operating on the files that begin with
# 'OpenInteract/Handler'...
! my @handler_file_list = grep /^OpenInteract\/Handler/, keys %{ $base_files };
foreach my $handler_filename ( @handler_file_list ) {
--- 1230,1241 ----
sub _copy_handler_files {
my ( $class, $info, $base_files ) = @_;
! my $website_pkg_dir = join( '/', $info->{website_dir},
! $info->{package_dir} );
# We're only operating on the files that begin with
# 'OpenInteract/Handler'...
! my @handler_file_list = grep /^OpenInteract\/Handler/,
! keys %{ $base_files };
foreach my $handler_filename ( @handler_file_list ) {
***************
*** 1222,1229 ****
# the 'OpenInteract::Handler::xx' with '$WEBSITE_NAME::Handler::xx'
! open( OLDHANDLER, $handler_filename ) || die "Cannot read handler ($handler_filename): $!";
eval { $class->_create_full_path( $new_filename ) };
! if ( $@ ) { die "Cannot create a directory tree to handler ($new_filename): $@" }
! open( NEWHANDLER, "> $new_filename" ) || die "Cannot write to handler ($new_filename): $!";
while ( <OLDHANDLER> ) {
s/$handler_class/$new_handler_class/g;
--- 1256,1267 ----
# the 'OpenInteract::Handler::xx' with '$WEBSITE_NAME::Handler::xx'
! open( OLDHANDLER, $handler_filename )
! || die "Cannot read handler ($handler_filename): $!";
eval { $class->_create_full_path( $new_filename ) };
! if ( $@ ) {
! die "Cannot create a dir tree to handler ($new_filename): $@";
! }
! open( NEWHANDLER, "> $new_filename" )
! || die "Cannot write to handler ($new_filename): $!";
while ( <OLDHANDLER> ) {
s/$handler_class/$new_handler_class/g;
|