寒い!風が強い!でも桜は散ってない!

週末は飲むぞ〜!

mt-daapd で iTunes を快適にしよう!
先日調子の悪くなったミニコンポ、CD チェンジャーの調子が悪くなって CD が聞けなくなった。目覚まし代わりなのにそりゃ困るよ! で、携帯で起きたりしていたのだけど、CD チェンジャーをガシャガシャいぢっていたらなおった。それはそれで良いのだけど、壊れている時に次に買おうと思ったコンポはネットワーク対応のやつ! で、あれこれネットワークとコンポの事を調べたりしていたら、linuxiTunes のサーバにできるソフトがある!って話を発見。そりゃ良いや! 容量を喰う曲データをサーバに入れて iTunes でどこからでも聞けるのは嬉しいね。
というわけで、debian に mt-daapd を入れてみた。


mt-daapd は debian のパッケージになってないみたい。仕方がないのでソースを持ってくる。http://www.mt-daapd.org/ からたどれる。最新版は 0.2.4 なのね。最近新しくなったばかりみたい。


さて、debian らしくパッケージにしてインストールをしたいな〜。というわけで、まずは debuild を試す。

paraches@debian:~/myTest/mt-daapd-0.2.4$ debuild
-bash: debuild: command not found

そうだね、パッケージを作ったりするパッケージが必要なのね…。debian 開発でググって、とにかくそれっぽいのを片っ端から入れてみよう。

paraches@debian:~/myTest/mt-daapd-0.2.4$ sudo apt-get install autoconf
paraches@debian:~/myTest/mt-daapd-0.2.4$ sudo apt-get install automaken
パッケージリストを読みこんでいます... 完了0%
依存関係ツリーを作成しています... 完了%     
automaken は以下のパッケージで提供されている仮想パッケージです:
  automake1.9 1.9.5-1
  automake1.8 1.8.5-3
  automake1.7 1.7.9-7
  automake1.6 1.6.3-12
  automake1.4 1:1.4-p6-9
インストールするパッケージを明示的に選択する必要があります。
E: パッケージ automaken にはインストール候補がありません

ん? それじゃ一番新しいっぽいものを。

paraches@debian:~/myTest/mt-daapd-0.2.4$ sudo apt-get install automake1.9
paraches@debian:~/myTest/mt-daapd-0.2.4$ sudo apt-get install dpkg-dev
paraches@debian:~/myTest/mt-daapd-0.2.4$ sudo apt-get install libc6-dev
paraches@debian:~/myTest/mt-daapd-0.2.4$ sudo apt-get install fakeroot
paraches@debian:~/myTest/mt-daapd-0.2.4$ sudo apt-get install libtool
paraches@debian:~/myTest/mt-daapd-0.2.4$ sudo apt-get install libtool-doc g77 gcj libltdl3-dev
paraches@debian:~/myTest/mt-daapd-0.2.4$ sudo apt-get install g77-doc g77-3.3-doc libgcj4-awt equivs gij fastjar gij-3.3 libgcj4-dev
paraches@debian:~/myTest/mt-daapd-0.2.4$ sudo apt-get install dh-make devscripts-el cvs-buildpackage debian-keyring dupload dput gnuplot libtimedate-perl lintian linda patchutils wdiff cvs gettext-doc curl libmail-sendmail-perl libcompress-zlib-perl

推奨されてたりするのも片っ端から入れてたら凄い量になった…。というわけで、推奨は途中で入れるのを諦めた。無い!って言われたら入れよう。
さて、これで行けるはず。debuild でパッケージを作るぞ!

debian:/home/paraches/myTest/mt-daapd-0.2.4/debian# debuild
debuild: fatal error at line 521:
cannot find readable debian/changelog anywhere!
Are you in the source code tree?
debian:/home/paraches/myTest/mt-daapd-0.2.4/debian# ls
:2eDS_Store  Makefile.am  compat   copyright  docs    postinst
ChangeLog    Makefile.in  control  dirs       init.d  rules

ん? ChangeLog はあるけど changelog は無いな〜。んじゃ新しく作ってトライ!

paraches@debian:~/myTest/mt-daapd-0.2.4/debian$ cp ChangeLog changelog
paraches@debian:~/myTest/mt-daapd-0.2.4/debian$ debuild
parsechangelog/debian: error: badly formatted trailer line, at changelog line 4
debuild: fatal error at line 538:
problem executing dpkg-parsechangelog | grep: 

次は changelog の4行目がどうしたって? badly formatted trailer lineって何よ?
とりあえず見てみよう。

debian:/home/paraches/myTest/mt-daapd-0.2.4/debian# cat changelog
mt-daapd (0.2.4-1) unstable; urgency=low
  * Fix for iTunes 6.0.4

 -- Ron Pedde <ron@pedde.com> Wed,  1 Mar 2006 18:48:00 -0600

mt-daapd (0.2.3-1) unstable; urgency=low
  * Fix mDNS advertising on amd64 and freebsd in 0.2.2

 -- Ron Pedde <ron@pedde.com>  Sun, 11 Sep 2005 14:09:00 -0500
(長いので省略)

わからない〜! 何が悪いの??? changelog の書き方の勉強しなきゃいけない?
というわけで、他の方法で作ってみよう。

paraches@debian:~/myTest/mt-daapd-0.2.4$ dpkg-buildpackage -rfakeroot
parsechangelog/debian: error: badly formatted trailer line, at changelog line 4
dpkg-buildpackage: unable to determine source package
paraches@debian:~/myTest/mt-daapd-0.2.4$ ls
:2eDS_Store  Makefile     aclocal.m4    config.status  depcomp
AUTHORS      Makefile.am  admin-root    config.sub     install-sh
COPYING      Makefile.in  config.guess  configure      missing
CREDITS      NEWS         config.h      configure.in   mkinstalldirs
ChangeLog    README       config.h.in   contrib        src
INSTALL      TODO         config.log    debian         stamp-h1

ん? またエラーじゃん。ソースのパッケージが見つからないって? ちゃんと src があるじゃん。そういうことじゃないの???
駄目だ、ちゃんとパッケージの作り方を勉強しないとついて行けない…。


仕方がないので普通にインストールすることにしよう。

debian:/home/paraches/myTest/mt-daapd-0.2.4# ./configure
bash: ./configure: 許可がありません

あれ? 何の許可?

paraches@debian:~/myTest/mt-daapd-0.2.4# ls -al configure
-rw-r--r--  1 paraches paraches 227120 2006-03-02 09:49 configure

あぁ、実行形式になってないのね。実行できるようにして再度挑戦。

debian:/home/paraches/myTest/mt-daapd-0.2.4# chmod 755 configure
debian:/home/paraches/myTest/mt-daapd-0.2.4# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
(長いので省略)
checking for stdint.h... yes
checking for unistd.h... yes
checking gdbm.h usability... no
checking gdbm.h presence... no
checking for gdbm.h... no
configure: error: gdbm.h not found... try --with-gdbm-includes=dir

あ〜 gdbm.h が無いと。gdbm を入れれば良いのか。

debian:/home/paraches/myTest/mt-daapd-0.2.4# apt-get install gdbm
パッケージリストを読みこんでいます... 完了%
依存関係ツリーを作成しています... 完了%     
E: パッケージ gdbm が見付かりません

そんなに簡単な事じゃないのね。仕方がないので http://www.debian.org/distrib/packages でパッケージ検索をして調べた。gdbm という名前のパッケージはいくつか出てくるけど、dev も付いてるし libgdbm-dev かな? 入れて試してみよう。

debian:/home/paraches/myTest/mt-daapd-0.2.3/debian# apt-get install libgdbm-dev
パッケージリストを読みこんでいます... 完了0%
依存関係ツリーを作成しています... 完了%     
以下のパッケージが新たにインストールされます:
  libgdbm-dev
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 0 個。
49.8kB のアーカイブを取得する必要があります。
展開後に追加で 176kB のディスク容量が消費されます。
取得:1 http://ftp.jp.debian.org stable/main libgdbm-dev 1.8.3-2 [49.8kB]
49.8kB を 57s で取得しました (865B/s)    
未選択パッケージ libgdbm-dev を選択しています。
(データベースを読み込んでいます... 現在 39601 個のファイルとディレクトリがインストールされています。)
(.../libgdbm-dev_1.8.3-2_powerpc.deb から) libgdbm-dev を展開しています...
libgdbm-dev (1.8.3-2) を設定しています ...

debian:/home/paraches/myTest/mt-daapd-0.2.4# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
(長いので省略)
checking gdbm.h usability... yes
checking gdbm.h presence... yes
checking for gdbm.h... yes
checking for gdbm_open in -lgdbm... yes
Have gdbm
Adding dynamic libgdbm
checking id3tag.h usability... no
checking id3tag.h presence... no
checking for id3tag.h... no
configure: error: id3tag.h not found... try --with-id3tag=dir

先に進んだぞ! で、今度は id3tag.h が駄目なのか〜。またパッケージ検索ね。これは libid3tag0-dev で良いのかな。

debian:/home/paraches/myTest/mt-daapd-0.2.4# apt-get install libid3tag0-dev
パッケージリストを読みこんでいます... 完了0%
依存関係ツリーを作成しています... 完了%     
以下の特別パッケージがインストールされます:
  libid3tag0 pkg-config
提案パッケージ:
  libgnome-dev
以下のパッケージが新たにインストールされます:
  libid3tag0 libid3tag0-dev pkg-config
アップグレード: 0 個、新規インストール: 3 個、削除: 0 個、保留: 1 個。
128kB のアーカイブを取得する必要があります。
展開後に追加で 483kB のディスク容量が消費されます。
続行しますか? [Y/n] y
取得:1 http://ftp.jp.debian.org stable/main libid3tag0 0.15.1b-4.1 [36.0kB]
取得:2 http://ftp.jp.debian.org stable/main pkg-config 0.17.2-1 [53.7kB]
取得:3 http://ftp.jp.debian.org stable/main libid3tag0-dev 0.15.1b-4.1 [37.9kB]
128kB を 56s で取得しました (2247B/s)       
未選択パッケージ libid3tag0 を選択しています。
(データベースを読み込んでいます... 現在 39652 個のファイルとディレクトリがインストールされています。)
(.../libid3tag0_0.15.1b-4.1_powerpc.deb から) libid3tag0 を展開しています...
未選択パッケージ pkg-config を選択しています。
(.../pkg-config_0.17.2-1_powerpc.deb から) pkg-config を展開しています...
未選択パッケージ libid3tag0-dev を選択しています。
(.../libid3tag0-dev_0.15.1b-4.1_powerpc.deb から) libid3tag0-dev を展開しています...
libid3tag0 (0.15.1b-4.1) を設定しています ...

pkg-config (0.17.2-1) を設定しています ...
libid3tag0-dev (0.15.1b-4.1) を設定しています ...

で、再度 ./configure をトライ!

debian:/home/paraches/myTest/mt-daapd-0.2.4# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
(長いので省略)
checking id3tag.h usability... yes
checking id3tag.h presence... yes
checking for id3tag.h... yes
checking for id3_file_open in -lid3tag... yes
Have id3tag
Adding dynamic libid3tag
checking for strcasestr... yes
checking for strsep... yes
(長いので省略)
checking for socket in -lsocket... no
configure: creating ./config.status
config.status: creating src/Makefile
config.status: creating admin-root/Makefile
config.status: creating contrib/Makefile
config.status: creating debian/Makefile
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
debian:/home/paraches/myTest/mt-daapd-0.2.4#

というわけで最後まで到着! 次は make だ!

debian:/home/paraches/myTest/mt-daapd-0.2.4# make
make  all-recursive
make[1]: Entering directory `/home/paraches/myTest/mt-daapd-0.2.4'
Making all in src
make[2]: Entering directory `/home/paraches/myTest/mt-daapd-0.2.4/src'
make  all-am
make[3]: Entering directory `/home/paraches/myTest/mt-daapd-0.2.4/src'
source='main.c' object='main.o' libtool=no ?
depfile='.deps/main.Po' tmpdepfile='.deps/main.TPo' ?
depmode=gcc3 /bin/sh ../depcomp ?
gcc -DHAVE_CONFIG_H -I. -I. -I..   -g -DHOST='"powerpc-unknown-linux-gnu"' -DNOT_HAVE_SA_LEN  -g -O2 -c `test -f 'main.c' || echo './'`main.c
(長いので省略)
gcc  -g -O2  -lpthread -lgdbm -lid3tag -lz -o mt-daapd  main.o uici.o webserver.o configfile.o err.o restart.o daap-proto.o daap.o db-gdbm.o mp3-scanner.o playlist.o lexer.o parser.o strcasestr.o strsep.o redblack.o dynamic-art.o query.o mDNS.o mDNSPosix.o mDNSUNP.o rend-posix.o rend-unix.o     
make[3]: Leaving directory `/home/paraches/myTest/mt-daapd-0.2.4/src'
make[2]: Leaving directory `/home/paraches/myTest/mt-daapd-0.2.4/src'
Making all in admin-root
make[2]: Entering directory `/home/paraches/myTest/mt-daapd-0.2.4/admin-root'
make[2]: `all' に対して行うべき事はありません。
make[2]: Leaving directory `/home/paraches/myTest/mt-daapd-0.2.4/admin-root'
Making all in contrib
make[2]: Entering directory `/home/paraches/myTest/mt-daapd-0.2.4/contrib'
make[2]: `all' に対して行うべき事はありません。
make[2]: Leaving directory `/home/paraches/myTest/mt-daapd-0.2.4/contrib'
Making all in debian
make[2]: Entering directory `/home/paraches/myTest/mt-daapd-0.2.4/debian'
make[2]: `all' に対して行うべき事はありません。
make[2]: Leaving directory `/home/paraches/myTest/mt-daapd-0.2.4/debian'
make[2]: Entering directory `/home/paraches/myTest/mt-daapd-0.2.4'
make[2]: Leaving directory `/home/paraches/myTest/mt-daapd-0.2.4'
make[1]: Leaving directory `/home/paraches/myTest/mt-daapd-0.2.4'
debian:/home/paraches/myTest/mt-daapd-0.2.4#

終わったけど、最後に「`all' に対して行うべき事はありません。」って何度か怒られてるな…。ま、いっか。
次は make install だね。

debian:/home/paraches/myTest/mt-daapd-0.2.4# make install
Making install in src
make[1]: Entering directory `/home/paraches/myTest/mt-daapd-0.2.4/src'
make[2]: Entering directory `/home/paraches/myTest/mt-daapd-0.2.4/src'
/bin/sh ../mkinstalldirs /usr/local/sbin
  /usr/bin/install -c mt-daapd /usr/local/sbin/mt-daapd
make[2]: `install-data-am' に対して行うべき事はありません。
make[2]: Leaving directory `/home/paraches/myTest/mt-daapd-0.2.4/src'
(長いので省略)
make[2]: `install-exec-am' に対して行うべき事はありません。
make[2]: `install-data-am' に対して行うべき事はありません。
make[2]: Leaving directory `/home/paraches/myTest/mt-daapd-0.2.4'
make[1]: Leaving directory `/home/paraches/myTest/mt-daapd-0.2.4'
debian:/home/paraches/myTest/mt-daapd-0.2.4# 

また怒られてるな〜。でも、なんとかなるでしょう!

というわけで、インストールも終了。後は設定ファイルをコピーして修正するだけかな?

paraches@debian:~/myTest/mt-daapd-0.2.4$ sudo cp contrib/mt-daapd.conf /etc
paraches@debian:~/myTest/mt-daapd-0.2.4$ sudo cp contrib/mt-daapd.playlist /etc

で、/etc/mt-daapd.conf の方は2カ所設定を変更。

#
# web_root (required)
#
# Location of the admin web pages.
#
# If you installed from .RPM, .deb, or tarball with --prefix=/usr, then
# this is correct. 
#
# If you installed from tarball without --prefix=/usr, then the correct
# path is probably /usr/local/share/mt-daapd/admin-root.
#

web_root        /usr/local/share/mt-daapd/admin-root

tarball から何も考えずに ./configure;make;make install しちゃったので、path が違ってる。ちゃんと local を間に挟んだ。

#
# mp3_dir (required)
#
# Location of the mp3 files to share.  Note that because the
# files are stored in the database by inode, these must be
# in the same physical filesystem.
#

#mp3_dir                /mnt/mp3
mp3_dir         /home/paraches/myMusic

曲データを置く場所。自分のディレクトリの myMusic フォルダにデータは置く。

というわけで、とりあえず一通りの設定終了。mt-daapd を起動してみよう。

paraches@debian:/etc$ sudo /usr/local/sbin/mt-daapd
Bad mp3 directory (/home/paraches/myMusic): No such file or directory
Error reading config file (/etc/mt-daapd.conf)

あ、まだフォルダの用意してなかった! フォルダを作って mp3 データをコピーして再度起動!

paraches@debian:/etc$ sudo /usr/local/sbin/mt-daapd

特に何も言われない。ちょっと daemon.log を覗いてみよう。

paraches@debian:/var/log$ sudo cat daemon.log
Mar 30 23:57:31 localhost mt-daapd[17023]: Starting rendezvous daemon 
Mar 30 23:57:31 localhost mt-daapd[17025]: Starting signal handler 
Mar 30 23:57:31 localhost mt-daapd[17025]: Loading playlists 
Mar 30 23:57:31 localhost mt-daapd[17025]: Initializing database 
Mar 30 23:57:31 localhost mt-daapd[17025]: Starting mp3 scan 
Mar 30 23:57:31 localhost mt-daapd[17025]: Starting web server from /usr/local/share/mt-daapd/admin-root on port 3689 
Mar 30 23:57:31 localhost mt-daapd[17025]: Registering rendezvous names 
Mar 30 23:57:31 localhost mt-daapd[17025]: Scanned 4 songs in  0 seconds 

を、ちゃんと起動してる。それじゃ、iTunes を起動して確認!

ちゃんと見えるよ! ちゃんと音楽も聴けるよ!
というわけで、なんとなく勢いで始めた mt-daapd のインストールは成功!

でも、init.d に置くファイルはどうすれば良いんだろう? contrib にあるファイルを使うか作れって言われてるけど、mt-daapd.debianって無いよ。mt-daapd.gentoo じゃ駄目かな? これはまた今度じっくり考えよう。それまでは手でスタートだ!