FirefoxOS のローカルミラー

FirefoxOS は commit が頻繁に行われ,master branch だけ追従してるとおかしな動作の時に拾うと残念なツリーになってしまうので,version branch で安定した環境も並列して構築しておきたいとなると,同じツリーをリモートから頻繁に取るのも何なのでローカルミラーが欲しくなります.

Android では本家に解説があります.

http://source.android.com/source/downloading.html#using-a-local-mirror

FirefoxOS の初回ビルド方法はMDNに解説があります.これが前提知識となりますので一度はトレースしておくのがよいかと思います.

https://developer.mozilla.org/ja/docs/Mozilla/Boot_to_Gecko/Preparing_for_your_first_B2G_build

FirefoxOS の場合は Android のモジュール管理ツールである repo を使いつつも shell script で自動化されているため,少々ややこしい手順が必要でした.またここでは git の操作が必要なので,git の知識が必要です.もしかしたらもっと単純で簡単な方法があるかもしれませんが.

ディレクトリイメージ

この例ではローカルミラーは以下のようなディレクトリを想定しています.青文字の "server:/opt/git/b2g" は「ホスト名 server」の「/opt/git/b2g ディレクトリ」のため,環境に合わせて読み替えてください.

server:/opt/git/b2g
|-- B2G
|-- projects
    |-- .repo
    |-- gaia.git
    |-- gecko.git
    :

リポジトリの取得

まず,server(以下 shell prompt が '$') にて最初のベースリポジトリを clone します.

$ cd /opt/git/b2g
$ git clone git://github.com/mozilla-b2g/B2G.git

リポジトリを初期化します.ここでは取得するベースとして ICS である emulator.xml を選択していますが,JellyBeans ベースなら emulator-jb.xml,Kitkat ベースなら emulator-kk.xml を指定します.機種を選択する場合は,b2g-manifest ディレクトリの xml ファイルを選択します.この sync は環境によってはかなりの時間を要します.

$ mkdir /opt/git/b2g/projects
$ cd /opt/git/b2g/projects
$ ../B2G/repo init -u git://github.com/mozilla-b2g/b2g-manifest.git -m emulator.xml --mirror
$ ../B2G/repo sync

ローカルへの対応

ローカル用の manifest に変更して,ローカル用のブランチ(local-master)に commit します.(リモートが更新された場合はリモートに追従して rebase または merge していきます.)

$ cd /opt/git/b2g/.repo/manifests
$ git checkout -b local-master origin/master
$ patch -p1 < emulator.xml.patch
$ git commit
$ git checkout default

local 用の manifest は remote のアドレスをローカルミラーの位置に修正したものを用意しておきます. 上記に登場した emulator.xml.patch は以下のようになります.

--- a/emulator.xml 2014-02-22 18:29:29.000000000 +0900
+++ b/emulator.xml 2014-03-22 01:28:46.000000000 +0900
@@ -2,18 +2,18 @@
<manifest>
<remote  name="aosp"
-        fetch="https://android.googlesource.com/" />
+        fetch="server:/opt/git/b2g/projects" />
 <remote name="caf"
-        fetch="git://codeaurora.org/" />
+        fetch="server:/opt/git/b2g/projects" />
 <remote name="b2gmozilla"
-         fetch="https://git.mozilla.org/b2g" />
+         fetch="server:/opt/git/b2g/projects" />
 <remote name="b2g"
-         fetch="git://github.com/mozilla-b2g/" />
+         fetch="server:/opt/git/b2g/projects" />
 <remote name="mozilla"
-       fetch="git://github.com/mozilla/" />
+       fetch="server:/opt/git/b2g/projects" />
 <remote name="mozillaorg"
-     fetch="https://git.mozilla.org/releases" />
- <remote name="apitrace" fetch="git://github.com/apitrace/" />
+     fetch="server:/opt/git/b2g/projects" />
+ <remote name="apitrace" fetch="server:/opt/git/b2g/projects" />
 <default revision="refs/tags/android-4.0.4_r2.1"
          remote="caf"
          sync-j="4" />

ベースが JellyBeans や KitKat の場合はマニフェストファイルが base-jb.xml,base-kk.xml に分かれているのでそれぞれローカルの対応が必要です.

 ローカルビルド

ローカル環境(以下 shell prompt が '%')では通常の手順通り config.sh を実行しますが,manifest リポジトリにローカルミラーの位置に,branch にローカル用 branch を指定して実行します.

% mkdir ~/work/b2g
% cd ~/work/b2g
% GITREPO=server:/opt/git/b2g/projects/.repo/manifests BRANCH=local-master ./config.sh emulator
% ./build.sh

 ローカルで新しいターゲットを追加する場合

ローカル向けに新しいターゲットを追加するには,次の手順を実施します.

  1. server:/opt/git/b2g/B2G にて config.sh にターゲット情報(例えば new-target)を追加して default  branch に commit
  2. server:/opt/git/b2g/projects/.repo/manifests にてターゲット用 manifest を作成してローカルbranch(local-master) に commit
  3. ローカルビルドは config.sh の引数に上記 1. で指定したターゲット名(new-target)を指定します.
    % GITREPO=server:/opt/git/b2g/projects/.repo/manifests BRANCH=local-master ./config.sh new-target

 


コメント

タイトルとURLをコピーしました