読者です 読者をやめる 読者になる 読者になる

まめ畑

ゆるゆると書いていきます

影舞を入れてみた

Server 影舞

Ruby製バグトラッキングシステムの影舞を入れる時のメモ。基本的にはインストールマニュアル通りなのですが、細々とバグがあり、パッチを適用しないといけないので注意が必要です
各パスなどはインストールする環境にあわせて下さい。今回はCentOS5.5を使用し、インストールパスなどは標準の物を使用しています

  • 必要なものを入れる
yum -y install mysql mysql-server mysql-devel httpd httpd-devel zlib zlib-devel libpng libpng-devel freetype freetype-devel
  • Ruby1.9だと動かなかったので
wget ftp://ftp.iij.ad.jp/pub/lang/ruby/1.8/ruby-1.8.7-p299.tar.gz
tar xzvf ruby-1.8.7-p299.tar.gz
cd ruby-1.8.7-p299
./configure
make
make install

wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
tar xzvf rubygems-1.3.7.tgz
cd rubygems-1.3.7
ruby setup.rb 
  • gemでいるものを入れる
gem install mysql dbi dbd-mysql
wget http://modruby.net/archive/mod_ruby-1.3.0.tar.gz
tar xzvf mod_ruby-1.3.0.tar.gz
cd mod_ruby-1.3.0
./configure.rb --with-apxs=/usr/sbin/apxs --with-apr-includes=/usr/include/apr-1
make
make install
LoadModule ruby_module modules/mod_ruby.so

<IfModule mod_ruby.c>
  RubyRequire apache/ruby-run
  <Files *.rbx>
    SetHandler ruby-object
    RubyHandler Apache::RubyRun.instance
  </Files>
</IfModule>
  • MySQLを使用する為にユーザを作成する
service mysqld start
mysql -u root
mysql> create database kagemai;
mysql> grant all on kagemai.* to kagemai@localhost identified by 'PASS';
  • 影舞をダウンロードして解凍
wget http://www.daifukuya.com/archive/kagemai/kagemai-0.8.8.tar.gz
tar xzvf kagemai-0.8.8.tar.gz
cd kagemai-0.8.8
  • 後は、インストール方法 の通りにインストールするだけなのですが、少しパッチを当てたりしないといけないです
  • 解凍後に、mod_ruby対応や、使用するディレクトリの権限を変える
cd /var/www/html/kagemai/
cp -p guest.cgi guest.rbx
cp -p user.cgi user.rbx
cp -p admin.cgi admin.rbx

groupadd kagemai
gpasswd -a apache kagema
cd /usr/local
chgrp -R kagemai kagemai
chmod -R 02770 kagemai
cd /var/lib
chgrp -R kagemai kagemai
chmod -R 02770 kagemai
  • このままだと、MySQLを使ったときにエラーが出るのでパッチを当てる
cd /usr/local/kagemai/lib/kagemai/
patch -p 1 < 以下のパッチ2
Index: dbistore3.rb
===================================================================
--- dbistore3.rb	(リビジョン 603)
+++ dbistore3.rb	(作業コピー)
@@ -26,6 +26,12 @@
 require 'kagemai/searchcond'
 require 'kagemai/dbiutil'
 
+class DateTime
+  def to_time
+    Time.local(year(), month(), day(), hour(), min(), sec())
+  end
+end
+
 module Kagemai  
   module BaseDBIStore3
--- kagemai/branches/0.8/lib/kagemai/dbistore3.rb	2008/11/30 12:20:26	611
+++ kagemai/branches/0.8/lib/kagemai/dbistore3.rb	2008/12/07 12:33:46	626
@@ -338,22 +338,26 @@
       attr_id = []
       execute do |db|
         if cond_attr && cond_attr.size > 0 then
+          param = []
           cond_attr_query = cond_attr.to_sql3(sql_search_op()) {|eid, word|
-            [col_name(eid), db.quote(store_kconv(word))]
+            param << store_kconv(word)
+            [col_name(eid), '?']
           }
           rorder = (order == 'report_id') ? 'id' : order
           query = "select id from #{table_name('reports')} where (#{cond_attr_query}) order by #{rorder}"
-          attr_id = do_search_query(db, query, 'id', offset, limit)
+          attr_id = do_search_query(db, query, 'id', offset, limit, *param)
           id = attr_id
         end
         
         other_id = []
         if cond_other && cond_other.size > 0 then
+          param = []
           cond_other_query = cond_other.to_sql3(sql_search_op()) {|eid, word|
-            [col_name(eid), db.quote(store_kconv(word))]
+            param << store_kconv(word)
+            [col_name(eid), '?']
           }
           query = "select DISTINCT report_id from #{table_name('messages')} where #{cond_other_query} order by #{order}"
-          other_id = do_search_query(db, query, 'report_id', offset, limit)
+          other_id = do_search_query(db, query, 'report_id', offset, limit, *param)
           if id.nil? then
             id = other_id
           else
@@ -499,11 +503,11 @@
       db_encoded_str
     end
     
-    def do_search_query(db, query, col, offset, limit)
+    def do_search_query(db, query, col, offset, limit, *param)
       Logger.debug('DBI', KKconv::conv(query, KKconv::EUC))
-      db.select_all(query).collect{|row| row[0]}
+      db.select_all(query, *param).collect{|row| row[0]}
     end
-        
+    
     def do_search_query2(db, query, col, offset, limit)
       result = []
       db.execute(query) do |cursor|
  • 以下は統計画面でグラフを出したい人のみ
  • 必要なライブラリを入れる
wget http://www.libgd.org/releases/gd-latest.tar.gz
tar xzvf gd-latest.tar.gz
cd gd-2.0.34/
CFLAGS="-g -O2 -DJISX0208" ./configure
make
make install

wget http://raa.ruby-lang.org/cache/ruby-gd/ruby-GD-0.7.4-1.tar.gz
tar xzvf ruby-GD-0.7.4-1.tar.gz
cd ruby-GD-0.7.4-1.tar.gz
ruby extconf.rb --with-ttf --with-freetype
make
make install

DL
http://sourceforge.jp/projects/ruby-gdchart/downloads/1080/ruby-gdchart-0.0.9-beta.tar.gz
tar xzvf ruby-gdchart-0.0.9-beta.tar.gz
cd ruby-gdchart-0.0.9-beta
patch -p 1 < 以下のパッチ
ruby extconf.rb
make
make install
  • これもまたパッチあてないとビルド出来ないので
diff --exclude='*~' -Naur ruby-gdchart-0.0.9-beta.orig/gdchart0.11.2dev/gdc.c ruby-gdchart-0.0.9-beta/gdchart0.11.2dev/gdc.c
--- ruby-gdchart-0.0.9-beta.orig/gdchart0.11.2dev/gdc.c	2002-07-24 00:59:34.000000000 -0300
+++ ruby-gdchart-0.0.9-beta/gdchart0.11.2dev/gdc.c	2006-01-07 16:42:51.000000000 -0200
@@ -5,6 +5,7 @@
 #define GDC_LIB
 #include <math.h>
 #include "gdc.h"
+#include <string.h>
 
 struct	GDC_FONT_T	GDC_fontc[GDC_numfonts] = { (gdFontPtr)NULL, 8,  5,
 											    (gdFontPtr)NULL, 8,  5,
diff --exclude='*~' -Naur ruby-gdchart-0.0.9-beta.orig/gdchart.c ruby-gdchart-0.0.9-beta/gdchart.c
--- ruby-gdchart-0.0.9-beta.orig/gdchart.c	2002-09-12 05:19:43.000000000 -0300
+++ ruby-gdchart-0.0.9-beta/gdchart.c	2006-01-07 16:52:09.000000000 -0200
@@ -235,7 +235,7 @@
       rb_raise(rb_eTypeError, "%s expect %s", name, "Bool Array");
 
     length = RARRAY(value)->len;
-    (char*)result = ALLOC_N(char, length);
+    result = (char*)ALLOC_N(char, length);
 
     for (i = 0; i < length; i++) {
       entry = rb_ary_entry(value, i);
@@ -272,7 +272,7 @@
       rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum Array");
     
     length = RARRAY(value)->len;
-    (int*)result = ALLOC_N(int, length);
+    result = (int*)ALLOC_N(int, length);
 
     for (i = 0; i < length; i++) {
       entry = rb_ary_entry(value, i);
@@ -309,7 +309,7 @@
       rb_raise(rb_eTypeError, "%s expect %s", name, "Fixnum Array");
 
     length = RARRAY(value)->len;
-    (unsigned long*)result = ALLOC_N(unsigned long, length);
+    result = (unsigned long*)ALLOC_N(unsigned long, length);
 
     for (i = 0; i < length; i++) {
       entry = rb_ary_entry(value, i);
@@ -369,7 +369,7 @@
 
   case ANNOTATION_T:
     /* Because only 1 annotatin is allowd. */
-    (GDC_ANNOTATION_T*)result = ALLOC(GDC_ANNOTATION_T);
+    result = (GDC_ANNOTATION_T*)ALLOC(GDC_ANNOTATION_T);
     
     if (value_to_annotation_t(value, (GDC_ANNOTATION_T*)result) == FALSE) {
       free(result);
@@ -384,7 +384,7 @@
       rb_raise(rb_eTypeError, "%s expect %s Array", name, rb_class2name(cGDChartScatter));
 
     length = RARRAY(value)->len;
-    (GDC_SCATTER_T*)result = ALLOC_N(GDC_SCATTER_T, length);
+    result = (GDC_SCATTER_T*)ALLOC_N(GDC_SCATTER_T, length);
 
     for (i = 0; i < length; i++) {
       entry = rb_ary_entry(value, i);


--- kagemai-0.8.8/lib/kagemai/cgi/legend.rb     2008-03-09 19:37:00.000000000 +0900
+++ /usr/local/apache2/htdocs/kagemai/lib/kagemai/cgi/legend.rb 2008-06-04 16:58:20.000000000 +0900
@@ -42,7 +42,7 @@
     end

     def add(text, color)
-      @items << LegendItem.new(text.ckconv(@kconv_to, @kconv_from), @ptsize, color, @font)
+      @items << LegendItem.new(KKconv.ckconv(text, @kconv_to, @kconv_from), @ptsize, color, @font)
     end

     def add_item(legend_item)