GBS文件配置概述

本文從:https://source.tizen.org/documentation/reference/git-build-system/configuration-file翻譯而來。

1 概述

GBS爲編譯tizen源碼的工具,GBS的配置文件包含GBS所有的配置信息.例如編譯後的根目錄;gbs build的遠程repo url地址;gbs remotebuild的OBS服務器等。

2 GBS如何如何使用配置文件

GBS將會在下述目錄中查找配置文件(.gbs.confi),如果GBS找到多個配置文件,那麼它將按下面的順序來裝載它:

  • /etc/.gbs.conf                 ---全局配置文件,不建議修改(如果存在的話)
  • ~/.gbs.conf                     ---由用戶修改的配置文件
  • $PWD/.gbs.conf           ---局部或本地配置文件

如果同時存在上述三個配置文件中的多個,那麼後面的參數值如果與前面有重複的話,那麼後面的參數值將會覆蓋前面定義的參數值。也可以指定具體使用哪個配置文件,可以在gbs -c(--conf)後面指定具體的配置文件。如果GBS找不到配置文件,那麼它將會生成一個配置文件,並且保存到~/.gbs.conf文件中。

3 配置文件中面向profile的風格

一個profile可以包含gbs build或gbs remotebuild的多項配置。也可以在一個conf文件中同時存在多個profile,以針對多個不同的設備,如手機,IVI等。

默認使用的profile在[general] 的section處定義。

注:這裏section不太好翻譯,它表示的是.gbs.conf文件中以中括號開始到下一個中括號之間的部分。可以包含多個選項,它一般作爲一個整體可以被其它地方索引,中括號內是它的索引名字.

如果你修改[general]的profile索引,那表示使用另一個配置,這可能跟之前的prlfile配置有很大的區別。

section必須遵循如下規則:

profile section的名字必須以profile.開頭。

OBS section的名字必須以obs.開頭。

Repository section的名字必須以repo.開頭。

常用的登陸認證信息可以在profile section部分進行配置,沒必要在不同的obs和repo處進行配置。如果實在是不同的obs和repo的登陸認證信息不一樣,那麼可以在不同的obs和repo section處理進行配置。

下面是一個配置文件的例子:

[general]
#Current profile name which should match a profile section name
profile = profile.tizen
buildroot = ~/GBS-ROOT/

[profile.tizen]
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/

[obs.tizen]
url = https://api.tizen.org
user = xxxx
passwd = xxxx
# 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>

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

4 如何爲gbs build進行配置

repo section部分配置的是倉庫信息,它的名字必須以repo.開頭,它主要包含三項信息:url,user和passwd.

注:當你配置倉庫信息時,請使用release下的目錄,而不是snapshot下的目錄。release下的images/repos是經過release工程師測試過的,而snapshot下的images/repos是由後臺服務自動生成,可靠性沒有保障。

你可以在conf文件中定義多個repo,請看示例:

[profile.tizen]
repos = repo.tizen_latest, repo.my_local

[repo.tizen_latest]
url = http://download.tizen.org/releases/trunk/daily/ivi/latest/
user = xxx
passwd = xxx
[repo.my_local]
#local repo must be an absolute path
url = /path/to/local/repo/

注:本地倉庫必須是絕對路徑。你不必要通過'createrepo'指令來創建那個本地倉庫,只需要寫上註釋即可。

5 爲gbs build配置生成根目錄

默認的gbs build生成的根目錄是~/GBS-ROOT/,不過你可以修改它。如下:

[profile.tizen]
obs = obs.tizen
repos = repo.tizen_latest
buildroot = ~/GBS-ROOT/

注:當使用gbs後,密碼passwd將會被自動修改成passwdx,如下所示:

[obs.tizen]
url = https://api.tizen.org
user = xxxx
passwdx = QlpoOTFBWSZTWVyCeo8AAAKIAHJAIAAhhoGaAlNOLuSKcKEguQT1
如果你要設置新密碼,那麼只需要將passwdx字樣改回passwd,然後修改其後的密碼即可。

6 配置多個profile

針對多種不同的設備,如手機,IVI等,你可以在一個gbs conf文件中配置多個profile,只需要在[general]下指定到底使用哪個profile即可。

如下:

[general]
profile = profile.ivi

[profile.mobile]
...
[profile.ivi]
...

7 在命令行下指定profile

除了在配置文件中指定profile,你也可以在命令行下指令,只需要在gbs build後面使用---profile/-P就可以了。你可以指出profile的全稱(包含profile.前綴),也可以指定不包含profile.前綴的名稱,如下:

$ gbs build --profile=profile.mobile -A i586
$ gbs remotebuild --profile=mobile -A i586   # given profile name without the "profile." prefix

8 在命令行下指定配置文件

如果你預告定義了多個配置文件,那麼你可以命令行下通過使用--conf/-C選項來指定到底使用哪個具體的配置文件,此時,默認的.gbs.conf將會被忽略。如下:

gbs -C ~/gbs-my.conf build -A ...


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章