めっちゃ苦労したので書き残しておくことにする。
清書するつもりはないので、やり方だけ知りたい人は一番上にまとめときます。
Navboxの移植方法まとめ
- Wikipediaのデータ書き出しページに飛ぶ
- テキストボックスにこいつらを入れて書き出しボタンでダウンロード
- 自分のWiki/Special:Importを開いて、さっきDLしたxmlをアップロード
- Extension:Scribunto - MediaWikiからファイルをダウンロードし、さくらのサーバー上のwiki/extensionsに展開
- さくらのサーバーにSSHで接続。この辺りを参考にどうぞ。公開鍵認証は設定しておくと色々楽です。
~/local/src/
のディレクトリが存在しなければmkdirで作成しておく- コマンドラインから次の手順でScribunto用のLuaをコンパイルする
cd ~/local/src/ wget http://www.lua.org/ftp/lua-5.1.5.tar.gz tar -zxvf lua-5.* cd lua-5.1.5 make freebsd LDFLAGS+="-L/usr/local/lib" LIBS+="-lreadline -ltinfo -lm" make local cd bin ln -s lua lua-5.1.5
無事にコンパイルが終わったらSSHは切断して問題ない(次の手順をコマンドラインでやりたければそれはそれで。。。) - さくらのサーバーコンパネからファイルマネージャでLocalSettings.phpを開いて以下のように追記する
$wgPFEnableStringFunctions = true; wfLoadExtension( 'Scribunto' ); $wgScribuntoDefaultEngine = 'luastandalone'; $wgScribuntoEngineConf['luastandalone']['luaPath'] = '/home/『自分のユーザ名』/local/src/lua-5.1.5/bin/lua-5.1.5'; $wgScribuntoEngineConf['luastandalone']['errorFile'] = '/home/『自分のユーザ名』/www/『自分のWikiディレクトリ』/extensions/Scribunto/errorfile.log'; $wgScribuntoUseGeSHi = true; $wgScribuntoUseCodeEditor = true;
- Navboxを使ってページ作成をしてみて動けば完了。
以下は非常に雑多な奮闘記。書き殴りたかっただけなので読まなくても問題ないです。
沼の始まり
- Navboxが欲しくて色々ググったものの、英語版Wikipediaしかそれっぽい手順がなかったので従う
- Wikipediaのデータ書き出しページに飛ぶ
- テキストボックスにこいつらを入れて書き出しボタンでダウンロード
- "自分のWiki/Special:Import"を開いて、さっきDLしたxmlをアップロード
- ParserFunctions拡張機能をインストール(最新版のMediaWikiにはファイルが同梱されてるのでLocalSetting.phpをいじるだけ)
- http://www.chekmate.org/wiki/index.php/MW:_ImageMap_Extensionとやらをインストール ←ココで引っかかる
- サイトに繋がらないので次のフェーズに移る
地獄の入り口
- とりあえずTemplate:Navboxインポートしたし開いてみるか→Luaのモジュールがないと怒られる→「Scribunto」とやらをいんすとーるすればよいらしい
- Extension:Scribunto - MediaWikiに従ってインストール→動かない
- MediaWikiにExtension:Scribuntoをインストール – Remove Before Flightを見つけたところ、できるらしい。やったね。
- とりあえずLua: download areaから最新版のソースをDLしてきてコンパイル。バイナリ生成できた。
- Wikipediaから以下のやつらをExportして自分のWikiにImport。
- Module:Navbox
- Module:Navbox/doc
- Module:Navbox/former
- Module:Navbox/former/sandbox
- Module:Navbox/sandbox
- Module:Navboxを開いてみる→「エラー:ステータス1」とか表示されてキレる。
- MediaWikiにExtension:Scribuntoをインストール – Remove Before Flightに立ち返ってみたところ「2016年3月7日現在、Luaの最新バージョンは5.3.2になっているが、Lua 5.2.xやLua 5.3.xを使用すると
ステータス1」を返してインタープリターがエラーを起こすことがある模様。
と書いてあった。3年も経ってるんだから直ってると思うじゃないか…… - Lua5.1系の最終版、「Lua5.1.5」をDLしてコンパイル→次のようなエラーが発生する
gcc -o lua lua.o liblua.a -lm -Wl,-E -lreadline //usr/local/lib/libreadline.so: undefined reference to
つらい……tputs' //usr/local/lib/libreadline.so: undefined reference to
tgoto' //usr/local/lib/libreadline.so: undefined reference totgetflag' //usr/local/lib/libreadline.so: undefined reference to
UP' //usr/local/lib/libreadline.so: undefined reference totgetent' //usr/local/lib/libreadline.so: undefined reference to
tgetnum' //usr/local/lib/libreadline.so: undefined reference toPC' //usr/local/lib/libreadline.so: undefined reference to
tgetstr' //usr/local/lib/libreadline.so: undefined reference to `BC' collect2: error: ld returned 1 exit status *** Error code 1
Luaのコンパイルをどうにかして通す
- エラー文でググっているとLua を一般ユーザでソースコードからインストールする - はちゅにっきを発見。ただしこちらの方の解決方法は既にncursesを自力で準備している環境だったため真似るだけでは解決できず。
- 30分くらいネットの海で溺れていたところFreeBSDのフォーラムでhttps://bugs.freebsd.org/bugzilla/show_bug.cgi?id=220796を発見。makeコマンドの末尾にLDFLAGS+=-L/usr/local/lib LIBS+="-lreadline -ltinfo"を追加してみたらエラー文が次のように変わる。
gcc -o lua lua.o liblua.a -lreadline -ltinfo liblua.a(lvm.o): In function
いいところまで来た気がする!Arith': lvm.c:(.text+0x411): undefined reference to
pow' liblua.a(lvm.o): In functionluaV_execute': lvm.c:(.text+0x22f2): undefined reference to
pow' liblua.a(lcode.o): In functioncodearith': lcode.c:(.text+0x1121): undefined reference to
pow' liblua.a(lmathlib.o): In functionmath_tan': lmathlib.c:(.text+0x9f): undefined reference to
tan' liblua.a(lmathlib.o): In functionmath_tanh': lmathlib.c:(.text+0xcf): undefined reference to
tanh' liblua.a(lmathlib.o): In functionmath_sqrt': lmathlib.c:(.text+0x12e): undefined reference to
sqrt' liblua.a(lmathlib.o): In functionmath_sin': lmathlib.c:(.text+0x14f): undefined reference to
sin' liblua.a(lmathlib.o): In functionmath_sinh': lmathlib.c:(.text+0x17f): undefined reference to
sinh' liblua.a(lmathlib.o): In functionmath_pow': lmathlib.c:(.text+0x5cc): undefined reference to
pow' liblua.a(lmathlib.o): In functionmath_log': lmathlib.c:(.text+0x64f): undefined reference to
log' liblua.a(lmathlib.o): In functionmath_log10': lmathlib.c:(.text+0x67f): undefined reference to
log10' liblua.a(lmathlib.o): In functionmath_fmod': lmathlib.c:(.text+0x74c): undefined reference to
fmod' liblua.a(lmathlib.o): In functionmath_exp': lmathlib.c:(.text+0x77f): undefined reference to
exp' liblua.a(lmathlib.o): In functionmath_cos': lmathlib.c:(.text+0x7af): undefined reference to
cos' liblua.a(lmathlib.o): In functionmath_cosh': lmathlib.c:(.text+0x7df): undefined reference to
cosh' liblua.a(lmathlib.o): In functionmath_atan': lmathlib.c:(.text+0x87f): undefined reference to
atan' liblua.a(lmathlib.o): In functionmath_atan2': lmathlib.c:(.text+0x8cc): undefined reference to
atan2' liblua.a(lmathlib.o): In functionmath_asin': lmathlib.c:(.text+0x8ff): undefined reference to
asin' liblua.a(lmathlib.o): In functionmath_acos': lmathlib.c:(.text+0x92f): undefined reference to
acos' collect2: error: ld returned 1 exit status *** Error code 1 - エラー文の1行目と2行目を検索窓に突っ込んでみたらgccのコンパイルエラー(undefined reference to `pow') | IT忘備録・メモ書きと日記が見つかった!
- というわけでmakeの後ろにLDFLAGS+="-L/usr/local/lib" LIBS+="-lreadline -ltinfo -lm"を追加してみたらコンパイル通ったじゃないか!!!!
動くかと思ったら
- Luaスクリプトの動作確認のつもりで「Module:Navbox」を開いてみたら「Module:ArgumentがUndefinedやで」とかおっしゃる……
- 試しにWikipediaで「Module:Argument」を探してみたらそのものズバリがあったのでExport/Import→エラー消えた!
- もしかしてと思ってTemplate:Navboxを使ったテンプレートを作ってみたらバッチリ動いてる!!!長い戦いだった!!!!!
Navboxの移植を決意してからこのブログを一気に書き上げるまで約3時間でした。
乱文ですが皆様のお役に立てたら嬉しいですね。