http://blog.csdn.net/flydream0/article/details/9004746
前一篇文章已经介绍了如何下载tizen源码(http://blog.csdn.net/flydream0/article/details/8996654),下面我将继续讲述如何编译源码.
1 下载安装gbs编译工具
tizen源码是用gbs工具进行编译的,因此我们首先得将此工具下载下来,并且设置好。
下面以Ubuntu12.04版本为例.
1.1 添加gbs的源
用vim打开source.list文件:
- $ sudo vim /etc/apt/sources.list
在最后添加两行:
- deb http://download.tizen.org/tools/latest-release/Ubuntu_12.04/ /
- deb-src http://download.tizen.org/tools/latest-release/Ubuntu_12.04/ /
如下图:
然后更新源:
- $sudo apt-get update
安装gbs工具:
- $sudo apt-get install gbs
可以相看当前gbs的版本:
- $ gbs -V
- gbs 0.16
1.2 修改.gbs.config文件
安装完gbs工具后,会在用户目录下生成一隐藏文件.gbs.config文件,用vim打开:
- $vim .gbs.config
初始安装gbs后的.gbs.config文件的默认内容如下:
- [general]
- #Current profile name which should match a profile section name
- profile = profile.tizen
- [profile.tizen]
- #Common authentication info for whole profile
- #user =
- #CAUTION: please use the key name "passwd" to reset plaintext password
- #passwd =
- obs = obs.tizen
- #Comma separated list of repositories
- repos = repo.tizen_latest
- #repos = repo.tizen_main, repo.tizen_base
- [obs.tizen]
- #OBS API URL pointing to a remote OBS.
- url = https://api.tizen.org
- #Optional user and password, set if differ from profile's user and password
- #user =
- #passwd =
- #Repo section example
- [repo.tizen_latest]
- #Build against repo's URL
- url = http://download.tizen.org/releases/daily/trunk/ivi/latest/
- #Optional user and password, set if differ from profile's user and password
- #user =
- #passwd =
- #Individual repo is also supported
- #[repo.tizen_base]
- #url = http://download.tizen.org/releases/daily/trunk/ivi/latest/repos/base/ia32/packages/
- #[repo.tizen_main]
- #url = http://download.tizen.org/releases/daily/trunk/ivi/latest/repos/ivi/ia32/packages/
修改为:
- [general]
- #Current profile name which should match a profile section name
- profile = profile.tizen
- [profile.tizen]
- #Common authentication info for whole profile
- #user =
- #CAUTION: please use the key name "passwd" to reset plaintext password
- #passwd =
- obs = obs.tizen
- #Comma separated list of repositories
- #repos = repo.tizen_latest
- repos = repo.tizen_main, repo.tizen_base
- [obs.tizen]
- #OBS API URL pointing to a remote OBS.
- url = https://api.tizen.org
- #Optional user and password, set if differ from profile's user and password
- #user =
- #passwd =
- #Repo section example
- #[repo.tizen_latest]
- #Build against repo's URL
- #url = http://download.tizen.org/releases/daily/trunk/ivi/latest/
- #Optional user and password, set if differ from profile's user and password
- #user =
- #passwd =
- #Individual repo is also supported
- [repo.tizen_base]
- #url = http://download.tizen.org/releases/daily/trunk/ivi/latest/repos/base/ia32/packages/
- url = http://download.tizen.org/releases/daily/2.0alpha/ivi-wayland/tizen-2.0alpha_20130522.2/repos/base/ia32/packages/
- [repo.tizen_main]
- #url = http://download.tizen.org/releases/daily/trunk/ivi/latest/repos/ivi/ia32/packages/
- url = http://download.tizen.org/releases/daily/2.0alpha/ivi-wayland/tizen-2.0alpha_20130522.2/repos/ivi-wayland/ia32/packages/
有关.gbs.config文件的格式说明请参照:http://blog.csdn.net/flydream0/article/details/9018443
2 本地编译源码
编译要求:
OS:Ubuntu12.04(64位)
内存:至少4G
Swap(交换分区大小):至少4G
注:内存和Swap大小都必要至少4G以上,不然会编译不过。操作系统必须是64位的,虽然在32位下也能源码编译通过,但是到后续制作镜像文件(使用mic工具时)会失败。
2.1 编译所有工程
输入如下指令进行编译:
cd到profile目录下, 然后通过如下指令对整个profile进行编译.
- $ gbs build -A i586
接下来要花很长一段时间才能编译完。
编译完后如下界面:
2.2 编译单个工程
当然也可以只针对某个project进行编译,方法很简单,只需要cd到某个project的根目录,然后使用
$gbs build -A i586
即可。
2.3 编译后的输出目录
在默认情况下,gbs build后将用户的工作目录(即~/)下生成GBS-ROOT目录保存下载或编译后的结果。如下:
- $ tree GBS-ROOT/ -L 3
- GBS-ROOT/
- └── local
- ├── BUILD-ROOTS
- │ └── scratch.i586.0
- ├── cache
- │ ├── f55c091634900cdc0c89559765a7b82f
- │ └── f92daa70cae15fb8d7f50595bc454ce0
- ├── order
- ├── repos
- │ └── tizen2.0alpha
- └── sources
- └── tizen2.0alpha
其中repos目录保存着RPM包:
- $ tree repos/ -L 3
- repos/
- └── tizen2.0alpha
- └── i586
- ├── logs
- ├── repodata
- ├── RPMS
- └── SRPMS
其中RPMS和SRPMS保存着编译后的结果RPM包,这些包为下一步制作镜像文件提供RPM包。
3 远程编译源码
tizen
源码不但可以在本地进行编译,还可以使用远程编译。所谓远程编译就是将本地的修改自动上传到远程服务器OBS进行编译。对于tizen源码,使用gbs
remotebuild指令来进行相关操作。这对于本地PC资源达不到要求的情况是十分有用的,只可惜远程编译需要授权才能进行,而目前我没有可以使用的
用户名和密码,因此,没有试验成功过。
有关如何制作镜像文件我将在后续文章中描述,敬请关注!