LoginSignup
2
2

More than 5 years have passed since last update.

Perl5 On FreeBSD pkg

Last updated at Posted at 2016-12-18

初めての方は初めまして。
いろんな界隈の片隅に咲くドクダミの花、相良☆無意味です。

こちらはPerl 5 Advent Calendar 2016 - Qiita19日目の記事です。
(Qiita内なので下にも出るはずですが)前回は@ozissanさんの「PerlでPDFにQRコード(画像)を埋め込む」でした。
私もつい数年前にpdfjでカラー画像をゴリゴリと並べるシステムを構築したのが、現職でMovableType以外のPerl(+php)でほぼ唯一ゼロから組んだシステム。
もはや遠い昔のことのようです。
次回は@touba_rumbaさんの「yapcjapanについて」改め「学生視点のYAPC::Hokkaidoの予定です。
北海道は行けませんでしたが、一応kansai.pmメンバーなので大阪には行くはずです。

概要

さくらのクラウド上のFreeBSDを11.0-RELEASEにアップグレードし、pkgにおけるPerl5の状況を確認しました。
実は手元にインストール済みのサーバもあるのですが、こちらはバリバリカスタムする可能性もあります(まだしてない。
復習とクーポンの活用を兼ねてこちらで作業を行いました。

本当はMovableTypeの立ち上げまでやってそちらで投稿しようかと思ったのですが、今冬中に安定公開まで持っていくのが厳しそうなので今回は見送りました。

FreeBSD

昭和世代には基本的なことからですが、改めて簡単に説明します。

我らがLarryの母校でもあるUCBで生まれたOSの直系と言っていいOSであり、本物の「unix」でもあります。
新機能の追加も活発ながらそれなりに後方互換性も保持しており、「404 Blog Not Found」の情報がまだ役に立つこともあります。

OS標準コマンドとその設定ファイルは「/bin」「/etc」などルート直下のディレクトリに存在し、後ほど紹介するpkgや、ソースベースパッケージ管理システムportsで導入したコマンドとその設定ファイル「/usr/local/bin」「/usr/local/etc」など「/usr/local」に隔離されます。

標準ツールのpython移行が完了しており、標準でperlが入っていません!!
まぁLarryもLinuxを使っているのでおあいこです(?)。
逆に言うと、自由にバージョンを選びやすいとも言えます。
[追記]コメントでご指摘いただきました。ちゃんと確認しないとダメですね。なんでこんな勘違いを……

さくらのクラウドではパブリックISOイメージから以下のバージョンがインストールできるほか、10.3-RELEASEの環境を構築した20GBのパブリックアーカイブを利用することができます。
1.FreeBSD 9.3-RELEASE 64bit
2.FreeBSD 10.3-RELEASE 64bit
3.FreeBSD 11.0-RELEASE 64bit

freebsd-update

今回はすでにパブリックアーカイブで10.3-RELEASEを構築して放置していますので、こちらをアップグレードしました。
11.0-RELEASEへのアップグレードはOpenSSLのセキュリティ脆弱性が重なった関係もあり、少々厄介です。
実際の作業自体はそこまででもないのですが、詳細はBSD界隈四方山話 第72回に詳しいのでそちらに譲ります。
(作業ログが取れていないのは秘密)

2、3回はやっているはずなのですが、ブラウザのバーチャルコンソールから行ったために少々手こずってしまいました。
しかし、下記のように無事バージョンが更新できました。

muimi@clowdaemon:~ % uname -a
FreeBSD clowdaemon 11.0-RELEASE-p2 FreeBSD 11.0-RELEASE-p2 #0: Mon Oct 24 06:55:27 UTC 2016     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
muimi@clowdaemon:~ % freebsd-version -uk
11.0-RELEASE-p2
11.0-RELEASE-p5
muimi@clowdaemon:~ % 

pkg

FreeBSD 10から標準のパッケージ管理システムです。
以前のバイナリベースのパッケージ管理システムpackagesや、ソースベースのportsの他OSへの移植版であるpkgsrcと区別しやすいように、pkgng(next generation)と呼ばれていました。
バイナリインストールのパッケージ管理システムとして最後発の部類に入り、とても使い勝手が良いです。

では、実際にperlが登録されているか調べてみましょう。

muimi@clowdaemon:~ % pkg search perl | wc -l
     149
muimi@clowdaemon:~ % 

149件?
あ、これモジュールとかも入ってますね。
では改めて。

muimi@clowdaemon:~ % pkg search perl5
perl5-5.20.3_15                Practical Extraction and Report Language
perl5-devel-5.25.5.24          Practical Extraction and Report Language
perl5.18-5.18.4_24             Practical Extraction and Report Language
perl5.22-5.22.3.r4             Practical Extraction and Report Language
perl5.24-5.24.1.r4             Practical Extraction and Report Language
muimi@clowdaemon:~ % 

5.18〜24までの安定バージョンと5.25が登録されており、pkg install perl5とすると5.20が入ることがわかります。
しかし、できればperl的にもモダンな管理ツールが使いたいところ。
こちらも登録されているかどうか確認しましょう。

root@clowdaemon:~ # pkg search perlbrew
p5-App-perlbrew-0.75           Perl Environment manager
root@clowdaemon:~ # pkg search plenv
root@clowdaemon:~ #

perlbrewはありますが、さすがにplenvはありません。
plenvを覚えてあわよくばpkgメンテナになる、なんて妄想も悪くないですね。
ただ一つ問題があり、一度運用に失敗しています。

plenvの紹介記事は大概bash前提で書かれています。
まぁLinux全盛のご時世で仕方のないことですが、FreeBSDの標準シェルはtcshなのです。
(だから一般ユーザのプロンプトが%なのです)
まぁ私は自分で選んでいますし、いっそzsh使えって話もありますが。

gitインストール

ともあれ、plenvを入れるために、まずはgitが入っていなければ入れましょう。
長いですが一気に載せます。

root@clowdaemon:~ # pkg list | grep git
/usr/local/lib/python2.7/cgitb.py
/usr/local/lib/python2.7/cgitb.pyc
/usr/local/lib/python2.7/cgitb.pyo
root@clowdaemon:~ # pkg search git
bzr-git-0.6.8_1                Plugin for bzr to work with git trees
cgit-1.0                       Hyperfast web frontend for Git repositories
digitemp-3.6.0                 Dallas Semiconductor 1-wire device reading console application
easygit-0.98                   Easy wrapper for git
geany-plugin-git-changebar-1.28 Geany plugin: highlight changed files tracked with Git
git-2.9.2_2                    Distributed source code management tool
git-bzr-ng-git20140423         Bi-directional git to bzr bridge
git-cinnabar-0.4.0.b3          Git remote helper to interact with Mercurial repositories
git-codereview-0.0.0.2016030201 Command-line tool for working with Gerrit
git-cola-2.6                   Sleek and powerful Git GUI
git-cvs-0.0.1.20151027         Tool to incrementally import changesets from CVS into Git
git-extras-4.1.0               Sub-commands for repo summary, repl, changelog population, and more
git-gui-2.9.2_2                Distributed source code management tool (GUI enabled)
git-lite-2.9.2_2               Distributed source code management tool (lite package)
git-merge-changelog-20140202   Git "merge" driver for GNU style ChangeLog files
git-modes-emacs25-1.2.2,1      GNU Emacs modes for Git-related files
git-review-1.25.0              Allow to push code to review and interact with a Gerrit server
git-subversion-2.9.2_2         Distributed source code management tool with FreeBSD subversion bindings
gitblit-1.8.0                  Open-source servlet for Git repositories
gitflow-1.8.0                  Git extensions to provide high-level repository operations
gitg-3.19.6                    GTK-based git repository viewer
gitg0-0.0.8_1                  GTK-based git repository viewer (gtk2 version)
github-backup-utils-2.4.0      GitHub Enterprise Backup Utilities
gitlab-8.9.6_2                 Web GUI for managing git repositories
gitlab-shell-3.0.0             GitLab Shell handles git commands for GitLab
gitlab-workhorse-0.7.5         Smart reverse proxy for GitLab
gitlist-0.5.0                  Web based Git repository browser written in PHP
gitolite-3.6.6,1               Access control layer on top of git
gitolite2-2.3.1_1              Access control layer on top of git
gitphp-0.2.8_1                 Web based git repository browser written in PHP
gittrac-2.0.1_1                Web-Based Bug And Patch-Set Tracking System For Git
go-git-lfs-1.4.4               Git extension for versioning large files
griels-quest-git20150512       Griel's Quest for the Sangraal
gtk-digital-cream-theme-1.0_8  Neat and clean theme for GNOME desktop
gtk-digital-harmony-theme-1.1_8 Another popular theme for GNOME desktop
hs-git-annex-5.20150727_1      Manage files with git, without checking their contents into git
hs-gitit-0.11.1                Wiki using happstack, git or darcs, and pandoc
libgit2-0.24.0                 Portable, pure C implementation of the Git core
libgit2-glib-0.24.0            Glib wrapper library around the libgit2 git access library
libvterm-git20160104           Implementation of a VT220/xterm/ECMA-48 terminal emulator
magit-emacs25-2.7.0            Interface to Git for Emacs
metacity-digital-cream-theme-1.0_8 Neat and clean theme for GNOME desktop
metacity-digital-harmony-theme-1.1_8 Another popular theme for GNOME desktop
osmium-git20130522_13          C++/Javascript framework for working with OSM files
p5-Algorithm-CheckDigits-1.3.2 Perl extension to generate and test check digits
p5-App-GitGot-1.333            Tool to make it easier to manage multiple git repositories
p5-App-GitHub-1.0.1_1          GitHub Command Tools
p5-Config-GitLike-1.16         Simple git-compatible config file parser for Perl
p5-Git-PurePerl-0.52           Pure Perl interface to Git repositories
p5-Git-Repository-1.320        Perl interface to Git repositories
p5-Git-Repository-Plugin-Log-1.314 Add a log() method to Git::Repository
p5-Git-Sub-0.161810            Git commands imported into the git:: namespace
p5-Git-Version-Compare-1.004   Functions to compare Git versions
p5-Git-Wrapper-0.045           Wrap git(7) command-line interface
p5-GitDDL-0.03                 Perl extension for database migration utility by git managed sql
p5-GitDDL-Migrator-0.07        Perl extension to extended p5-GitDDL
p5-Net-GitHub-0.83             Perl interface to github.com
p5-Test-Requires-Git-1.006     Check your test requirements against the available version of Git
p5-WWW-GitHub-Gist-0.17_1      Perl interface to Gist
p5-github_creator-0.15_1       Create a Github repository for your Perl module
pear-SebastianBergmann_Git-1.2.0 Simple wrapper for Git
pear-VersionControl_Git-0.4.4  OO interface to handle Git repository
py27-GitPython-1.0.1           Python Git Library
py27-django-taggit-0.15.0_1    Reusable Django application for simple tagging
py27-git-up-1.3.0              Python implementation of 'git up'
py27-gitdb-0.6.4_2             Pure Python git object database
py27-gitosis-0.2.20090917_1    Software for hosting git repositories
py27-hg-git-0.8.3              Mercurial extension to pull from or push to a Git repository
py27-pygit2-0.24.1             Python bindings for libgit2
py27-pygithub-1.26.0           Python library implementing the full GitHub API v3
py27-python-digitalocean-1.8   API to manage digitalocean.com droplets
py27-setuptools-git-1.1        Setuptools plugin for git
py27-wsgitools-0.3             Useful middlewares and filters for wsgi as well as scgi servers
qgit-qt4-2.3_1                 Graphical interface to git repositories
rubygem-gemnasium-gitlab-service-0.2.6 Gemnasium support for GitLab projects
rubygem-git-1.2.9.1            Ruby wrapper library around git(1)
rubygem-git-version-bump-0.15.1 Manage your app version entirely via git tags
rubygem-github-linguist-4.8.5  GitHub Language detection
rubygem-github-markdown-0.6.9  Self-contained Markdown parser for GitHub
rubygem-github-markup-1.4.0_1  Render any fancy markup
rubygem-github_api-0.14.0      Wrapper that supports all of the GitHub API v3 methods
rubygem-gitlab-flowdock-git-hook-1.0.1 GitLab-patched Git Post-Receive hook for Flowdock
rubygem-gitlab-gollum-lib-1.1.0_3 Simple, Git-powered wiki with a sweet API and local frontend
rubygem-gitlab-grack-2.0.2_2   Ruby/Rack Git Smart-HTTP Server Handler
rubygem-gitlab-grit-2.8.1_1    Library for extracting information from a git repository
rubygem-gitlab-linguist-3.0.1  GitHub Language detection
rubygem-gitlab-pygments.rb-0.5.4 Exposes the pygments syntax highlighter to Ruby
rubygem-gitlab_emoji-0.3.1     Provides Gitlab Emoji assets
rubygem-gitlab_git-10.3.2,1    GitLab wrapper around git objects
rubygem-gitlab_meta-7.0        GitLab meta gem
rubygem-gitlab_omniauth-ldap-1.2.1 LDAP strategy for OmniAuth
rubygem-html-pipeline-gitlab-0.2.0 Extension filters for html-pipeline used by GitLab
rubygem-omniauth-github-1.1.2  Official OmniAuth strategy for GitHub
rubygem-omniauth-github-discourse-1.1.2 Fork of Official OmniAuth strategy for GitHub
rubygem-omniauth-gitlab-1.0.2  OmniAuth strategy for GitLab
rubygem-svn2git-2.3.2_1        Ruby utilities for exporting SVN repo to git
sagittarius-scheme-0.7.5       R6RS/R7RS Scheme system
stagit-0.4                     Static Git page generator
svn2git-1.0.11.a.20151201      Imports svn repositories into git
uwsgitop-0.9                   uWSGI top-like app
xtgyoretsu-git20140822         Extended ncurses version of "Renshu-cho gyoretsu"
root@clowdaemon:~ # ^search^install
pkg install git
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 16 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    git: 2.9.2_2
    expat: 2.2.0
    p5-Error: 0.17024
    perl5: 5.20.3_15
    cvsps: 2.1_2
    p5-Authen-SASL: 2.16_1
    p5-Digest-HMAC: 1.03_1
    p5-GSSAPI: 0.28_1
    curl: 7.51.0_1
    ca_root_nss: 3.27.1
    p5-Net-SMTP-SSL: 1.03
    p5-IO-Socket-SSL: 2.038
    p5-Net-SSLeay: 1.78
    p5-IO-Socket-IP: 0.37_1
    p5-Socket: 2.021
    p5-Mozilla-CA: 20160104

Number of packages to be installed: 16

The process will require 78 MiB more space.
19 MiB to be downloaded.

Proceed with this action? [y/N]: y
Please type 'Y[es]' or 'N[o]' to make a selection

Proceed with this action? [y/N]: Y
Fetching git-2.9.2_2.txz: 100%    4 MiB 804.1kB/s    00:05    
Fetching expat-2.2.0.txz: 100%  101 KiB 103.5kB/s    00:01    
Fetching p5-Error-0.17024.txz: 100%   24 KiB  24.8kB/s    00:01    
Fetching perl5-5.20.3_15.txz: 100%   13 MiB 459.4kB/s    00:30    
Fetching cvsps-2.1_2.txz: 100%   42 KiB  42.9kB/s    00:01    
Fetching p5-Authen-SASL-2.16_1.txz: 100%   44 KiB  45.1kB/s    00:01    
Fetching p5-Digest-HMAC-1.03_1.txz: 100%    9 KiB   9.5kB/s    00:01    
Fetching p5-GSSAPI-0.28_1.txz: 100%   41 KiB  41.8kB/s    00:01    
Fetching curl-7.51.0_1.txz: 100%    1 MiB 351.6kB/s    00:03    
Fetching ca_root_nss-3.27.1.txz: 100%  324 KiB 332.3kB/s    00:01    
Fetching p5-Net-SMTP-SSL-1.03.txz: 100%   11 KiB  10.8kB/s    00:01    
Fetching p5-IO-Socket-SSL-2.038.txz: 100%  156 KiB 159.7kB/s    00:01    
Fetching p5-Net-SSLeay-1.78.txz: 100%  241 KiB 246.7kB/s    00:01    
Fetching p5-IO-Socket-IP-0.37_1.txz: 100%   27 KiB  27.4kB/s    00:01    
Fetching p5-Socket-2.021.txz: 100%   37 KiB  38.1kB/s    00:01    
Fetching p5-Mozilla-CA-20160104.txz: 100%  147 KiB 150.7kB/s    00:01    
Checking integrity... done (0 conflicting)
[1/16] Installing perl5-5.20.3_15...
[1/16] Extracting perl5-5.20.3_15: 100%
[2/16] Installing p5-Net-SSLeay-1.78...
[2/16] Extracting p5-Net-SSLeay-1.78: 100%
[3/16] Installing p5-IO-Socket-IP-0.37_1...
[3/16] Extracting p5-IO-Socket-IP-0.37_1: 100%
[4/16] Installing p5-Socket-2.021...
[4/16] Extracting p5-Socket-2.021: 100%
[5/16] Installing p5-Mozilla-CA-20160104...
[5/16] Extracting p5-Mozilla-CA-20160104: 100%
[6/16] Installing p5-Digest-HMAC-1.03_1...
[6/16] Extracting p5-Digest-HMAC-1.03_1: 100%
[7/16] Installing p5-GSSAPI-0.28_1...
[7/16] Extracting p5-GSSAPI-0.28_1: 100%
[8/16] Installing ca_root_nss-3.27.1...
[8/16] Extracting ca_root_nss-3.27.1: 100%
[9/16] Installing p5-IO-Socket-SSL-2.038...
[9/16] Extracting p5-IO-Socket-SSL-2.038: 100%
[10/16] Installing expat-2.2.0...
[10/16] Extracting expat-2.2.0: 100%
[11/16] Installing p5-Error-0.17024...
[11/16] Extracting p5-Error-0.17024: 100%
[12/16] Installing cvsps-2.1_2...
[12/16] Extracting cvsps-2.1_2: 100%
[13/16] Installing p5-Authen-SASL-2.16_1...
[13/16] Extracting p5-Authen-SASL-2.16_1: 100%
[14/16] Installing curl-7.51.0_1...
[14/16] Extracting curl-7.51.0_1: 100%
[15/16] Installing p5-Net-SMTP-SSL-1.03...
[15/16] Extracting p5-Net-SMTP-SSL-1.03: 100%
[16/16] Installing git-2.9.2_2...
===> Creating groups.
Creating group 'git_daemon' with gid '964'.
===> Creating users
Creating user 'git_daemon' with uid '964'.
[16/16] Extracting git-2.9.2_2: 100%
Message from perl5-5.20.3_15:
The /usr/bin/perl symlink has been removed starting with Perl 5.20.
For shebangs, you should either use:

#!/usr/local/bin/perl

or

#!/usr/bin/env perl

The first one will only work if you have a /usr/local/bin/perl,
the second will work as long as perl is in PATH.
Message from ca_root_nss-3.27.1:
********************************* WARNING *********************************

FreeBSD does not, and can not warrant that the certification authorities
whose certificates are included in this package have in any way been
audited for trustworthiness or RFC 3647 compliance.

Assessment and verification of trust is the complete responsibility of the
system administrator.

*********************************** NOTE **********************************

This package installs symlinks to support root certificates discovery by
default for software that uses OpenSSL.

This enables SSL Certificate Verification by client software without manual
intervention.

If you prefer to do this manually, replace the following symlinks with
either an empty file or your site-local certificate bundle.

  * /etc/ssl/cert.pem
  * /usr/local/etc/ssl/cert.pem
  * /usr/local/openssl/cert.pem

***************************************************************************
Message from cvsps-2.1_2:
===>   NOTICE:

The cvsps port currently does not have a maintainer. As a result, it is
more likely to have unresolved issues, not be up-to-date, or even be removed in
the future. To volunteer to maintain this port, please create an issue at:

https://bugs.freebsd.org/bugzilla

More information about port maintainership is available at:

https://www.freebsd.org/doc/en/articles/contributing/ports-contributing.html#maintain-port
Message from git-2.9.2_2:
------------------------------------------------------------------------
*************************** GITWEB *************************************
If you installed the GITWEB option please follow these instructions:

In the directory /usr/local/share/examples/git/gitweb you can find all files to
make gitweb work as a public repository on the web.

All you have to do to make gitweb work is:
1) Copy the files /usr/local/share/examples/git/gitweb/* to a directory on
   your web server (e.g. Apache2) in which you are able to execute
   CGI-scripts.
2) In gitweb.cgi, adjust the variable $projectroot to point to
   your git repository (that is where you have your *.git project
   directories).
*************************** GITWEB *************************************

*************************** CONTRIB ************************************
If you installed the CONTRIB option please note that the scripts are
installed in /usr/local/share/git-core/contrib. Some of them require
other ports to be installed (perl, python, etc), which you may need to
install manually.
*************************** CONTRIB ************************************
------------------------------------------------------------------------
root@clowdaemon:~ #

あれ、もうまとめ?

これでgit2.9.2_2がインストールされたわけですが……
お気づきでしょうか?
依存関係があり、Perl5.20が入ってしまいました。

逆に言うと、自由にバージョンを選びやすいとも言えます。

私が上で書いたこれ、なんだったんでしょうか(汗

ともあれ、これでOSのメインPerlは5.20になりました。
あとはplenvなりperlbrewを導入して、使いやすい環境にしていきましょう。

P.S.

そう言えば土曜日に電車内で帽子の上から悪魔のツノをつけているおじさんを見ました。
彼もバークレイストだったのでしょうか……
なお、私はYAPC::Asia Tokyo 2015(まだ終わらせていない奴がここにいます)のトートを肩にかけ、キンジ・タキガワのテンガロンハット(ブラック)に百円ショップのクリップ留めする紐をつけて被っていました。

閑話休題

plenvを使用するならpkgから入れることはまずありませんが、cpanminusも用意されています。

muimi@clowdaemon:~ % pkg search cpanm
p5-App-cpanminus-1.7039        Perl extension to get, unpack, build, and install modules from CPAN
muimi@clowdaemon:~ % 

せっかくなのでperl6もみてみましょう。
下記のとおりです。

muimi@clowdaemon:~ % pkg search perl6
p5-Bundle-Perl6-0.12_1         Bundle to install Perl6-related modules
p5-Perl6-Builtins-0.0.3_2      Provide Perl 5 versions of the new Perl 6 builtins
p5-Perl6-Export-0.07_2         Implements the Perl 6 'is export(...)' trait
p5-Perl6-Export-Attrs-0.000005 Perl 6 'is export(...)' trait as a Perl 5 attribute
p5-Perl6-Form-0.04_2           Implements the Perl 6 'form' built-in
p5-Perl6-Junction-1.60000_1    Perl6 style Junction operators in Perl5
p5-Perl6-Rules-0.03_1          Implements (most of) the Perl 6 regex syntax
p5-Perl6-Say-0.16_1            Perl 6 say (print, but no newline needed) function
p5-Perl6-Slurp-0.051005        Implements the Perl6 'slurp' built-in
p5-Perl6-Subs-0.05_2           Perl6::Subs - Define your subroutines in the Perl 6 style
muimi@clowdaemon:~ % 
2
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2