This is an automated email from the git hooks/post-receive script. kanashiro-guest pushed a commit to branch master in repository carton.
commit 44810653f688d4d4601eb092fe224cb6cfb4ef38 Author: Tatsuhiko Miyagawa <miyag...@bulknews.net> Date: Fri Jun 24 02:12:10 2011 -0700 Initial commit --- .gitignore | 8 +++ .shipit | 2 + Changes | 4 ++ MANIFEST | 19 +++++ MANIFEST.SKIP | 17 +++++ Makefile.PL | 11 +++ README | 110 +++++++++++++++++++++++++++++ TODO | 20 ++++++ bin/carton | 132 +++++++++++++++++++++++++++++++++++ lib/App/Carton.pm | 204 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ t/00_compile.t | 4 ++ xt/pod.t | 4 ++ 12 files changed, 535 insertions(+) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e116d1a --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +MYMETA.* +META.yml +Makefile +inc/ +pm_to_blib +*~ +extlib/ +carton.json diff --git a/.shipit b/.shipit new file mode 100644 index 0000000..d2778c7 --- /dev/null +++ b/.shipit @@ -0,0 +1,2 @@ +steps = FindVersion, ChangeVersion, CheckChangeLog, DistTest, Commit, Tag, MakeDist, UploadCPAN +git.push_to = origin diff --git a/Changes b/Changes new file mode 100644 index 0000000..bb48eb3 --- /dev/null +++ b/Changes @@ -0,0 +1,4 @@ +Revision history for Perl extension App::carton + +0.01 Fri Jun 10 19:27:39 2011 + - original version diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..a2f0d0f --- /dev/null +++ b/MANIFEST @@ -0,0 +1,19 @@ +.gitignore +Changes +inc/Module/Install.pm +inc/Module/Install/Base.pm +inc/Module/Install/Can.pm +inc/Module/Install/Fetch.pm +inc/Module/Install/Makefile.pm +inc/Module/Install/Metadata.pm +inc/Module/Install/ReadmeFromPod.pm +inc/Module/Install/Repository.pm +inc/Module/Install/Win32.pm +inc/Module/Install/WriteAll.pm +lib/App/carton.pm +Makefile.PL +MANIFEST This list of files +META.yml +README +t/00_compile.t +xt/pod.t diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP new file mode 100644 index 0000000..5f8714b --- /dev/null +++ b/MANIFEST.SKIP @@ -0,0 +1,17 @@ +\bRCS\b +\bCVS\b +\.svn/ +\.git/ +^MANIFEST\. +^Makefile$ +~$ +\.old$ +^blib/ +^pm_to_blib +^MakeMaker-\d +\.gz$ +\.cvsignore +\.shipit +MYMETA +extlib +carton.json diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..70d16a0 --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,11 @@ +use inc::Module::Install; +name 'carton'; +version_from 'lib/App/Carton.pm'; +all_from 'bin/carton'; +readme_from('bin/carton'); +requires 'version', 0.77; +requires 'JSON'; +build_requires 'Test::More', 0.88; +test_requires 'Test::Requires'; +auto_set_repository(); +WriteAll; diff --git a/README b/README new file mode 100644 index 0000000..d2f5a52 --- /dev/null +++ b/README @@ -0,0 +1,110 @@ +NAME + carton - Perl module dependency manager (aka Bundler for Perl) + +SYNOPSIS + # During the development + > carton install Plack + > git commit -m "add Plack" carton.json + + # Then on other machine + > carton install --deployment + +DESCRIPTION + carton is a command line tool to track the Perl module dependencies for + your Perl application. + +TUTORIAL + Initializing your carton environment + First, you have to initialize your carton environment. + + > cd ~/devel/MyApp + > carton init + > echo extlib >> .gitignore + > git add .gitignore carton.json + > git commit -m "initialized carton" + + This will create an empty extlib directory and "carton.json" to start + tracking your dependencies. + + The extlib directory is compatible to local::lib. You can add: + + use FindBin; + use lib "$FindBin::Bin/../extlib/lib/perl5"; + + to one of the scripts to add the directory to the @INC path. + + Tracking the dependencies + You have two options to add and track your dependencies. + + First is just install dependencies to your application as you go. + + > carton install Plack + > carton install AnyEvent::Redis + + Second is to manage it via the standard "Makefile.PL" or "Build.PL". + + # Makefile.PL + use inc::Module::Install; + name 'MyApp'; + requires 'DBD::mysql'; + requires 'HTTP::Message'; + WriteAll; + + And then you can install these dependencies via: + + > carton install + + In either way, the modules are installed into your "extlib" directory + with the history information and "carton.json" in your directory is + updated. + + Make sure you add "carton.json" to your version controlled repository + and commit changes as you update dependencies. + + Deploying your application + Once you've done installing all the dependencies, you can push your + application directory to a remote machine and run the following: + + > carton install --deployment + + This will look at the "carton.json" and install the exact same versions + of the dependencies into "extlib", and now your application is ready to + run. + + Bundling modules + carton can bundle all the tarballs for your dependencies into a + directory so that you can even install dependencies that are not + available on CPAN, such as internal distribution aka DarkPAN. + + > carton bundle + + will bundle these tarballs into "extlib/cache" directory, and + + > carton install --local + + will install modules using this local cache. This way you can avoid a + dependency on CPAN meta DB and search.cpan.org at a deploy time, or you + can have dependencies onto private CPAN modules aka DarkPAN. + +AUTHOR + Tatsuhiko Miyagawa + +COPYRIGHT + Tstsuhiko Miyagawa 2011- + +LICENSE + This software is licensed under the same terms as Perl itself. + +SEE ALSO + cpanm + + Bundler <http://gembundler.com/> + + pip <http://pypi.python.org/pypi/pip> + + npm <http://npmjs.org/> + + perlrocks <https://github.com/gugod/perlrocks> + + only + diff --git a/TODO b/TODO new file mode 100644 index 0000000..003f41c --- /dev/null +++ b/TODO @@ -0,0 +1,20 @@ +# 1.0 +Track what is the top-level installs and display build tree +cpanm: save 'provides' into local.json for proper indexing +support CPAN distro only +carton config / .carton/config +check Makefile.PL/Build.PL mtime +-g, --global +carton update +exec + +# 1.1 +carton bundle +self-contained cpanm and carton + +# 1.2 +Support DarkPAN/github etc +dzil support + +# 1.3 +perlrocks multiple versions diff --git a/bin/carton b/bin/carton new file mode 100755 index 0000000..b78fb10 --- /dev/null +++ b/bin/carton @@ -0,0 +1,132 @@ +#!perl +use strict; +use 5.008001; +use App::Carton; + +App::Carton->new->run(@ARGV); + +__END__ + +=head1 NAME + +carton - Perl module dependency manager (aka Bundler for Perl) + +=head1 SYNOPSIS + + # During the development + > carton install Plack + > git commit -m "add Plack" carton.json + + # Then elsewhere (on a deployment machine) + > carton install + > carton exec myscript.pl arg1 arg2 + +=head1 WARNING + +B<This software is under the heavy development and considered alpha +quality till the version hits v1.0.0. Things might be broken, and APIs +will be likely to change. You have been warned.> + +=head1 DESCRIPTION + +carton is a command line tool to track the Perl module dependencies +for your Perl application. + +=head1 TUTORIAL + +=head2 Initializing your carton environment + +First, you have to initialize your carton environment. + + > cd ~/devel/MyApp + > carton init + > echo extlib >> .gitignore + > git add .gitignore carton.json + > git commit -m "initialized carton" + +This will create an empty extlib directory and C<carton.json> to +start tracking your dependencies. + +=head2 Tracking the dependencies + +You have two options to add and track your dependencies. + +First is just install dependencies to your application as you go. + + > carton install Plack + > carton install AnyEvent::Redis + +Second is to manage it via the standard C<Makefile.PL> or C<Build.PL>. + + # Makefile.PL + use inc::Module::Install; + name 'MyApp'; + requires 'DBD::mysql'; + requires 'HTTP::Message', 5.800; + WriteAll; + +And then you can install these dependencies via: + + > carton install + +In either way, the modules are installed into your C<extlib> directory +with the history information and C<carton.json> in your directory is +updated. + +Make sure you add C<carton.json> to your version controlled +repository and commit changes as you update dependencies. + +=head2 Deploying your application + +Once you've done installing all the dependencies, you can push your +application directory to a remote machine and run the following: + + > carton install + +This will look at the C<carton.json> and install the exact same +versions of the dependencies into C<extlib>, and now your application +is ready to run. + +=head2 Bundling modules + +carton can bundle all the tarballs for your dependencies into a +directory so that you can even install dependencies that are not +available on CPAN, such as internal distribution aka DarkPAN. + + > carton bundle + +will bundle these tarballs into C<extlib/cache> directory, and + + > carton install --cached + +will install modules using this local cache. This way you can avoid a +dependency on CPAN meta DB and search.cpan.org at a deploy time, or +you can have dependencies onto private CPAN modules aka DarkPAN. + +=head1 AUTHOR + +Tatsuhiko Miyagawa + +=head1 COPYRIGHT + +Tstsuhiko Miyagawa 2011- + +=head1 LICENSE + +This software is licensed under the same terms as Perl itself. + +=head1 SEE ALSO + +L<cpanm> + +L<Bundler|http://gembundler.com/> + +L<pip|http://pypi.python.org/pypi/pip> + +L<npm|http://npmjs.org/> + +L<perlrocks|https://github.com/gugod/perlrocks> + +L<only> + +=cut diff --git a/lib/App/Carton.pm b/lib/App/Carton.pm new file mode 100644 index 0000000..e333944 --- /dev/null +++ b/lib/App/Carton.pm @@ -0,0 +1,204 @@ +package App::Carton; + +use strict; +use 5.008_001; +use version; our $VERSION = qv('v0.9.0'); + +use Config; +use Getopt::Long; +use Term::ANSIColor qw(colored); + +our $Colors = { + SUCCESS => 'green', + INFO => 'cyan', + ERROR => 'red', +}; + +sub new { + my $class = shift; + bless { + path => 'extlib', + color => 1, + verbose => 0, + cpanm => $ENV{PERL_CARTON_CPANM} || 'cpanm', + }, $class; +} + +sub run { + my($self, @args) = @_; + + local @ARGV = @args; + my $p = Getopt::Long::Parser->new( + config => [ "no_ignore_case", "pass_through" ], + ); + $p->getoptions( + "h|help" => sub { unshift @ARGV, 'help' }, + "v|version" => sub { unshift @ARGV, 'version' }, + "color!" => \$self->{color}, + "verbose!" => \$self->{verbose}, + ); + + my $cmd = shift @ARGV || 'help'; + my $call = $self->can("cmd_$cmd"); + + if ($call) { + $self->$call(@ARGV); + } else { + die "Could not find command '$cmd'\n"; + } +} + +sub parse_options { + my($self, @opts) = @_; + Getopt::Long::GetOptionsFromArray(@opts); +} + +sub print { + my($self, $msg, $type) = @_; + $msg = colored $msg, $Colors->{$type} if $type && $self->{color}; + print $msg; +} + +sub error { + my($self, $msg) = @_; + $self->print($msg, "ERROR"); + exit(1); +} + +sub cmd_help { + my $self = shift; + my $cmd = $_[0] ? "carton-$_[0]" : "carton"; + system "perldoc", $cmd; +} + +sub cmd_version { + print "carton $VERSION\n"; +} + +sub cmd_install { + my($self, @args) = @_; + + $self->parse_options(\@args, "p|path=s", \$self->{path}, "deployment!" => \$self->{deployment}); + + if (@args) { + $self->print("Installing modules from the command line\n"); + $self->install_modules(@args); + $self->update_packages; + } elsif (my $file = $self->has_build_file) { + $self->print("Installing modules using $file\n"); + $self->install_from_build_file($file); + $self->update_packages; + } elsif (-e 'carton.json') { + $self->print("Installing modules using carton.json\n"); + $self->install_from_lock(); + } else { + $self->error("Can't locate build file or carton.json\n"); + } + + $self->print("Complete! Modules were installed into $self->{path}\n", "SUCCESS"); +} + +sub has_build_file { + my $self = shift; + + # deployment mode ignores build files and only uses carton.json + return if $self->{deployment}; + + my $file = (grep -e, qw( Build.PL Makefile.PL ))[0] + or return; + + if ($self->mtime($file) > $self->mtime("carton.json")) { + return $file; + } + + return; +} + +sub mtime { + my($self, $file) = @_; + return (stat($file))[9] || 0; +} + +sub install_from_build_file { + my($self, $file) = @_; + $self->run_cpanm("--installdeps", "."); +} + +sub install_modules { + my($self, @args) = @_; + $self->run_cpanm(@args); +} + +sub install_from_lock { + # build MIRROR index from carton.json and install with cpanm +} + +*cmd_list = \&cmd_show; + +sub cmd_show { + my($self, @args) = @_; + + my $data = $self->parse_json('carton.json') + or $self->error("carton.json: not found\n"); + for my $module (values %{$data->{modules} || {}}) { + printf "$module->{dist}\n"; + } +} + +sub cmd_check { + # check carton.json and extlib consistency +} + +sub cmd_update { + # "cleanly" update distributions in extlib + # rebuild the tree, update modules with DFS +} + +sub cmd_exec { + # setup lib::core::only, -L env, put extlib/bin into PATH and exec script +} + +sub run_cpanm { + my($self, @args) = @_; + system $self->{cpanm}, "--notest", "--reinstall", "-L", $self->{path}, @args; +} + +sub parse_json { + my($self, $file) = @_; + + open my $fh, "<", $file or return; + + require JSON; + JSON::decode_json(join '', <$fh>); +} + +sub update_packages { + my $self = shift; + + my %locals = $self->find_locals; + + require JSON; + open my $fh, ">", "carton.json" or die $!; + print $fh JSON->new->pretty->encode({ modules => \%locals }); + + return 1; +} + +sub find_locals { + my $self = shift; + + require File::Find; + + my @locals; + my $wanted = sub { + if ($_ eq 'local.json') { + push @locals, $File::Find::name; + } + }; + File::Find::find($wanted, "$self->{path}/lib/perl5/auto/meta"); + + return map { my $module = $self->parse_json($_); ($module->{name} => $module) } @locals; +} + +1; +__END__ diff --git a/t/00_compile.t b/t/00_compile.t new file mode 100644 index 0000000..9f66699 --- /dev/null +++ b/t/00_compile.t @@ -0,0 +1,4 @@ +use strict; +use Test::More tests => 1; + +BEGIN { use_ok 'App::carton' } diff --git a/xt/pod.t b/xt/pod.t new file mode 100644 index 0000000..437887a --- /dev/null +++ b/xt/pod.t @@ -0,0 +1,4 @@ +use Test::More; +eval "use Test::Pod 1.00"; +plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; +all_pod_files_ok(); -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/carton.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits