その他

MacPortsで自前のPortsファイルを作って使ってみよう

前回はMacPortsの基本的なコマンドを紹介しました。このMacPortsを使うとOSX上でより良いUNIX生活を送ることができるわけですが、時折、コンパイルのオプションを変更したいとかパッチを当てたいとか、またまた、使いたいものがあるけどまだ誰もPortsファイルにしていない等々、何かしらの理由で非公式のPortsファイルが必要になったりすることがあります。そんなことで、今回は自前のPortsファイルを作成し使ってみようと思います。

まず、前準備としてそれ用のリポジトリを作成しなければなりません。ということで、早速作成します。場所はどこでもいいのですが、私の場合は /opt/local/var/ 以下に localports という名のディレクトリを作成しました。


$ sudo mkdir /opt/local/var/localports

次にsources.confにこのリポジトリを追加します。


$ sudo vi /opt/local/etc/macports/sources.conf

このファイルのできるかぎり始めの方に、file:///opt/local/var/localportsと記述しています。すると、以下のような感じになります。


# MacPorts system wide sources configuration file
# $Id: sources.conf 26177 2007-06-15 10:11:22Z jmpp@macports.org $
#
# To enable your local ports repository, uncomment and customize the
# following line to point at your local ports directory
# Example: file:///Users/landonf/misc/MacPorts/ports
file:///opt/local/var/localports
#
# To prevent a source from synchronizing when `port sync` is used,
# append [nosync] to the end of the line
# Example: file:///Users/landonf/misc/MacPorts/dports [nosync]
#
# To get the ports tree from the MacPorts rsync.macports.org server use:
# rsync://rsync.macports.org/release/ports/
rsync://rsync.macports.org/release/ports/

で、あとはこのリポジトリ内に指定されたカテゴリ名のディレクトリを作成しそこに自前のPortsファイルを設置して準備完了となります。ちなみカテゴリ名って何?という感じだと思うのですか、この辺はMacPortsで用意されているリポジトリを参考にするとわかりやすいです。/opt/local/var/macports/sources/rsync.macports.org/release/ports以下にrsyncで取得されたPortsファイルらがあります。

例えば、私的に開発する上で欠かすことのできない screen は sysutils というカテゴリにあります。


$ cd /opt/local/var/macports/sources/rsync.macports.org/release/ports
$ cd sysutils/screen
$ ls -la

すると以下のように表示されます。

ここにあるPortfileというものが目的のものです。このファイルを開いてもらうとなにやらいろいろ記述されています。これがPortsファイルです。この内容に従ってサイトからファイルをダウンロードしてconfigureをしてビルドしてインストールするわけです。よってこれを変更したり、参考にして作れば自前のPortsファイルを作ることができるようになります。

では、早速これを参考にCVS版のscreenのPortsファイルを作成してみましょう。


$ sudo mkdir /opt/local/var/localports/sysutils
$ sudo cp -R /opt/local/var/macports/sources/rsync.macports.org/release/ports/sysutils/screen /opt/local/var/localports/sysutils
$ cd /opt/local/var/localports/sysutils/screen

以上のようにしてオリジナルのscreenのPortsファイルを先ほど作成したリポジトリにコピーします。そしてPortfileを編集します。


PortSystem 1.0
name            screen
version         4.0.3.cvs
homepage        http://www.gnu.org/software/screen/
description     Screen manager with VT100/ANSI terminal emulation
long_description    Screen is a full-screen window manager that multiplexes a physical \
            terminal between several processes (typically interactive shells). \
            Each virtual terminal provides the functions of a DEC VT100 terminal \
            and, in addition, several control functions from the ANSI X3.64 (ISO \
            6429) and ISO 2022 standards (e.g. insert/delete line and support for \
            multiple character sets). There is a scrollback history buffer for each \
            virtual terminal and a copy-and-paste mechanism that allows moving text \
            regions between windows.
categories      sysutils
platforms       darwin
patchfiles      patch-maxargs patch-pty.c
depends_lib     port:ncurses
fetch.type  cvs
cvs.root  :pserver:anonymous@cvs.savannah.gnu.org:/sources/screen
cvs.module  ${name}
worksrcdir ${name}/src
configure.args  --mandir=${prefix}/share/man \
                --infodir=${prefix}/share/info \
                --enable-locale \
                --enable-telnet \
                --enable-colors256 \
                --enable-rxct_osc
configure.env   LIBS=-lncurses
post-destroot {
    xinstall -644 ${workpath}/${name}/src/etc/etcscreenrc ${destroot}/${prefix}/etc/screenrc
    xinstall -644 ${workpath}/${name}/src/terminfo/screencap ${destroot}/${prefix}/etc/termcap
    system "tic ${workpath}/${name}/src/terminfo/screeninfo.src"
}
post-install {
ui_msg "===============================================================================\n"
ui_msg "Any screens running before upgrading, will not be available, post-install.\n"
ui_msg "===============================================================================\n"
}

オレオレ的なPortsファイルですが、こんな感じではないでしょうか。

で、あとはインデックスを更新するために以下のようにリポジトリのディレクトリ内でコマンドを実行します。


$ cd /opt/local/var/localports
$ sudo portindex

お疲れ様です、これで自前のPortsファイルを使うことができるようになりました。


$ sudo port -d install screen

インストールはいつものようにこんな感じで、完了すると、縦分割やlayoutといった新たな機能が実装されているCVS版screenがインストールされているハズです!

ということでそれほど難しくはないので、ぜひ試してみてはいかがでしょうか。

author img for asial

asial

前の記事へ

次の記事へ

一覧へ戻る
PAGE TOP