본문 바로가기

IT/Tizen

[Tizen] 타이젠 gbs의 모든 것

타이젠에 올라가는 앱은 타이젠 SDK를 사용하여 빌드할 수 있습니다.

하지만, 타이젠 플랫폼 자체를 빌드하기 위해서는 SDK로는 안됩니다.


타이젠 그룹에서는 타이젠 플랫폼의 패키지들을 빌드할 수 있는 환경을 제공하고 있습니다.

타이젠 개발자들은 실제로 이러한 방법으로 패키지를 만들어내고 있습니다.


지금 이 순간에도,

세계 각지의 타이젠 개발자들은 타이젠 빌드서버에 접속하여 빌드를 하고 있습니다.



안녕하세요, Tizen 개발자 윤진입니다.


gbs를 사용하려면 우선 설치가 되어 있어야겠지요?

gbs는 아래 포스팅을 참고하여 설치하실 수 있습니다.

"우분투에 Tizen 플랫폼 툴인 gbs & sdb 설치해보기, http://storycompiler.tistory.com/35"


우분투 15.04 환경에서 gbs가 동작하지 않는 문제가 있습니다.

이 문제는 아래 포스팅을 참고해주세요.

[Tizen] 우분투 15.04에서 gbs 실행에러 처리


gbs는 Git Build System의 약자로,

타이젠 플랫폼의 패키지를 빌드하기 위한 커맨드라인 툴입니다.

- Git repo.를 기준으로 tar.gz 파일을 생성한 뒤,

- 로컬 빌드를 수행하고,

- 타이젠 메인에 업로드할 수 있습니다.



gbs로 빌드하기 위해서는 위의 그림 좌우에 있는 4개의 박스가 필요합니다.

- Source Code

   git을 기반으로한 소스 repository는 빌드 대상이 되겠지요.

   타이젠 오픈소스는 아래 포스팅을 참고하여 클론 받으실 수 있습니다.

   "Tizen 오픈소스 모두 내려받기, http://storycompiler.tistory.com/16"

- Build config

   gbs의 설정파일은 빌드하기 위한 방법이 명시되어 있습니다.

- Repositories

   빌드하기 위한 재료입니다. 플랫폼을 이루는 rpms가 저장된 곳이지요.

- Local repository

   플랫폼을 이루는 패키지 중 일부만 임의로 변경하고자 하는 경우에,

   Local repo.에 패키지를 설치해두면 됩니다.

   gbs는 빌드를 하며 Local repo.를 먼저 살펴보고 패키지를 찾기 때문이죠.

   Local repo.에 패키지가 없으면 Repositories에서 찾습니다.

   대부분 패키지는 Repositories에서 찾게 되겠지요.


gbs, source를 구비했다면 이제 빌드를 위한 기본설정을 할 차례입니다.

설정을 한 파일은 아래 위치 중 한 군데에 놓으면 됩니다.


  • $PWD/.gbs.conf: project-specific configuration settings that affect only the specific project in the specified working directory. These settings have the highest precedence.
  • /home/<user>/.gbs.conf: user-specific configuration settings that affect only the specified user.
  • /etc/gbs.conf: system-wide configuration settings that affect the entire system. These settings have the lowest precedence.


상단에 있는 $PWD/.gbs.conf의 우선순위가 가장 높고,

/etc/gbs.conf의 우선순위가 가장 낮습니다.

우선순위 순으로 conf 파일을 찾아보고 높은 순위의 conf 설정대로 빌드가 수행되죠.


gbs 명령은 빌드하고자 하는 프로젝트의 디렉토리에서 수행합니다.

혹은 다수의 프로젝트를 빌드하기 위해서는 프로젝트들이 모여있는 디렉토리에서 하면 되지요.

$PWD는 gbs를 수행하는 그 위치를 의미합니다.

gbs가 실행되면 우선적으로 명령을 실행한 디렉토리에 .gbs.conf 파일이 있는지 확인하게 됩니다.


위의 위치에 .gbs.conf가 없다면,

일반적으로 설정 파일을 놓는,

/home/<user>/.gbs.conf 파일을 참조하게 됩니다.

다수의 프로젝트를 빌드하려면 위의 위치에 .gbs.conf 파일을 설치하는 편이 좋습니다.


마지막으로 /etc/gbs.conf는 어느 사용자나 사용할 수 있는 설정파일입니다.

다수의 사용자를 위해 gbs 환경을 제공해야하는 경우에 사용하면 됩니다.


그 외의 위치에 다른 이름으로 conf 파일을 만들고자 하는 경우도 있을 겁니다.

그럴 때에는 gbs 명령을 수행할 때 별도의 위치에 다른 이름으로 있다는 것을 gbs에 알려줘야 합니다.

-c 옵션으로 conf 파일의 위치를 넘겨줄 수 있습니다.

$ gbs -c ~/my-gbs.conf build ...


gbs를 설치하였다면,

기본적으로 /home/<user>/.gbs.conf 파일이 설치되어 있을 겁니다.

그 내용을 먼저 살펴보겠습니다.


$ cat ~/.gbs.conf 
[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
#Build config for gbs build
#buildconf = <patch/to/build-config-file>
#Comma separated list of additional packages be excluded building
#exclude_packages = libtool,gettext

[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/


위의 설정값 중 굵은 글씨로 표시된,

[repo.tizen_latest] 섹션의 url 필드값만 변경하면 빌드를 할 수 있습니다.

url 필드에 타이젠 플랫폼의 릴리스 바이너리 주소를 입력하면 드디어 빌드를 위한 재료가 준비된 셈입니다.

url 필드에 입력하는 주소로 빌드에 사용할 플랫폼의 버전을 선택할 수 있습니다.

타이젠 플랫폼에는 2015. 6. 6 현재 10개의 릴리스 버전이 있습니다.

각각의 릴리스 버전 아래에 url을 명시해두었으니 복사해서 쓰시면 됩니다.


- Tizen 1.0 : 2012년 4월 30일 첫번째 빌드

   url = 없음, gbs 빌드 대상이 아니었음.

- Tizen 2.0 Emulator : 2013년 2월 18일 7번째 빌드

   url = http://download.tizen.org/releases/2.0-emul/tizen-2.0-emul_20130218.7/repos/base/ia32/packages/

- Tizen 2.0 : 2013년 2월 19일 4번째 빌드

   url = http://download.tizen.org/releases/2.0/latest/

- Tizen 2.1 Beta : 2013년 5월 5일 3번째 빌드

   url = http://download.tizen.org/releases/2.1b/tizen-2.1_20130505.3/

- Tizen 2.1 : 2013년 5월 17일 6번째 빌드

   url = http://download.tizen.org/releases/2.1/latest/

- Tizen 2.2 Beta : 2013년 7월 1일 5번째 빌드

   url = 없음

- Tizen 2.2 Emulator : 2013년 7월 19일 2번째 빌드

   url = http://download.tizen.org/releases/2.2-emul/latest/

- Tizen 2.2 : 2013년 7월 19일 3번째 빌드

   url = http://download.tizen.org/releases/2.2/latest/

- Tizen 2.2.1 : 2013년 11월 7일 3번째 빌드

   url = http://download.tizen.org/releases/2.2.1/latest/

- Tizen 2.3 : 2015년 3월 11일 3번째 빌드

   [mobile]

   url = http://download.tizen.org/releases/2.3/2.3-mobile/tizen-2.3-mobile_20150311.3/

   [wearable]

   url = http://download.tizen.org/releases/2.3/2.3-wearable/tizen-2.3-wearable_20150311.3/


각각의 릴리스 버전은 아래 사이트에서도 확인할 수 있습니다.

릴리스 사이트 : http://download.tizen.org/releases/



위에서 클론을 받은 타이젠 소스 repo.에서 gbs를 수행해보시죠.

$ gbs build -A i586
info: generate repositories ...
info: build conf has been downloaded at:
      /var/tmp/usr-gbs/tizen.conf
info: start building packages from: /home/user/tizen/apps/apps.home.settings (git)
2015-06-07 00:38 +0900
gbs 0.23.2
info: prepare sources...
info: start export source from: /home/user/tizen/apps/apps.home.settings ...
Argument "" isn't numeric in numeric eq (==) at /usr/bin/depanneur line 642.
warning: Deprecated option '--git-export-only', please use '--no-build' instead!
info: Creating (native) source archive org.tizen.setting-0.1.98.tar.gz from 'HEAD'
info: package files have been exported to:
     /home/user/GBS-ROOT/local/sources/tizen/org.tizen.setting-0.1.98-99
info: retrieving repo metadata...
info: parsing package data...
info: building repo metadata ...
info: resolving skipped packages ...
info: package dependency resolving ...
info: next pass:
org.tizen.setting
...


첫 빌드는 릴리스 패키지를 다운로드 & 인스톨해야 하므로 꽤나 시간이 걸립니다.

하지만, 두번째 빌드부터는 첫번째 빌드에서 구축한 환경에서 이뤄지므로 금방 빌드를 할 수 있습니다.


만약 빌드를 진행하다가 멈춘다면,

$ gbs build -A armv7l --clean --clean-repos

설치도중 에러가 발생한 것일 수도 있으니,

clean으로 깨끗이 정리한 뒤 다시 빌드를 시도해보세요.


빌드를 성공하면 아래와 같은 메시지를 볼 수 있습니다.

...
info: finished building starter
info: updating local repo
info: *** Build Status Summary ***
=== Total succeeded built packages: (1) ===
info: generated html format report:
     /home/user/GBS-ROOT/local/repos/tizen/i586/index.html
info: generated RPM packages can be found from local repo:
     /home/user/GBS-ROOT/local/repos/tizen/i586/RPMS
info: generated source RPM packages can be found from local repo:
     /home/user/GBS-ROOT/local/repos/tizen/i586/SRPMS
info: build logs can be found in:
     /home/user/GBS-ROOT/local/repos/tizen/i586/logs
info: build roots located in:
     /home/user/GBS-ROOT/local/BUILD-ROOTS/scratch.i586.*
info: Done


위에서 굵은 글씨로 표시되어있는 장소가,

빌드 결과물인 rpm 파일이 저장되어 있는 위치입니다.


빌드를 해보았으니,

conf 파일을 자세히 살펴보아 자신의 환경에 맞게 설정해보도록 하죠.


conf 파일은 총 4개의 섹션으로 이뤄져 있습니다.

[general] / [profile] / [obs] / [repo]

위의 4가지 섹션을 각각 살펴보겠습니다.

개인적으로 사용하는  .gbs.conf 파일을 붙여놓겠습니다.

gbs.conf

[general]
#upstream_branch = upstream
packaging_branch = tizen_2.3
buildroot = ~/GBS-ROOT/
packaging_dir = packaging
#Current profile name which should match a profile section name
profile = profile.mobile
#tmpdir = /var/tmp
#work_dir = .


- upstream_branch = master

  $ gbs clone 명령어로 다운로드 받을 upstream branch를 지정할 수 있습니다.

  git에서 master는 기본으로 다운로드 받으니 위의 명령어는 주석처리해도 무방합니다.

  실질적으로 쓸모가 없고, 최신 gbs에서 에러를 뱉네요.


- packaging_branch

  $ gbs clone 명령어로 git을 클론 받을 수도 있습니다.

  clone을 받은 후에 checkout 되는 브랜치를 general에서 미리 지정할 수 있습니다.


- buildroot

   빌드를 수행하기 위해 필요한 환경은 buildroot 디렉토리에 구축됩니다.

   각 프로파일별로도 buildroot를 만들 수 있습니다.

   만약 프로파일에서 설정한 buildroot가 없다면 general 섹션을 참고하게 됩니다.


- packaging_dir

  rpm패키징을 위해 설정하는 spec파일의 위치를 지정할 수 있습니다.

  default는 root/packaging이니, packaging으로 설정해두면 됩니다.


- profile

   타이젠은 멀티 프로파일을 지향하는 플랫폼입니다.

   모바일/웨어러블/자동차 등을 타겟으로 하고 있죠.

   따라서 빌드도 각 프로파일별로 수행할 수 있습니다.

   Default로 빌드할 프로파일은 위의 프로파일에서 지정할 수 있습니다.

   하지만, 빌드타임에 프로파일을 변경하고자 하면,

   $ gbs build --profile=profile.wearable -A i586

   위와 같이 --profile 옵션을 사용해야 합니다.


- tmpdir / work_dir

  general에는 변수선언이 가능합니다.

  다른 섹션에서 ${tmpdir}이나 ${work_dir}과 같이 변수를 사용할 수 있습니다.


[profile.mobile]
obs = obs.tizen
repos = repo.tizen_latest
# If no buildroot for profile, the buildroot in general section will be used
#buildroot = ~/GBS-ROOT-profile.tizen/
# Specify build conf for a specific profile by using shell-style variable references
#buildconf = ${work_dir}/tizen-conf/build.conf
# Specify a list of packages that don't participate in the building, which
# can also be used to break dependency circle.
#exclude_packages=filesystem,aul,libmm-sound,libtool
# Common authentication information
#user = xxx
#passwd = xxx


- obs

  프로파일을 remote에서 빌드하고자 할 때 참고하고, 

  obs 섹션과 동일한 이름을 넣어야 합니다.


- repos

  타이젠 플랫폼 패키지들이 있는 위치가 명시되어 있는 repos 섹션을 넣습니다.


- buildroot

  프로파일마다 buildroot를 다르게 지정하고자 하는 경우 입력합니다.

  그렇지 않으면 [general]에서 설정한 값이 설정됩니다.


- exclude_packages

  다수의 패키지를 빌드하고자 할때 빌드풀에 포함시키지 않을 패키지를 넣습니다.


- user / passwd

  repo.에 접근할 때 권한이 필요한 경우 넣어줍니다.

  repo.별로도 설정할 수 있습니다.


[obs.tizen]
url = https://api.tizen.org
user = xxx
passwd = xxx
# set default base_prj for this obs
#base_prj=Tizen:Main
# set default target prj for this obs, default is home:<user>:gbs:<base_prj>
#target_prj=<specify target project>


- url

  remote 빌드를 하기 위한 주소를 입력합니다.


- user / passwd

  remote 서버에 권한이 필요하다면 입력해주어야 합니다.


- base_prj

  remote 서버에서 빌드하고자 하는 패키지가 속한 base 프로젝트를 선택해둡니다.


- target_prj

  패키지가 장차 체크인될 프로젝트를 선택할 수도 있습니다.

  통상 base 프로젝트와 동일한 프로젝트를 입력합니다만,

  베이스 따로 타겟 따로 지정할 수도 있습니다.


[repo.tizen_2.1]
url = http://download.tizen.org/releases/2.1/latest/
#Optional user and password, set if differ from profile's user and password
#user =
#passwd =


- url

   url은 빌드를 수행하기 위해 dependency가 있는 모든 rpm이 다운로드 받을 수 있는 위치를 지정해야 합니다.

   로컬의 절대경로일 수도 있고, 인터넷 주소일 수도 있습니다.


- user / passwd

   위의 url에 접근하기 위해 별도의 권한이 필요한 경우 지정할 수 있습니다.

   타이젠은 오픈이기 때문에 user / passwd를 설정해줄 필요가 없습니다.


이상으로 gbs에 대한 설명을 마치겠습니다.

gbs를 사용하는 분들께 도움이 되면 좋겠습니다. :)


끝_


* References

https://source.tizen.org/documentation/reference/git-build-system?langredirect=1

https://source.tizen.org/documentation/reference/git-build-system/configuration-file

https://source.tizen.org/documentation/reference/git-build-system/usage/gbs-build?langredirect=1