MacPortsで自作パッケージを作る(変更あり)
変更点:岡野原さんにtxと同じ場所にPortfileを置いてもらえたため、Portfileをダウンロードできるリンクを記述しました。
はじめに
オープンソースのソフトウェアを使おうとすると欠かせないパッケージ管理ソフト。Mac OS Xの場合はMacportsが便利です。
しかしながら、Linuxにおけるapt, rpmと比べるとコミュニティが小さいためパッケージ化されていないソフトも多々あります。
そこでパッケージができるまで待つでも無く、configure,make,make installをして入れるでも無く、ローカルに自分用のMacports
インデックスを作成し、Macportsを用いてインストールをするという方法を説明したいと思います。
今日は初級編として岡野原大輔氏の作成したTx( http://www-tsujii.is.s.u-tokyo.ac.jp/~hillbig/tx-j.htm )を用います。
Tx自身は依存するソフトウェアは無く、インストール時に特別なオプションも必要無いので、全てデフォルトで良いためPortfileも単純なものですみます。
作ってみた
いきなりだが、コードを貼付ける。
ダウンロードはこちらから行って下さい。
PortSystem 1.0 name tx version 0.12 revision 1 description Library for a compact trie data structure. long_description Tx is a library for a compact trie data structure. \ Tx requires 1/4 - 1/10 of the memory usage compared to the previous implementations, \ and can therefore handle quite a large number of keys (e.g. 1 billion) efficiently. \ A trie data structure supports exact matching and common prefix matching, \ which are used for natural language processing etc. \ Tx uses Level-Order Unary Degree Sequence (LOUDS) for trie representation. categories devel platforms darwin homepage http://www-tsujii.is.s.u-tokyo.ac.jp/~hillbig/tx.htm master_sites http://www-tsujii.is.s.u-tokyo.ac.jp/~hillbig/software/ checksums md5 9e381d2c6c6f0fed7371e9a2f5f64d98
これをPortfileというファイル名で保存した後
$ sudo mkdir -p /opt/local/var/localports/devel/tx $ sudo cp Portfile /opt/local/local/var/localports/devel/tx/ $ cd /opt/local/var/localports $ sudo portindex $ sudo port -v selfupdate
と実行すればMacportsにtxが組み込まれる。
$ port list tx tx @0.12 devel/tx
ちゃんとでてきますね。
解説
一行ずつ解説していきます。
name tx
パッケージの名前を指定します。
version 0.12
ソフトウェアのバージョンです。なおダウンロードしてくるソースファイルは
name-version.tar.gz
です。autotoolsを使っているのならmake dist で作成されます。
revision 1
Portfile自体のバージョンです。同じバージョンのソフトウェアに対して修正等を行った時にはrevisionを
上げておくとアップデートされます。
description Library for a compact trie data structure.
port search の検索の時に表示される説明文。端的に書きましょう。
long_description Tx is a library for a compact trie data structure. \ Tx requires 1/4 - 1/10 of the memory usage compared to the previous implementations, \ and can therefore handle quite a large number of keys (e.g. 1 billion) efficiently. \ A trie data structure supports exact matching and common prefix matching, \ which are used for natural language processing etc. \ Tx uses Level-Order Unary Degree Sequence (LOUDS) for trie representation.
port info で詳細に表示した時に現れる長い説明文です。
categories devel
ソフトウェアの種類を表す。/opt/local/var/macports/sources/rsync.macports.org/release/ports/ を見るとどんなカテゴリがあるか分かると思います。ライブラリはdevelのようです。
platforms darwin
動作する環境(OS)を指定します。MacportsはMac以外にもFreeBSDやLinuxでも動作するのでOSの指定がある場合はここで指定します。といってもほとんどのものはdarwinしか指定していないみたいです。
homepage http://www-tsujii.is.s.u-tokyo.ac.jp/~hillbig/tx.htm
プロジェクト本家等、情報が載っているホームページのアドレスです。
master_sites http://www-tsujii.is.s.u-tokyo.ac.jp/~hillbig/software/
ソフトウェアの存在しているURLです。Macportsは内部的に以下のコマンドでソースファイルを取得します。
$ wget master_sites/name-version.tar.gz
最後に
checksums md5 9e381d2c6c6f0fed7371e9a2f5f64d98
参考URL
必要な情報のほとんどはここにある。
- アシアルブログ MacPortsで自前のPortsファイルを作って使ってみよう http://blog.asial.co.jp/381
ローカルのリポジトリを作るコマンドはここを参考にしました。