« MTアップグレードで不具合/ドイツ遠征検討 | メイン | 定例ボウリング大会 »
2006年07月16日
perlアップグレードでトホホ |
連休だが今日も在宅にてサーバメンテ。
MovableTypeの改造を少々。
●画像にtitle属性を自動的につける
lib/MT/App/CMS.pm
4790行目付近を以下のように変更
if ($thumb) {
return <
HTML
} else {
return <
« MTアップグレードで不具合/ドイツ遠征検討 | メイン | 定例ボウリング大会 »
perlアップグレードでトホホ |
連休だが今日も在宅にてサーバメンテ。
MovableTypeの改造を少々。
●画像にtitle属性を自動的につける
lib/MT/App/CMS.pm
4790行目付近を以下のように変更
if ($thumb) {
return <
●画像アップロード時に「HTMLを表示 」をデフォルトにする(通常は「エントリーを投稿」がデフォルト)
tmpl/cms/upload.tmpl
[変更前]
<select name="site_path" onchange="setExtraPath(this)">
<option value="1"><<MT_TRANS phrase="Site Root">></option>
<TMPL_IF NAME=ENABLE_ARCHIVE_PATHS>
<option value="0"><<MT_TRANS phrase="Archive Root">></option>
</TMPL_IF>
[変更後]
<select name="site_path" onchange="setExtraPath(this)">
<TMPL_IF NAME=ENABLE_ARCHIVE_PATHS>
<option value="0"><<MT_TRANS phrase="Archive Root">></option>
</TMPL_IF>
<option value="1"><<MT_TRANS phrase="Site Root">></option>
DBIやDBD:pgを更新すると直ると聞き、挑戦してみたが、perlもバージョンアップ(v5.6.1→v5.6.2)してみよう。
悲劇はここから始まった。
perlをソースからビルドし、/usr/bin/perl を更新したら、MTの管理画面が機能しなくなった!!
mt.cgiへアクセスすると、以下のようなメッセージが表示されてしまう。
Got an error: Unsupported driver MT::ObjectDriver::DBI::postgres:
Can't locate DBI.pm in @INC (@INC contains:
/usr/local/apache/cgi-bin/mt/extlib lib
/usr/local/perl-5.6.2/lib/5.6.2/i686-linux
/usr/local/perl-5.6.2/lib/5.6.2
/usr/local/perl-5.6.2/lib/site_perl/5.6.2/i686-linux
/usr/local/perl-5.6.2/lib/site_perl/5.6.2
/usr/local/perl-5.6.2/lib/site_perl .) at lib/MT/ObjectDriver/DBI.pm
line 10.
BEGIN failed--compilation aborted at lib/MT/ObjectDriver/DBI.pm line 10.
Compilation failed in require at lib/MT/ObjectDriver/DBI/postgres.pm line 10.
BEGIN failed--compilation aborted at
lib/MT/ObjectDriver/DBI/postgres.pm line 10.
Compilation failed in require at (eval 4) line 1.
BEGIN failed--compilation aborted at (eval 4) line 1.
これはいったいどういうことか。
perlUGに伴い、IncludePath(パス)が大幅に変更になってしまった。
/usr/lib/perl5/site_perl/5.6.1/i386-linux/
↓
/usr/local/perl-5.6.2/lib/5.6.2/i686-linux
Perl周りのモジュールを逐次インストールしていくことにした。
mt-check.cgi の出力結果を見ながら以下の通り作業した。
・Storableがない
CPAN(http://search.cpan.org/)から探してダウンロード
Storable-2.15.tar.gz
perlモジュールのインストール方法はたいてい共通で以下の通りだ。
---
perl Makefile.PL
make
make test
sudo make install
---
・HTML::Entitiesがない
HTML-Parser-3.55.tar.gz
make test中にエラー発生
Can't locate HTML/Tagset.pm
依存関係があるらしい
・HTML::Templateがない!
HTML-Template-2.8.tar.gz
make test中にエラー発生
Can't locate Digest/MD5.pm
これも依存関係があるらしい
Digest-MD5-2.36が必要?
Digest-MD5-2.36.tar.gz
うまくいった。
さて、HTML::Template インストール再開...
make test成功→インストールOK
さて、HTML::Entities(HTML::Parser) インストール再開...
make test中にまたもHTML/Tagset.pmがない、とおっしゃる
↓
HTML-Tagset-3.10が必要らしい
HTML-Tagset-3.10.tar.gz
無事インストール成功
↓
さて、HTML::Entities(HTML::Parser) インストール再開...
今度はうまくいった。
これまでのところで、ブログシステムは復旧したようだ。
・File::Specも更新しておこう
[現状]
File::Spec (version >= 0.8)
サーバーには、File::Specがインストールされています。(バージョン: 0.86)
CPANからDL
PathTools-3.19.tar.gz
make test1中にエラー発生
t/taint............Can't locate Scalar/Util.pm in @INC ...
Scalar::Util というのが必要らしい
Scalar-List-Utils-1.18.tar.gz
これは無事インストール成功
さて、File::Spec更新作業再開...
今度はうまくいった。
・XML::Atomをインストール
XML-Atom-0.21.tar.gz
これは少し趣が違う...
perl Makefile.PL
$ perl Makefile.PL
*** Module::AutoInstall version 1.02
*** Checking for Perl dependencies...
[Core Features]
- MIME::Base64 ...loaded. (3.07)
- URI ...missing.
==> Auto-install the 1 mandatory module(s) from CPAN? [y] y
[Faster XML parsing with libxml]
- XML::LibXML ...missing. (would need 1.54)
==> Auto-install the 1 optional module(s) from CPAN? [y] y
[Pure perl XML parsing with XML::XPath]
- XML::XPath ...missing.
==> Auto-install the 1 optional module(s) from CPAN? [y] y
[Client/Server for Atom API]
- LWP ...missing.
- LWP::Authen::Wsse ...missing.
- Digest::SHA1 ...missing.
- DateTime ...missing.
==> Auto-install the 4 optional module(s) from CPAN? [y] y
[Feed and API Auto-discovery]
- HTML::Parser ...loaded. (3.55)
/home/user/.cpan/CPAN/MyConfig.pm initialized.
CPAN is the world-wide archive of perl resources. It consists of about
100 sites that all replicate the same contents all around the globe.
Many countries have at least one CPAN site already. The resources
found on CPAN are easily accessible with the CPAN.pm module. If you
want to use CPAN.pm, you have to configure it properly.
If you do not want to enter a dialog now, you can answer 'no' to this
question and I'll try to autoconfigure. (Note: you can revisit this
dialog anytime later by typing 'o conf init' at the cpan prompt.)
Are you ready for manual configuration? [yes]
The following questions are intended to help you with the
configuration. The CPAN module needs a directory of its own to cache
important index files and maybe keep a temporary mirror of CPAN files.
This may be a site-wide directory or a personal directory.
I see you already have a directory
/home/user/.cpan
Shall we use it as the general CPAN build and cache directory?
CPAN build and cache directory? [/home/user/.cpan]
If you want, I can keep the source files after a build in the cpan
home directory. If you choose so then future builds will take the
files from there. If you don't want to keep them, answer 0 to the
next question.
How big should the disk cache be for keeping the build directories
with all the intermediate files?
Cache size for build directory (in MB)? [10]
By default, each time the CPAN module is started, cache scanning
is performed to keep the cache size in sync. To prevent from this,
disable the cache scanning with 'never'.
Perform cache scanning (atstart or never)? [atstart]
To considerably speed up the initial CPAN shell startup, it is
possible to use Storable to create a cache of metadata. If Storable
is not available, the normal index mechanism will be used.
Cache metadata (yes/no)? [yes]
The next option deals with the charset your terminal supports. In
general CPAN is English speaking territory, thus the charset does not
matter much, but some of the aliens out there who upload their
software to CPAN bear names that are outside the ASCII range. If your
terminal supports UTF-8, you say no to the next question, if it
supports ISO-8859-1 (also known as LATIN1) then you say yes, and if it
supports neither nor, your answer does not matter, you will not be
able to read the names of some authors anyway. If you answer no, names
will be output in UTF-8.
Your terminal expects ISO-8859-1 (yes/no)? [yes]
The CPAN module can detect when a module that which you are trying to
build depends on prerequisites. If this happens, it can build the
prerequisites for you automatically ('follow'), ask you for
confirmation ('ask'), or just ignore them ('ignore'). Please set your
policy to one of the three values.
Policy on building prerequisites (follow, ask or ignore)? [ask] ignore
The CPAN module will need a few external programs to work properly.
Please correct me, if I guess the wrong path for a program. Don't
panic if you do not have some of them, just press ENTER for those. To
disable the use of a download program, you can type a space followed
by ENTER.
Where is your gzip program? [/bin/gzip]
Where is your tar program? [/bin/tar]
Where is your unzip program? [/usr/local/bin/unzip]
Where is your make program? [/usr/bin/make]
Warning: lynx not found in PATH
Where is your lynx program? []
Where is your wget program? [/usr/bin/wget]
Where is your ncftpget program? [/usr/bin/ncftpget]
Where is your ftp program? [/usr/bin/ftp]
What is your favorite pager program? [/usr/bin/less]
What is your favorite shell? [/bin/bash]
Every Makefile.PL is run by perl in a separate process. Likewise we
run 'make' and 'make install' in processes. If you have any
parameters (e.g. PREFIX, LIB, UNINST or the like) you want to pass
to the calls, please specify them here.
If you don't understand this question, just press ENTER.
Parameters for the 'perl Makefile.PL' command?
Typical frequently used settings:
POLLUTE=1 increasing backwards compatibility
LIB=~/perl non-root users (please see manual for more hints)
Your choice: []
Parameters for the 'make' command?
Typical frequently used setting:
-j3 dual processor system
Your choice: []
Parameters for the 'make install' command?
Typical frequently used setting:
UNINST=1 to always uninstall potentially conflicting files
Your choice: []
Sometimes you may wish to leave the processes run by CPAN alone
without caring about them. As sometimes the Makefile.PL contains
question you're expected to answer, you can set a timer that will
kill a 'perl Makefile.PL' process after the specified time in seconds.
If you set this value to 0, these processes will wait forever. This is
the default and recommended setting.
Timeout for inactivity during Makefile.PL? [0]
If you're accessing the net via proxies, you can specify them in the
CPAN configuration or via environment variables. The variable in
the $CPAN::Config takes precedence.
Your ftp_proxy?
Your http_proxy?
Your no_proxy?
You have no /home/user/.cpan/sources/MIRRORED.BY
I'm trying to fetch one
LWP not available
Please, install Net::FTP as soon as possible. CPAN.pm installs it for you
if you just type
install Bundle::libnet
Trying with "/usr/bin/ncftpget" to get
ftp://ftp.perl.org/pub/CPAN/MIRRORED.BY
MIRRORED.BY: 156.56 kB 407.39 kB/s
Your /home/user/.cpan/sources/MIRRORED.BY is older than 60 days,
I'm trying to fetch one
Trying with "/usr/bin/ncftpget" to get
ftp://ftp.perl.org/pub/CPAN/MIRRORED.BY
MIRRORED.BY: 156.56 kB 408.63 kB/s
Now we need to know where your favorite CPAN sites are located. Push
a few sites onto the array (just in case the first on the array won't
work). If you are mirroring CPAN to your local workstation, specify a
file: URL.
First, pick a nearby continent and country (you can pick several of
each, separated by spaces, or none if you just want to keep your
existing selections). Then, you will be presented with a list of URLs
of CPAN mirrors in the countries you selected, along with previously
selected URLs. Select some of those URLs, or just keep the old list.
Finally, you will be prompted for any extra URLs -- file:, ftp:, or
http: -- that host a CPAN mirror.
(1) Africa
(2) Asia
(3) Central America
(4) Europe
(5) North America
(6) Oceania
(7) South America
Select your continent (or several nearby continents) [] 2
(1) China
(2) Hong Kong
(3) India
(4) Indonesia
(5) Iran
(6) Israel
(7) Japan
(8) Malaysia
(9) Philippines
(10) Republic of Korea
(11) Russian Federation
(12) Saudi Arabia
(13) Singapore
(14) Taiwan
(15) Thailand
(16) Turkey
Select your country (or several nearby countries) [] 7
(1) ftp://ftp.dti.ad.jp/pub/lang/CPAN/
(2) ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/
(3) ftp://ftp.kddilabs.jp/CPAN/
(4) ftp://ftp.nara.wide.ad.jp/pub/CPAN/
(5) ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/
(6) ftp://ftp.u-aizu.ac.jp/pub/CPAN
(7) ftp://ftp.yz.yamagata-u.ac.jp/pub/lang/cpan/
(8) http://ftp.cpan.jp/
Select as many URLs as you like,
put them on one line, separated by blanks [] 2
Enter another URL or RETURN to quit: []
New set of picks:
ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/
WAIT support is available as a Plugin. You need the CPAN::WAIT module
to actually use it. But we need to know your favorite WAIT server. If
you don't know a WAIT server near you, just press ENTER.
Your favorite WAIT server?
[wait://ls6.informatik.uni-dortmund.de:1404]
commit: wrote /home/user/.cpan/CPAN/MyConfig.pm
*** Dependencies will be installed the next time you type 'make'.
(You may need to do that as the 'root' user.)
*** Module::AutoInstall configuration finished.
Checking if your kit is complete...
Looks good
Warning: prerequisite URI 0 not found.
Writing Makefile for XML::Atom
(EOF)
make testでは やはりエラー(全部エラー)
先の依存関係チェックでmissingとなっていた各モジュールを入れよう。
・URI
URI-1.35.tar.gz
すんなり成功
・XML::LibXML
XML-LibXML-1.58.tar.gz
$ perl Makefile.PL
enable native perl UTF8
running xml2-config...failed
The installed version of libxml2 is known not to work.
The installed version was tested and prooved not as stable
Don't expect XML::LibXML to build or work correctly.
Don't report errors!!!
Don't send patches!
Check the README file for more informations and versions
that are tested with XML::LibXML
→これはいったいどういうことか?
とりあえずxml2-configが必要らしいが、あるぞ。
$xml2-config --version
2.4.19
現バージョンのlibml2が動かないらしい。
READMEを読んでみた。依存関係の注意にちゃんと書いてあった。
---
DEPENDENCIES
============
Prior to installation you MUST have installed the libxml2 library. You can get
the latest libxml2 version from
http://xmlsoft.org
Without libxml2 installed this module will neither build nor run.
Also XML::LibXML requires the following packages:
o XML::LibXML::Common - general functions used by various
XML::LibXML modules
o XML::SAX - DOM building support from SAX
o XML::NamespaceSupport - DOM building support from SAX
These packages are required. If one is missing some tests will fail.
Again, libxml2 is required to make XML::LibXML work. The library is not just
requiered to build XML::LibXML, it has to be accessible during runtime as well.
Because of this you need to make sure libxml2 is installed properly. To test
this, run the xmllint program on your system. xmllint is shipped with libxml2
and therefore should be available.
---
ということで最新のlibxml2をGETし、インストール ftp://xmlsoft.org/libxml2/
libxml2-2.6.26.tar.gz
tar zxf libxml2-2.6.26.tar.gz
cd libxml2-2.6.26
./configure
make
sudo make install
さて、XML::LibXMLインストール再開...
perl Makefile.PL 実行時にワーニング
Warning: prerequisite XML::LibXML::Common 0 not found.
Warning: prerequisite XML::NamespaceSupport 1.07 not found.
Warning: prerequisite XML::SAX 0.11 not found.
→それぞれインストール
XML-LibXML-Common-0.13.tar.gz
XML-NamespaceSupport-1.09.tar.gz
XML-SAX-0.14.tar.gz
さて、XML::LibXMLインストール再開...
perl Makefile.PL 実行時のワーニングは消えた(当たり前)
make時にエラー
perl-libxml-mm.c: In function `nodeC2Sv':
perl-libxml-mm.c:968: parse error before `*'
perl-libxml-mm.c:972: `decoded' undeclared (first use in this function)
perl-libxml-mm.c:972: (Each undeclared identifier is reported only once
perl-libxml-mm.c:972: for each function it appears in.)
make: *** [perl-libxml-mm.o] エラー 1
ぐぐったところ、V1.58.1で解決されたとのこと。
XML-LibXML-1.58_1.tar.gz (DEVELOPER RELEASE)
make 時のエラーは発生しなくなった!
インストールに成功!
・DBIの更新
今日したかったのはこれだった。
DBI-1.51.tar.gz
perl Makefile.PL
make
LANG=C
make testで問題発生
:
t/40profile..............NOK 5# Failed test (t/40profile.t at line 60)
# Structures begin differing at:
# $got->{Data}{DESTROY} = HASH(0x830ec60)
# $expected->{Data}{DESTROY} = Does not exist
t/40profile..............NOK 6# Failed test (t/40profile.t at line 71)
# Structures begin differing at:
# $got->{Data}{}{STORE}[0] = '1'
# $expected->{Data}{}{STORE}[0] = '2'
t/40profile..............NOK 7# Failed test (t/40profile.t at line 84)
# Structures begin differing at:
# $got->{Data}{}{STORE}[0] = '1'
# $expected->{Data}{}{STORE}[0] = '2'
t/40profile..............NOK 26# Failed test (t/40profile.t at line 153)
# Structures begin differing at:
# $got->{Data}{}[0] = '1'
# $expected->{Data}{}[0] = '3'
t/40profile..............NOK 31# Failed test (t/40profile.t at line 187)
# Structures begin differing at:
# $got->{Data}{usrnam}{}{foo}{STORE}[0] = '1'
# $expected->{Data}{usrnam}{}{foo}{STORE}[0] = '2'
t/40profile..............ok 36/36# Looks like you failed 5 tests of 36.
t/40profile..............dubious
Test returned status 5 (wstat 1280, 0x500)
DIED. FAILED tests 5-7, 26, 31
Failed 5/36 tests, 86.11% okay
:
Failed Test Stat Wstat Total Fail Failed List of Failed
-------------------------------------------------------------------------------
t/40profile.t 5 1280 36 5 13.89% 5-7 26 31
16 tests and 142 subtests skipped.
Failed 1/49 test scripts, 97.96% okay. 5/2162 subtests failed, 99.77% okay.
make: *** [test_dynamic] Error 11
ぐぐったら同様の事例があった。profile機能は使わないので
そのままmake install
・DBD::pgの更新
DBD-Pg-1.49.tar.gz
・ついでにFile::Tempの更新
File-Temp-0.16.tar.gz
今のところ、InternalServerErrorは再発していないが、
(本作業前から)apacheのエラーログに以下のメッセージが出力されている。
高負荷時にでやすいようだ。
メッセージ: 「Internal callback」は、次の理由で使えません: Can't handle date (, , , , -1,
100) at lib/MT/Util.pm line 117
詳しく調べると、FireFoxで管理画面を出した後、「トラックバック一覧」あるいは「コメント一覧」を表示させたときに出現するようだ。原因は不明である。
思ったのは、このURLを文字参照にしてしまえば多少は耐スパムTBに効果があるのでは?と思った次第。
文字参照とは、あらゆる文字列を数字で表現する手法で主に非英語圏(日本語、ハングル、タイ文字、アラビア文字など)をユニバーサルに表現するためのルールらしい。
例えば、CGIという文字は&#x43;&#x47;&#x49;という表現になる。
これは16進数表現だが、10進数表現だと、&#67;&#71;&#73;となる。
文字列の変換スクリプトが公開されており、わしも有り難く利用させていただいた。
数値文字参照変換スクリプトhttp://www.eris.ais.ne.jp/~hiro/html/
さて、本題。MT用のコメントおよびトラックバックcgiのファイル名は、
(MT_APPLICATION_DIR)/lib/MT/ConfigMgr.pm で定義されている。
CommentScriptがコメント投稿用cgi、
TrackBackScriptがトラックバック処理用cgiで、ご存じの通りデフォルトはそれぞれ、
mt-comments.cgi mt-tb.cgi となっている。
これを以下の通り変更する。
['CommentScript', { Default =>
'&#x6d;&#x74;&#x2d;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x2e;&#x63;&#x67;&#x69;'
}],
['TrackbackScript', { Default =>
'&#x6d;&#x74;&#x2d;&#x74;&#x62;&#x2e;&#x63;&#x67;&#x69;' }],
変更後に再構築されたアーカイブコンテンツ内の
「このエントリーのトラックバックURL:〜」は、ブラウザでの見た目は、今まで通りアルファベット表示だが、ソースをみると
&#x6d;&#x74;&#x2d;&#x74;&#x62;&#x2e;&#x63;&#x67;&#x69;/98765
となっており、ぱっと見、理解不能な文字列である。ブラウザ内で変換して人間に読める文字で表示してくれるのだ。
webサーバからはこのような文字参照で送られるが、メジャーなブラウザが変換してくれるので人間が閲覧する分には全く問題がない。一方でスパマー御用達のコンテンツ収集ロボットや解析ツールには都合の悪い仕様になっている。
本対応はスパマ側ですぐに対応策が思いつく稚拙な対応ではあるが、多少はスパムトラックバックが減ることを願いたい。
2.0β6以上からのアップグレード †
1. ファイル「mt4i.cgi」「mt4imgr.cgi」、ディレクトリ(フォルダ)「mt4ilib」をサーバーにアップロード(前バージョンを上書き)。
2. Webブラウザより「mt4imgr.cgi」にアクセス。
3. パスワードを入力してログインし、各種設定値を見直して「保存」ボタン押下。
4. Webブラウザより「mt4i.cgi」にアクセスして動作確認。
投稿者 onsenfan [ Linuxサーバ, トホホ ] : 2006年07月16日 23:13
この記事が役に立った/おもしろいと思ったら、ワンクリックで応援お願いしますこのエントリーのトラックバックURL:
https://blog.odorokutamegoro.com/mt-tb.cgi/1425_0490495140872