在一个页面从头开始生成Tizen IVI镜像

简介

本文档提供了有关如何从无到有的一步一步的创建Tizen IVI镜像的指导信息。

本文档将引导用户建立最新的Tizen IVI里程碑版本:

https://download.tizen.org/releases/milestone/tizen/ivi/tizen_20140422.1/

下面的部分包括:

  • 克隆源代码
  • 使用GBS编译所有包
  • 使用MIC创建镜像

克隆Tizen源代码

确保以下准备工作已经做好:

  • Gerrit账号有效可用。
  • ~/.ssh/config已经正确配置,如下:
Host review.tizen.org
Hostname review.tizen.org
Port 29418
User <INPUT_YOUR_USER>
# ProxyCommand connect -S <proxy:port> %h %p
 
Host tizen
Hostname review.tizen.org
Port 29418
User <INPUT_YOUR_USER>
# ProxyCommand connect -S <proxy:port> %h %p

更多关于账户注册和配置信息,请参考以下链接:

https://source.tizen.org/documentation/developer-guide/environment-setup

假设Tizen IVI源目录是~/tizen_ivi_src,执行以下命令克隆源代码:

$ mkdir ~/tizen_ivi_src & cd ~/tizen_ivi_src
$ repo init -u tizen:scm/manifest -b tizen -m ivi.xml
$ wget https://download.tizen.org/releases/milestone/tizen/ivi/tizen_20140422.1/builddata/manifest/tizen_20140422.1_ia32.xml -O .repo/manifests/ivi/projects.xml
$ sed -i '3,4d' .repo/manifests/ivi/projects.xml # remove duplicated <remote> and <default> lines
$ repo sync -j 32 # sync code

如果tizen_ivi分支最新版本的build-config发生了变化,这将导致一些包构建失败,那么请按照此命令使用正确的版本:

$ cd scm/meta/build-config && git checkout afede20b3af513e25eac44d725d19097ba8e541f && cd -

这只适用于tizen_20140422.1版本,最新的tizen_ivi分支的build-config适用于最新的tizen IVI。

有关克隆源代码的其他场景,请参考https://source.tizen.org/documentation/developer-guide/getting-started-guide/cloning-tizen-source第2.2.2节

使用GBS编译所有包

更新GBS配置

添加远程仓储库来更新~/tizen_ivi_src/.gbs.conf

[general]
tmpdir=/var/tmp/
profile = profile.tizen3.0_ivi
work_dir=.
 
[repo.tizen3.0_x86]
url=${work_dir}/pre-built/toolchain-x86/
 
# Newly added repo
[repo.tizen3.0_ivi]
url=https://download.tizen.org/releases/milestone/tizen/ivi/tizen_20140422.1
 
[profile.tizen3.0_ivi]
repos=repo.tizen3.0_x86, repo.tizen3.0_ivi
buildconf=${work_dir}/scm/meta/build-config/build.conf

有关.g​​bs.conf其他profiles的详细信息,请参见第2.3节 https://source.tizen.org/documentation/developer-guide/getting-started-g...

修复已知的打包错误

因为打包问题导致的gbs输出失败,下列软件包将不会被编译。

  • platform/upstream/qtchooser
  • platform/upstream/xkeyboard-config
  • platform/core/uifw/libhangul

所有这些由于上游分支或/和上游标签无法与远程清单的commit ID工作导致的打包错误,将导致GBS输出失败,错误信息如下:

info: tracking branch: origin/upstream -> upstream
info: tracking branch: origin/pristine-tar -> pristine-tar
error: Invalid upstream treeish upstream/2.7
error: Generating upstream tarball and/or generating patches failed. GBS tried this as you have upstream branch in you git tree. Fix the problem by either:
1. Update your upstream branch and/or fix the spec file. Also, check the upstream tag format.
2. Remove or rename the upstream branch (change the package to native)
See https://source.tizen.org/documentation/reference/git-build-system/upstream-package for more details.
error: <gbs>Failed to export packaging files from git tree

或者,如:

info: Generating patches from git (upstream/39..HEAD)
error: Start commit 'upstream/39' not an ancestor of end commit 'HEAD'
error: Generating upstream tarball and/or generating patches failed. GBS tried this as you have upstream branch in you git tree. Fix the problem by either:
1. Update your upstream branch and/or fix the spec file. Also, check the upstream tag format.
2. Remove or rename the upstream branch (change the package to native)
See https://source.tizen.org/documentation/reference/git-build-system/upstream-package for more details.
error: <gbs>Failed to export packaging files from git tree

要解决这个错误,只需为这个工程添加一个默认.gbs.conf,并从HEAD产生tar包。

$ cd ~/tizen_ivi_src/<path/to/package/dir>
$ echo -e "[general]\nupstream_branch=NONE" >.gbs.conf
$ git add .gbs.conf && git commit -m "don't use upstream branch"

编译所有包

只要下载了所有的Tizen源代码,并且gbs.conf文件也正确配置,下一步就可以使用GBS编译所有源码:

# For Devices image
$ nohup gbs build -A i586 --threads=4 --exclude=libtool,gettext,emulator-yagl >build.log 2>&1 &
# For emulator image
$ nohup gbs build -A i586 --threads=4 --exclude=libtool,gettext,mesa >build.log 2>&1 &
$ tail -f build.log

注:

  1. libtool和gettext将打破依赖循环,因为GBS不支持使用依赖循环构建多个包。
  2. 只有emulator-yagl和mesa以被构建。 mesa针对设备镜像,反之emulator-yagl针对模拟器镜像。

一旦GBS构建完成后,可以在build.log文件查看总结报告,使用上面的命令可以获取。 可能会出现以下错误:

  • 输出错误
  • 依赖缺失错误
  • RPM编译错误

在我们实验构建时,以下三个包的生成错误是由于缺少依赖关系:

=== the following packages failed to build due to missing build dependencies (3) ===
cross-i386-gcc48-icecream-backend:
nothing provides cross-i386-binutils
gcc48-testresults:
nothing provides fastjar
nothing provides dejagnu
libgcj48:
nothing provides fastjar

上面的错误可以忽略不计,因为这三个包仍然没有被构建到编译系统中,不影响最终镜像的生成。 libffi48构建错误的问题,由于同样的原因也可忽略。

有些软件包的构建可能会失败,以下是错误日志:

[ 0s] Memory limit set to 21760284KB
[ 0s] Using BUILD_ROOT=/home/<User>/tizen_IVI_BUILD_ROOT/local/BUILD-ROOTS/scratch.i586.0
[ 0s] Using BUILD_ARCH=i686:i586:i486:i386:noarch
[ 0s] processing specfile /home/<User>/tizen_IVI_BUILD_ROOT/local/sources/tizen3.0_ivi/unifdef-2.8-1/unifdef.spec ...
[ 0s] init_buildsystem --configdir /usr/lib/build/configs --cachedir /home/<User>/tizen_IVI_BUILD_ROOT/local/cache --repository /home/<User>/tizen_IVI_BUILD_ROOT/local/repos/tizen3.0_ivi/i586/RPMS --repository /home/<User>/tizen/pre-built/toolchain-x86/ --repository http://linux-ftp.bj.intel.com/pub/mirrors/tizen/releases/milestone/tizen/ivi/tizen_20140422.1/repos/ivi/ia32/packages --repository http://linux-ftp.bj.intel.com/pub/mirrors/tizen/releases/milestone/tizen/ivi/tizen_20140422.1/repos/emul/ia32/packages /home/<User>/tizen_IVI_BUILD_ROOT/local/sources/tizen3.0_ivi/unifdef-2.8-1/unifdef.spec ...
[ 0s] initializing /home/<User>/tizen_IVI_BUILD_ROOT/local/BUILD-ROOTS/scratch.i586.0/.srcfiles.cache ...
[ 0s] /usr/lib/build/createrpmdeps /home/<User>/tizen_IVI_BUILD_ROOT/local/repos/tizen3.0_ivi/i586/RPMS
[ 0s] /usr/lib/build/createrepomddeps /home/<User>/tizen/pre-built/toolchain-x86/
[ 0s] /usr/lib/build/createrepomddeps --cachedir=/home/<User>/tizen_IVI_BUILD_ROOT/local/cache http://download.tizen.org/releases/milestone/tizen/ivi/tizen_20140422.1/repos/ivi/ia32/packages
[ 1s] Couldn't open /home/<User>/tizen_IVI_BUILD_ROOT/local/cache/338f7aa828eb615f0dfd4593f33ae5f2/repodata/repomd.xml:
[ 1s] No such file or directory at /usr/lib/build/createrepomddeps line 436

这是由网络错误引起一个已知的问题,这是可以通过使用相同的GBS命令重新构建来修复。

使用MIC创建镜像

本节将介绍如何下载和配置KS文件,然后它将被用于与MIC一起创建镜像。

更多信息请参考:
https://source.tizen.org/documentation/developer-guide/getting-started-guide/creating-tizen-images-mic

下载ks文件

http://download.tizen.org/releases/milestone/tizen/ivi/tizen_20140422.1/builddata/image-configs/下载指定的ks文件

$ wget http://download.tizen.org/releases/milestone/tizen/ivi/tizen_20140422.1/builddata/image-configs/ivi-release-mbr-i586.ks -O ~/tizen_ivi_src/ivi-release-mbr-i586.ks

更新ks文件

基于以下的diff内容更新KS文件:

-repo --name=ivi --baseurl=http://download.tizen.org/snapshots/tizen/ivi/ivi-release/@BUILD_ID@/repos/ivi/ia32/packages/
+repo --name=ivi --baseurl=http://download.tizen.org/releases/milestone/tizen/ivi/tizen_20140422.1/repos/ivi/ia32/packages/
+repo --name=local --baseurl=file:///home/<user>/GBS-ROOT/local/repos/tizen3.0_ivi/i586 --priority=1
+repo --name=local-toolchain --baseurl=file:///home/<user>/tizen_ivi_src/pre-built/toolchain-x86/ --priority=2

创建Tizen镜像

执行以下命令创建Tizen镜像:

$ cd ~/tizen_ivi_src/
$ rm /var/tmp/mic/cache/packages/ivi/ -rf
$ time sudo mic cr auto ivi-release-mbr-i586.ks –tmpfs
...
INFO: The new image can be found here:
/home/<User>/tizen_ivi_src/mic-output/ivi-release-mbr-i586-201405141920-sdb.bmap
/home/<User>/tizen_ivi_src/mic-output/ivi-release-mbr-i586-201405141920-sdb.raw.bz2
/home/<User>/tizen_ivi_src/mic-output/ivi-release-mbr-i586-201405141920.xml
/home/<User>/tizen_ivi_src/mic-output/ivi-release-mbr-i586-201405141920-vmlinuz-3.13.3-3-x86-ivi
INFO: Finished.
real 3m21.476s
user 2m57.236s
sys 0m7.864s

下一步是检查所有用来生成镜像的包是否来自本地repo,这可以通过检查MIC的缓存目录来完成:

$ find /var/tmp/mic/cache/packages/ivi/
/var/tmp/mic/cache/packages/ivi/
/var/tmp/mic/cache/packages/ivi/libmm-player-0.2.19-12.4.i686.rpm
/var/tmp/mic/cache/packages/ivi/libhangul-0.1.0-12.1.i686.rpm

在上述情况下,本地构建错误导致会从远程存储库下载这两个包。

至目前为止,镜像生成已经完成。