当前tizen发布的最新源码版本是2.1,本文将以图文教程讲述如何下载tizen源码,关于如何编译后述文章将讲解。
1 注册及设置gerrit
1.1注册邮箱
首先打开https://source.tizen.org/,在右上角点击注册一个你的用户,成功注册好后,再点击https://review.tizen.org/gerrit登陆gerrit,将出现如下界面:
以之前注册好的用户名以密码登陆。
注:tizen源码是用gerrit来管理的。
登陆后的界面如下:
点击右上角的Settings,然后在左边点击Contact Information在显示的界面上添加自己的邮箱,Gerrit系统会自动发送一件验证邮件到你所指定的邮箱中,点击邮件中给出的验证链接进行验证,难证通过后,表示你的Gerrit帐户已经**,可以正常使用了。
2 配置访问Gerrit的SSH
2.1 安装ssh工具
首先得安装ssh工具:
- $ sudo apt-get install ssh
2.2 生成RSA**
通过如下指令生成RSA**:
- ~/.ssh$ ssh-****** -t rsa -C flydream0
系统提示:
- Generating public/private rsa key pair.
- Enter file in which to save the key (/home/arthur/.ssh/id_rsa):
然后系统回提示你设置一个你的密码,两次设置无误后会出现如下界面:
2.3 配置SSH配置文件
进入~/.ssh目录下,创建config文件,将如下内容拷贝进去:
- Host tizen
- Hostname review.tizen.org
- IdentityFile ~/.ssh/id_rsa
- User flydream0
- Port 29418
- #The line below is optional configuration applicable to Ubuntu and openSUSE.
- #Add when using proxy, otherwise, skip it.
- #ProxyCommand nc -X5 -x <Proxy Address>:<Port> %h %p
- #The line below is optional configuration applicable to Fedora.
- #Add when using proxy, otherwise, skip it.
- #ProxyCommand nc --proxy-type socks4 --proxy <Proxy Address>:<Port> %h %p
2.4 上传SSH公钥到Gerrit
打开~/.ssh目录下的id_rsa.pub文件:
- $vim ~/.ssh/id_rsa.pub
将你的公钥添加到gerrit中,这样的话你就可以通过Git指令获得gerrit中的tizen源码了。
2.5 验证SSH连接
执行如下指令:
- $ ssh tizen
输入你之前设置好的SSH密码,然后回车,如果连接正常,将会出现如下界面:
这就表示SSH设置是OK的。
3 配置git
首先得确保安装了git,如果未安装,则执行如下指令进行安装:
- $ sudo apt-get install git
安装完git后得配置git的全局用户名及邮箱:
- $ git config --global user.name flydream0
- $ git config --global user.email [email protected]
然后你可以通过如下指令看到你配置好的内容:
- [email protected]:~/.ssh$ git config --global -l
- color.ui=auto
- user.name=flydream0
- [email protected]
- [email protected]:~/.ssh$
4 下载并配置repo
tizen源码下载借鉴了Android源码下载的方式,因此,我们首先将 Androiod源码下载工具repo下载并设置好。
在~/目录下创建bin目录:
- $cd ~/
- $mkdir bin
- $PATH=~/bin:$PATH
- $cd bin
安装curl工具:
- $sudo apt-get install curl
然后下载repo工具:
- $curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
- $chmod a+x ~/bin/repo
5 下载tizen源码
5.1 在Gerrit中查看tizen源码
在Gerrit中左上角点击projects,projects字下面的List,然后就会看到tizen源码下的所有project,如下所示:
可以发现,tizen下的工程太多了,那么如何下载呢?下载哪些呢?
5.2 初始化repo环境
在浏览器中查找manifest,你会发现有一个工程为:tools/manifest/tizen-2.0-main
我们就先将这个工程下载下来,然后利用这个manifest文件,用 repo工具同步所有tizen源码文件。
我们先建立一下tizen目录:、
- $cd ~/
- $mkdir tizen
- $cd tizen
首先查看自己Gerrit的地址:
- $ ssh tizen
- **** Welcome to Gerrit Code Review ****
- Hi arthur, you have successfully connected over SSH.
- Unfortunately, interactive shells are disabled.
- To clone a hosted Git repository, use:
- git clone ssh://[email protected]:29418/REPOSITORY_NAME.git
- Connection to review.tizen.org closed.
然后使用manifest/tizen-2.0-main初始化repo下载环境:
- $ repo init -u ssh://[email protected]:29418/tools/manifest/tizen-2.0-main
将上面的flydream0替换成你自已的Gerrit用户名,也可以用 $repo init -u ssh://[email protected]:29418/tools/mainifest/tizen-2.0-main.git
有没有git后缀对repo来说都是一样的。
接下来有可能要你输入ssh的密码。再接下来会将tizen源码的环境同步到本地,在当前目录下将会生成.repo隐藏目录。如下图:
注意:这一步下载有点难度,有很大概率会出现如下错误提示:
- fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle
- fatal: error [Errno 101] Network is unreachable
这个是由于网络原因造成,也有人说是天朝神力所致。但不管怎样,多试几次应该会成功的。一旦失败后,必须先检查当前目录下是否存在.repo子目录($ls -al),一旦存在,则删除它(rm -rf .repo/),然后在重新尝试。
5.3 修改manifest.xml清单文件
接下来打开./.repo/manifests/default.xml清单文件:
- $ vim .repo/manifests/default.xml
如下图:
同样将flydream0修改为你自己的Gerrit用户名.
5.4 同步tizen源码
最后下载源码:
- $repo sync -j4
下载界面如下:
下载过程是一个漫长而痛苦的等待过程,之所以说痛苦,那是因为中途还可能会出错,得不断重新输入指令,最后下载完的时间取决于各自的机器与网络速度。
好了,tizen源码的下载就讲到这了,下一章我将继续讲述如何编译tizen 源码及如何生成镜像文件,敬请关注!
6 后续补充
上述方法没有错,但是后来发现用此方法下载时老是出错,错误信息大概如下:
- Fetching projects: 1% (10/915) fatal: '/adaptation/devices/alsa-scenario-files-0.0': not a Gerrit project
- fatal: The remote end hung up unexpectedly
- fatal: '/adaptation/devices/alsa-scenario-files-0.0': not a Gerrit project
- fatal: The remote end hung up unexpectedly
- error: Cannot fetch adaptation/devices/alsa-scenario-files-0.0
打开http://download.tizen.org/链接,会发现这里边有tizen发布的各种版本的镜像文件,找一个比较新的,比如:
在此目录下包含tizen镜像文件tizenxxx.raw.bz2,还有其对应的清单文件ivi-wayland-release-tizen-2.0alpha_20130522.2.manifest.xml,这个清单文件对我们来说非常重要,因为它包含了此tizen版本对镜像文件对应的所有资源链接信息,这样一来,我们就可以利用此清单文件下载到所有源文件!
6.1 下载清单文件
如里你是用firefox浏览单打开的此网页,那么可以右点击 ivi-wayland-release-tizen-2.0alpha_20130522.2.manifest.xml,然后选择cope link location,然后粘贴到wget后面:
- $ wget http://download.tizen.org/releases/daily/2.0alpha/ivi-wayland/tizen-2.0alpha_20130522.2/images/ivi-wayland-release/ivi-wayland-release-tizen-2.0alpha_20130522.2.manifest.xml
6.2 修改清单文件的内容
用vim打开上面下载的清单文件:
- $ vim ivi-wayland-release-tizen-2.0alpha_20130522.2.manifest.xml
当然上述的flyream0需要修改成你自己的Gerrit用户名.
6.3 替换现有的清单文件
先备份好现有的清单文件:
- $ cp .repo/manifests/default.xml default.xml.bak
- $ cp ivi-wayland-release-tizen-2.0alpha_20130522.2.manifest.xml .repo/manifests/default.xml
6.4 同步tizen源码
- $repo sync -j4
再次进入漫长而痛苦的等待过程,这次下载不再出现中途会出现错误的情况了。
下载成功后的界面如下:
有关如何编译tizen源码请参考:http://blog.csdn.net/flydream0/article/details/9004746一文.
好了,祝大家一切顺利。
备注:
备注:
下面是整理的一些问题和解决办法,希望大家在评论中也一起总结和讨论。
$repo sync
等着下载完毕即可完成,repo支持断点续传功能,下次可以再次运行$repo sync下载。可以写脚本自动进行,网上比较多,下面提供一个:
- #!/bin/bash
- echo "======start repo sync======"
- repo sync
- while [ $? = 1 ]; do
- echo "======sync failed, re-sync again======"
- sleep 3
- repo sync
- done
(1)“A new repo command ( 1.18) is available”
解决:依照提示输进去就可以了, cp /home/cfy/android/.repo/repo/repo /home/cfy/bin/repo
(2) error: Failed connect to android.googlesource.com:443;
Connection refused while accessing
https://android.googlesource.com/a/platform/frameworks/base/info/refs
fatal: HTTP request failederror: Cannot fetch platform/tools/motodev
error: Cannot fetch platform/frameworks/base
error: Cannot fetch platform/prebuilts/sdk
error: Exited sync due to fetch errors
等错误信息。
解决:
编辑/etc/hosts文件
$ sudo gedit /etc/hosts
增加下面内容,保存
74.125.237.1 dl-ssl.google.com
74.125.71.82 www.googlesource.com
74.125.31.82 android.googlesource.com
203.208.46.172 cache.pack.google.com
59.24.3.173cache.pack.google.com
注:
google source 的ip 是会改动的,所以使用如下命令:
$ nslookup googlesource.com
$ nslookup android.googlesource.com
查看实际ip,将上面得到ip地址按照74.125.31.82 android.googlesource.com 格式加到/etc/hosts
(3) fatal: '../platform/abi/cpp.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
error: Cannot fetch platform/abi/cpp
解决:
在~/JK_WorkSpace/Android/AndroidResource/Android4.4/.repo下的
manifest.xml里找到fetch属性,改成fetch="git://Android.git.linaro.org"即可
(4) fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle
fatal: error [Errno 101] Network is unreachable
解决:
代理环境变量造成的问题,用下列指令清除代理:
unset HTTP_PROXY
(5)
遇到如下问题:
- [email protected]:~/WORKING_DIRECTORY$ repo init -u https://android.googlesource.com/platform/manifest
- gpg: key 920F5C65: "Repo Maintainer <repo@android.kernel.org>" not changed
- gpg: key 338871A4: public key "Conley Owens <cco3@android.com>" imported
- gpg: Total number processed: 2
- gpg: imported: 1 (RSA: 1)
- gpg: unchanged: 1
- fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle
- fatal: error [Errno 101] Network is unreachable
解决方法,官网说明,和网上统一口径,如下:
- 1, 先按官网的步骤一步步执行
- 2,当遇到上述问题后,用浏览器登录https://android.googlesource.com/new-password,并用gmail帐号登录;
- 3, 点击网页上的“允许访问”,得到类似的结果:
- machine android.googlesource.com login git-<userName>.gmail.com password <password>
- machine android-review.googlesource.com login git-<userName>.gmail.com password <password>
- 将上边的两行追加到~/.netrc文件结尾。(如果你的linux系统中从来没有建立过此文件,就在home目录下建立.netrc文件,将上面的信息加到新建的文件中去),
- 4,下载地址的URI更改为https://android.googlesource.com/a/platform/manifest(中间加上了“/a”)。
- 因为访问基本是匿名的,为了防止连接过多,对同一IP地址的连接数做了一定的限制。用gmail帐号进行认证。
- 在公司网络内或者用虚拟机下载的话,会经常遇到这问题。
待续...