Perl6のモジュールインストール(panda版)

[Perl 6 Advent Calendar 2015](http://qiita.com/advent-calendar/2015/perl6)の4日目です。

Perl6のモジュールをインストールするには`panda`コマンドを使います:panda_face:

## 使い方

```
$ panda
Panda -- Perl 6 Module Installer

Usage:
    panda <action> [options]

Common options:
    --prefix=/path/to/modules    Place to put modules, executable scripts, etc.

Actions:
    install        Installs the modules listed on the command line, and their
                   dependencies.
        --notests    Don't run tests for the modules being installed.
        --nodeps     Skip installing modules' dependencies.

    installdeps    Installs the dependencies of the listed modules, but not the
                   modules themselves.
        --notests    Don't run tests for the dependencies being installed.

    list           Lists all the modules available.
        --verbose      Provide verbose output
        --installed    List only installed modules

    update         Updates the local copy of the module database.

    info           Lists information available on given modules.

    search         Searches the database for module names/descriptions matching
                   the given substring.

    gen-meta       Generates a META.info with supplied options (see below).
        --notests          Specifies that the module whose META.info is being
                           generated doesn't have tests(?)
        --name=A::Name     Specify the module's name
        --auth=JRandom     Specify the author's name
        --ver=v0.1         Specify the module version
        --desc="A desc"    Specify the module description

    smoke          Tests and installs all packages. (Not for typical use.)
        --exclude=A::Name    Specifies a package to skip testing.

    look           Downloads and unpacks the listed modules, afterwards going to
                   them with your shell.

'list', 'update', and 'smoke' don't take a list of module names to
install. 'search' takes a string to search case-insensitively for in the
database.
```

## インストール済モジュール一覧

```
$ panda --installed --verbose list
Bailador                   [installed]   *       ?  git://github.com/tadzik/Bailador
DBIish                     [installed]   *       ?  git://github.com/perl6/DBIish
Debugger::UI::CommandLine  [installed]   *       ?  git://github.com/jnthn/rakudo-debugger
Digest::MD5                [installed]   0.05    ?  git://github.com/cosimo/perl6-digest-md5
File::Directory::Tree      [installed]   *       ?  git://github.com/labster/p6-file-directory-tree
File::Find                 [installed]   0.1     ?  git://github.com/tadzik/File-Find
File::Temp                 [installed]   0.0.2   ?  git://github.com/perlpilot/p6-File-Temp
Grammar::Debugger          [installed]   *       ?  git://github.com/jnthn/grammar-debugger
Grammar::Profiler::Simple  [installed]   0.01    ?  git://github.com/perlpilot/Grammar-Profiler-Simple
HTTP::Easy                 [installed]   *       ?  git://github.com/supernovus/perl6-http-easy
HTTP::Status               [installed]   *       ?  git://github.com/supernovus/perl6-http-status
JSON::Fast                 [installed]   v0.3    ?  git://github.com/timo/json_fast
JSON::RPC                  [installed]   0.17.1  ?  git://github.com/bbkr/jsonrpc
JSON::Tiny                 [installed]   *       ?  git://github.com/moritz/json
LWP::Simple                [installed]   0.086   ?  git://github.com/cosimo/perl6-lwp-simple
MIME::Base64               [installed]   1.2     ?  git://github.com/perl6/Perl6-MIME-Base64
PSGI                       [installed]   *       ?  git://github.com/supernovus/perl6-psgi
Pod::Coverage              -dependency-  *       ?  git://github.com/teodozjan/pod6-coverage.git
Pod::To::HTML              [installed]   *       ?  git://github.com/perl6/Pod-To-HTML
SVG                        [installed]   *       ?  git://github.com/moritz/svg
SVG::Plot                  [installed]   *       ?  git://github.com/moritz/svg-plot
Shell::Command             [installed]   *       ?  git://github.com/tadzik/Shell-Command
Template::Mojo             [installed]   v0.1    ?  git://github.com/tadzik/Template-Mojo
Template::Mustache         [installed]   *       ?  git://github.com/softmoth/p6-Template-Mustache
Terminal::ANSIColor        [installed]   *       ?  git://github.com/tadzik/Terminal-ANSIColor
Test::Mock                 [installed]   *       ?  git://github.com/jnthn/test-mock
URI                        [installed]   v0.1.1  ?  git://github.com/perl6-community-modules/uri
XML::Writer                [installed]   *       ?  git://github.com/masak/xml-writer
p6doc                      [installed]   *       ?  git://github.com/perl6/doc
panda                      [installed]   *       ?  git://github.com/tadzik/panda
ufo                        [installed]   *       ?  git://github.com/masak/ufo
```

## モジュールの検索

[Perl 6 Modules](http://modules.perl6.org/)からモジュールを探します

```bash
# 検索
$ panda search Green
Green                    0.1.0      Parallel testing utility, it's really
                                    great

# 大文字小文字区別されないから便利
$ panda search abc
ABC                      *          Toolkit for dealing with ABC music
                                    notation
```

## モジュールのインストール

```bash
# インストール
$ panda install Green
==> Fetching Green
==> Building Green
==> Testing Green
t/00-use.t ........... ok
t/01-time.t .......... ok
t/02-concise.t ....... ok
t/03-more_concise.t .. ok
All tests successful.
Files=4, Tests=6, 11 wallclock secs ( 0.02 usr  0.00 sys +  8.55 cusr  0.29 csys =  8.86 CPU)
Result: PASS
==> Installing Green
Copying blib/lib/Green.pm6 to /usr/local/Cellar/rakudo-star/2015.11/share/perl6/site/lib/Green.pm6
Copying bin/green to /usr/local/Cellar/rakudo-star/2015.11/share/perl6/site/bin/green
==> Successfully installed Green
```

## 依存モジュールだけインストール

* `Inline::Perl5`モジュールが依存しているモジュールだけインストールします[^LibraryMake]。

```
$ panda --notests installdeps Inline::Perl5
==> Inline::Perl5 depends on LibraryMake
==> Fetching LibraryMake
==> Building LibraryMake
==> Installing LibraryMake
Copying blib/lib/LibraryMake.pm6 to /usr/local/Cellar/rakudo-star/2015.11/share/perl6/site/lib/LibraryMake.pm6
==> Successfully installed LibraryMake
```

`Inline::Perl5`が依存している`LibraryMake`だけインストールされました。

##### 備考

```
# LibraryMakeはちょっとエラーになってるみたいです
$ perl6 -c /usr/local/Cellar/rakudo-star/2015.11/share/perl6/site/lib/LibraryMake.pm6
===SORRY!===
Function 'CompUnit::Repository::FileSystem' needs parens to avoid gobbling block
at /usr/local/Cellar/rakudo-star/2015.11/share/perl6/site/lib/LibraryMake.pm6:213
------>         }⏏<EOL>
Missing block (apparently claimed by 'CompUnit::Repository::FileSystem')
at /usr/local/Cellar/rakudo-star/2015.11/share/perl6/site/lib/LibraryMake.pm6:214
------>         }⏏<EOL>
```

```
# 一旦アンインストールしておきます(手作業)
$ rm /usr/local/Cellar/rakudo-star/2015.11/share/perl6/site/lib/LibraryMake.pm6
```

おわりです:whale2:

## 追記(2017/03/03)

`panda` コマンドを実行すると、DEPRECATED となった旨のメッセージが出るようになりました。

```bash
$ panda install OpenCV
==> Fetching OpenCV
==> Building OpenCV
==> Testing OpenCV
t/01-load.t ......... ok
t/02-highgui.t ...... ok
t/99-author-meta.t .. ok
All tests successful.
Files=3, Tests=5,  9 wallclock secs
Result: PASS
==> Installing OpenCV
==> Successfully installed OpenCV

DEPRECATED
'panda' is shortly to be removed from Rakudo Star and replaced by 'zef'.
'zef' is available in this release and recommended over 'panda'
```

zef の使い方は[こちら](http://qiita.com/B73W56H84/items/75a5f9e5d2ebf22d3de4)

## 参考と注釈

* [Perl 6 Modules](http://modules.perl6.org/)
* [tadzik/panda](https://github.com/tadzik/panda)
* [Perl6のモジュールインストール(zef版) - Qiita](http://qiita.com/B73W56H84/items/75a5f9e5d2ebf22d3de4)

[^LibraryMake]: [2015.12.03現在]`LibraryMake`はちょっとエラーになってるみたいなので`--notests`オプションつけてます。