2011年3月25日金曜日

Redmine を Debian Squeeze にインストールしてみる - その 4

じゅんびをいんすとーる

しらべるのもあきてきたので。

$ sudo aptitude install ruby rails libdbd-mysql-ruby libjs-scriptaculous libapache2-mod-passenger
[sudo] password for takashima:
以下の新規パッケージがインストールされます:
libactionmailer-ruby1.8{a} libactionpack-ruby1.8{a} libactiverecord-ruby1.8{a}
libactiveresource-ruby1.8{a} libactivesupport-ruby1.8{a} libapache2-mod-passenger
libbreakpoint-ruby1.8{a} libbuilder-ruby1.8{a} libcmdparse2-ruby1.8{a}
libdaemons-ruby1.8{a} libdbd-mysql-ruby libdbd-mysql-ruby1.8{a} libdbi-ruby1.8{a}
libdeprecated-ruby1.8{a} libi18n-ruby1.8{a} libjs-jquery{a} libjs-prototype{a}
libjs-scriptaculous liblog4r-ruby1.8{a} libmemcache-client-ruby1.8{a}
libmmap-ruby1.8{a} libmysql-ruby1.8{a} libncurses-ruby1.8{a} librack-ruby{a}
librack-ruby1.8{a} libredcloth-ruby1.8{a} libruby1.8{a} libruby1.8-extras{a}
libsqlite3-ruby1.8{a} libtext-format-ruby1.8{a} libtmail-ruby1.8{a}
libtzinfo-ruby1.8{a} rails rails-ruby1.8{a} rake{a} ruby ruby1.8{a} rubygems{a}
rubygems1.8{a}
以下のパッケージが推奨されていますがインストールされません:
build-essential javascript-common libmocha-ruby1.8 ruby1.8-dev zip
更新: 0 個、新規インストール: 39 個、削除: 0 個、保留: 0 個。
5,994 kB のアーカイブを取得する必要があります。展開後に 32.0 MB のディスク領域が新たに消費されます。
先に進みますか? [Y/n/?]
rubygems (バージョン無し)がふえてるなぁ…。

Redmine を Debian Squeeze にインストールしてみる - その 3

libjs-scriptaculous ってなに?

そういえばlibjs-scriptaculous なるものが減ってた。

ぐぐってみる

公式では

パッケージ: libjs-scriptaculous (1.8.3-1)

JavaScript library for dynamic web applications
script.aculo.us is a JavaScript library providing dynamic visual effects and user interface elements via the Document Object Model.
script.aculo.us extends the Prototype Javascript Framework by adding visual effects, user interface controls, and utilities. It is most notably included with Ruby on Rails, but also provided separately to work with other web application frameworks and scripting languages.
…よくわかんないけど,いれといたほうがいいのかな?

Redmine を Debian Squeeze にインストールしてみる - その 2

インストールするパッケージのげんせん

てけとーにいれてうごいた~!でもいいんだけれども。ruby, rails, libdbd-mysql-ruby ではどんなもんでしょ?

$ sudo aptitude install ruby rails libdbd-mysql-ruby
[sudo] password for takashima:
以下の新規パッケージがインストールされます:
libactionmailer-ruby1.8{a} libactionpack-ruby1.8{a} libactiverecord-ruby1.8{a}
libactiveresource-ruby1.8{a} libactivesupport-ruby1.8{a} libbreakpoint-ruby1.8{a}
libbuilder-ruby1.8{a} libcmdparse2-ruby1.8{a} libdaemons-ruby1.8{a}
libdbd-mysql-ruby libdbd-mysql-ruby1.8{a} libdbi-ruby1.8{a}
libdeprecated-ruby1.8{a} libi18n-ruby1.8{a} libjs-jquery{a} libjs-prototype{a}
liblog4r-ruby1.8{a} libmemcache-client-ruby1.8{a} libmmap-ruby1.8{a}
libmysql-ruby1.8{a} libncurses-ruby1.8{a} librack-ruby{a} librack-ruby1.8{a}
libredcloth-ruby1.8{a} libruby1.8{a} libruby1.8-extras{a} libsqlite3-ruby1.8{a}
libtext-format-ruby1.8{a} libtmail-ruby1.8{a} libtzinfo-ruby1.8{a} rails
rails-ruby1.8{a} rake{a} ruby ruby1.8{a} rubygems1.8{a}
以下のパッケージが推奨されていますがインストールされません:
build-essential javascript-common libmocha-ruby1.8 ruby1.8-dev zip
更新: 0 個、新規インストール: 36 個、削除: 0 個、保留: 0 個。
5,396 kB のアーカイブを取得する必要があります。展開後に 29.5 MB のディスク領域が新たに消費されます。
先に進みますか? [Y/n/?]

けんしょう

増えたのは libdbd-mysql-ruby 関連。減ったのは…

  • dbconfig-common は,honeplusのメモ帳 aptでRedmineをインストールしてみた(Debian 6.0 "Squeeze") によると redmine のインストール時の設定に使うだけみたいだから,いらないはず。
  • libactionmailer-ruby, libactionpack-ruby, libactiveresource-ruby, libactivesupport-ruby はそれぞれ1.8のついたパッケージをインストールしてるからいらない。
  • libdbd-sqlite3-ruby, libdbd-sqlite3-ruby1.8, sqlite3 は,SQLite 使わないからいらない。

あ゛,Passenger わすれてた…

2011年3月24日木曜日

mpt-statusd: detected non-optimal RAID status

ことのおこり

新しく作った vmware な Debian Squeeze 君が,10分おきなんか言ってる…。

これは logcheck が送ってきたメール。

This email is sent by logcheck. If you no longer wish to receive
such mail, you can either deinstall the logcheck package or modify
its configuration file (/etc/logcheck/logcheck.conf).

System Events
=-=-=-=-=-=-=
Mar 24 17:08:40 vmware-squeeze mpt-statusd: detected non-optimal RAID status
Mar 24 17:18:42 vmware-squeeze mpt-statusd: detected non-optimal RAID status
Mar 24 17:28:42 vmware-squeeze mpt-statusd: detected non-optimal RAID status
Mar 24 17:38:44 vmware-squeeze mpt-statusd: detected non-optimal RAID status
Mar 24 17:48:46 vmware-squeeze mpt-statusd: detected non-optimal RAID status
Mar 24 17:58:46 vmware-squeeze mpt-statusd: detected non-optimal RAID status

ぐぐる

英語でわかんないけど,これかな~? Debian User Forums • View topic - Debian Reports Non-optimal RAID Status

Uninstall mpt-status.

It may have been installed because you are running on vmware, or it could be a default from ticking the mail server option in the installer.
とのことなので,mpt-status をパージしておきましょう。…どうなるかな?

一時間経って,ログ見てみたけど,出なくなったみたい。

Redmine を Debian Squeeze にインストールしてみる

ことのおこり

Debian GNU/Linux 6.0 "Squeeze" には Redmine 1.0.1 なパッケージがあるから,インストール楽なんぢゃないかな?

ちょうさ

しらべてみましょ。vmwareにインストールしたばかり…,ええと,Apache2 と MySQL はすでにインストール済み,な環境。

$ sudo aptitude install redmine
以下の新規パッケージがインストールされます:
dbconfig-common{a} libactionmailer-ruby{a} libactionmailer-ruby1.8{a}
libactionpack-ruby{a} libactionpack-ruby1.8{a} libactiverecord-ruby1.8{a}
libactiveresource-ruby{a} libactiveresource-ruby1.8{a} libactivesupport-ruby{a}
libactivesupport-ruby1.8{a} libbreakpoint-ruby1.8{a} libbuilder-ruby1.8{a}
libcmdparse2-ruby1.8{a} libdaemons-ruby1.8{a} libdbd-sqlite3-ruby{a}
libdbd-sqlite3-ruby1.8{a} libdbi-ruby1.8{a} libdeprecated-ruby1.8{a}
libi18n-ruby1.8{a} libjs-jquery{a} libjs-prototype{a} libjs-scriptaculous{a}
liblog4r-ruby1.8{a} libmemcache-client-ruby1.8{a} libmmap-ruby1.8{a}
libncurses-ruby1.8{a} librack-ruby{a} librack-ruby1.8{a} libredcloth-ruby1.8{a}
libruby1.8{a} libruby1.8-extras{a} libsqlite3-ruby1.8{a} libtext-format-ruby1.8{a}
libtmail-ruby1.8{a} libtzinfo-ruby1.8{a} rails{a} rails-ruby1.8{a} rake{a} redmine
redmine-sqlite{a} ruby{a} ruby1.8{a} rubygems1.8{a} sqlite3{a}
以下のパッケージが推奨されていますがインストールされません:
build-essential javascript-common libmocha-ruby1.8 ruby1.8-dev zip
更新: 0 個、新規インストール: 44 個、削除: 0 個、保留: 0 個。
7,698 kB のアーカイブを取得する必要があります。展開後に 44.2 MB のディスク領域が新たに消費されます。
先に進みますか? [Y/n/?]

redmine-mysql

ほおっておくとSQLiteを使うながれになりそうなので。これも調査。

$ aptitude show redmine-mysql
パッケージ: redmine-mysql
状態: インストールされていません
バージョン: 1.0.1-1
優先度: 特別
セクション: web
メンテナ: Jérémy Lal
展開サイズ: 65.5 k
依存: libdbd-mysql-ruby, mysql-client | virtual-mysql-client
提案: mysql-server
説明: metapackage providing MySQL dependencies for Redmine
This package only provides MySQL dependencies for Redmine, a flexible project management
web application. Install this one if you want to use a MySQL database with Redmine.

Redmine package should be installed along with this package.
ホームページ: http://www.redmine.org

$ aptitude show libdbd-mysql-ruby
パッケージ: libdbd-mysql-ruby
状態: インストールされていません
バージョン: 0.4.4-1
優先度: 任意
セクション: ruby
メンテナ: Dmitry Borodaenko
展開サイズ: 61.4 k
依存: libdbd-mysql-ruby1.8
説明: Ruby/DBI MySQL driver
Ruby/DBI is a database independent interface for accessing databases, similar to Perl's
DBI.

This package is a dependency package, which depends on the package containing actual
Ruby/DBI MySQL driver for the default Ruby version (currently 1.8).
ホームページ: http://rubyforge.org/projects/ruby-dbi

$ aptitude show libdbd-mysql-ruby1.8
パッケージ: libdbd-mysql-ruby1.8
状態: インストールされていません
バージョン: 0.4.4-1
優先度: 任意
セクション: ruby
メンテナ: Dmitry Borodaenko
展開サイズ: 123 k
依存: libmysql-ruby1.8, libdbi-ruby1.8 (>= 0.4.2)
説明: Ruby/DBI MySQL driver for Ruby 1.8
Ruby/DBI is a database independent interface for accessing databases, similar to Perl's
DBI.

This package contains Ruby/DBI driver for MySQL database.
ホームページ: http://rubyforge.org/projects/ruby-dbi
…なんとなくredmine-rubyは入れたくないので,libdbd-mysql-rubyあたりをいれればいいかな?

2011年3月3日木曜日

DokuWiki-2010-11-07a その2

inc/indexer.php

こんな感じに変更。

でぃふ


--- indexer.php.org 2011-03-03 16:42:26.000000000 +0900
+++ indexer.php.110303171410 2011-03-03 17:14:10.000000000 +0900
@@ -42,6 +42,8 @@
']?');
define('IDX_ASIAN', '(?:'.IDX_ASIAN1.'|'.IDX_ASIAN2.'|'.IDX_ASIAN3.')');

+define('PRE_TOKENIZER', '/usr/bin/mecab -O wakati');
+

/**
* Measure the length of a string.
* Differs from strlen in handling of asian characters.
@@ -49,11 +51,15 @@
* @author Tom N Harris <tnharris@whoopdedo.org>
*/
function wordlen($w){
- $l = strlen($w);
+ $l = utf8_strlen($w);
+
+ /*

// If left alone, all chinese "words" will get put into w3.idx
// So the "length" of a "word" is faked
if(preg_match('/'.IDX_ASIAN2.'/u',$w))
$l += ord($w) - 0xE1; // Lead bytes from 0xE2-0xEF
+ */
+
return $l;
}

@@ -217,6 +223,28 @@

list($page,$body) = $data;

+ if(function_exists(proc_open) && defined('PRE_TOKENIZER')) {

+ $dspec = array(
+ 0 => array("pipe", "r"),
+ 1 => array("pipe", "w"),
+ 2 => array("file", "/dev/null", "w")
+ );
+ $process = proc_open(PRE_TOKENIZER, $dspec, $pipes);

+ if(is_resource($process)) {
+ stream_set_blocking($pipes[0], FALSE);
+ stream_set_blocking($pipes[1], FALSE);
+ fwrite($pipes[0], $body . "\n");
+ fclose($pipes[0]);
+
+ $body = '';
+ while(!feof($pipes[1])) {
+ $body .= fgets($pipes[1], 32768);

+ }
+ fclose($pipes[1]);
+ proc_close($process);
+ }
+ }
+
$body = strtr($body, "\r\n\t", ' ');
$tokens = explode(' ', $body);
$tokens = array_count_values($tokens); // count the frequency of each token
@@ -533,7 +561,7 @@
$wild |= 2;
$wlen -= 1;
}

- if ($wlen < IDX_MINWORDLENGTH && $wild == 0 && !is_numeric($xword)) continue;
+ if (preg_match('/[^0-9A-Za-z]/u', $string) && $wlen < IDX_MINWORDLENGTH && $wild == 0 &
& !is_numeric($xword)) continue;
if(!isset($tokens[$xword])){
$tokenlength[$wlen][] = $xword;
}

@@ -676,12 +704,36 @@
*/
function idx_tokenizer($string,&$stopwords,$wc=false){
$words = array();
+
+ if(function_exists(proc_open) && defined('PRE_TOKENIZER')) {
+ $dspec = array(
+ 0 => array("pipe", "r"),

+ 1 => array("pipe", "w"),
+ 2 => array("file", "/dev/null", "w")
+ );
+ $process = proc_open(PRE_TOKENIZER, $dspec, $pipes);
+ if(is_resource($process)) {
+ stream_set_blocking($pipes[0], FALSE);
+ stream_set_blocking($pipes[1], FALSE);

+ fwrite($pipes[0], $string . "\n");
+ fclose($pipes[0]);
+ $string = '';
+ while(!feof($pipes[1])) {
+ $string .= fgets($pipes[1], 32768);
+ }
+ fclose($pipes[1]);
+ proc_close($process);
+ }

+ }
+
$wc = ($wc) ? '' : $wc = '\*';

if(preg_match('/[^0-9A-Za-z]/u', $string)){
+ /*
// handle asian chars as single words (may fail on older PHP version)
$asia = @preg_replace('/('.IDX_ASIAN.')/u',' \1 ',$string);
if(!is_null($asia)) $string = $asia; //recover from regexp failure
+ */

$arr = explode(' ', utf8_stripspecials($string,' ','\._\-:'.$wc));
foreach ($arr as $w) {

DokuWiki-2010-11-07a その1

ことのおこり

ひさしぶりに管理者でDokuWikiにログインしたら上のほうがうるさいの。

ぐぐる…

DokuWiki はぐぐっても情報ないんだよね…。

ちょうさ

うちのDokuWikiは ここを参考に MeCab 入れて,inc/indexer.php に手を加えている。indexer.php が変わると,ただコピペしているだけの身としては手が出なくなる…。

ええと,

  • idx_listIndexLengths()
    が増えた。
  • idx_indexLengths(&$filter)
    idx_listIndexLengths()
    を使って書き換えられた。
  • idx_upgradePageWords()
    がなくなった。

かな?これならいけそう??

でぃふ

--- E:/dokuwiki/dokuwiki-2009-12-25c/dokuwiki-2009-12-25/inc/indexer.php    Sun Jan 17 19:35:46 2010
+++ E:/dokuwiki/dokuwiki-2010-11-07a/inc/indexer.php    Mon Jan 17 03:04:09 2011
@@ -1,15 +1,12 @@
<?php /** - * Common DokuWiki functions + * Functions to create the fulltext search index * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Andreas Gohr <andi@splitbrain.org> */ if(!defined('DOKU_INC')) die('meh.'); -require_once(DOKU_INC.'inc/io.php'); -require_once(DOKU_INC.'inc/utf8.php'); -require_once(DOKU_INC.'inc/parserutils.php'); // set the minimum token length to use in the index (note, this doesn't apply to numeric tokens) if (!defined('IDX_MINWORDLENGTH')) define('IDX_MINWORDLENGTH',2); @@ -308,6 +305,8 @@ } unset($page_idx); // free memory + idx_saveIndexLine('title', '', $pid, p_get_first_heading($page, false)); + $pagewords = array(); // get word usage in page $words = idx_getPageWords($page); @@ -413,7 +412,58 @@ return join(':',$updated)."\n"; } +/** + * Get the list of lenghts indexed in the wiki + * + * Read the index directory or a cache file and returns + * a sorted array of lengths of the words used in the wiki. + * + * @author YoBoY <yoboy.leguesh@gmail.com> + */ +function idx_listIndexLengths() { + global $conf; + // testing what we have to do, create a cache file or not. + if ($conf['readdircache'] == 0) { + $docache = false; + } else { + clearstatcache(); + if (@file_exists($conf['indexdir'].'/lengths.idx') and (time() < @filemtime($conf['indexdir'].'/lengths.idx') + $conf['readdircache'])) { + if (($lengths = @file($conf['indexdir'].'/lengths.idx', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ) !== false) { + $idx = array(); + foreach ( $lengths as $length) { + $idx[] = (int)$length; + } + return $idx; + } + } + $docache = true; + } + if ($conf['readdircache'] == 0 or $docache ) { + $dir = @opendir($conf['indexdir']); + if($dir===false) + return array(); + $idx[] = array(); + while (($f = readdir($dir)) !== false) { + if (substr($f,0,1) == 'i' && substr($f,-4) == '.idx'){ + $i = substr($f,1,-4); + if (is_numeric($i)) + $idx[] = (int)$i; + } + } + closedir($dir); + sort($idx); + // we save this in a file. + if ($docache === true) { + $handle = @fopen($conf['indexdir'].'/lengths.idx','w'); + @fwrite($handle, implode("\n",$idx)); + @fclose($handle); + } + return $idx; + } + + return array(); +} /** * Get the word lengths that have been indexed. @@ -421,35 +471,27 @@ * Reads the index directory and returns an array of lengths * that there are indices for. * - * @author Tom N Harris <tnharris@whoopdedo.org> + * @author YoBoY <yoboy.leguesh@gmail.com> */ function idx_indexLengths(&$filter){ global $conf; - $dir = @opendir($conf['indexdir']); - if($dir===false) - return array(); $idx = array(); if(is_array($filter)){ - while (($f = readdir($dir)) !== false) { - if (substr($f,0,1) == 'i' && substr($f,-4) == '.idx'){ - $i = substr($f,1,-4); - if (is_numeric($i) && isset($filter[(int)$i])) - $idx[] = (int)$i; + // testing if index files exists only + foreach ($filter as $key => $value) { + if (@file_exists($conf['indexdir']."/i$key.idx")) { + $idx[] = $key; } } }else{ - // Exact match first. - if(@file_exists($conf['indexdir']."/i$filter.idx")) - $idx[] = $filter; - while (($f = readdir($dir)) !== false) { - if (substr($f,0,1) == 'i' && substr($f,-4) == '.idx'){ - $i = substr($f,1,-4); - if (is_numeric($i) && $i > $filter) - $idx[] = (int)$i; + $lengths = idx_listIndexLengths(); + foreach ( $lengths as $key => $length) { + // we keep all the values equal or superior + if ((int)$length >= (int)$filter) { + $idx[] = $length; } } } - closedir($dir); return $idx; } @@ -657,51 +699,6 @@ } return $words; -} - -/** - * Create a pagewords index from the existing index. - * - * @author Tom N Harris <tnharris@whoopdedo.org> - */ -function idx_upgradePageWords(){ - global $conf; - $page_idx = idx_getIndex('page',''); - if (empty($page_idx)) return; - $pagewords = array(); - $len = count($page_idx); - for ($n=0;$n<$len;$n++){ - $pagewords[] = array(); - } - unset($page_idx); - - $n=0; - foreach (idx_indexLengths($n) as $wlen) { - $lines = idx_getIndex('i',$wlen); - $len = count($lines); - for ($wid=0;$wid<$len;$wid++) { - $wkey = "$wlen*$wid"; - foreach (explode(':',trim($lines[$wid])) as $part) { - if($part == '') continue; - list($doc,$cnt) = explode('*',$part); - $pagewords[(int)$doc][] = $wkey; - } - } - } - - $fn = $conf['indexdir'].'/pageword'; - $fh = @fopen($fn.'.tmp','w'); - if (!$fh){ - trigger_error("Failed to write word index", E_USER_ERROR); - return false; - } - foreach ($pagewords as $line){ - fwrite($fh, join(':',$line)."\n"); - } - fclose($fh); - if($conf['fperm']) chmod($fn.'.tmp', $conf['fperm']); - io_rename($fn.'.tmp', $fn.'.idx'); - return true; } //Setup VIM: ex: et ts=4 enc=utf-8 :

つづく