sohatach's blog

http://github.com/soha

Scala逆引きレシピを始める

翔泳社サイトの以下のリンクからサンプルコードをダウンロードできます。
http://www.seshop.com/book/download/9784798125411/


まずはScalaのインストール
以下Windows8にて行いました。

http://www.scala-lang.org/downloads
よりscala-2.9.2.zipをダウンロードし、
C:\scala-2.9.2に展開しました。

続いて環境変数の設定
SCALA_HOME変数を新たに追加し、値として、「C:\scala-2.9.2」を指定
PATH変数の冒頭に「%SCALA_HOME%\bin;」を追加。

コマンドプロンプトを開き直し、

scala -version

で以下の通り表示されることを確認しました。

Scala code runner version 2.9.2 -- Copyright 2002-2011, LAMP/EPFL

Scala逆引きレシピのサンプルコードをEclipseで動かしたかったのですが、サンプルコードはEclipseのプロジェクト形式にはなっておらず
添付のREADMEによれば、ScalaのsbtというコマンドでEclipseプロジェクト形式に変えてやる必要があるようです。

========
> cd chapter01
> sbt eclipse
========

しかしこのsbtコマンド、単にscala-2.9.2.zipを展開しただけでは入っていないようです。
別途インストールが必要とのこと。


ここからダウンロードできるようです。
http://www.scala-sbt.org/release/docs/Getting-Started/Setup.html#installing-sbt
ここではsbt.zipをダウンロードしました。
サイトのManual Installationの項目には、sbt.batを作れとか書いてありますが、
sbt.zipの中のbinフォルダの中に既に入っているようです。
そのため公式サイトに記載されている手順と異なりますが、
sbt.zipの中のbinフォルダをscala-2.9.2のbinフォルダの中に混ぜてしまいました。(こちらは既にPATHも通っているので)


再度

sbt eclipse

をしたところ最初にいろいろライブラリがダウンロードされた後、Eclipseプロジェクト形式に変換されました。

この自動ダウンロードでユーザのホームディレクトリの.ivyフォルダにいろいろファイルが入ったようです。
結局scala-2.9.2自体もダウンロードされている。。。
むしろ先にsbtだけ入れれば良かったのかも?


なお.gitignoreは以下のように設定しました。

*.class
target/
cache/
.cache

公式Factory ImageのAndroid 4.2(JOP40C)のGALAXY NEXUSのセルスタンバイ問題対策

以下
http://sohatach.hatenablog.jp/entry/2012/10/16/002455
からのAndroid 4.1と4.2の差分手順のみ記載します。

Android4.2では、セルスタンバイの対応に修正が必要なGsmServiceStateTracker.smaliというファイルの場所が
がframework.jarからtelephony-common.jarに変更されているようです。(yakju JOP40Cにて)
4.1の手順からframework.jarをtelephony-common.jarに読み替え実施する。

GsmServiceStateTracker.smaliの修正箇所は以下の場所でした。
(矢印のつけた場所をpswitch_1bからpswitch_1cにした)
Javaの元ソース
http://tools.oesf.biz/android-4.2.0_r1.0/xref/frameworks/opt/telephony/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
を参考に修正箇所を見つけました。
少し目を凝らすとsmaliファイルの中身がなんとなく推測できるようになります。

.line 1225
:pswitch_data_20
.packed-switch 0x0
:pswitch_1b
:pswitch_1c
:pswitch_1b
:pswitch_1c ←ここ
:pswitch_1b
:pswitch_1e
:pswitch_5
:pswitch_5
:pswitch_5
:pswitch_5
:pswitch_1b
:pswitch_5
:pswitch_1b
:pswitch_1c ←ここ
:pswitch_1b
.end packed-switch
.end method

line 1225をキーにファイル内検索してみてください。

GALAXY NEXUS向けにAndroid(4.1.2)をビルドする。

参考資料
・日経Linux 2012年9月号の特集3 Androidを自分好みに改造する
http://itpro.nikkeibp.co.jp/article/MAG/20120806/414422/?ST=oss
android open source project
http://source.android.com/source/initializing.html

ビルドに使うマシン
ThinkPad X201sにUbuntu12.04の64bit版をインストールしたマシン
主なスペックは以下の通りです。
CPU: Intel(R) Core(TM) i7 CPU L 640 @ 2.13GHz
memory: 8GB
HDD: 750G


ビルドに必要な各種ソフトウェアのインストール

・JDK6
最新版(jdk6u37)をOracleのサイトから取得し、インストールします。
http://www.oracle.com/technetwork/java/javase/downloads/jdk6u37-downloads-1859587.html
規約に同意する必要などがあるため、ブラウザでアクセスし、Linux用64bit版のjdk-6u37-linux-x64.binをダウンロードします。
ホームディレクトリに展開し、JAVA_HOME及びPATH環境変数に設定する。

cd ~
sh jdk-6u37-linux-x64.bin
vi ~/.profile
export JAVA_HOME=$HOME/jdk1.6.0_37
export PATH=$JAVA_HOME/bin:$PATH
. ~/.profile

Ubuntuのパッケージファイル

sudo aptitude install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline-gplv2-dev lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils python-software-properties xsltproc libx11-dev:i386 gcc-4.5 g++-4.5 gcc-4.5-multilib g++-4.5-multilib

パッケージが多いため、少し時間が掛かります。20分程度掛かりました。

.Android SDKLinux

http://dl.google.com/android/android-sdk_r20.0.3-linux.tgz
tar xvfz android-sdk_r20.0.3-linux.tgz
mv android-sdk-linux/ ~/

export JAVA_HOME=$HOME/jdk1.6.0_37
export ANDROID_SDK_HOME=$HOME/android-sdk-linux
export PATH=$JAVA_HOME/bin:$ANDROID_SDK_HOME/platform-tools:$PATH

APIバージョンのSDKのダウンロード

tools/android update sdk -u

これも結構時間が掛かります。1時間弱程度掛かりました。


Androidソースコード(の取得コマンド)

mkdir ~/bin
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
mkdir android_source
cd android_source
repo init -u https://android.googlesource.com/platform/manifest

NameとEmailを聞かれるので適当に入れる。

repo init -u https://android.googlesource.com/platform/manifest -b android-4.1.2_r1

repo sync

これが数時間掛かる。

ビルドマシンのユーザのオープンできるファイル数を増やす。

vi /etc/security/limits.conf
hard nofile 10240
soft nofile 10240

念のためビルドマシンを再起動しておく。



・Nexusのドライバ
https://developers.google.com/android/nexus/drivers#magurojzo54k
broadcom-maguro-jzo54k-8b0d7637.tgz
imgtec-maguro-jzo54k-0911a9b5.tgz
invensense-maguro-jzo54k-ff2586d3.tgz
nxp-maguro-jzo54k-95659b1e.tgz
samsung-maguro-jzo54k-b8a098be.tgz
をダウンロードする。
各ファイルを展開するとそれぞれextract-XXXX-maguro.shというファイルになるので、
android_sourceにコピーし、実行する。
android_source下にvenderというディレクトリが作成され、そこに展開される。


・ビルド

cd ~/android_source
source build/envsetup.sh
lunch full_maguro-userdebug
make -j4

こちらも数時間掛かります。翌日確認するくらいのつもりでも良いかと思います。


・成果物
android_sourceの下のout/target/maguro/の下にboot.img,system.imgができるので、
fastbootでPCから接続し、端末に書き込む。
書き込む前にuserdata,cache領域をクリアする必要があるようです。

fastboot -w
fastboot flash boot boot.img
fastboot flash system system.img

このsystem.imgには、Google PlayなどのGoogle製アプリ(Gapps)が入っていないため、
xdaなどでバイナリを探してきて別途CWMからインストールします。


20121028追記
日経Linuxにも記載されていますが、カメラを正常に動作させるには、ducati-m3.binというバイナリを元の端末から吸い出し
/system/vender/firmwareにコピーしてやる必要があるようです。
また上記Googleのサイトからダウンロードできなかったバイナリとして、smc_pa_wvdrm.iftというファイルも
/system/vender/firmwareに入っていたため、合わせて端末からバックアップしていたファイルをコピーしました。
(smc_pa_wvdrm.iftの用途は不明)

公式Factory ImageのAndroid 4.1.2のGALAXY NEXUSのセルスタンバイ問題対策

・アンテナピクト問題・セルスタンバイ問題とは何か
http://techlog.iij.ad.jp/archives/487
何が問題かについて、こちらで詳しく解説していただいています。
要するにデータ通信専用のSIMでは、常時圏外扱いとなり基地局を探すためバッテリがすぐ無くなってしまうようです。
そのためAndroidOS側を少しいじり圏外扱いにならないようにします。

手順については以下のサイトを参考にさせていただきました。
Android + b-mobile データ専用 SIM で電界強度を表示する
http://bl.oov.ch/2012/01/b-mobile-sim.html

Googleが提供している公式Factory Image
https://developers.google.com/android/nexus/images
は、odex化という端末に最適化した形式になっているため、今回はこちらの手順が該当します。
・ICS for S51SEセルスタンバイ対策(処理モード1)
http://430fx.cocolog-nifty.com/blog/2012/07/ics-for-s51se-b.html

・キャリア提供アプリのdeodex化とodex化
http://blog.livedoor.jp/yasuhide_t/archives/5506120.html



事前準備

  • clockworkリカバリ(recovery-clockwork-5.5.0.2-maguro.img)が端末で起動可能なこと。
  • 端末にbusyboxがインストールされていること。(端末側で事前にGoogle Playからインストールしておく)

busyboxインストールのためroot化が(多分)必要。

clockworkリカバリで端末を起動する。
clockworkを使い、端末側で/systemをmountする。/dataもmountする。
adbで接続できること。

baksmaliでframework.odexの中身をoutフォルダに展開する。

mkdir framework
adb pull /system/framework framework
cd framework
java -jar ..\baksmali-1.4.0.jar --api-level 16 -x framework.odex

outフォルダが作られる。

/framework/out/com/android/internal/telephony/gsm/GsmServiceStateTracker.smaliをエディタで編集する。
圏外でも圏内と認識させるようになるようです。

> :pswitch_data_22
> .packed-switch 0x0
> :pswitch_1c
> :pswitch_1d
> :pswitch_1c
> :pswitch_1c
> :pswitch_1c
> :pswitch_1f
> :pswitch_5
> :pswitch_5
> :pswitch_5
> :pswitch_5
> :pswitch_1c
> :pswitch_5
> :pswitch_1c
> :pswitch_1c
> :pswitch_1c
> .end packed-switch

> :pswitch_data_22
> .packed-switch 0x0
> :pswitch_1c
> :pswitch_1d
> :pswitch_1c
> :pswitch_1d ←ここ
> :pswitch_1c
> :pswitch_1f
> :pswitch_5
> :pswitch_5
> :pswitch_5
> :pswitch_5
> :pswitch_1c
> :pswitch_5
> :pswitch_1c
> :pswitch_1d ←ここ
> :pswitch_1c
> .end packed-switch
と書き換える。

smaliでclasses.dexにまとめる。

java -jar ..\smali-1.4.0.jar --api-level 16 -o classes.dex out

cleasses.dexができる。odex化していないカスタムOSなどであればこれがそのまま使えるはず。

odex化したframework.odexを生成する。
framework下のframework.jarを展開し、生成したclasses.dexを入れて再度zip圧縮しframework.jarを作り直す。

mkdir work
cp framework.jar work
cp classes.dex work
cd work
unzip framework.jar
古いファイル削除しておく。
rm framework.jar
work下のファイルをまとめてzip化し、framework.jarというファイル名にする。

生成したframework.jarを端末にコピーする。まずは/data/local/tmpにでも入れる。

adb push framework.jar /data/local/tmp

dexopt-wrapperも端末にコピーする。

cd ..\..
adb push dexopt-wrapper /data/local/tmp
adb shell
chmod +x /data/local/tmp/dexopt-wrapper

adb shellで端末に繋ぎ、framework.jarをodex化する。

adb shell
cd /data/local/tmp
export BOOTCLASSPATH=/system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar
./dexopt-wrapper framework.jar framework.odex ←これがうまくいかないっぽい。コマンドが古い?

結局生成した/system/framework/framework.jarにコピーし、端末側でodexファイルを生成させる。

/system/framework/framework.odexを削除した状態で端末を起動し、しばらく待つとフリーズしたままだが、
/data/dalvik-cache/にsystem@framework@framework.jar@classes.dexが生成される。
このファイルをリネームし、framework.odexとして使う。
cp framework.odex framework.odex.new

framework.odexができる。successとなっているのを確認すること。

動作させるには署名を書き換える必要があるとのことなので、既存のframework.odexの書名部分をコピーする。

busybox dd if=/system/framework/framework.odex of=/data/local/tmp/framework.odex.new bs=1 count=20 skip=52 seek=52 conv=notrunc

cd /system/framework
cp framework.odex framework.odex.bak
cp /data/local/tmp/framework.odex.new framework.odex
sync
reboot

clockworkからDalvik Cacheをwipeする。
端末を再起動後、IIJmioのSIMで、アンテナ表示及び「設定」->「電池」から圏外となっていないことを確認しました。

DropboxのLAN Syncを止める

Dropbox(Linuxで使用中)では、LAN Syncといって
同一ネットワークに常にブロードキャストしているようです。
https://www.dropbox.com/help/137/en

tcpdump port 17500

などでパケットを確認可能。

古い情報では、
dropbox_set_lansync.pyを使用すると記載されているものもありますが、
最近のdropboxでは、使えなくなってるようです。
現在は、

dropbox.py lansync n

で止めれるようです。
https://gist.github.com/2417583

Debian6.0へのGitLab2.8のインストール

・GitLab
GITLAB: Self Hosted Git Management Application

・公式のインストール手順
Page not found · GitHub
インストールにRuby1.9.2以上が必要。

基本的には、公式のインストール手順書の通りとなりますが、
いくつか躓いた箇所もありましたため、補足で追記してます。

Create user for git(git実行用のユーザ作成):

sudo adduser \
--system \
--shell /bin/sh \
--gecos 'git version control' \
--group \
--disabled-password \
--home /home/git \
git

Create user for GitLab(GitLab実行用のユーザ作成):

sudo adduser --disabled-login --gecos 'gitlab system' gitlab

Add your user to the git group:

sudo usermod -a -G git gitlab

Generate key:

sudo -H -u gitlab ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa

Clone GitLab's fork of the Gitolite source code(Giotliteの最新版をgit cloneし取得する):

cd /home/git
sudo -H -u git git clone -b gl-v304 https://github.com/gitlabhq/gitolite.git /home/git/gitolite

Setup(設定):

cd /home/git
sudo -u git -H mkdir bin
sudo -u git sh -c 'echo -e "PATH=\$PATH:/home/git/bin\nexport PATH" >> /home/git/.profile'
sudo -u git sh -c 'gitolite/install -ln /home/git/bin'

sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
sudo chmod 0444 /home/git/gitlab.pub

sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub"
sudo -u git -H sed -i 's/0077/0007/g' /home/git/.gitolite.rc

Permissions(gitレポジトリディレクトリへのアクセス権設定):

sudo chmod -R g+rwX /home/git/repositories/
sudo chown -R git:git /home/git/repositories/

Clone GitLab source and install prerequisites(GitLabの最新取得とインストール)

sudo gem install charlock_holmes --version '0.6.8'
sudo pip install pygments
sudo gem install bundler
cd /home/gitlab

**************************************************************************************

********** icu required (brew install icu4c or apt-get install libicu-dev) ***********

**************************************************************************************

と出て、charlock_holmesのインストールに失敗。
指示通りlibicu-devを入れる。

sudo aptitude install libicu-dev

再度

sudo gem install charlock_holmes --version '0.6.8'

でインストール。

# Get gitlab code. Use this for stable setup
sudo -H -u gitlab git clone -b stable https://github.com/gitlabhq/gitlabhq.git gitlab

cd gitlab

# Rename config files
sudo -u gitlab cp config/gitlab.yml.example config/gitlab.yml

Select the database you want to use(データベースの設定、ここではMySQLを使用する)

# Mysql
# Install MySQL as directed in Step #1

# Login to MySQL
$ mysql -u root -p

# Create the GitLab production database
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;

# Create the MySQL User change $password to a real password
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password';

# Grant proper permissions to the MySQL User
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';

# Exit MySQL Server and copy the example config, make sure to update username/password in config/database.yml
sudo -u gitlab cp config/database.yml.example config/database.yml

database.ymlのDBの接続ユーザ、パスワードを修正する。

Install gems

gemで入れたbundleコマンドがパスが通ってないのでフルパスで指定する。
sudo -u gitlab -H /var/lib/gems/1.8/bin/bundle install --without development test --deployment

Setup database(データベースの設定)

sudo -u gitlab /var/lib/gems/1.8/bin/bundle exec rake gitlab:app:setup RAILS_ENV=production
sudo -u gitlab bundle exec rake gitlab:app:setup RAILS_ENV=production

WARNING: Invalid .gemspec format in '/home/gitlab/gitlab/vendor/bundle/ruby/1.8/specifications/carrierwave-0.6.2.gemspec'
Could not find carrierwave-0.6.2 in any of the sources
Run `bundle install` to install missing gems.

こんなエラーが出た。

sudo gem install carrierwave
sudo -u gitlab /var/lib/gems/1.8/bin/bundle install

で入れる。
再度

sudo -u gitlab /var/lib/gems/1.8/bin/bundle exec rake gitlab:app:setup RAILS_ENV=production

一見エラーは起きず、インストールできたように思いましたが、Ruby1.8系でインストールを進めていたため後ほどうまくいっていないことがわかりました。


Setup GitLab hooks(gitのフック処理の設定)

sudo mkdir -p /home/git/share/gitolite/hooks/common
sudo cp ./lib/hooks/post-receive /home/git/share/gitolite/hooks/common/post-receive
sudo chown git:git /home/git/share/gitolite/hooks/common/post-receive

Check application status(ステータスのチェック)

sudo -u gitlab /var/lib/gems/1.8/bin/bundle exec rake gitlab:app:status RAILS_ENV=production

エラーが発生しました。(どんなエラーかはメモし忘れ・・・)
調べたところ結局Ruby1.8系では動かないらしいことがわかりました。
結局rubyが最新のruby-1.9.3でないとダメなようなのでrvmでgitlabユーザにだけruby1.9.3を使えるようにする。

sudo su - gitlab
curl -L https://get.rvm.io | bash -s stable --ruby
. ~/.bashrc
rvm use 1.9.3

(rvm useがtmux等のターミナルエミュレータ上では正しく動かせないようだった(?)ので、普通にログインして実行する。)

以降sudoコマンド経由だと、bundle等のコマンドが見つからないとなってしまったので、gitlabユーザでログインして進めました。

$ bundle exec rake gitlab:app:setup RAILS_ENV=production --trace
rake aborted!
An invalid interpreter was specified.
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rubypython-0.6.2/lib/rubypython.rb:124:in `block in start'
:10:in `synchronize'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rubypython-0.6.2/lib/rubypython.rb:111:in `start'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/bundler/gems/pygments.rb-2cada028da50/lib/pygments/ffi.rb:9:in `start'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/bundler/gems/pygments.rb-2cada028da50/lib/pygments/ffi.rb:43:in `lexers'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/bundler/gems/pygments.rb-2cada028da50/lib/pygments/lexer.rb:147:in `'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/bundler/gems/pygments.rb-2cada028da50/lib/pygments/lexer.rb:1:in `'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/bundler/gems/linguist-c3d6fc5af8cf/lib/linguist/language.rb:230:in `initialize'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/bundler/gems/linguist-c3d6fc5af8cf/lib/linguist/language.rb:42:in `new'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/bundler/gems/linguist-c3d6fc5af8cf/lib/linguist/language.rb:42:in `create'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/bundler/gems/linguist-c3d6fc5af8cf/lib/linguist/language.rb:449:in `block in '
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/bundler/gems/linguist-c3d6fc5af8cf/lib/linguist/language.rb:448:in `each'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/bundler/gems/linguist-c3d6fc5af8cf/lib/linguist/language.rb:448:in `'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/bundler/gems/linguist-c3d6fc5af8cf/lib/linguist/language.rb:5:in `'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/bundler/gems/linguist-c3d6fc5af8cf/lib/linguist/blob_helper.rb:1:in `'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/bundler/gems/linguist-c3d6fc5af8cf/lib/linguist.rb:1:in `'
/home/gitlab/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.0/lib/bundler/runtime.rb:68:in `require'
/home/gitlab/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.0/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/home/gitlab/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.0/lib/bundler/runtime.rb:66:in `each'
/home/gitlab/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.0/lib/bundler/runtime.rb:66:in `block in require'
/home/gitlab/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.0/lib/bundler/runtime.rb:55:in `each'
/home/gitlab/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.0/lib/bundler/runtime.rb:55:in `require'
/home/gitlab/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.0/lib/bundler.rb:128:in `require'
/home/gitlab/gitlab/config/application.rb:9:in `'
/home/gitlab/gitlab/Rakefile:5:in `require'
/home/gitlab/gitlab/Rakefile:5:in `'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/bin/rake:23:in `load'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/bin/rake:23:in `

'

Ruby1.9.3の環境で実行するも上記エラーが発生しました。

エラー内容を見てもよくわかりにくいですが、調べたところどうもpythonの開発パッケージが入ってないのがいけないようでしたので追加でインストール。
Google グループ

sudo aptitude install python-dev

rake aborted!
Connection refused - Unable to connect to Redis on 127.0.0.1:6379
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:236:in `rescue in establish_connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:222:in `establish_connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:23:in `connect'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:247:in `ensure_connected'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:137:in `block in process'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:206:in `logging'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:136:in `process'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:46:in `call'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/redis-2.2.2/lib/redis.rb:435:in `block in sadd'
/home/gitlab/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/redis-2.2.2/lib/redis.rb:434:in `sadd'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/redis-namespace-1.0.3/lib/redis/namespace.rb:213:in `method_missing'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/resque-1.20.0/lib/resque.rb:205:in `watch_queue'
/home/gitlab/gitlab/config/initializers/4_resque_queues.rb:1:in `'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `block in load'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:588:in `block (2 levels) in '
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:587:in `each'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:587:in `block in '
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/gitlab/gitlab/config/environment.rb:5:in `'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:103:in `require_environment!'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:295:in `block (2 levels) in initialize_tasks'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/gitlab/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/home/gitlab/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:373:in `block (3 levels) in '
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/gitlab/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/home/gitlab/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/home/gitlab/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/bin/rake:23:in `load'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/bin/rake:23:in `

'
Tasks: TOP => db:schema:load => environment

再度実行すると別のエラーが。。。

これは、実行に必要なredis-serverというKVSサーバが動いていないことによるようですので追加でインストール。

sudo aptitude install redis-server

これにてrake gitlab:app:setupが正常に完了しました。

bundle exec rake gitlab:app:status RAILS_ENV=production

を実行してもすべて正常に完了しました。

Server up(サーバの起動)

bundle exec rails s -e production -d

Run resque process (for processing queue).(queueプロセスの起動(メールの送信などに使用しているようです))

./resque.sh

# GITLAB2.8では自動でrake gitlab:app:setup時にautomergeが有効にされているようですが、されていないようであれば有効化。
bundle exec rake gitlab:app:enable_automerge RAILS_ENV=production



上記で動くようにはなりましたが、運用を考えるとWebサーバにNginxを使用した方が良いとのこと。

Nginx

sudo apt-get install nginx

cd /home/gitlab/gitlab
cp config/unicorn.rb.orig config/unicorn.rb
bundle exec unicorn_rails -c config/unicorn.rb -E production -D

# Change **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN** IPアドレスとホスト名を修正する
# to the IP address and fully-qualified domain name
# of the host serving GitLab.
sudo vim /etc/nginx/sites-enabled/gitlab

#起動スクリプトのインストール
sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab -P /etc/init.d/

sudo chmod +x /etc/init.d/gitlab

#debianのサービス自動起動の設定
sudo update-rc.d gitlab defaults

sudo /etc/init.d/gitlab restart

こちらはすんなり行きました。

Spring roo 1.2.2でdatabase introspectできない。

・Spring Roo 入門: 第 2 回 Spring Roo を使ってアプリケーションを開発する
http://www.ibm.com/developerworks/jp/opensource/library/os-springroo2/index.html

こちらの記事を参考に
Spring roo 1.2.2でデータベース・リバース・エンジニアリングというのをやってみた。

roo> database introspect --schema feedback_schema

のところで

Spring Roo automatic add-on discovery service currently unavailable
JDBC driver not available for 'com.mysql.jdbc.Driver'

というエラーが出てしまい、どうやらMySQLJDBCドライバが入っていないよう。

調べたところ既知のバグらしいです。(本来は自動でインストールされるらしい)

MySQL driver can't be downloaded
https://jira.springsource.org/browse/ROO-3191
・RooBot addon registration does not work
https://jira.springsource.org/browse/ROO-3184

roo> osgi start --url file:C:\Users\hoge\.m2\repository\mysql\mysql-connector-java\5.1.18\mysql-connector-java-5.1.18.jar

とりあえずこんな感じで手動でインストールすると入るようです。