From Fedora Project Wiki
(sync en)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{autolang}}
{{autolang}}
= 在 Fedora 中使用 Koji 构建系统 =
= 在 Fedora 中使用 Koji 构建系统 =


[[Koji| Koji 构建系统]] 是 Fedora 的 RPM 构建系统。打包人员需要使用相应客户端来请求构建并获得有关信息。Koji 运行在 Mock 之上来构建针对不同架构的 RPM,其自身包含多个架构的几十台在线构建宿主。
[[Koji| Koji 构建系统]] 是 Fedora 的 RPM 构建系统。打包人员需要使用 koji 客户端来请求构建包,并获得构建系统返回的相关信息。Koji 运行在 Mock 之上来构建不同架构的 RPM 包,并确保它们正确构建。服务自身包含多个架构的几十台在线构建宿主机。
 
这里还有一个 [[Zh/使用Koji编译打包系统|简体中文版本]]。


== 安装 Koji ==
== 安装 Koji ==
Line 8: Line 11:
==== 安装 Koji CLI ====
==== 安装 Koji CLI ====


Everything you need to use Koji (and be a Fedora contributor) can be installed in a single step:
要使用 Koji(需要您是 Fedora 的贡献者),请安装 fedora-packager 包:
 
<pre>
<pre>
yum install fedora-packager
dnf install fedora-packager
</pre>
</pre>


fedora-packager provides useful scripts to help maintain and setup your koji environment. Additionally, it includes dependencies on the Koji CLI, so it will be installed when you install <code>fedora-packager</code>.  The command is called <code>koji</code> and is included in the main koji package. By default the koji tool authenticates to the central server using Kerberos.  However SSL and username/password authentications are available. You will need to have a valid authentication token to use many features. However, many of the read-only commands will work without authentication.
fedora-packager 提供了一系列脚本帮助你安装和管理 koji 环境。额外地,它也包括了 Koji CLI 的依赖,当安装 <code>fedora-packager</code> 时 CLI 工具会被自动安装。该命令名为 <code>koji</code>,包含在 koji 主包里。koji 工具默认使用 Kerberos 协议认证客户端和中心服务器。您需要具备一个有效的认证令牌,才能使用 Koji 服务。否则,在未认证的情况下,只能运行只读命令。
 
如果您需要身份验证方面的帮助,或想成为 Fedora packager,请查看本指南:[[Join_the_package_collection_maintainers]]<br>
您需要安装 fedora-packager 软件包,执行 fedora-packager-setup 并获得有效的 kerberos 票据以执行构建。


==== Fedora 账户系统设置 ====
==== 初始化 Fedora Setup ====


In order to interface with the koji server, maintainers will need to run
为了使用 Koji 服务器,软件包维护者需要运行:
<pre>
<pre>
/usr/bin/fedora-packager-setup
/usr/bin/fedora-packager-setup
</pre>
</pre>


Each user on a system will need to run fedora-packager-setup if they wish to use Koji to build Fedora packages. Each user has their own certificates that authenticate them.
如果用户需要使用 Koji 去构建 Fedora 的软件包,则必须要运行一次该命令。每个用户都必须拥有他们的证书用于认证身份。
 
{{admon/tip|Plague users rejoice!|For existing users of plague (the old build system that preceded Koji), <code>fedora-packager-setup</code> will use your existing certificates.  If you did not have plague before, it will get the server CA certs and tell you where to get your user cert.}}
 
===== Fedora 证书 =====
Koji uses three certificates:
; <code>~/.fedora.cert</code> (specific to the Fedora Maintainer) : This cert is generated from running <code>fedora-cert -n</code>. It should have been generated when you became maintainer. You may need to refresh it when it expires.  You can check if it has expired with <code>fedora-cert -v</code>.
 
the following are downloaded automatically by fedora-packager-setup and dont need to be manually setup
 
; <code>~/.fedora-upload-ca.cert</code> (The certificate for the Certificate Authority used to sign the user keys.) : It can be manually downloaded from [https://admin.fedoraproject.org/accounts/fedora-upload-ca.cert here] or <code>fedora-packager-setup or fedora-cert -n</code> should fetch it. using the CLI is prefered.
; <code>~/.fedora-server-ca.cert</code> (The certificate for the Certificate Authority used to sign the build system's server keys.) : It can be downloaded manually from [https://admin.fedoraproject.org/accounts/fedora-server-ca.cert here] or <code>fedora-packager-setup</code> should fetch it.
 
{{admon/warning|RHEL6 cert bug|If you're using RHEL6, an incompatibility between RHEL6's openssl and nss causes certificates downloaded from fas to fail to work with some fedpkg tools.  [[https://bugzilla.redhat.com/show_bug.cgi?id=631000 Bug 631000 rhel6 openssl creates PKCS#8 encoded PEM RSA private key files, nss can't read them]].  The cert can be made compatible using this command: <code>(openssl x509 -in ~/.fedora.cert -text; echo; openssl rsa -in ~/.fedora.cert) > fedora.cert.new</code>}}
 
==== Koji 设置 ====
The global local client configuration file for koji is <code>/etc/koji.conf</code>. You should not need to change this from the defaults for building Fedora packages.These will allow you to use the primary build system as well as secondary arch build systems.
 
== The web interface ==
 
{{admon/tip|Optional|The web interface is optional.  You may skip to the
next section if you like.}}
 
The primary interface for viewing Koji data is a web application.
It is available at http://koji.fedoraproject.org/koji/ .
Most of the interface is read-only, but with sufficient privileges,
you can log in and perform some additional actions. For example:
 
* Cancel a build
* Resubmit a failed task
* Setup a notification
 
Those with admin privileges will find additional actions, such as:
 
* Create/Edit/Delete a tag
* Create/Edit/Delete a target
* Enable/Disable a build host
 
The web site utilizes SSL authentication. In order to log in you will need a
valid SSL certificate and your web browser will need to be configured to trust
the SSL cert.  Instructions on how to do this are printed when running
<code>fedora-packager-setup --with-browser-cert</code>.
 
{{admon/warning|Using the certificate directly downloaded from the FAS web
interface|If you have generated and downloaded the certificate
<code>~/.fedora.cert</code> directly from FAS using the form referenced
above, you need to convert it into a format that the browser can understand
using the following command:
<code>openssl pkcs12 -export -in ~/.fedora.cert -CAfile ~/.fedora-upload-ca.cert -out ~/fedora-browser-cert.p12</code>,
where <code>.fedora-upload-ca.cert</code> can be downloaded from the URL
referenced above.}}
 
==== Installing SSL Certificates in Firefox ====
 
{{admon/note|Optional|You only need to check these instructions if you are intending to authenticate with the web interface with Firefox.  Authenticating with the web interface is optional.}}
 
Once you have created your FAS account, generated your certificate in the
form posted in the link above and ran
<code>fedora-packager-setup --with-browser-cert</code>, you will need
to import it into your web browser. You can do this in Firefox by doing
the following:
 
1. Launch Firefox and click on the '''Edit''' menu from the toolbar


2. Select '''Preferences''' in  the sub-menu which appears.
==== Fedora 证书 ====
Koji 使用以下三份证书:


3. This should open the '''Preferences''' window where you can switch to the '''Advanced''' section
; <code>~/.fedora.cert</code>(给与 Fedora 软件包维护者) : 此份证书是在 [[Infrastructure/AccountSystem | FAS]] 的 [https://admin.fedoraproject.org/accounts/user/gencert 此页面] 生成的。当你成为软件包维护者,它会自动生成。当证书过期时,你需要重新生成。


4. In the '''Advanced''' section switch to the '''Encryption''' tab
; <code>~/.fedora-upload-ca.cert</code>(此证书在验证时,用于导入使用者的密钥) : 可以在 [https://admin.fedoraproject.org/accounts/fedora-upload-ca.cert 此处] 下载,或使用 <code>fedora-packager-setup</code> 获取。


5. Click on the '''View Certificates''' button and the Certificates window will appear
; <code>~/.fedora-server-ca.cert</code>(此证书在验证时,用于导入编译服务器的密钥) : 可以在 [https://admin.fedoraproject.org/accounts/fedora-server-ca.cert 此处] 下载,或使用 <code>fedora-packager-setup</code> 获取。


6. Switch to the '''Your Certificates''' tab and click on the '''Import''' button
==== 配置 Koji ====
Koji 本地客户端的全局配置文件在 <code>/etc/koji.conf</code>。你不需要为编译 Fedora 软件包去更改配置文件。这些配置文件,允许你使用首要架构编译系统和次级架构编译系统。


7. Point to where your Fedora Certificate is located and click '''Open''' (fedora-packager-setup will have told you where it was saved and will have asked you to set a password for the cert)
== 使用 fedpkg targets 构建 ==
 
 
You should now be able to see your Fedora Certificate listed under '''Your Certificates''' and you should be able to authenticate with the koji web interface.
 
 
==== Installing SSL Certificates in Chromium ====
 
{{admon/note|Optional|You only need to check these instructions if you are intending to authenticate with the web interface with Chromium.  Authenticating with the web interface is optional.}}
 
Chromium uses the NSS Shared DB, you will need the nss-tools package installed.
<pre>
pk12util -d sql:$HOME/.pki/nssdb -i fedora-browser-cert.p12
</pre>
 
==== 通知 ====
 
When authenticated with the Koji web interface, you can setup a notification
requests to make sure you do not miss when a package you care about gets
built.  Login and scroll to the bottom of the page, there you should find a
''[https://koji.fedoraproject.org/koji/notificationcreate Add a notification]''
link and a list of your configured notifications.
 
== Building with fedpkg targets ==
 
Every push is automatically tagged via git.  All you have done to build the package is to run,


每次推送都通过 git 自动标记。你要做的是执行以下命令构建软件包,
<pre>
<pre>
fedpkg build
fedpkg build
</pre>
</pre>


This will trigger a build request for the branch. Easy!
这将触发当前分支的构建请求。很简单吧!
 
It is also possible to target a specific koji tag as follows:


还可以如下,指定特定的 koji 标签:
<pre>
<pre>
fedpkg build --target TARGET
fedpkg build --target TARGET
</pre>
</pre>


for example, if building on rawhide against a special tag created by rel-eng for updating API for many packages, e.g. <code>dist-f14-python</code> you would use the following:
例如,在 rawhide 上构建针对由 rel-eng 创建的用于更新许多包的 API 的特殊标签,例如 <code>dist-f14-python</code>,您可以使用以下命令:
 
<pre>
<pre>
fedpkg build --target 'dist-f14-python'
fedpkg build --target 'dist-f14-python'
</pre>
</pre>


==== 链式构建 ====
==== Chained builds ====
{{Admon/warning | chain-builds only work when building on the devel/ branch (aka rawhide).  To chain-build packages to update a released OS version, [https://fedoraproject.org/wiki/Bodhi/BuildRootOverrides set up an override using bodhi] requesting packages to be included in the proper buildroot.}}
 
Sometimes you want to make sure than one build succeeded before
{{Admon/warning | chain-builds 仅在 devel/ 分支 (又称为rawhide) 上工作。为了更新一个已发行的版本而 chain-build,[https://fedoraproject.org/wiki/Bodhi/BuildRootOverrides 请使用 bodhi 设置覆盖],请求将软件包包含在正确的 buildroot 中。}}
launching the next one, for example when you want to rebuild
 
a package against a just rebuilt dependency. In that case
有时,你想在启动下一个任务之前确保前一个编译成功。例如,当你想为重建依赖关系而重新构建一个包时。这种情况下,您可以使用链式构建:
you can use a chain build with:


  fedpkg chain-build libwidget libgizmo
  fedpkg chain-build libwidget libgizmo


The current package is added to the end of the CHAIN list. Colons (:) can be used in the CHAIN parameter to define groups of packages. Packages in any single group will be built in parallel and all packages in a group must build successfully and populate the repository before the next group will begin building. For example:
当前的软件包将会被加入到 CHAIN 列表的最后。冒号“:”可以作为 CHAIN 参数使用,来定义软件包所属的组。在下一组编译开始前,任何一个组中的软件包都会被并行编译,且一个组中的所有软件包都必须编译成功,并移送到软件包仓库。例如:
                      
                      
  fedpkg chain-build libwidget libaselib : libgizmo :
  fedpkg chain-build libwidget libaselib : libgizmo :


will cause libwidget and libaselib to be built in parallel, followed by libgizmo and then the currect directory package. If no groups are defined, packages will be built sequentially.
此举将会同时编译 libwidget 和 libaselib,随后是 libgizmo,然后到现有目录内的软件包。如果没有定义组,那么软件包将会按照顺序编译。如果其中一个编译失败,跟随的编译就会被取消,但已经编译好的软件包将会被推送到软件仓库。
 
If a build fail, following builds are cancelled but the builds that already succeeded are pushed to the repository.


== Scratch Builds ==
== Scratch Builds ==


Sometimes it is useful to be able to build a package against the buildroot but without actually including it in the release. This is called a scratch build. The following section covers using koji directly as well as the fedpkg tool to do scratch builds. To create a scratch build from changes you haven't committed,  do the following:
有时,能够针对 buildroot 构建一个未实际包含在发行版中的包是有用的。这称为 scratch 构建。以下部分介绍,直接使用 koji 以及使用 fedpkg 工具执行 scratch 构建。要从尚未提交的更改创建临时构建,请执行以下操作:


<pre>
<pre>
Line 168: Line 84:
</pre>
</pre>


From the latest git commit:
构建最新的 git commit:


<pre>
<pre>
Line 174: Line 90:
</pre>
</pre>


Warning: Scratch builds will ''not'' work correctly if your .spec file does something different depending on the value of %fedora, %fc9, and so on.  Macro values like these are set by the ''builder'', not by koji, so the value of %fedora will be for whatever created the source RPM, and ''not'' what it's being built on.  Non-scratch builds get around this by first re-building the source RPM.
警告:如果您的 .spec 文件根据 %fedora 的值(%fc9等)来执行不同的操作,则临时构建将 ''不会'' 正常工作。像这样的宏值是由 ''builder'' 设置,而不是由 koji 设置,因此 %fedora 的值将由 SRPM 的值决定,而''不是''由正在构建的内容决定。非临时构建通过首先重新构建 SRPM 来解决这个问题。


If you have committed the changes to git and you are in the current branch, you can do a scratch build with fedpkg tool which wraps the koji command line tool with the appropriate options:
如果您已将更改提交到 git 并且位于当前分支中,则可以使用 fedpkg 工具进行暂存(scratch)构建,该工具以适当的选项包装了 koji 工具:


<pre>
<pre>
Line 182: Line 98:
</pre>
</pre>


if you want to do a scratch build for a specific architecture, you can type:
如果您想要针对指定架构执行一个 scratch 构建,您可以执行:


<pre>
<pre>
Line 188: Line 104:
</pre>
</pre>


<archs> can be a comma separated list of several architectures.
<archs> 是一个逗号分隔的架构列表。


finally is possible to combine the scratch-build command with a specific koji tag in the form:
最后可以将 scratch-build 命令与特定 koji tag 结合使用:


<pre>
<pre>
Line 196: Line 112:
</pre>
</pre>


fedpkg scratch-build --help or koji build --help for more information.
请查看 fedpkg scratch-build --help koji build --help 了解更多信息。


== 构建失败 ==
== 构建失败 ==
Line 208: Line 124:
</pre>
</pre>


您可以通过查看日至来了解具体的原因。 build.log 是最好的分析来源。除此之外还可以查看 init.log。
您可以通过查看日志来了解编译失败的具体原因。build.log 是最好的分析来源。除此之外还可以查看 init.log。


Logs can be found via the web interface in the Task pages for the failed task.  Alternatively the koji client can be used to view the logs via the <code>watch-logs</code> command.  See the help output for more details.
失败任务的日志可以在 koji web 界面的 Task 页面里找到。或者可以使用 koji 客户端的 <code>watch-logs</code> 命令查看日志。查看帮助命令了解更详细信息。


== Advanced use of Koji ==
== Koji 高级应用 ==


We've tried to make Koji self-documenting wherever possible. The command line tool will print a list of valid commands and each command supports --help. For example:
我们已经完善了 Koji 的帮助命令,确保其可以正常运行。命令行工具将会显示一个有效命令的列表,每个命令都支持 --help 参数。例如:


<pre>
<pre>
Line 220: Line 136:


Koji commands are:
Koji commands are:
build                Build a package from source
build                Build a package from source //从 SRPM 构建一个软件包
cancel-task          Cancel a task
cancel-task          Cancel a task //取消一个任务
help                List available commands
help                List available commands //列出可用的命令
latest-build        Print the latest rpms for a tag
latest-build        Print the latest rpms for a tag //输出一个标记的最新rpms
latest-pkg          Print the latest builds for a tag
latest-pkg          Print the latest builds for a tag //输出一个标记的最新构建
[...]  
[...]  
</pre>
</pre>
Line 235: Line 151:


options:
options:
-h, --help            show this help message and exit
-h, --help            show this help message and exit //显示帮助信息并退出
--skip-tag            Do not attempt to tag package
--skip-tag            Do not attempt to tag package //不标记一个软件包
--scratch            Perform a scratch build
--scratch            Perform a scratch build //运行一个 scratch 构建任务
--nowait              Don't wait on build
--nowait              Don't wait on build //不等待构建
[...]  
[...]  
</pre>
</pre>


==== Using koji to generate a mock config to replicate a buildroot ====
==== 使用 koji 生成一份 mock 配置来复制一个编译链 ====
 
koji 可以为本地调试复制一个编译链。


koji can be used to replicate a build root for local debugging
<pre>
<pre>
koji mock-config --help
koji mock-config --help
Line 251: Line 168:


Options:
Options:
   -h, --help            show this help message and exit
   -h, --help            show this help message and exit //显示帮助信息并退出
   --arch=ARCH          Specify the arch
   --arch=ARCH          Specify the arch //指定架构
   --tag=TAG            Create a mock config for a tag
   --tag=TAG            Create a mock config for a tag //为一个标记创建一份 mock 配置
   --task=TASK          Duplicate the mock config of a previous task
   --task=TASK          Duplicate the mock config of a previous task //复制前一个任务的 mock 配置
   --buildroot=BUILDROOT
   --buildroot=BUILDROOT Duplicate the mock config for the specified buildroot id //复制指定 buildroot id 的 mock 配置
                        Duplicate the mock config for the specified buildroot
   --mockdir=DIR        Specify mockdir //指定 mock 的目录
                        id
   --topdir=DIR          Specify topdir //指定 top 目录
   --mockdir=DIR        Specify mockdir
   --topurl=URL          url under which Koji files are accessible //设置 Koji 文件的url地址
   --topdir=DIR          Specify topdir
   --distribution=DIST  Change the distribution macro //修改发行版的宏
   --topurl=URL          url under which Koji files are accessible
   -o FILE              Output to a file //输出到一个文件
   --distribution=DISTRIBUTION
                        Change the distribution macro
   -o FILE              Output to a file
</pre>
</pre>
for example to get the latest buildroot for dist-f12-build run
 
例如,获得最新的 dist-f14-build 编译链可以运行:
<pre>
<pre>
koji mock-config --tag dist-f12-build --arch=x86_64 --topurl=http://kojipkgs.fedoraproject.org/ dist-f12
koji mock-config --tag dist-f14-build --arch=x86_64 --topurl=http://kojipkgs.fedoraproject.org/ dist-f14
</pre>
</pre>


you will need to pass in --topurl=http://kojipkgs.fedoraproject.org/ to any mock-config command to get a working mock-config from fedoras koji.
您需要传入 --topurl=http://koji.fedoraproject.org/ 参数到对应的 mock-config 命令,从 Fedora Koji 获得一份可以运行的 mock-config。


==== Using Koji to control tasks ====
==== 使用 Koji 控制任务 ====


List tasks:
列出任务:
<pre>
<pre>
koji list-tasks
koji list-tasks
</pre>
</pre>


List only tasks requested by you:
仅列出您请求的任务:
<pre>
<pre>
koji list-tasks --mine
koji list-tasks --mine
</pre>
</pre>


requeue an already-processed task: general syntax is: koji resubmit [options] taskID
重新排列一个已经进行的任务:通用语法:koji resubmit [options] taskID
 
<pre>
<pre>
koji resubmit 3
koji resubmit 3
</pre>
</pre>


==== Building a Package with the command-line tool ====
==== 使用命令行构建一个软件包 ====


Instead of using the fedpkg target, you can also directly
您可以使用 fedpkg target,也可以直接使用 koji 命令行工具。
use the command_line tool, koji.
 
To build a package, the syntax is:


构建软件包的命令的语法是:
<pre>
<pre>
$ koji build <build target> <git URL>
$ koji build <build target> <git URL>
</pre>
</pre>


For example:
例如:
{{Admon/warning | Replace <code>dist-f14</code> with the tag you wish to build against, e.g. <code>dist-rawhide</code>}}
{{Admon/warning | 使用您需要编译的标记替换 <code>dist-f14</code>,例如 <code>dist-rawhide</code>}}


<pre>
<pre>
Line 308: Line 220:
</pre>
</pre>


The koji build command creates a build task in Koji. By default the tool will wait and print status updates until the build completes. You can override this with the --nowait option.
koji build 命令在 Koji 中创建一个构建任务。默认情况下,工具将等待并打印状态更新,直到构建完成。您可以使用 --nowait 选项覆盖此行为。
</pre>


NOTE: For fedora koji, the git url MUST be based on pkgs.fedoraproject.org. Other arbitrary git repos cannot be used for builds.
注意:对于 fedora koji,git url 必须基于 pkgs.fedoraproject.org。其他任何 git repos 不能用于构建。


== Koji tags and packages organization ==
== Koji 标记和软件包的组织 ==


==== Terminology ====
==== 术语 ====
In Koji, it is sometimes necessary to distinguish between a package in general, a specific build of a package, and the various rpm files created by a build. When precision is needed, these terms should be interpreted as follows:
Koji 中,有时需要区分一个普通的软件包,一个包的特定构建,以及由构建创建的各种 rpm 文件。当需要精确描述时,这些术语应解释如下:


* Package: The name of a source rpm. This refers to the package in general and not any particular build or subpackage. For example: kernel, glibc, etc.
* Package:源码包的名称,通常指普通软件包,而不是任何特定的构建或子包。例如:kernel, glibc 等。
* Build: A particular build of a package. This refers to the entire build: all arches and subpackages. For example: kernel-2.6.9-34.EL, glibc-2.3.4-2.19.
* Build:一个软件包的特定构建。这里指的是完整编译:所有架构和主包。例如:kernel-2.6.9-34.EL, glibc-2.3.4-2.19。
* RPM: A particular rpm. A specific arch and subpackage of a build. For example: kernel-2.6.9-34.EL.x86_64, kernel-devel-2.6.9-34.EL.s390, glibc-2.3.4-2.19.i686, glibc-common-2.3.4-2.19.ia64
* RPM:一个特定的 rpm。一个编译任务里的一个特定架构和主包。例如:kernel-2.6.9-34.EL.x86_64, kernel-devel-2.6.9-34.EL.s390, glibc-2.3.4-2.19.i686, glibc-common-2.3.4-2.19.ia64


==== Tags and targets ====
==== 标记和目标 (tags and targets) ====


Koji organizes packages using tags. In Koji a tag is roughly a collection of packages:
Koji 使用标记来管理软件包。在 Koji 中,一个标记是一个软件包的集合:


* Tags support inheritance
* 标记支持继承
* Each tag has its own list of valid packages (inheritable)
* 每个标记都有它们拥有的有效的软件包列表(可继承)
* Package ownership can be set per-tag (inheritable)
* 每个标记可以设置软件包的拥有权(可继承)
* When you build you specify a target rather than a tag
* 当您构建时,指定的是目标,而不是标记


A build target specifies where a package should be built and how it should be tagged afterwards. This allows target names to remain fixed as tags change through releases.
一个编译目标指定了一个软件包应该在哪里编译和如何在编译后被标记。这允许目标名称,在标签发布修改时,保持固定。


==== Koji commands for tags ====
==== 用于标记的 Koji 命令 ====
 
 
===== Targets =====
You can get a full list of build targets with the following command:


===== 目标 (Targets) =====
使用以下命令列出编译目标的完整列表:
<pre>
<pre>
$ koji list-targets
$ koji list-targets
</pre>
</pre>


You can see just a single target with the --name option:
你可以添加 --name 参数查看单独的目标:
 
<pre>
<pre>
$ koji list-targets --name dist-f14
$ koji list-targets --name dist-f14
Line 350: Line 258:
Name                          Buildroot                      Destination
Name                          Buildroot                      Destination
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
dist-f14                     dist-f14-build                dist-f14
dist-f14                       dist-f14-build                dist-f14
</pre>
</pre>


This tells you a build for target dist-f14 will use a buildroot with packages from the tag dist-f14-build and tag the resulting packages as dist-f14.
以上内容告诉你,一个属于 dist-fc14 目标的编译任务将使用一个带有标记为 dist-fc14-build 的软件包组成的编译链,并且在编译完成后生成的软件包会被标记为 dist-fc14。


Watch out: You probably don't want to build against dist-rawhide.  If Fedora N is the latest one out, to build to the next one, choose dist-f{N+1}.
留意:你可能不希望在 dist-rawhide 上编译。如果 Fedora N 是一个已发布的最新版本,那么你可以选择编译到下一个版本,标记为 dist-f{N+1}


===== Tags =====
===== 标记 (Tags) =====


You can get a list of tags with the following command:
您可以通过下列命令获得可用的发行版本分支标记:
<pre>
<pre>
$ koji list-tags
$ koji list-tags
</pre>
</pre>


===== Packages =====
===== 软件包 (Packages) =====


As mentioned above, each tag has its own list of packages that may be placed in the tag. To see that list for a tag, use the list-pkgs command:
如上所述,每个标记都拥有属于它的软件包列表。查看一个标记的软件包列表,使用 list-pkgs 命令:


<pre>
<pre>
$ koji list-pkgs --tag dist-f14
$ koji list-pkgs --tag dist-f14


Package                Tag                    Extra Arches    Owner
----------------------- ----------------------- ---------------- ----------------
ElectricFence          dist-fc14                                pmachata
GConf2                  dist-fc14                                rstrode
lucene                  dist-fc14                                dbhole
lvm2                    dist-fc14                                lvm-team
ImageMagick            dist-fc14                                nmurray
m17n-db                dist-fc14                                majain
m17n-lib                dist-fc14                                majain
MAKEDEV                dist-fc14                                clumens
[...]
</pre>
</pre>


The first column is the name of the package, the second tells you which tag the package entry has been inherited from, and the third tells you the owner of the package.
第一列为软件包的名称,第二列表明软件包继承自哪一个标记,第三列显示软件包的所有者。


===== Latest Builds =====
===== 最新的构建任务 =====


To see the latest builds for a tag, use the latest-pkg command:
为了查看某个标记的最新构建,使用 latest-pkg 命令:


<pre>
<pre>
$ koji latest-pkg --all dist-f14
$ koji latest-pkg --all dist-f14


Build                                    Tag                  Built by
----------------------------------------  --------------------  ----------------
ConsoleKit-0.1.0-5.fc14                  dist-fc14            davidz
ElectricFence-2.2.2-20.2.2                dist-fc14            jkeating
GConf2-2.16.0-6.fc14                      dist-fc14            mclasen
ImageMagick-6.2.8.0-3.fc14                dist-fc14-updates    nmurray
MAKEDEV-3.23-1.2                          dist-fc14            nalin
MySQL-python-1.2.1_p2-2                  dist-fc14            katzj
NetworkManager-0.6.5-0.3.fc14            dist-fc14            caillon
ORBit2-2.14.6-1.fc14                      dist-fc14            mclasen
</pre>
</pre>


The output gives you not only the latest builds, but which tag they have been inherited from and who built them.
输出不仅仅会告诉你最新的编译,而且会告诉你继承自哪一个标记和谁在编译它们。


[[Category:Package Maintainers]]
[[Category:Package Maintainers]]

Latest revision as of 08:31, 5 February 2017

在 Fedora 中使用 Koji 构建系统

Koji 构建系统 是 Fedora 的 RPM 构建系统。打包人员需要使用 koji 客户端来请求构建包,并获得构建系统返回的相关信息。Koji 运行在 Mock 之上来构建不同架构的 RPM 包,并确保它们正确构建。服务自身包含多个架构的几十台在线构建宿主机。

这里还有一个 简体中文版本

安装 Koji

安装 Koji CLI

要使用 Koji(需要您是 Fedora 的贡献者),请安装 fedora-packager 包:

dnf install fedora-packager

fedora-packager 提供了一系列脚本帮助你安装和管理 koji 环境。额外地,它也包括了 Koji CLI 的依赖,当安装 fedora-packager 时 CLI 工具会被自动安装。该命令名为 koji,包含在 koji 主包里。koji 工具默认使用 Kerberos 协议认证客户端和中心服务器。您需要具备一个有效的认证令牌,才能使用 Koji 服务。否则,在未认证的情况下,只能运行只读命令。

如果您需要身份验证方面的帮助,或想成为 Fedora packager,请查看本指南:Join_the_package_collection_maintainers
您需要安装 fedora-packager 软件包,执行 fedora-packager-setup 并获得有效的 kerberos 票据以执行构建。

初始化 Fedora Setup

为了使用 Koji 服务器,软件包维护者需要运行:

/usr/bin/fedora-packager-setup

如果用户需要使用 Koji 去构建 Fedora 的软件包,则必须要运行一次该命令。每个用户都必须拥有他们的证书用于认证身份。

Fedora 证书

Koji 使用以下三份证书:

~/.fedora.cert(给与 Fedora 软件包维护者)
此份证书是在 FAS此页面 生成的。当你成为软件包维护者,它会自动生成。当证书过期时,你需要重新生成。
~/.fedora-upload-ca.cert(此证书在验证时,用于导入使用者的密钥)
可以在 此处 下载,或使用 fedora-packager-setup 获取。
~/.fedora-server-ca.cert(此证书在验证时,用于导入编译服务器的密钥)
可以在 此处 下载,或使用 fedora-packager-setup 获取。

配置 Koji

Koji 本地客户端的全局配置文件在 /etc/koji.conf。你不需要为编译 Fedora 软件包去更改配置文件。这些配置文件,允许你使用首要架构编译系统和次级架构编译系统。

使用 fedpkg targets 构建

每次推送都通过 git 自动标记。你要做的是执行以下命令构建软件包,

fedpkg build

这将触发当前分支的构建请求。很简单吧!

还可以如下,指定特定的 koji 标签:

fedpkg build --target TARGET

例如,在 rawhide 上构建针对由 rel-eng 创建的用于更新许多包的 API 的特殊标签,例如 dist-f14-python,您可以使用以下命令:

fedpkg build --target 'dist-f14-python'

Chained builds

Warning.png
chain-builds 仅在 devel/ 分支 (又称为rawhide) 上工作。为了更新一个已发行的版本而 chain-build,请使用 bodhi 设置覆盖,请求将软件包包含在正确的 buildroot 中。

有时,你想在启动下一个任务之前确保前一个编译成功。例如,当你想为重建依赖关系而重新构建一个包时。这种情况下,您可以使用链式构建:

fedpkg chain-build libwidget libgizmo

当前的软件包将会被加入到 CHAIN 列表的最后。冒号“:”可以作为 CHAIN 参数使用,来定义软件包所属的组。在下一组编译开始前,任何一个组中的软件包都会被并行编译,且一个组中的所有软件包都必须编译成功,并移送到软件包仓库。例如:

fedpkg chain-build libwidget libaselib : libgizmo :

此举将会同时编译 libwidget 和 libaselib,随后是 libgizmo,然后到现有目录内的软件包。如果没有定义组,那么软件包将会按照顺序编译。如果其中一个编译失败,跟随的编译就会被取消,但已经编译好的软件包将会被推送到软件仓库。

Scratch Builds

有时,能够针对 buildroot 构建一个未实际包含在发行版中的包是有用的。这称为 scratch 构建。以下部分介绍,直接使用 koji 以及使用 fedpkg 工具执行 scratch 构建。要从尚未提交的更改创建临时构建,请执行以下操作:

rpmbuild -bs foo.spec
koji build --scratch rawhide foo.srpm

构建最新的 git commit:

koji build --scratch rawhide 'git url'

警告:如果您的 .spec 文件根据 %fedora 的值(%fc9等)来执行不同的操作,则临时构建将 不会 正常工作。像这样的宏值是由 builder 设置,而不是由 koji 设置,因此 %fedora 的值将由 SRPM 的值决定,而不是由正在构建的内容决定。非临时构建通过首先重新构建 SRPM 来解决这个问题。

如果您已将更改提交到 git 并且位于当前分支中,则可以使用 fedpkg 工具进行暂存(scratch)构建,该工具以适当的选项包装了 koji 工具:

fedpkg scratch-build

如果您想要针对指定架构执行一个 scratch 构建,您可以执行:

fedpkg scratch-build-<archs>

<archs> 是一个逗号分隔的架构列表。

最后可以将 scratch-build 命令与特定 koji tag 结合使用:

fedpkg scratch-build --target TARGET

请查看 fedpkg scratch-build --help 或 koji build --help 了解更多信息。

构建失败

如果您上传的软件包无法通过构建,您将会看到类似的信息:

420066 buildArch kernel-2.6.18-1.2739.10.9.el5.jjf.215394.2.src.rpm,
ia64): open (build-1.example.com) -> FAILED: BuildrootError:
error building package (arch ia64), mock exited with status 10

您可以通过查看日志来了解编译失败的具体原因。build.log 是最好的分析来源。除此之外还可以查看 init.log。

失败任务的日志可以在 koji web 界面的 Task 页面里找到。或者可以使用 koji 客户端的 watch-logs 命令查看日志。查看帮助命令了解更详细信息。

Koji 高级应用

我们已经完善了 Koji 的帮助命令,确保其可以正常运行。命令行工具将会显示一个有效命令的列表,每个命令都支持 --help 参数。例如:

$ koji help

Koji commands are:
build                Build a package from source //从 SRPM 构建一个软件包
cancel-task          Cancel a task //取消一个任务
help                 List available commands //列出可用的命令
latest-build         Print the latest rpms for a tag //输出一个标记的最新rpms
latest-pkg           Print the latest builds for a tag //输出一个标记的最新构建
[...] 
$ koji build --help

usage: koji build [options]  tag URL
(Specify the --help global option for a list of other help options)

options:
-h, --help            show this help message and exit //显示帮助信息并退出
--skip-tag            Do not attempt to tag package //不标记一个软件包
--scratch             Perform a scratch build //运行一个 scratch 构建任务
--nowait              Don't wait on build //不等待构建
[...] 

使用 koji 生成一份 mock 配置来复制一个编译链

koji 可以为本地调试复制一个编译链。

koji mock-config --help
Usage: koji mock-config [options] name
(Specify the --help global option for a list of other help options)

Options:
  -h, --help            show this help message and exit //显示帮助信息并退出
  --arch=ARCH           Specify the arch //指定架构
  --tag=TAG             Create a mock config for a tag //为一个标记创建一份 mock 配置
  --task=TASK           Duplicate the mock config of a previous task //复制前一个任务的 mock 配置
  --buildroot=BUILDROOT Duplicate the mock config for the specified buildroot id //复制指定 buildroot id 的 mock 配置
  --mockdir=DIR         Specify mockdir //指定 mock 的目录
  --topdir=DIR          Specify topdir //指定 top 目录
  --topurl=URL          url under which Koji files are accessible //设置 Koji 文件的url地址
  --distribution=DIST   Change the distribution macro //修改发行版的宏
  -o FILE               Output to a file //输出到一个文件

例如,获得最新的 dist-f14-build 编译链可以运行:

koji mock-config --tag dist-f14-build --arch=x86_64 --topurl=http://kojipkgs.fedoraproject.org/ dist-f14

您需要传入 --topurl=http://koji.fedoraproject.org/ 参数到对应的 mock-config 命令,从 Fedora Koji 获得一份可以运行的 mock-config。

使用 Koji 控制任务

列出任务:

koji list-tasks

仅列出您请求的任务:

koji list-tasks --mine

重新排列一个已经进行的任务:通用语法:koji resubmit [options] taskID

koji resubmit 3

使用命令行构建一个软件包

您可以使用 fedpkg target,也可以直接使用 koji 命令行工具。

构建软件包的命令的语法是:

$ koji build <build target> <git URL>

例如:

Warning.png
使用您需要编译的标记替换 dist-f14,例如 dist-rawhide
$ koji build dist-f14 'git url'

koji build 命令在 Koji 中创建一个构建任务。默认情况下,工具将等待并打印状态更新,直到构建完成。您可以使用 --nowait 选项覆盖此行为。

注意:对于 fedora koji,git url 必须基于 pkgs.fedoraproject.org。其他任何 git repos 不能用于构建。

Koji 标记和软件包的组织

术语

在 Koji 中,有时需要区分一个普通的软件包,一个包的特定构建,以及由构建创建的各种 rpm 文件。当需要精确描述时,这些术语应解释如下:

  • Package:源码包的名称,通常指普通软件包,而不是任何特定的构建或子包。例如:kernel, glibc 等。
  • Build:一个软件包的特定构建。这里指的是完整编译:所有架构和主包。例如:kernel-2.6.9-34.EL, glibc-2.3.4-2.19。
  • RPM:一个特定的 rpm。一个编译任务里的一个特定架构和主包。例如:kernel-2.6.9-34.EL.x86_64, kernel-devel-2.6.9-34.EL.s390, glibc-2.3.4-2.19.i686, glibc-common-2.3.4-2.19.ia64

标记和目标 (tags and targets)

Koji 使用标记来管理软件包。在 Koji 中,一个标记是一个软件包的集合:

  • 标记支持继承
  • 每个标记都有它们拥有的有效的软件包列表(可继承)
  • 每个标记可以设置软件包的拥有权(可继承)
  • 当您构建时,指定的是目标,而不是标记

一个编译目标指定了一个软件包应该在哪里编译和如何在编译后被标记。这允许目标名称,在标签发布修改时,保持固定。

用于标记的 Koji 命令

目标 (Targets)

使用以下命令列出编译目标的完整列表:

$ koji list-targets

你可以添加 --name 参数查看单独的目标:

$ koji list-targets --name dist-f14

Name                           Buildroot                      Destination
---------------------------------------------------------------------------------------------
dist-f14                       dist-f14-build                 dist-f14

以上内容告诉你,一个属于 dist-fc14 目标的编译任务将使用一个带有标记为 dist-fc14-build 的软件包组成的编译链,并且在编译完成后生成的软件包会被标记为 dist-fc14。

留意:你可能不希望在 dist-rawhide 上编译。如果 Fedora N 是一个已发布的最新版本,那么你可以选择编译到下一个版本,标记为 dist-f{N+1}。

标记 (Tags)

您可以通过下列命令获得可用的发行版本分支标记:

$ koji list-tags
软件包 (Packages)

如上所述,每个标记都拥有属于它的软件包列表。查看一个标记的软件包列表,使用 list-pkgs 命令:

$ koji list-pkgs --tag dist-f14

Package                 Tag                     Extra Arches     Owner
----------------------- ----------------------- ---------------- ----------------
ElectricFence           dist-fc14                                pmachata
GConf2                  dist-fc14                                rstrode
lucene                  dist-fc14                                dbhole
lvm2                    dist-fc14                                lvm-team
ImageMagick             dist-fc14                                nmurray
m17n-db                 dist-fc14                                majain
m17n-lib                dist-fc14                                majain
MAKEDEV                 dist-fc14                                clumens
[...]

第一列为软件包的名称,第二列表明软件包继承自哪一个标记,第三列显示软件包的所有者。

最新的构建任务

为了查看某个标记的最新构建,使用 latest-pkg 命令:

$ koji latest-pkg --all dist-f14

Build                                     Tag                   Built by
----------------------------------------  --------------------  ----------------
ConsoleKit-0.1.0-5.fc14                   dist-fc14             davidz
ElectricFence-2.2.2-20.2.2                dist-fc14             jkeating
GConf2-2.16.0-6.fc14                      dist-fc14             mclasen
ImageMagick-6.2.8.0-3.fc14                dist-fc14-updates     nmurray
MAKEDEV-3.23-1.2                          dist-fc14             nalin
MySQL-python-1.2.1_p2-2                   dist-fc14             katzj
NetworkManager-0.6.5-0.3.fc14             dist-fc14             caillon
ORBit2-2.14.6-1.fc14                      dist-fc14             mclasen

输出不仅仅会告诉你最新的编译,而且会告诉你继承自哪一个标记和谁在编译它们。