diff options
Diffstat (limited to 'files/zh-tw/archive/b2g_os/firefox_os_build_prerequisites')
-rw-r--r-- | files/zh-tw/archive/b2g_os/firefox_os_build_prerequisites/index.html | 606 |
1 files changed, 606 insertions, 0 deletions
diff --git a/files/zh-tw/archive/b2g_os/firefox_os_build_prerequisites/index.html b/files/zh-tw/archive/b2g_os/firefox_os_build_prerequisites/index.html new file mode 100644 index 0000000000..dd2fd2efb5 --- /dev/null +++ b/files/zh-tw/archive/b2g_os/firefox_os_build_prerequisites/index.html @@ -0,0 +1,606 @@ +--- +title: Firefox OS build prerequisites +slug: Archive/B2G_OS/Firefox_OS_build_prerequisites +translation_of: Archive/B2G_OS/B2G_OS_build_prerequisites +--- +<div class="summary"> +<p><span class="seoSummary">在您開始取得程式碼並建立您的Firefox OS作業系統以前,需要一個設定正確的編譯環境,請參考<a href="https://developer.mozilla.org/en-US/docs/Developer_Guide/Build_Instructions" title="https://developer.mozilla.org/en-US/docs/Developer_Guide/Build_Instructions">build system</a>這個頁面,裡面有詳細的說明。這裡簡單的提一下,您可以在64位元的Linux以及OS X上面作編譯。</span></p> +</div> + +<div class="note"> +<p><strong>註</strong>: 若您計畫編譯一個Firefox OS並裝載在一隻手機上,請確認該手機在編譯動作開始時"並未"跟您的電腦連接,正確的連結時機會在詳細步驟中說明。</p> +</div> + +<h2 id="支援的裝置或模擬器">支援的裝置或模擬器</h2> + +<p>您需要一個目標來裝載您建立的Firefox OS,他可以是一個真實的裝置或是一個模擬器。我們支援數種裝置但一個裝製常常有多種的版本,這樣的情況我們只支援特定的版本。另外不同的裝置我們的支援程度也稍有不同。</p> + +<div class="note"> +<p>註:Mozilla的<a href="https://github.com/mozilla-b2g/B2G">B2G source code</a>是一個B2G的參考實現,而手機製造商是可以自由的為他們的手機做出patch以及修改的。舉例來說,您在市場上購買的Alcatel One Touch這隻手機裡面的B2G就是一個製造商的版本。這樣B2G版本的差異安裝在上面的應用程式是沒有差異的,不過在平台這一層是有一些差別的。由於Nexus 4的版本是直接由Mozilla維護的,因此跟其他第三級支援裝置比較起來我們各版本的Gecko應該更能直接在Nexus 4上直接無問題的使用。</p> +</div> + +<h3 id="第一級支援裝置">第一級支援裝置</h3> + +<p>第一級支援裝置是一些主要開發用的裝置,因此一般來說能得最快的新功能與新的bug fixes。</p> + +<dl> + <dt>Keon</dt> + <dd>Keon 即為 <a href="http://www.geeksphone.com/" title="http://www.geeksphone.com/">Geeksphone</a> Keon 裝置, 也是最初的開發機種中的一個。 請注意這個裝置上的Forefox OS是由 Geeksphone提供.</dd> + <dt>Inari</dt> + <dd>Inari 是另外一個測試裝置. 在您建立Firefox OS給ZTE Open的裝置時請使用這個configuration (configuration的細節後面會提到)。<strong>注意:</strong> 較新版本的Firefox版本可能會無法在ZTE Open手機的default boot partition中開機成功。</dd> + <dt>Flame</dt> + <dd>Flame 是 Mozilla 最新的 Firefox OS 標準參考開發裝置,除了Flame這隻手機以外,在您建立給 ZTE Open C 這個裝置的Firefox OS時請也在configuration 中選用Flame(configuration 的細節後面會提到)。 兩隻手機都用一樣的設定原因是他們都是基於 Android jellybean。</dd> + <dt><a href="/en-US/docs/Mozilla/Firefox_OS/Using_the_B2G_emulators" title="en-US/docs/Mozilla/Firefox_OS/Using_the_B2G_emulators">模擬器 (ARM 與 x86)</a></dt> + <dd>有兩種模擬器,一種是模擬ARM code,另外一種直接用x86 code執行所有的功能. 更多相關資訊請參考<a href="/en-US/docs/Mozilla/Firefox_OS/Using_the_B2G_emulators" title="/en-US/docs/Mozilla/Firefox_OS/Using_the_B2G_emulators">Learn more about installing and using the emulators</a>.</dd> + <dd><strong>請注意基本上您應該不要使用 x86 模擬器 — 這個模擬器安裝不易而且支援的程度不是很理想。</strong></dd> + <dt><a href="/en-US/docs/Mozilla/Firefox_OS/Using_the_B2G_desktop_client" title="/en-US/docs/Mozilla/Firefox_OS/Using_the_B2G_desktop_client">桌面 client 程式</a></dt> + <dd>您也可以建立一個桌面版本的Firefox OS; 這個版本是讓 <a href="/en-US/docs/Mozilla/Gecko" title="/en-US/docs/Mozilla/Gecko">Gecko</a> 跑在一個 <a href="/en-US/docs/XULRunner" title="/en-US/docs/XULRunner">XULRunner</a> 程式裡面讓您可以使用 <a href="/en-US/docs/Mozilla/Firefox_OS/Platform/Gaia/Introduction_to_Gaia" title="/en-US/docs/Mozilla/Firefox_OS/Platform/Gaia/Introduction_to_Gaia">Gaia</a> 提供的使用者界面.</dd> + <dt>Flatfish</dt> + <dd>Flatfist 是第一隻 Firefox OS 平板版本,雖然某些功能像是<a href="/zh-TW/docs/Web/Guide/Telephony">Web Telephony</a> 沒有辦法使用。在編譯 Flatfish 時,會需要一些<a href="https://github.com/flatfish-fox/flatfish-kernel">額外的設定</a>。</dd> +</dl> + +<p>另外雖然可能很顯而易見,還是提一下您在建立 <a href="/en-US/docs/Mozilla/Firefox_OS/Using_the_B2G_desktop_client" title="en-US/docs/Mozilla/Firefox_OS/Using_the_B2G_desktop_client">桌面 client 程式</a> 或任意一個 <a href="/en-US/docs/Mozilla/Firefox_OS/Using_the_B2G_emulators" title="en-US/docs/Mozilla/Firefox_OS/Using_the_B2G_emulators">模擬器</a> 時是不需要手機的。</p> + +<h3 id="第二級支援裝置">第二級支援裝置</h3> + +<p><span id="answer_long1" style="display: block;">一般來說,Firefox的功能在第二級支援裝置上都是可用的,這一些裝置被許多開發者使用(特別是應用程式開發者),因此並不需要太過即時的得到Firefox OS上新的改變。</span></p> + +<dl> + <dt><a href="/en-US/docs/Mozilla/Firefox_OS/Samsung_Nexus_S" title="/en-US/docs/Mozilla/Firefox_OS/Samsung_Nexus_S"><span class="link-https">Samsung Nexus S</span></a></dt> + <dd>已知的 Nexus S 支援型號為 GT-I9020A 以及 GT-I9023,其他的型號可能可以支援</dd> + <dt>Samsung Nexus S 4G</dt> + <dd>SPH-D720 這個型號被當作第二級的支援裝置</dd> +</dl> + +<h3 id="第三級支援裝置">第三級支援裝置</h3> + +<p><span id="answer_long1" style="display: block;">給這一些裝置的Firefox OS是可以被建立的,不過工程師並不會時常用這一些裝置做開發,因此穩定度與功能上面會明顯的比前兩級的支援裝置要不足。</span></p> + +<dl> + <dt>Samsung Galaxy S2</dt> + <dd>只有i9100這個型號是被正式支援的。(i9100P 應該也可以支援因為差異只在 NFC 晶片)</dd> + <dt>Samsung Galaxy Nexus</dt> + <dd>現在看起來所有的型號都可以支援</dd> + <dt>Nexus 4</dt> + <dd>有一些在 IRC 上的使用者測試並成功過。 如果機器本身是 Android 4.4 也許需要降回 4.3 (Android <a href="https://developers.google.com/android/nexus/images#occamjwr66y">images available from Google</a>)</dd> + <dt>Nexus 5</dt> + <dd>一些在 IRC 上的使用者測試並成功過。</dd> + <dt>Tara</dt> + <dd>Tara 是另一之測試裝置. Tara 的 manifest 只在 master branch. 取得 Tara 的 script 為 "BRANCH=master ./config.sh tara"。</dd> + <dt>Unagi</dt> + <dd>Unagi 用來當作中低階智慧型手機的測試與開發裝置。很多 Firefox OS的開發者使用 Unagi 作開發。</dd> + <dt><a href="/en-US/docs/Mozilla/Firefox_OS/Pandaboard" title="/en-US/docs/Mozilla/Firefox_OS/Pandaboard">Pandaboard</a></dt> + <dd>Pandaboard 是一片基於 OMAP 4 架構的開發板,作為在各種不同行動平台的開發使用。</dd> +</dl> + +<div class="warning"><strong>重要</strong>: 只有基於 <strong>Android 4</strong> (aka <strong>Ice Cream Sandwich</strong>) 以上的裝置才被支援。若您手上的裝置是上面提到的其中之一但 Android 的版本比較舊,請務必在做任何動作前先將它升級。</div> + +<div class="note"> +<p><strong>註</strong>: 第二級與第三級支援裝置沒有硬體的 Home 按鈕,不過會有一個軟體的 Home 按鈕</p> + +<p>所有第一級支援裝置都有一個硬體的 Home 按鈕,這個按鈕可以讓使用者直接回到 Home screen。現在市面上大多數基於 ICS 的 Android 裝置使用在螢幕上的觸碰按鍵。我們現在提供一個虛擬的 Home 按鈕給這一些缺少硬體按鍵的裝置。若您發現這個虛擬的 Home 按鈕沒出現,請打開 Setting 程式,然後到<span style="font-size: 14px; line-height: 1.5em;"> <a href="/en-US/Firefox_OS/Debugging/Developer_settings">Developer settings</a> 並選取 <a href="/en-US/Firefox_OS/Debugging/Developer_settings#Enable_software_home_button">Enable software home button</a>。</span></p> + +<p><span style="font-size: 14px; line-height: 1.5em;">在 Firefox OS 1.4 版有另外一個 developer option 叫做 "Home gesture enabled"; 開啟這的選項表示虛擬的 Home 按鈕將消失,取而代之的是一個由螢幕下方向上滑動的手勢。</span></p> +</div> + +<h2 id="使用_GNULinux_的需求">使用 GNU/Linux 的需求</h2> + +<div class="warning"> +<p><strong>重要</strong>: 即使您沒有要編譯自己的 Boot 2 Gecko,而只有要使用到<a href="https://developer.mozilla.org/en-US/Firefox_OS/Developing_Gaia/make_options_reference"> Gaia's make system</a>, 您仍需要正確版本的 <strong>Python</strong> 與 <strong>Node.js</strong>。</p> +</div> + +<p>在 Linux 建立 Firefox OS, 您需要:</p> + +<ul> + <li>一種 <strong>64 bit 的 GNU/Linux</strong> distribution (建議Ubuntu 14.04).</li> + <li>至少 <strong>4 GB</strong> 的記憶體.</li> + <li>至少 <strong>40 GB</strong> 的硬碟空間.</li> +</ul> + +<p>這其實比最低需求要高不過常常在建立 Firefox OS 的過程出現問題只是因為資源不太夠。一個常見的例子為 "<span style="line-height: 1.5;"><strong>arm-linux-androideabi-g++: Internal error: Killed (program cc1plus)</strong>".</span></p> + +<p>下面列出個工具也必須被安裝:</p> + +<ul> + <li><strong>autoconf 2.13</strong></li> + <li><strong>bison</strong></li> + <li><strong>bzip2</strong></li> + <li><strong>ccache</strong></li> + <li><strong>curl</strong></li> + <li><strong>flex</strong></li> + <li><strong>gawk</strong></li> + <li><strong>git</strong></li> + <li><strong>gcc / g++ / g++-multilib</strong></li> + <li><strong>java sdk (jdk)</strong></li> + <li><strong>lzop</strong></li> + <li><strong>make</strong></li> + <li><strong>OpenGL shared libraries</strong></li> + <li><strong>patch</strong></li> + <li><strong>X11 headers</strong></li> + <li><strong>32-bit ncurses</strong></li> + <li><strong>32-bit zlib</strong></li> +</ul> + +<h3 id="64_位元安裝需求">64 位元安裝需求</h3> + +<p>這個部份列出了一些在不同的Linux發行版本中你必須執行的指令, 以利於安裝所有的需求來建構 Firefox OS.</p> + +<h4 id="Ubuntu_12.04_Linux_Mint_13_Debian_6">Ubuntu 12.04 / Linux Mint 13 / Debian 6</h4> + +<p>在終端機中執行下列指令:</p> + +<pre class="language-html"><code class="language-html">sudo apt-get update +sudo apt-get install autoconf2.13 bison bzip2 ccache curl flex gawk gcc g++ g++-multilib git ia32-libs lib32ncurses5-dev lib32z1-dev libasound-dev libgconf2-dev libgl1-mesa-dev libx11-dev lzop make zip</code></pre> + +<p>如果您將建構 <a href="https://developer.mozilla.org/en-US/Firefox_OS/Developer_phone_guide/Flame">"Flame"</a> reference device 或是 Nexus 5, 請在終端機執行以下指令:</p> + +<pre>sudo apt-get install libxml2-utils </pre> + +<p>您可以透過<a href="http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html">這個ppa</a>來安裝 jdk。</p> + +<p>And see the above comments about emulator build issues!</p> + +<h4 id="Ubuntu_12.10_Debian_7">Ubuntu 12.10 / Debian 7</h4> + +<p>在終端機中執行下列指令:</p> + +<pre>sudo apt-get install autoconf2.13 bison bzip2 ccache curl flex gawk gcc g++ g++-multilib gcc-4.6 g++-4.6 g++-4.6-multilib git ia32-libs lib32ncurses5-dev lib32z1-dev libgl1-mesa-dev libx11-dev make zip</pre> + +<p>In addition to the emulator build issues discussed above, the compiler will default to <code>gcc-4.7</code>, which will fail to build with an error along the following lines:</p> + +<p>"<code>KeyedVector.h:193:31: error: indexOfKey was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation"</code></p> + +<p>To fix this, you will need to specify GCC 4.6 as the default host compiler after having retrieved the B2G sources: Read <a href="/en-US/docs/Mozilla/Firefox_OS/Customization_with_the_.userconfig_file#Changing_the_default_host_compiler">Changing the default host compiler</a> to find out how to do it.</p> + +<p class="note">In a fresh Ubuntu 12.10 install, you'll get an error about unmet dependencies for ia32-libs. The following commands fix it:</p> + +<pre>sudo dpkg --add-architecture i386 +sudo apt-get update +sudo apt-get install ia32-libs</pre> + +<h4 id="Ubuntu_13.04">Ubuntu 13.04</h4> + +<p>Run the following command in Terminal:</p> + +<pre>sudo apt-get install --no-install-recommends autoconf2.13 bison bzip2 ccache curl flex gawk gcc g++ g++-multilib gcc-4.6 g++-4.6 g++-4.6-multilib git ia32-libs lib32ncurses5-dev lib32z1-dev zlib1g:amd64 zlib1g-dev:amd64 zlib1g:i386 zlib1g-dev:i386 libgl1-mesa-dev libx11-dev make zip</pre> + +<p>In addition to the emulator build issues discussed above, the compiler will default to <code>gcc-4.7</code>, which will fail to build with an error along the following lines:</p> + +<p>"<code>KeyedVector.h:193:31: error: indexOfKey was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation"</code></p> + +<p>To fix this, you will need to specify GCC 4.6 as the default host compiler after having retrieved the B2G sources: Read <a href="/en-US/docs/Mozilla/Firefox_OS/Customization_with_the_.userconfig_file#Changing_the_default_host_compiler">Changing the default host compiler</a> to find out how to do it.</p> + +<h4 id="Ubuntu_13.10">Ubuntu 13.10</h4> + +<p>With Ubuntu 13.10, multi-arch packages are now the main way to support multiple architectures (e.g. 32-bit on a 64-bit install). You must tell your Ubuntu system that you want to support 32-bit packages as well:<br> + </p> + +<pre>sudo dpkg --add-architecture i386 +sudo apt-get update</pre> + +<p>Once you've completed that, then you can install the necessary packages:</p> + +<pre style="font-family: 'Open Sans', sans-serif; line-height: 21px;">sudo apt-get install --no-install-recommends autoconf2.13 bison bzip2 ccache curl flex gawk gcc g++ g++-multilib gcc-4.6 g++-4.6 g++-4.6-multilib git lib32ncurses5-dev lib32z1-dev zlib1g:amd64 zlib1g-dev:amd64 zlib1g:i386 zlib1g-dev:i386 libgl1-mesa-dev libx11-dev make zip libxml2-utils + +sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 1 + +sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 2 + +sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 1 + +sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 2 + +sudo update-alternatives --set gcc "/usr/bin/gcc-4.6" + +sudo update-alternatives --set g++ "/usr/bin/g++-4.6" </pre> + +<h4 id="Ubuntu_14.04">Ubuntu 14.04</h4> + +<p>Follow the instructions given for Ubuntu 13.10.</p> + +<h4 id="Fedora_17181920">Fedora 17/18/19/20</h4> + +<p>Run the following command in Terminal:</p> + +<pre class="note">sudo yum install autoconf213 bison bzip2 ccache curl flex gawk gcc-c++ git glibc-devel glibc-static libstdc++-static libX11-devel make mesa-libGL-devel ncurses-devel patch zlib-devel ncurses-devel.i686 readline-devel.i686 zlib-devel.i686 libX11-devel.i686 mesa-libGL-devel.i686 glibc-devel.i686 libstdc++.i686 libXrandr.i686 zip perl-Digest-SHA wget</pre> + +<p>In addition to the above you will need GCC 4.6.x in order to compile the project:</p> + +<ul> + <li><a href="http://people.mozilla.org/~gsvelto/gcc-4.6.4-fc18.tar.xz">Pre-compiled GCC 4.6.x for Fedora 17/18</a></li> + <li><a href="http://people.mozilla.org/~gsvelto/gcc-4.6.4-fc19.tar.xz">Pre-compiled GCC 4.6.x for Fedora 19/20</a></li> +</ul> + +<p>Download the right version for your Fedora installation, then install it to <code>/opt,</code> with the following command on Fedora 17/18:</p> + +<pre class="note">curl -O http://people.mozilla.org/~gsvelto/gcc-4.6.4-fc18.tar.xz +sudo tar -x -a -C /opt -f gcc-4.6.4-fc18.tar.xz +</pre> + +<p>And with the following command for Fedora 19/20:</p> + +<pre class="note">curl -O http://people.mozilla.org/~gsvelto/gcc-4.6.4-fc19.tar.xz +sudo tar -x -a -C /opt -f gcc-4.6.4-fc19.tar.xz +</pre> + +<p>You will need to specify GCC 4.6.x as the default host compiler after having retrieved the B2G sources: Read <a href="/en-US/docs/Mozilla/Firefox_OS/Customization_with_the_.userconfig_file#Changing_the_default_host_compiler">Changing the default host compiler</a> to find out how to do it.</p> + +<p>If build fails with the compiler complaining about not finding libmpc.so.2, install the package compat-libmpc</p> + +<h4 id="Arch_Linux"><strong>Arch Linux</strong></h4> + +<p>Run the following command in Terminal:</p> + +<pre class="note">sudo <span><span>pacman -S --needed </span></span><span><span>alsa-lib </span></span><span><span>autoconf2.13</span></span><span><span> bison</span></span><span><span> ccache</span></span><span><span> </span></span><span><span>curl firefox </span></span><span><span>flex </span></span><span><span>gcc-multilib </span></span><span><span>git </span></span><span><span>gperf </span></span><span><span>libnotify </span></span><span><span>libxt </span></span><span><span>libx11 mesa multilib-devel </span></span><span><span>wget wireless_tools </span></span><span><span>yasm</span></span><span><span> zip </span></span><span><span>lib32-mesa </span></span>lib32-mesa-libgl <span><span>lib32-ncurses lib32-readline</span></span><span><span> </span></span><span><span>lib32-zlib</span></span></pre> + +<p>To install the lib32-* packages you need to have the multilib repository enabled.</p> + +<p>B2G <a href="https://developer.mozilla.org/en-US/Firefox_OS/Building#KeyedVector.h.3A193.3A31.3A_error.3A_indexOfKey_was_not_declared_in_this_scope">can only be compiled with gcc4.6.4</a>, and because Arch Linux always has bleeding edge software you will need to install <a href="https://aur.archlinux.org/packages/gcc46-multilib">gcc46-multilib from AUR</a>. Note that you will have to edit the PKGBUILD and add <code>staticlibs</code> to the <code>options</code> array, or gcc will be unable to compile B2G and give you a <code>cannot find -lgcc</code> error when compiling. You will also need to add the following to your <code>.userconfig</code> file:</p> + +<pre class="language-html">export CC=gcc-4.6.4 +export CXX=g++-4.6.4</pre> + +<p>By default, Arch Linux uses Python3. You'll have to force it to use the old python2. You can do that by linking the python2 executable to python but this is discouraged and considered error-prone. This will also break python 3 if it is installed on your system. A better way is to use <code>virtualenv</code>/<code>virtualenvwrapper</code>:</p> + +<pre><span><span>sudo pacman -S python-virtualenvwrapper +</span></span>source /usr/bin/virtualenvwrapper.sh +mkvirtualenv -p `which python2` firefoxos +workon firefoxos +</pre> + +<p>Android will complain that you need make 3.81 or make 3.82 instead of 4.0. You can download <a href="https://aur.archlinux.org/packages/make-3.81/">make 3.81 from AUR</a>. This will install the make-3.81 binary on your path, you need to create a symlink named make to a location earlier in the PATH variable for the build to use the correct version.</p> + +<pre>mkdir -p ~/bin +ln -s `which make-3.81` ~/bin/make +export PATH=~/bin:$PATH +</pre> + +<p>Android also needs the Java6 SDK and Arch only has Java7. Unfortunately the aur build is broken, but you can still download the <a href="http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html#jdk-6u45-oth-JPR">Java 6 SDK</a> and install it manually. You will then need to put it in your path.</p> + +<pre>cp ~/Downloads/jdk-6u45-linux-x64.bin /opt +su +cd /opt +chmod +x jdk-6u45-linux-x64.bin +./jdk-6u45-linux-x64.bin +exit +ln -s /opt/jdk1.6.0_45/bin/java ~/bin/java + +</pre> + +<h4 id="Gentoo_Linux"><strong>Gentoo Linux</strong></h4> + +<h5 id="Installing_ccache">Installing ccache</h5> + +<p>You will need to install <strong><a href="http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=3#doc_chap3">ccache</a></strong>, a tool for caching partial builds.</p> + +<pre><span><span># emerge -av ccache</span></span> +</pre> + +<p>Because ccache is known to frequently cause support issues, Gentoo encourages you to use it <em>explicitly</em> and <em>sparingly</em>.</p> + +<p>To enable the required use of ccache, on <em>the subsequent step</em> of this guide where the <code>./build.sh</code> script is called, Gentoo users should instead run the command with an explicitly extended path, ie.</p> + +<pre><span><span><strong>PATH=/usr/lib64/ccache/bin:$PATH</strong> ./build.sh</span></span> +</pre> + +<h5 id="Generating_Partition_Images">Generating Partition Images</h5> + +<p>If you are building B2G for actual physical hardware, then you may at some point also wish to generate some partition images for upload to your device. (For example, to restore backed up files to the device via the <strong><em>fastboot</em></strong> utility)</p> + +<p>The filesystem image format used in this case is YAFFS2 (Yet Another Filesystem 2). Gentoo has support for the very latest (ie. git HEAD) <code>yaffs2-utils</code> userland package in portage. (Note: You will also need kernel patches if you want to mount YAFFS2 images, but this is not really required since you can deconstruct and rebuild them instead.)</p> + +<pre># emerge --autounmask-write yaffs2-utils; etc-update; emerge -av yaffs2-utils</pre> + +<p>In order to generate such an image, simply change to the parent directory of the partition filesystem tree you wish to package, and issue a command like this:</p> + +<pre>mkyaffs2image system/ system.img</pre> + +<h2 id="使用_Mac_OS_X_的需求">使用 Mac OS X 的需求</h2> + +<p>要在Mac OS X 上建構 Firefox OS, 您必須遵循一些步驟, 以下將會詳細說明. 我們也會提出一些您可能在特殊情況下會遇到的錯誤, 以及他們的解決方法.</p> + +<div class="note"> +<p><strong>Note: Configuring and Building B2G for Keon WON'T WORK on a Mac</strong>. You'll need to use Linux to build B2G for this device.</p> +</div> + +<h3 id="版本相容性"><strong>版本相容性</strong></h3> + +<p>XCode 4.2 以下的版本與 Mac OS X 10.9 (a.k.a. "Mavericks") 並不相容, 所以您可能會很驚訝地發現Firefox OS會建構錯誤. 基本上您無法在 Mac OS X 10.9 以上的版本建構 ICS emulator, 並且 flatfish 在XCode 5.x系列會無法建構.</p> + +<table class="standard-table"> + <caption>Mac OS X 10.9.x 的版本相容性</caption> + <tbody> + <tr> + <td> </td> + <td>emulator (ICS)</td> + <td>flatfish (JB-4.2)</td> + <td>emulator-jb (JB-4.3)</td> + <td>emulator-kk (KitKat-4.4)</td> + </tr> + <tr> + <td>XCode 4.3.3</td> + <td style="text-align: center;">X</td> + <td style="text-align: center;">X</td> + <td style="text-align: center;">X</td> + <td style="text-align: center;">X</td> + </tr> + <tr> + <td>XCode 4.4.1</td> + <td style="text-align: center;">X</td> + <td style="text-align: center;">O[1]</td> + <td style="text-align: center;">O</td> + <td style="text-align: center;">O</td> + </tr> + <tr> + <td>XCode 4.5.2</td> + <td style="text-align: center;">X</td> + <td style="text-align: center;">O[1]</td> + <td style="text-align: center;">O</td> + <td style="text-align: center;">O</td> + </tr> + <tr> + <td>XCode 4.6.3</td> + <td style="text-align: center;">X</td> + <td style="text-align: center;">O[1]</td> + <td style="text-align: center;">O</td> + <td style="text-align: center;">O</td> + </tr> + <tr> + <td>XCode 5.0.2</td> + <td style="text-align: center;">X</td> + <td style="text-align: center;">X</td> + <td style="text-align: center;">O</td> + <td style="text-align: center;">O</td> + </tr> + <tr> + <td>XCode 5.1.1</td> + <td style="text-align: center;">X</td> + <td style="text-align: center;">X</td> + <td style="text-align: center;">O</td> + <td style="text-align: center;">O</td> + </tr> + </tbody> +</table> + +<ol> + <li>您必須將設定環境變數 <strong>BUILD_MAC_SDK_EXPERIMENTAL=1</strong> 並將其 export 以建構 flatfish.</li> +</ol> + +<h3 id="安裝_XCode_Command_Line_Utilities"><strong>安裝 XCode Command Line Utilities</strong></h3> + +<p>您必須安裝 Xcode's Command Line Utilities. 您可以只下載 Command Line Utilities, 只需要在 <a href="https://developer.apple.com/downloads/" title="https://developer.apple.com/downloads/">Apple's developer downloads page</a> 挑選您的 OS X 版本, 然而如果您想要完整的 Xcode suite, 你可以在 Mac App Store <a href="http://itunes.apple.com/us/app/xcode/id497799835?mt=12">安裝</a>他們<span style="line-height: 1.572;">. </span></p> + +<p>Xcode 4.3.1 (OS X 10.7 "Lion") 以及其他較新的版本如 4.4.1+ (也就是 Mac OS X 10.8 "Mountain Lion"), 並不會自動包含我們所需的 Command Line Utilities. 當您安裝 Xcode 時, 請確認進入 Preferences, then the Downloads panel, and install the Command Line Utilities. 另外, 請確認您至少有 20 GB 的硬碟空間.</p> + +<p><img alt="Screenshot of Xcode Downloads Command Line Tools" src="/files/4557/xcode_downloads_command_line_tools.png" style="height: 528px; width: 750px;"></p> + +<div class="note"> +<p><strong>Note:</strong> The Firefox OS 模擬器 需要 Core 2 Duo processor 或較新的處理器; 也就是, 一個相容於Mac OS X 10.7 "Lion"的作業系統. 您的作業系統不一定要是OS X Lion, 您只需要與其相容. 也就是您當然可以建構Firefox OS 在較舊版本的Mac 上.</p> +</div> + +<div class="note"> +<p><strong>Note:</strong> XCode 4.2.x or older is not compatible with Mac OS X 10.9 or above, and XCode 4.3.x has no platform SDK for 10.8. Please install a newer version. If you're also working on flatfish, please make sure any of XCode 4.4, 4.5, and 4.6 is available.</p> +</div> + +<h3 id="Run_Firefox_OS_Mac_Bootstrap">Run Firefox OS Mac Bootstrap</h3> + +<p>Next, open a terminal and run the following command:</p> + +<pre class="brush: bash">curl -fsSL https://raw.github.com/mozilla-b2g/B2G/master/scripts/bootstrap-mac.sh | bash</pre> + +<p>This will pull and run a bootstrap script that makes sure you have all the prerequisites met to build the emulator. It will also prompt you for permission to install anything you're missing, and provide warnings and suggested fixes to problems. The script will check for and install the following items:</p> + +<ul> + <li><code>git</code></li> + <li><code>gpg</code></li> + <li><code>ccache</code></li> + <li><code>yasm</code></li> + <li><code>autoconf-213</code></li> + <li><code>gcc-4.6</code></li> + <li><code>gnu-tar</code></li> + <li><code>homebrew</code></li> +</ul> + +<h4 id="Xcode_wrangling">Xcode wrangling</h4> + +<p>If you have already upgraded to Xcode 4.4+ and get the message that Xcode is outdated, check the Xcode path with:</p> + +<pre>xcode-select -print-path</pre> + +<p>If it still points to <code>/Developer</code> you can update the path with:</p> + +<pre>sudo xcode-select -switch /Applications/Xcode.app</pre> + +<h4 id="Making_the_Mac_OS_X_10.6_SDK_available">Making the Mac OS X 10.6 SDK available</h4> + +<p>You also need to have the Mac OS X 10.6 SDK available. The SDK needs to be available at</p> + +<pre>/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/</pre> + +<p>If it cannot be found there you will need to extract and copy it from Xcode 4.3. To do this:</p> + +<ol> + <li>Download the XCode 4.3 .dmg file from the <a class="external" href="https://developer.apple.com/downloads/index.action">Apple Developer</a> portal (you'll need an <a href="https://developer.apple.com/register/index.action" title="https://developer.apple.com/register/index.action">Apple Developer account</a>).</li> + <li>Download the utility <a href="http://www.charlessoft.com/" title="http://www.charlessoft.com/">Pacifist</a> and use it to extract the 10.6 SDK from the XCode 4.3 .dmg file. Click on the "Extract Package" button, find the SDK by searching for 10.6 in the search box, then <em>Ctrl + click</em> on the MacOSX10.6.sdk directory and Extract it to a suitable location.</li> + <li>Add a symlink from the 10.6 SDK location to the <code>/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/</code> directory. For example, if you put the 10.6 SDK on your desktop, the comment would be</li> +</ol> + +<pre>ln -s /Users/<em><yourusername></em>/Desktop/MacOSX10.6.sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/</pre> + +<div class="note"> +<p><strong>Note:</strong> This is not necessary for Mac OS X 10.9 or above, because 10.6 SDK is for ICS and ICS doesn't supports Mac OS X 10.9.</p> +</div> + +<h3 id="Be_aware_of_Mac_file_system_case_sensitivity">Be aware of Mac file system case sensitivity</h3> + +<p>By default, Mac OS X ships with a case-insensitive file system. This is problematic because the Linux kernel has a number of files with the same name, but different case. For example, see the header files <code>xt_CONNMARK.h</code> and <code>xt_connmark.h</code>. This results in a number of files appearing to be modified in <code>/kernel</code> after a fresh <code>./config.sh</code>.</p> + +<p>In many cases you can run the build just fine; for some platforms, however, you may encounter the following error:</p> + +<pre><span class="quote">ERROR: You have uncommited changes in kernel +You may force overwriting these changes +with |source build/envsetup.sh force| + +ERROR: Patching of kernel/ failed.</span></pre> + +<p><span class="quote">Please see <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=867259" title="https://bugzilla.mozilla.org/show_bug.cgi?id=867259">bug 867259</a></span> for more discussion and possible fixes for this problem.</p> + +<p>Alternatively, it will always be safest to build on a case sensitive file system. The easiest way to do this is to create a separate, mountable disk image with case-sensitivity enabled. You can do this using Apple's Disk Utility application or from the command line:</p> + +<pre>hdiutil create -volname 'firefoxos' -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 40g ~/firefoxos.sparseimage</pre> + +<p>Mount the drive with:</p> + +<pre>open ~/firefoxos.sparseimage</pre> + +<p>Change into the mounted drive with:</p> + +<pre>cd /Volumes/firefoxos/</pre> + +<p>You can then check out the code and compile from this location without worrying about case-sensitivity problems.</p> + +<h3 id="Mountain_Lion_homebrew_gotcha">Mountain Lion homebrew gotcha</h3> + +<div> +<div>If you are on Mountain Lion and you receive an error during the installation of the dependencies via homebrew, such as:</div> +</div> + +<div> +<pre>clang: error: unable to execute command: Segmentation fault: 11</pre> +... try reinstalling the dependency manually adding the <code>--use-gcc</code> flag, for example: + +<pre>brew install mpfr --use-gcc</pre> +</div> + +<h3 id="Follow_Samsung_Galaxy_S2_extra_steps">Follow Samsung Galaxy S2 extra steps</h3> + +<p>If you plan to build for the Samsung Galaxy S2, you will also need to install heimdall. See {{ anch("Installing heimdall") }} for details. This is <strong>not</strong> done for you by the bootstrap script!</p> + +<div class="note"><strong>Note:</strong> If you have installed the <a class="external" href="http://www.samsung.com/us/kies/" title="http://www.samsung.com/us/kies/">Samsung Kies</a> tool, which is used to manage the contents of many Samsung phones, you will have to remove it before you can flash Firefox OS onto your device. You can use the standard application removal process on Windows; on Mac, the Kies install disk image has a utility to fully remove Kies from your system. Flashing <strong>will not work</strong> if you have Kies installed. If you forget to remove Kies, the build system will detect it and remind you to uninstall it. Note also that the uninstall tool does not correctly remove the folder <code>~/Library/Application Support/.FUS</code>, and leaves a reference to a utility there in your user startup items list. You will want to remove these manually.</div> + +<h3 class="note" id="Fix_libmpc_dependency_if_broken">Fix libmpc dependency if broken</h3> + +<p><code>gcc 4.6</code> was built with <code>libmpc 0.9</code>; if you then use homebrew to update packages, libmpc gets updated to version 1.0, but homebrew doesn't rebuild <code>gcc 4.6</code> after the library version changes. So you need to create a symlink to make things work again, like this:</p> + +<pre>cd /usr/local/lib/ +ln -s libmpc.3.dylib libmpc.2.dylib</pre> + +<h3 id="Optional_Install_HAX">Optional: Install HAX</h3> + +<p>Intel provides a special driver that lets the B2G emulator run its code natively on your Mac instead of being emulated, when you're using the x86 emulator. If you wish to use this, you can <a class="external" href="http://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager/" title="http://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager/">download and install</a> it. It's not required, but it can improve emulation performance and stability. </p> + +<p>Before you install HAX you will need to install the <a href="http://developer.android.com/sdk/index.html" title="http://developer.android.com/sdk/index.html">Android SDK</a>.</p> + +<h2 class="note" id="Install_adb">Install adb</h2> + +<p>The build process needs to pull binary blobs from the Android installation on the phone before building B2G (unless you're building the emulator, of course). For this, you will need <code>adb</code>, the Android Debug Bridge. Our <a href="/en-US/Firefox_OS/Debugging/Installing_ADB">Installing ADB</a> article explains how to get <code>adb</code> installed.</p> + +<div class="warning"> +<p>Note for future when you start to use adb: adb needs the phone's lock screen to be unlocked in order to see your phone (at least in later versions of Firefox OS). You'll probably want to disable the lock screen (we'll get to how later in the build instructions).</p> +</div> + +<h2 class="note" id="Install_heimdall">Install heimdall</h2> + +<p>Heimdall is a utility for flashing the Samsung Galaxy S2. It's used by the Boot to Gecko flash utility to replace the contents of the phone with Firefox OS, as well as to flash updated versions of B2G and Gaia onto the device. You'll need it if you want to install Firefox OS on a Galaxy S2; it is <strong>not</strong> needed for any other device. For other devices, we build and use the fastboot utility instead.</p> + +<div class="note"><strong>Note:</strong> Again, it's important to note that this is <strong>only required for installing Firefox OS on the Samsung Galaxy S2</strong>.</div> + +<p>There are two ways to install heimdall:</p> + +<ul> + <li>You can <a class="link-https" href="https://github.com/Benjamin-Dobell/Heimdall" title="https://github.com/Benjamin-Dobell/Heimdall">download the code</a> GitHub and build it yourself.</li> + <li>Use a package manager to install it. + <ul> + <li>On Linux: <code>sudo apt-get install libusb-1.0-0 libusb-1.0-0-dev</code></li> + <li>On Mac, you can <a class="link-https" href="https://github.com/downloads/Benjamin-Dobell/Heimdall/heimdall-suite-1.3.2-mac.dmg" title="https://github.com/downloads/Benjamin-Dobell/Heimdall/heimdall-suite-1.3.2-mac.dmg">download an installer package</a> and use that.</li> + </ul> + </li> +</ul> + +<h2 id="Configure_ccache">Configure ccache</h2> + +<p>The B2G build process uses ccache. The default cache size for ccache is 1GB, but the B2G build easily saturates this; around 3GB is recommended. You can configure your cache by running the following command inside terminal:</p> + +<pre><code>$ ccache --max-size 3GB</code></pre> + +<h2 id="For_Linux_configure_the_udev_rule_for_your_phone">For Linux: configure the udev rule for your phone</h2> + +<div class="note"> +<p><strong>Note</strong>: This section is specific to Linux; Mac OS X has the necessary device permissions set up already.</p> +</div> + +<p>Next, you need to confingure the udev rule for your phone,</p> + +<p>You can get the <a href="https://developer.android.com/tools/device.html#VendorIds">USB vendor ID</a> by running <code>lsusb</code> with your phone plugged in, but typically it's Google <code>18d1,</code> Samsung <code>04e8</code>, ZTE <code>19d2</code>, Geeksphone/Qualcomm <code>05c6</code>. Add this line in your <code>/etc/udev/rules.d/android.rules</code> file (replacing <code>XXXX</code> with the ID for your device):</p> + +<h2 id="相容的">相容的</h2> + +<pre>SUBSYSTEM=="usb", ATTR{idVendor}=="XXXX", MODE="0666", GROUP="plugdev"</pre> + +<p>Take ZTE for example, the content in android.rules will be</p> + +<pre style="font-size: 14px;">SUBSYSTEM=="usb", ATTR{idVendor}=="19d2", MODE="0666", GROUP="plugdev"</pre> + +<div class="note"> +<p><span style="line-height: 1.572;">If the file doesn't exist, create it. The <code>rules.d</code> directory is usually read only by default, so you may have to use <code>chmod</code> to make the directory writeable, or the file, or both.</span></p> +</div> + +<p><span style="line-height: 1.572;">Once you've saved the file, and closed it, make the file readable:</span></p> + +<pre>sudo chmod a+r /etc/udev/rules.d/android.rules +</pre> + +<p>Now that the udev rules have been updated, restart the udev daemon.</p> + +<p><strong>Ubuntu</strong></p> + +<pre>sudo service udev restart</pre> + +<p><strong>Fedora 20</strong></p> + +<pre>sudo systemctl restart systemd-udevd.service</pre> + +<p>Finally, unplug and the USB cable but don't replug it in because we need to enable remote debugging on the phone first.</p> + +<h2 id="Enable_remote_debugging">Enable remote debugging</h2> + +<p>Before you plug your phone back into your USB port, put it USB developer mode. This allows you to debug and flash the phone. To enable developer mode, on your phone enable <a href="/en-US/Firefox_OS/Debugging/Developer_settings#Remote_debugging">Remote Debugging</a> in <a href="/en-US/Firefox_OS/Debugging/Developer_settings">Developer settings</a> (this was called Developer mode on older versions.) Once the option is checked, remote debugging is enabled, and you are ready to go.</p> + +<p>At this point, connect your phone to your computer via a USB cable (if you created the udev rule before, this will trigger udev to detect the phone and create the device node with the right permissions). Now you can check if you can list your device via the <code>adb devices</code> command (remember that adb can only see your phone when the lock screen is unlocked). If everything has worked ok, you should see an output similar to this (the following is for a Geeksphone Keon):</p> + +<pre style="font-size: 14px;">$ adb devices +List of devices attached +full_keon device</pre> + +<p>If the device did not list as expect, check the file name and the script are all correct (see previous section), then restart the computer and retype the command again. Note also that if your device uses fastboot, the bootloader may identify itself with a different vendor ID than the one you see when the device boots normally.</p> + +<h2 id="Backup_the_phone_system_partition">Backup the phone system partition</h2> + +<div class="note"> +<p><strong>Note</strong>: You have to do this before you build your device if you do not have an existing system backup, because some libraries will be referenced in build time. These library might be proprietary so we can't provide in our code base.</p> +</div> + +<p>It is recommended that you back up the entire Android system partition on your phone.</p> + +<p>You can use this copy of the binary blobs for Android in case you later delete your B2G tree. To do this, run:</p> + +<pre>adb pull /system <backup target dir>/system +</pre> + +<p> Depending on the phone, you may also need to pull the <code>/data</code> and/or <code>/vendor</code> directories:</p> + +<pre>adb pull /data <backup target dir>/data +adb pull /vendor <backup target dir>/vendor +</pre> + +<p>If the pull commands fail with an "insufficient permission" message, try the following:</p> + +<ul> + <li>stop and restart the adb server, or if that fails,</li> + <li>double-check that you have granted root permissions to the <code>adb</code> tool within your custom ROM (e.g. under CyanogenMod, change <em>Settings > System > Developer Options > Root Access</em> to <em>Apps and ADB</em> or <em>ADB only</em>).</li> + <li>Verify that you have set up the udev rule correctly (see {{ anch("For Linux: configure the udev rule for your phone") }}.</li> +</ul> + +<h2 id="On_to_the_next_step">On to the next step</h2> + +<p>At this point, you should be ready to <a href="/en-US/docs/Mozilla/Firefox_OS/Preparing_for_your_first_B2G_build" title="en-US/docs/Mozilla/Firefox_OS/Preparing_for_your_first_B2G_build">fetch the Firefox OS code</a>!</p> |