2003年11月11日(火)

地雷踏んだの、まさか俺だけ?

subversion で遊ぼうと思いながら、端末環境の MacOSX でコンパイルできずに棚上げになっていたのを少々調査。

MacOSX では fink に任せて build させようとしているんだが、これがうまくいかない。何故か apache2 の install でコケてしまう。ログをよく見ると mod_access.so をインストール先にコピーしようとしたところで、その .so が何故かない。
ってんで、 |& tee hoge しながら build させてみる。

ログで mod_access を compile している当たりで何かヒントがないかと見てみると、

lding shared: mod_access.la mod_auth.la mod_auth_anon.la mod_auth_dbm.la mod_aut
h_digest.la
/bin/sh /sw/share/apr-0/build/libtool --silent --mode=compile gcc  -g -O2    -DD
ARWIN -DSIGPROCMASK_SETS_THREAD_MASK -DAP_HAVE_DESIGNATED_INITIALIZER -I/sw/incl
ude  -I/sw/include/apr-0 -I/sw/include -I. -I/sw/src/apache2-2.0.47-5/httpd-2.0.
47/os/unix -I/sw/src/apache2-2.0.47-5/httpd-2.0.47/server/mpm/worker -I/sw/src/a
pache2-2.0.47-5/httpd-2.0.47/modules/http -I/sw/src/apache2-2.0.47-5/httpd-2.0.4
7/modules/filters -I/sw/src/apache2-2.0.47-5/httpd-2.0.47/modules/proxy -I/sw/sr
c/apache2-2.0.47-5/httpd-2.0.47/include -I/sw/src/apache2-2.0.47-5/httpd-2.0.47/
modules/dav/main -prefer-pic -c mod_access.c && touch mod_access.slo
/bin/sh /sw/share/apr-0/build/libtool --silent --mode=link gcc  -g -O2    -DDARW
IN -DSIGPROCMASK_SETS_THREAD_MASK -DAP_HAVE_DESIGNATED_INITIALIZER -I/sw/include
  -I/sw/include/apr-0 -I/sw/include -I. -I/sw/src/apache2-2.0.47-5/httpd-2.0.47/
os/unix -I/sw/src/apache2-2.0.47-5/httpd-2.0.47/server/mpm/worker -I/sw/src/apac
he2-2.0.47-5/httpd-2.0.47/modules/http -I/sw/src/apache2-2.0.47-5/httpd-2.0.47/m
odules/filters -I/sw/src/apache2-2.0.47-5/httpd-2.0.47/modules/proxy -I/sw/src/a
pache2-2.0.47-5/httpd-2.0.47/include -I/sw/src/apache2-2.0.47-5/httpd-2.0.47/mod
ules/dav/main -export-dynamic -L/sw/lib      -o mod_access.la -rpath /sw/lib/apa
che2/modules -module -avoid-version  mod_access.lo
/sw/share/apr-0/build/libtool: Mach-O dynamically linked shared library: command
not found

思いっきりうさん臭い部分があるじゃん(^^;;;。 どう見ても libtool の中で存在しないコマンドを叩こうとしたってことだろう。この libtool も fink が compile して作ったはずなのに、まさか俺しか引っかかってないんだろうか?ともあれ、 libtool の中でこの文字列を探すと

# Method to check whether dependent libraries are shared objects.
deplibs_check_method="file_magic Mach-O dynamically linked shared library"

# Command to use when deplibs_check_method == file_magic.
file_magic_cmd="/usr/bin/file -L"

こんな感じでばっちり埋まってる。問題は、こいつがどう参照されるかで、 sh の -x option 使って、ログからコケてた時のコマンドを実行してベタに出力させてみる。

+ deplibs_check_method=file_magic Mach-O dynamically linked shared library
+ file_magic_cmd=/usr/bin/file -L

値を突っ込んでるところはこのとおりちゃんと見えてる。

+ eval /usr/bin/file -L '"$potlib"'
+ /usr/bin/sed 10q
+ 'Mach-O dynamically linked shared library'
/sw/share/apr-0/build/libtool: Mach-O dynamically linked shared library: command
 not found

コケた所はこんな感じ。問題は、この部分が script 中でどこに埋まっているかだが、

+ set dummy file_magic Mach-O dynamically linked shared library
++ expr 'file_magic Mach-O dynamically linked shared library' : 'file_magic \(.*
\)'
+ file_magic_regex=Mach-O dynamically linked shared library

ログのちょっと前にこんな部分があって、こっちは割と簡単に

        file_magic*)
          set dummy $deplibs_check_method
          file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`

と発見できる。この後ろを見てゆくと…

                      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
                         | ${SED} 10q \
                         | $EGREP "$file_magic_regex" > /dev/null; then

sed を実行している部分が指紋になってくれて、コケた原因がばっちり判る。 そうっ、 $EGREP が未定義なのだ

(o_ _)oイイノカヨソレデ…

しかし、この libtool には、他にも

/sw/share/apr-0/build/libtool: test: : integer expression expected

が山ほど出てくるんだよね…………

[referer:

Script Error

The script did not produce proper HTTP headers. Please see the error log to see the detail of the errors. Depending on the server configuration, you can also run thisscript under CGIWrap debugging. Usually, either rename or linkthe script temporarily to a file which ends with .cgidextension, or add a AddHandler cgi-script-debug .cgiline to your .htaccess file.

]

あわせて読みたい