From: Chris W. <la...@us...> - 2005-03-09 20:26:33
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29942/lib/OpenInteract2 Modified Files: App.pm Package.pm Log Message: OIN-72: be able to install an OI2 package from a CPAN dist Index: App.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/App.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** App.pm 13 Feb 2005 20:44:28 -0000 1.1 --- App.pm 9 Mar 2005 20:26:22 -0000 1.2 *************** *** 5,8 **** --- 5,10 ---- use strict; use base qw( Class::Factory Class::Accessor::Fast ); + use OpenInteract2::Brick; + use OpenInteract2::Config::Package; use OpenInteract2::Exception qw( oi_error ); use OpenInteract2::Manage; *************** *** 12,18 **** my @FIELDS = qw( ! name version module_dependencies build_date author_names author_emails url has_sql_structures ); sub list_apps { --- 14,23 ---- my @FIELDS = qw( ! name version module_dependencies author_names author_emails url has_sql_structures ); + __PACKAGE__->mk_accessors( @FIELDS ); + + # CLASS METHODS sub list_apps { *************** *** 21,25 **** } ! sub install { _must_implement( 'install', @_ ) } sub _must_implement { --- 26,55 ---- } ! ! # OBJECT METHODS ! ! sub init { ! my ( $self ) = @_; ! my $brick = OpenInteract2::Brick->new( $self->get_brick_name ); ! my $package_ini_info = $brick->load_resource( 'package.ini' ); ! my $package_conf = OpenInteract2::Config::Package->new({ ! content => $package_ini_info->{content}, ! }); ! $self->name( $package_conf->name ); ! $self->version( $package_conf->version ); ! $self->module_dependencies( $package_conf->module ); ! $self->author_names( [ $package_conf->author_names ] ); ! $self->author_emails( [ $package_conf->author_emails ] ); ! $self->url( $package_conf->url ); ! ! my $manifest_info = $brick->load_resource( 'MANIFEST' ); ! my @struct_files = grep /^struct/, split /\r?\n/, $manifest_info->{content}; ! $self->has_sql_structures( scalar @struct_files ); ! return $self; ! } ! ! ! sub install { _must_implement( 'install', @_ ) } ! sub get_brick_name { _must_implement( 'get_brick_name', @_ ) } sub _must_implement { *************** *** 71,75 **** "Version: ", $app->version, "\n", "Dependencies: ", join( ", ", $app->module_dependencies, "\n", - "Build date: ", $app->build_date, "\n", "Authors: ", join( ", ", $app->author_names ), "\n", "URL: ", $app->url, "\n", --- 101,104 ---- *************** *** 110,113 **** --- 139,156 ---- Installs the application to C<$website_dir>. + =head1 PROPERTIES + + B<version> + + B<module_dependencies> + + B<author_names> + + B<author_emails> + + B<url> + + B<has_sql_structures> + =head1 SEE ALSO Index: Package.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Package.pm,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** Package.pm 6 Mar 2005 15:06:36 -0000 1.51 --- Package.pm 9 Mar 2005 20:26:22 -0000 1.52 *************** *** 367,371 **** $installed_package->installed_date( scalar( localtime ) ); $installed_package->_install_html_and_widget_files_to_website; ! $installed_package->_install_conf_files_to_website; $log->is_info && $log->info( "Copied package files to website ok" ); --- 367,371 ---- $installed_package->installed_date( scalar( localtime ) ); $installed_package->_install_html_and_widget_files_to_website; ! $installed_package->copy_configuration_to_website(); $log->is_info && $log->info( "Copied package files to website ok" ); *************** *** 380,383 **** --- 380,418 ---- } + sub copy_configuration_to_website { + my ( $self ) = @_; + return unless ( $self->repository ); + my $website_dir = $self->repository->website_dir; + my $package_dir = rel2abs( $self->directory ); + my $dest_conf_dir = catdir( $website_dir, 'conf', $self->name ); + my $dest_update_dir = catdir( $dest_conf_dir, 'updates' ); + + mkpath( $dest_conf_dir ) unless ( -d $dest_conf_dir ); + + my @conf_files = grep /^conf/, @{ $self->get_files }; + my @to_checksum = (); + my %checksums = $self->_read_conf_checksums( $dest_conf_dir ); + FILE: + foreach my $src_base ( @conf_files ) { + my $src_path = catfile( $package_dir, $src_base ); + my $filename = basename( $src_path ); + my $dest_path = catfile( $dest_conf_dir, $filename ); + if ( -f $dest_path ) { + my $md5 = OpenInteract2::Util->digest_file( $src_path ); + next FILE if ( $checksums{ $filename } eq $md5 ); + my $update_path = + catfile( $dest_update_dir, $filename . '-' . $self->version ); + $self->_create_full_path( $update_path ); + cp( $src_path, $update_path ) + || oi_error "Cannot copy $src_path -> $update_path: $!"; + } + else { + cp( $src_path, $dest_path ) + || oi_error "Cannot copy $src_path -> $dest_path: $!"; + push @to_checksum, $filename; + } + } + $self->_write_conf_checksums( $dest_conf_dir, @to_checksum ); + } ######################################## *************** *** 770,810 **** } - sub _install_conf_files_to_website { - my ( $self ) = @_; - my $website_dir = $self->repository->website_dir; - my $package_dir = rel2abs( $self->directory ); - my $dest_conf_dir = catdir( $website_dir, 'conf', $self->name ); - unless ( -d $dest_conf_dir ) { - mkpath( $dest_conf_dir ); - } - my $dest_update_dir = catdir( $dest_conf_dir, 'updates' ); - - my @conf_files = grep /^conf/, @{ $self->get_files }; - my @to_checksum = (); - my %checksums = $self->_read_conf_checksums( $dest_conf_dir ); - FILE: - foreach my $src_base ( @conf_files ) { - my $src_path = catfile( $package_dir, $src_base ); - my $filename = basename( $src_path ); - my $dest_path = catfile( $dest_conf_dir, $filename ); - - if ( -f $dest_path ) { - my $md5 = OpenInteract2::Util->digest_file( $src_path ); - next FILE if ( $checksums{ $filename } eq $md5 ); - my $update_path = - catfile( $dest_update_dir, $filename . '-' . $self->version ); - $self->_create_full_path( $update_path ); - cp( $src_path, $update_path ) - || oi_error "Cannot copy $src_path -> $update_path: $!"; - } - else { - cp( $src_path, $dest_path ) - || oi_error "Cannot copy $src_path -> $dest_path: $!"; - push @to_checksum, $filename; - } - } - $self->_write_conf_checksums( $dest_conf_dir, @to_checksum ); - } - sub _read_conf_checksums { my ( $self, $conf_dir ) = @_; --- 805,808 ---- |