如何下载tizen源码(图文教程)

来源:互联网 发布:js 判断是否等于nan 编辑:程序博客网 时间:2024/06/05 08:13

当前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工具:

[plain] view plain copy
  1. $ sudo apt-get install ssh  
安装ssh成功后会在~/目录下自动生成.ssh隐藏目录.

2.2 生成RSA密钥

通过如下指令生成RSA密钥:

[plain] view plain copy
  1. ~/.ssh$ ssh-keygen -t rsa -C flydream0  
其中flydream0为提示内容,可以随便写点内容,一般写做自己的用户名就可以了.

系统提示:

[plain] view plain copy
  1. Generating public/private rsa key pair.  
  2. Enter file in which to save the key (/home/arthur/.ssh/id_rsa):   
系统提示保存密钥的保存地址,直接按回车键,默认保存到~/.ssh目录下。

然后系统回提示你设置一个你的密码,两次设置无误后会出现如下界面:

2.3 配置SSH配置文件

进入~/.ssh目录下,创建config文件,将如下内容拷贝进去:

[plain] view plain copy
  1. Host tizen  
  2.   Hostname review.tizen.org  
  3.   IdentityFile ~/.ssh/id_rsa  
  4.   User flydream0  
  5.   Port 29418  
  6.   
  7.   #The line below is optional configuration applicable to Ubuntu and openSUSE.  
  8.   #Add when using proxy, otherwise, skip it.  
  9.   #ProxyCommand nc -X5 -x <Proxy Address>:<Port> %h %p  
  10.   
  11.   #The line below is optional configuration applicable to Fedora.  
  12.   #Add when using proxy, otherwise, skip it.  
  13.   #ProxyCommand nc --proxy-type socks4 --proxy <Proxy Address>:<Port> %h %p  
其中flydream0替换掉你之前注册的Gerrit用户名,不要包含尖括号.

2.4 上传SSH公钥到Gerrit

打开~/.ssh目录下的id_rsa.pub文件:

[plain] view plain copy
  1. $vim ~/.ssh/id_rsa.pub  
复制里边的全部内容,然后返回到gerrit的设置界面,点击左边的SSH Public Keys,然后添加公钥,如下图所示:

将你的公钥添加到gerrit中,这样的话你就可以通过Git指令获得gerrit中的tizen源码了。

2.5 验证SSH连接

执行如下指令:

[plain] view plain copy
  1. $ ssh tizen  
将会提示你输入密码:

输入你之前设置好的SSH密码,然后回车,如果连接正常,将会出现如下界面:

这就表示SSH设置是OK的。

3 配置git

首先得确保安装了git,如果未安装,则执行如下指令进行安装:

[plain] view plain copy
  1. $ sudo apt-get install git  

安装完git后得配置git的全局用户名及邮箱:

[plain] view plain copy
  1. $ git config --global user.name flydream0  
  2. $ git config --global user.email bumaoxia204@163.com  
将flydream0和buamoxia204@163.com替换成你自己的gerrit用户名及邮箱。

然后你可以通过如下指令看到你配置好的内容:

[plain] view plain copy
  1. arthur@arthur-laptop:~/.ssh$ git config --global -l  
  2. color.ui=auto  
  3. user.name=flydream0  
  4. user.email=bumaoxia204@163.com  
  5. arthur@arthur-laptop:~/.ssh$   

4 下载并配置repo

tizen源码下载借鉴了Android源码下载的方式,因此,我们首先将 Androiod源码下载工具repo下载并设置好。

在~/目录下创建bin目录:

[plain] view plain copy
  1. $cd ~/  
  2. $mkdir bin  
  3. $PATH=~/bin:$PATH  
  4. $cd bin  

安装curl工具:

[plain] view plain copy
  1. $sudo apt-get install curl  

然后下载repo工具:

[plain] view plain copy
  1. $curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo  
  2. $chmod a+x ~/bin/repo  
这里就下载并配置好了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目录:、

[plain] view plain copy
  1. $cd ~/  
  2. $mkdir tizen  
  3. $cd tizen  

首先查看自己Gerrit的地址:

[plain] view plain copy
  1. $ ssh tizen  
  2.   
  3.   ****    Welcome to Gerrit Code Review    ****  
  4.   
  5.   Hi arthur, you have successfully connected over SSH.  
  6.   
  7.   Unfortunately, interactive shells are disabled.  
  8.   To clone a hosted Git repository, use:  
  9.   
  10.   git clone ssh://flydream0@review.tizen.org:29418/REPOSITORY_NAME.git  
  11.   
  12. Connection to review.tizen.org closed.  
得出tizen源码链接地址为ssh://flydream0@review.tizen.org:29418/......

然后使用manifest/tizen-2.0-main初始化repo下载环境:

[plain] view plain copy
  1. $ repo init -u ssh://flydream0@review.tizen.org:29418/tools/manifest/tizen-2.0-main  

将上面的flydream0替换成你自已的Gerrit用户名,也可以用 $repo init -u ssh://flydream0@review.tizen.org:29418/tools/mainifest/tizen-2.0-main.git

有没有git后缀对repo来说都是一样的。

接下来有可能要你输入ssh的密码。再接下来会将tizen源码的环境同步到本地,在当前目录下将会生成.repo隐藏目录。如下图:

注意:这一步下载有点难度,有很大概率会出现如下错误提示:

[plain] view plain copy
  1. fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle  
  2. fatal: error [Errno 101] Network is unreachable  

这个是由于网络原因造成,也有人说是天朝神力所致。但不管怎样,多试几次应该会成功的。一旦失败后,必须先检查当前目录下是否存在.repo子目录($ls -al),一旦存在,则删除它(rm -rf .repo/),然后在重新尝试。

5.3 修改manifest.xml清单文件

接下来打开./.repo/manifests/default.xml清单文件:

[plain] view plain copy
  1. $ vim .repo/manifests/default.xml   
将fetch后面的内容修改为:"ssh://flydream0@review.tizen.org:29418",review后面的内容修改为:"https://review.tizen.org/gerrit/"

如下图:

同样将flydream0修改为你自己的Gerrit用户名.

5.4 同步tizen源码

最后下载源码:

[plain] view plain copy
  1. $repo sync -j4  

下载界面如下:


下载过程是一个漫长而痛苦的等待过程,之所以说痛苦,那是因为中途还可能会出错,得不断重新输入指令,最后下载完的时间取决于各自的机器与网络速度。

好了,tizen源码的下载就讲到这了,下一章我将继续讲述如何编译tizen 源码及如何生成镜像文件,敬请关注!



6 后续补充

上述方法没有错,但是后来发现用此方法下载时老是出错,错误信息大概如下:

[plain] view plain copy
  1. Fetching projects:   1% (10/915)  fatal: '/adaptation/devices/alsa-scenario-files-0.0': not a Gerrit project  
  2. fatal: The remote end hung up unexpectedly  
  3. fatal: '/adaptation/devices/alsa-scenario-files-0.0': not a Gerrit project  
  4. fatal: The remote end hung up unexpectedly  
  5. error: Cannot fetch adaptation/devices/alsa-scenario-files-0.0  
发现原来是清单文件的问题,清单文件的链接内容是已经过时的了,因此需要找一个比较新的清单文件来替换现有的清单文件。

打开http://download.tizen.org/链接,会发现这里边有tizen发布的各种版本的镜像文件,找一个比较新的,比如:

http://download.tizen.org/releases/daily/2.0alpha/ivi-wayland/tizen-2.0alpha_20130522.2/images/ivi-wayland-release/,如下所示:


在此目录下包含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后面:

[plain] view plain copy
  1. $ 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打开上面下载的清单文件:

[plain] view plain copy
  1. $ vim ivi-wayland-release-tizen-2.0alpha_20130522.2.manifest.xml  
同5.3节的步骤一样,将fetch后面的内容修改成你自己的Gerrit地址:

当然上述的flyream0需要修改成你自己的Gerrit用户名.

6.3 替换现有的清单文件

先备份好现有的清单文件:

[plain] view plain copy
  1. $ cp .repo/manifests/default.xml default.xml.bak  
然后再替换它:

[plain] view plain copy
  1. $ cp ivi-wayland-release-tizen-2.0alpha_20130522.2.manifest.xml .repo/manifests/default.xml   

6.4 同步tizen源码

[plain] view plain copy
  1. $repo sync -j4  

再次进入漫长而痛苦的等待过程,这次下载不再出现中途会出现错误的情况了。

下载成功后的界面如下:



有关如何编译tizen源码请参考:http://blog.csdn.net/flydream0/article/details/9004746一文.

好了,祝大家一切顺利。



备注

备注
下面是整理的一些问题和解决办法,希望大家在评论中也一起总结和讨论。

$repo sync

       等着下载完毕即可完成,repo支持断点续传功能,下次可以再次运行$repo sync下载。可以写脚本自动进行,网上比较多,下面提供一个:

[plain] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. #!/bin/bash      
  2. echo "======start repo sync======"      
  3. repo sync      
  4. while [ $? = 1 ]; do      
  5. echo "======sync failed, re-sync again======"      
  6. sleep 3      
  7. repo sync      
  8. 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 failed  
       error: 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)

遇到如下问题:

[html] view plain copy
  1. jianguoliao@jianguoliao-Lenovo-IdeaPad-Y470:~/WORKING_DIRECTORY$ repo init -u https://android.googlesource.com/platform/manifest  
  2. gpg: key 920F5C65: "Repo Maintainer <repo@android.kernel.org>" not changed  
  3. gpg: key 338871A4: public key "Conley Owens <cco3@android.com>" imported  
  4. gpg: Total number processed: 2  
  5. gpg:               imported: 1  (RSA: 1)  
  6. gpg:              unchanged: 1  
  7.   
  8.   
  9. fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle  
  10. fatal: error [Errno 101] Network is unreachable  

解决方法,官网说明,和网上统一口径,如下:

[html] view plain copy
  1. 1,  先按官网的步骤一步步执行  
  2. 2,当遇到上述问题后,用浏览器登录https://android.googlesource.com/new-password,并用gmail帐号登录;  
  3. 3, 点击网页上的“允许访问”,得到类似的结果:  
  4.    
  5. machine android.googlesource.com login git-<userName>.gmail.com password <password>  
  6. machine android-review.googlesource.com login git-<userName>.gmail.com password <password>  
  7.  将上边的两行追加到~/.netrc文件结尾。(如果你的linux系统中从来没有建立过此文件,就在home目录下建立.netrc文件,将上面的信息加到新建的文件中去),  
  8. 4,下载地址的URI更改为https://android.googlesource.com/a/platform/manifest(中间加上了“/a”)。  
  9.    
  10. 因为访问基本是匿名的,为了防止连接过多,对同一IP地址的连接数做了一定的限制。用gmail帐号进行认证。  
  11. 在公司网络内或者用虚拟机下载的话,会经常遇到这问题。  

待续...


备注
阅读全文
0 0
原创粉丝点击