[Bps-public-commit] r10738 - in Shipwright: . lib/Shipwright lib/Shipwright/Backend lib/Shipwright/Script lib/Shipwright/Source

sunnavy at bestpractical.com sunnavy at bestpractical.com
Wed Feb 6 16:40:50 EST 2008


Author: sunnavy
Date: Wed Feb  6 16:40:50 2008
New Revision: 10738

Removed:
   Shipwright/lib/Shipwright/Config.pm
   Shipwright/lib/Shipwright/Script/Export.pm
   Shipwright/lib/Shipwright/Script/List.pm
Modified:
   Shipwright/META.yml
   Shipwright/Makefile.PL
   Shipwright/lib/Shipwright.pm
   Shipwright/lib/Shipwright/Backend.pm
   Shipwright/lib/Shipwright/Backend/SVK.pm
   Shipwright/lib/Shipwright/Backend/SVN.pm
   Shipwright/lib/Shipwright/Logger.pm
   Shipwright/lib/Shipwright/Script/Build.pm
   Shipwright/lib/Shipwright/Script/Import.pm
   Shipwright/lib/Shipwright/Script/Initialize.pm
   Shipwright/lib/Shipwright/Script/Maintain.pm
   Shipwright/lib/Shipwright/Source/Base.pm
   Shipwright/lib/Shipwright/Util.pm

Log:
no config anymore

Modified: Shipwright/META.yml
==============================================================================
--- Shipwright/META.yml	(original)
+++ Shipwright/META.yml	Wed Feb  6 16:40:50 2008
@@ -19,11 +19,11 @@
   Algorithm::Dependency::Ordered: 0
   Algorithm::Dependency::Source::HoA: 0
   App::CLI: 0
+  CPAN: 1.9205
   CPAN::DistnameInfo: 0
   Class::Accessor::Fast: 0
   File::Copy: 0
   File::Copy::Recursive: 0
-  File::HomeDir: 0
   File::Slurp: 0
   File::Spec: 0
   File::Temp: 0

Modified: Shipwright/Makefile.PL
==============================================================================
--- Shipwright/Makefile.PL	(original)
+++ Shipwright/Makefile.PL	Wed Feb  6 16:40:50 2008
@@ -10,7 +10,6 @@
 requires 'CPAN::DistnameInfo' => 0;
 requires 'Class::Accessor::Fast' => 0;
 requires 'File::Temp' => 0;
-requires 'File::HomeDir' => 0;
 requires 'File::Copy' => 0;
 requires 'File::Copy::Recursive' => 0;
 requires 'File::Spec' => 0;

Modified: Shipwright/lib/Shipwright.pm
==============================================================================
--- Shipwright/lib/Shipwright.pm	(original)
+++ Shipwright/lib/Shipwright.pm	Wed Feb  6 16:40:50 2008
@@ -8,9 +8,8 @@
 
 use base qw/Class::Accessor::Fast/;
 
-__PACKAGE__->mk_accessors(qw/config backend source build/);
+__PACKAGE__->mk_accessors(qw/backend source build log_level/);
 
-use Shipwright::Config;
 use Shipwright::Backend;
 use Shipwright::Source;
 use Shipwright::Build;
@@ -26,56 +25,22 @@
 
     my %args = @_;
 
-    unless ( $args{config} ) {
-        require File::Spec;
-        require File::HomeDir;
-        $args{config} =
-          File::Spec->catfile( File::HomeDir->my_home, '.shipwright', 'config.yml' );
-    }
-
-    my $self = {};
+    my $self = { log_level => $args{log_level} };
     bless $self, $class;
 
-    $self->config(
-        Shipwright::Config->new( config => delete $args{config}, name => $args{name} )
-    );
-
-    if ( $self->config->name ) {
-        Shipwright::Logger->new($self);
-
-        $self->backend(
-            Shipwright::Backend->new(
-                %{ $self->config->name->{backend} },
-                name => $args{name},
-            )
-        );
-
-        if ( $args{source} ) {
-            $self->source(
-                Shipwright::Source->new(
-                    %{ $self->config->name->{source} },
-                    follow => $args{follow},
-                    source => $args{source},
-                    name   => $args{source_name},
-                )
-            );
-            $self->source->log(
-                Log::Log4perl->get_logger( ref $self->source ) );
-        }
-
-        $self->build(
-            Shipwright::Build->new(
-                %{ $self->config->name->{build} },
-                $args{build_script} && scalar @{ $args{build_skip} }
-                ? ( skip => $args{build_skip} )
-                : (),
-            )
-        );
-
-        for my $comp (qw/backend build/) {
-            $self->$comp->log( Log::Log4perl->get_logger( ref $self->$comp ) );
-        }
+    Shipwright::Logger->new($self);
+
+    $self->backend( Shipwright::Backend->new(%args) );
+
+    if ( $args{source} ) {
+        $self->source( Shipwright::Source->new(%args) );
+        $self->source->log( Log::Log4perl->get_logger( ref $self->source ) );
+    }
+
+    $self->build( Shipwright::Build->new(%args) );
 
+    for my $comp (qw/backend build/) {
+        $self->$comp->log( Log::Log4perl->get_logger( ref $self->$comp ) );
     }
     return $self;
 }

Modified: Shipwright/lib/Shipwright/Backend.pm
==============================================================================
--- Shipwright/lib/Shipwright/Backend.pm	(original)
+++ Shipwright/lib/Shipwright/Backend.pm	Wed Feb  6 16:40:50 2008
@@ -17,12 +17,17 @@
     my $class = shift;
     my %args  = @_;
 
-    my $module = delete $args{module};
+    my $module;
 
-    croak "need a backend module, please check your config" unless $module;
-    croak "need name option"                                unless $args{name};
-
-    $module = 'Shipwright::Backend::' . $module unless $module =~ /^Shipwright::Backend/;
+    if ( $args{repository} =~ s{^\s*svk:}{} ) {
+        $module = 'Shipwright::Backend::SVK';
+    }
+    elsif ( $args{repository} =~ s{^\s*svn:}{} ) {
+        $module = 'Shipwright::Backend::SVN';
+    }
+    else {
+        croak "invalid repository: $args{repository}\n";
+    }
 
     $module->require or die $@;
 
@@ -30,7 +35,7 @@
 }
 
 my %scripts = (
-        wrapper => <<'EOF'
+    wrapper => <<'EOF'
 #!/bin/sh
 if [ -z `which readlink` ]; then  
     # if we don't have readlink, we're on some pitiful platform like solaris
@@ -53,8 +58,8 @@
     exec $LINK "$@"
 fi
 EOF
-,
-perl_wrapper => <<'EOF'
+    ,
+    perl_wrapper => <<'EOF'
 #!/bin/sh
 if [ -z `which readlink` ]; then  
     # if we don't have readlink, we're on some pitiful platform like solaris
@@ -77,8 +82,8 @@
     exec $LINK "$@"
 fi
 EOF
-  ,
-utility => <<'EOF'
+    ,
+    utility => <<'EOF'
 #!/usr/bin/env perl
 use strict;
 use warnings;
@@ -174,7 +179,7 @@
 }
 
 EOF
-,
+    ,
     builder => <<'EOF'
 #!/usr/bin/env perl
 use warnings;
@@ -577,8 +582,8 @@
 
 }
 EOF
-, 
-installed_utility => <<'EOF'
+    ,
+    installed_utility => <<'EOF'
 #!/usr/bin/env perl 
 use strict;
 use warnings;
@@ -627,8 +632,8 @@
 }
 
 EOF
-,
-source_bash => <<'EOF'
+    ,
+    source_bash => <<'EOF'
 #!/usr/bin/env bash
 if [ $# = 1 ]; then
     export PATH=$1/bin:$PATH
@@ -639,8 +644,8 @@
     echo 'USAGE: source shipwright-source-bash BASEPATH'
 fi
 EOF
-,
-source_tcsh => <<'EOF'
+    ,
+    source_tcsh => <<'EOF'
 #!/usr/bin/env tcsh
 if ( $# == 1 ) then
     setenv PATH $1/bin:$PATH
@@ -651,8 +656,8 @@
     echo 'USAGE: source shipwright-source-tcsh BASEPATH'
 endif
 EOF
-,
-null => '',    
+    ,
+    null => '',
 );
 
 =head2 make_script

Modified: Shipwright/lib/Shipwright/Backend/SVK.pm
==============================================================================
--- Shipwright/lib/Shipwright/Backend/SVK.pm	(original)
+++ Shipwright/lib/Shipwright/Backend/SVK.pm	Wed Feb  6 16:40:50 2008
@@ -5,7 +5,7 @@
 use Carp;
 use File::Spec;
 use CPAN::DistnameInfo;
-use Shipwright::Config;
+use Shipwright::Util;
 use File::Temp qw/tempdir/;
 use File::Copy;
 

Modified: Shipwright/lib/Shipwright/Backend/SVN.pm
==============================================================================
--- Shipwright/lib/Shipwright/Backend/SVN.pm	(original)
+++ Shipwright/lib/Shipwright/Backend/SVN.pm	Wed Feb  6 16:40:50 2008
@@ -5,7 +5,7 @@
 use Carp;
 use File::Spec;
 use CPAN::DistnameInfo;
-use Shipwright::Config;
+use Shipwright::Util;
 use File::Temp qw/tempdir/;
 use File::Copy;
 

Modified: Shipwright/lib/Shipwright/Logger.pm
==============================================================================
--- Shipwright/lib/Shipwright/Logger.pm	(original)
+++ Shipwright/lib/Shipwright/Logger.pm	Wed Feb  6 16:40:50 2008
@@ -9,8 +9,8 @@
 =cut
 
 sub new {
-    my $class = shift;
-    my $shipwright   = shift;
+    my $class      = shift;
+    my $shipwright = shift;
 
     my $self = {};
     bless $self, $class;
@@ -22,25 +22,18 @@
 }
 
 sub _initialize_log4perl {
-    my $class = shift;
-    my $shipwright   = shift;
+    my $class      = shift;
+    my $shipwright = shift;
 
-    my $log_config = $shipwright->config->name->{'log'}{config};
-
-    if ( $log_config && -r $log_config ) {
-        Log::Log4perl->init($log_config);
-    }
-    else {
-        my $log_level = uc $shipwright->config->name->{'log'}{level} || 'INFO';
-        my %default = (
-            'log4perl.rootLogger'      => "$log_level,Screen",
-            'log4perl.appender.Screen' => 'Log::Log4perl::Appender::Screen',
-            'log4perl.appender.Screen.stderr' => 1,
-            'log4perl.appender.Screen.layout' =>
-              'Log::Log4perl::Layout::SimpleLayout'
-        );
-        Log::Log4perl->init( \%default );
-    }
+    my $log_level = uc $shipwright->log_level || 'INFO';
+    my %default = (
+        'log4perl.rootLogger'             => "$log_level,Screen",
+        'log4perl.appender.Screen'        => 'Log::Log4perl::Appender::Screen',
+        'log4perl.appender.Screen.stderr' => 1,
+        'log4perl.appender.Screen.layout' =>
+          'Log::Log4perl::Layout::SimpleLayout'
+    );
+    Log::Log4perl->init( \%default );
 }
 
 1;

Modified: Shipwright/lib/Shipwright/Script/Build.pm
==============================================================================
--- Shipwright/lib/Shipwright/Script/Build.pm	(original)
+++ Shipwright/lib/Shipwright/Script/Build.pm	Wed Feb  6 16:40:50 2008
@@ -6,7 +6,8 @@
 
 use base qw/App::CLI::Command Class::Accessor::Fast/;
 __PACKAGE__->mk_accessors(
-    qw/config name install_base build_base skip skip_test only_test force/);
+    qw/repository log_level install_base build_base skip skip_test only_test force/
+);
 
 use Shipwright;
 
@@ -15,13 +16,13 @@
 
 sub options {
     (
-        'n|name=s'         => 'name',
-        'c|config=s'       => 'config',
-        'i|install-base=s' => 'install_base',
-        'skip=s'           => 'skip',
-        'skip-test'        => 'skip_test',
-        'only-test'        => 'only_test',
-        'force'            => 'force',
+        'r|repository=s' => 'repository',
+        'l|log-level=s'  => 'log_level',
+        'install-base=s' => 'install_base',
+        'skip=s'         => 'skip',
+        'skip-test'      => 'skip_test',
+        'only-test'      => 'only_test',
+        'force'          => 'force',
     );
 }
 
@@ -33,13 +34,13 @@
     my $install_base = shift;
     $self->install_base($install_base) if $install_base;
 
-    die "need name arg" unless $self->name;
+    die "need repository arg" unless $self->repository;
 
     $self->skip( [ split /,\s*/, $self->skip || '' ] );
 
     my $shipwright = Shipwright->new(
-        config     => $self->config,
-        name       => $self->name,
+        repository => $self->repository,
+        log_level  => $self->log_level,
         build_skip => $self->skip,
     );
     $shipwright->backend->export( target => $shipwright->build->build_base );
@@ -61,9 +62,9 @@
   shipwright build           build a project
 
  Options:
-   --config(-c)       specify which config.yml we'll use
-   --name(-n)         specify the project's name
-   --install-base(-i) specify install base. overide the item in config.yml
+   --repository(-r)   specify the repository of our project
+   --log-level(-l)    specify the log level
+   --install-base     specify install base. overide the item in config.yml
    --skip             specify dists which'll be skipped
    --skip-test        specify whether to skip test
    --only-test        just test(the running script is t/test)

Modified: Shipwright/lib/Shipwright/Script/Import.pm
==============================================================================
--- Shipwright/lib/Shipwright/Script/Import.pm	(original)
+++ Shipwright/lib/Shipwright/Script/Import.pm	Wed Feb  6 16:40:50 2008
@@ -6,13 +6,13 @@
 
 use base qw/App::CLI::Command Class::Accessor::Fast/;
 __PACKAGE__->mk_accessors(
-    qw/config name comment source no_follow build_script require_yml
+    qw/repository log_level comment source follow build_script require_yml
       source_name test_script extra_tests/
 );
 
 use Shipwright;
 use File::Spec;
-use Shipwright::Config;
+use Shipwright::Util;
 use File::Copy qw/copy move/;
 use File::Temp qw/tempdir/;
 use Config;
@@ -22,12 +22,12 @@
 
 sub options {
     (
-        'c|config=s'     => 'config',
-        'n|name=s'       => 'name',
+        'r|repository=s' => 'repository',
+        'l|log-level=s'  => 'log_level',
         'm|comment=s'    => 'comment',
         's|source=s'     => 'source',
         'source-name=s'  => 'source_name',
-        'no-follow'      => 'no_follow',
+        'follow=s'      => 'follow',
         'build-script=s' => 'build_script',
         'require-yml=s'  => 'require_yml',
         'test-script=s'  => 'test_script',
@@ -46,20 +46,20 @@
 
     $self->source($source) if $source;
 
+    for (qw/repository source/) {
+        die "need $_ arg" unless $self->$_();
+    }
+
     my $shipwright = Shipwright->new(
-        config      => $self->config,
-        name        => $self->name,
+        repository  => $self->repository,
+        log_level   => $self->log_level,
         source      => $self->source,
         source_name => $self->source_name,
-        follow      => !$self->no_follow,
+        follow      => defined $self->follow ? $self->follow : 1,
     );
 
     if ( $self->source ) {
 
-        for (qw/name source/) {
-            die "need $_ arg" unless $self->$_();
-        }
-
         $self->source(
             $shipwright->source->run( '__require.yml' => $self->require_yml ) );
 
@@ -76,7 +76,7 @@
             $self->generate_build( $self->source, $script_dir, $shipwright );
         }
 
-        unless ( $self->no_follow ) {
+        if ( $self->follow ) {
             $self->import_req( $self->source, $shipwright );
 
             move(
@@ -96,11 +96,11 @@
         );
     }
 
-# import tests
+    # import tests
     if ( $self->extra_tests ) {
         $shipwright->backend->import(
-            source  => $self->extra_tests,
-            comment => 'import extra tests',
+            source       => $self->extra_tests,
+            comment      => 'import extra tests',
             _extra_tests => 1,
         );
     }
@@ -119,7 +119,7 @@
 sub import_req {
     my $self         = shift;
     my $source       = shift;
-    my $shipwright          = shift;
+    my $shipwright   = shift;
     my $require_file = File::Spec->catfile( $source, '__require.yml' );
 
     my $dir = parent_dir($source);
@@ -186,7 +186,7 @@
     my $self       = shift;
     my $source_dir = shift;
     my $script_dir = shift;
-    my $shipwright        = shift;
+    my $shipwright = shift;
 
     chdir $source_dir;
 
@@ -194,7 +194,9 @@
     if ( -f 'configure' ) {
         @commands = (
             'configure: ./configure --prefix=%%INSTALL_BASE%%',
-            'make: make', 'install: make install', 'clean: make clean'
+            'make: make',
+            'install: make install',
+            'clean: make clean'
         );
     }
     elsif ( -f 'Build.PL' ) {
@@ -203,8 +205,9 @@
         push @commands, "make: ./Build";
         push @commands, "test: ./Build test";
         push @commands, "install: ./Build install";
-# ./Build won't work because sometimes the perl path in the shebang line 
-# is just a symblic link which can't do things right
+
+        # ./Build won't work because sometimes the perl path in the shebang line
+        # is just a symblic link which can't do things right
         push @commands, "clean: %%PERL%% Build realclean";
     }
     elsif ( -f 'Makefile.PL' ) {
@@ -250,14 +253,14 @@
   shipwright import          import a source
 
  Options:
-   --config(-c)       specify which config.yml we'll use
-   --name(-n)         specify the project's name
+   --repository(-r)   specify the repository of our project
+   --log-level(-l)    specify the log level
    --comment(-m)      specify the comment
    --source(-s)       specify the source path
    --build-script     specify the build script
    --source-name      specify the sorce name
    --require-yml      specify the require.yml
-   --no-follow        don't follow the dependent chain
+   --follow           follow the dependent chain or not
    --extra-test       specify the extra test source(for --only-test when build)
    --test-script      specify the test script(for --only-test when build)
 

Modified: Shipwright/lib/Shipwright/Script/Initialize.pm
==============================================================================
--- Shipwright/lib/Shipwright/Script/Initialize.pm	(original)
+++ Shipwright/lib/Shipwright/Script/Initialize.pm	Wed Feb  6 16:40:50 2008
@@ -5,19 +5,19 @@
 use Carp;
 
 use base qw/App::CLI::Command Class::Accessor::Fast/;
-__PACKAGE__->mk_accessors(qw/config name/);
+__PACKAGE__->mk_accessors(qw/repository log_level/);
 
 use Shipwright;
 use File::Spec;
-use Shipwright::Config;
+use Shipwright::Util;
 
 =head2 options
 =cut
 
 sub options {
     (
-        'c|config=s'   => 'config',
-        'n|name=s'  => 'name',
+        'r|repository=s' => 'repository',
+        'l|log-level=s'  => 'log_level',
     );
 }
 
@@ -25,16 +25,18 @@
 =cut
 
 sub run {
-    my $self = shift;
-    my $name = shift;
-    $self->name( $name ) if $name;
-    die 'need name arg' unless $self->name;
-
-    my $shipwright = Shipwright->new( config => $self->config, name => $self->name );
+    my $self       = shift;
+    my $repository = shift;
+    $self->repository($repository) if $repository;
+    die 'need repository arg' unless $self->repository;
+
+    my $shipwright = Shipwright->new(
+        repository => $self->repository,
+        log_level  => $self->log_level,
+    );
     $shipwright->backend->initialize();
 }
 
-
 1;
 
 __END__
@@ -48,8 +50,8 @@
   shipwright create          create a project
 
  Options:
-   --config(-c)       specify which config.yml we'll use
-   --name(-n)         specify the project's name
+   --repository(-r)       specify the repository of our project
+   --log-level(-l)            specify the log level
 
 =head1 AUTHOR
 

Modified: Shipwright/lib/Shipwright/Script/Maintain.pm
==============================================================================
--- Shipwright/lib/Shipwright/Script/Maintain.pm	(original)
+++ Shipwright/lib/Shipwright/Script/Maintain.pm	Wed Feb  6 16:40:50 2008
@@ -6,7 +6,7 @@
 
 use base qw/App::CLI::Command Class::Accessor::Fast/;
 __PACKAGE__->mk_accessors(
-    qw/config name update_order keep_recommends
+    qw/repository log_level update_order keep_recommends
       keep_build_requires keep_requires for_dists/
 );
 
@@ -17,8 +17,8 @@
 
 sub options {
     (
-        'c|config=s'            => 'config',
-        'n|name=s'              => 'name',
+        'r|repository=s'        => 'repository',
+        'l|log-level=s'         => 'log_level',
         'update-order'          => 'update_order',
         'keep-recommends=s'     => 'keep_recommends',
         'keep-requires=s'       => 'keep_requires',
@@ -33,13 +33,11 @@
 sub run {
     my $self = shift;
 
-    for (qw/name/) {
-        die "need $_ arg" unless $self->$_();
-    }
+    die "need repository arg" unless $self->repository();
 
     my $shipwright = Shipwright->new(
-        config => $self->config,
-        name   => $self->name,
+        repository => $self->repository,
+        log_level  => $self->log_level,
     );
 
     if ( $self->update_order ) {
@@ -49,13 +47,12 @@
             keep_requires =>
               ( defined $self->keep_requires ? $self->keep_requires : 1 ),
 
-            keep_recommends => (
-                defined $self->keep_recommends ? $self->keep_recommends
-                : $shipwright->config->name->{source}{keep_recomemnds}
-            ),
+            keep_recommends =>
+              ( defined $self->keep_recommends ? $self->keep_recommends : 1 ),
             keep_build_requires => (
-                defined $self->keep_build_requires ? $self->keep_build_requires
-                : $shipwright->config->name->{source}{keep_build_requires}
+                defined $self->keep_build_requires
+                ? $self->keep_build_requires
+                : 1
             ),
             for_dists => [ split /,\s*/, $self->for_dists ],
         );
@@ -75,8 +72,8 @@
   shipwright maintain --update-order        update the build order
 
  Options:
-   --config(-c)       specify which config.yml we'll use
-   --name(-n)         specify the project's name
+   --repository(-r)   specify the repository of our project
+   --log-level(-l)    specify the log level
    --update-order     update the build order
 
 =head1 AUTHOR

Modified: Shipwright/lib/Shipwright/Source/Base.pm
==============================================================================
--- Shipwright/lib/Shipwright/Source/Base.pm	(original)
+++ Shipwright/lib/Shipwright/Source/Base.pm	Wed Feb  6 16:40:50 2008
@@ -7,7 +7,7 @@
 use File::Slurp;
 use Module::CoreList;
 use Shipwright::Source;
-use Shipwright::Config;
+use Shipwright::Util;
 use Cwd qw/getcwd/;
 
 use base qw/Class::Accessor::Fast/;

Modified: Shipwright/lib/Shipwright/Util.pm
==============================================================================
--- Shipwright/lib/Shipwright/Util.pm	(original)
+++ Shipwright/lib/Shipwright/Util.pm	Wed Feb  6 16:40:50 2008
@@ -43,7 +43,8 @@
     $log->warn("run err:\n$err")    if $err;
 
     if ($?) {
-        $log->error( 'failed to run ' . join( ' ', @$cmd ) . ":$?" );
+        $log->error(
+            'failed to run ' . join( ' ', @$cmd ) . " with exit number $?" );
 
         die "something wrong :-(" unless $ignore_failure;
     }



More information about the Bps-public-commit mailing list