From Fedora Project Wiki
m (internal link cleaning)
 
(16 intermediate revisions by 2 users not shown)
Line 2: Line 2:
= Koji =
= Koji =


Koji 是一个构建 [http://koji.fedoraproject.org/koji/ 所有与 Fedora 项目有关的软件包] 工具。它使用 [http://fedoraproject.org/wiki/Projects/Mock Mock] 来创建chroot环境以便完成构建。如果您想下载 Koji 的源代码,或者是反馈问题、加入邮件列表等等,请见 [https://fedorahosted.org/koji/wiki Koji 项目的首页] 。
Koji [http://koji.fedoraproject.org/koji/ Fedora 社区的编译系统]。它使用 [[Projects/Mock|Mock]]  创建编译软件包时需要的编译环境。如果您想下载 Koji 的源代码、反馈问题、加入邮件列表,参见 [https://fedorahosted.org/koji/wiki Koji 项目首页] 。


== 使用手册 ==
== 说明文档 ==


在 Fedora 中部署 Koji:
如果您想搭建或者使用 Koji 系统,这里有一些说明文档:


* [[Using the Koji build system]]  
* [[Using the Koji build system| 使用 Koji 系统]]  
* [[Koji/ServerHowTo/zh-cn| Run Your Own Koji Build Server]]
* [[Koji/ServerHowTo/zh-cn| 搭建您自己的 Koji 系统]]
* [[Koji/KojiLiveCDHowTo| Building Images in Koji]]
* [[Koji/KojiLiveCDHowTo| Koji 中制作系统镜像文件]]
* [[Koji/Policies| Defining hub policies]]
* [[Koji/Policies| 定义 hub 中的策略]]
* [http://jianlee.ylinux.org/Computer/Server/koji.html  Chinese howto about Koji Build Server]
* [http://jianlee.ylinux.org/Computer/Server/koji.html  关于 Koji 系统搭建过程的一篇中文文档]


== Koji 构成 ==
== 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): source rpm 的名称。表示一般意义上的软件包,没有指定软件包的具体版本和编译出的子包。比如: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): 一个特定的 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。


== Koji 的组件 ==
== Koji 的组件 ==
Line 28: Line 28:


==== Koji-Hub ====
==== Koji-Hub ====
koji-hub is the center of all Koji operations. It is an XML-RPC server running under mod_python in Apache. koji-hub is passive in that it only receives XML-RPC calls and relies upon the build daemons and other components to initiate communication. koji-hub is the only component that has direct access to the database and is one of the two components that have write access to the file system.
koji-hub 是所有 Koji 操作的核心。它是一个运行在 Apache 服务器的 mod_python 模块下的 XML-RPC 服务器。koji-hub 采用被动方式工作,它只接收 XML-RPC 请求,然后依靠编译守护进程以及其他组件来进行通信。Koji-hub 是唯一可以直接访问数据库的组件,也是两个对文件系统具有写权限的组件之一。


==== Kojid ====
==== Kojid ====
kojid is the build daemon that runs on each of the build machines. Its primary responsibility is polling for incoming build requests and handling them accordingly. Essentially kojid asks koji-hub for work. Koji also has support for tasks other than building. Creating install images is one example. kojid is responsible for handling these tasks as well. kojid uses mock for building. It also creates a fresh buildroot for every build. kojid is written in Python and communicates with koji-hub via XML-RPC.
kojid 是运行在每一台编译机上的编译守护进程。它的主要任务是查询发送过来的编译请求,根据实际情况进行处理。特别地, kojid 通过查询 koji-hub 上的信息进行工作。除了编译软件包 Koji 还支持其他的任务,例如制作系统安装文件,这些任务也由 kojid 进行处理。kojid 利用 mock 创建原始的编译环境,并且为每一次编译任务单独创建一个编译环境。kojid 是用 Python 编写的,并且通过 XML-RPC 与 koji-hub 进行通信。


=== Koji-Web ===
=== Koji-Web ===
koji-web is a set of scripts that run in mod_python and use the Cheetah templating engine to provide a web interface to Koji. It acts as a client to koji-hub providing a visual interface to preform a limited amount of administration. koji-web exposes a lot of information and also provides a means for certain operations, such as cancelling builds.
koji-web 是一系列运行在 mod_python 模块下,采用 Cheetah 模板引擎生成的可以对 Koji 提供一套 web 页面接口的脚本文件。它作为 koji-hub 的客户端运行,为一些系统管理命令提供了可视化的接口。通过 koji-web,您可以查看 Koji 系统中很多信息。并且 koji-web 提供了一种方式完成系统中的部分操作,如取消软件包编译任务。


=== Koji Client ===
=== Koji Client ===
koji-client is a CLI written in Python that provides many hooks into Koji. It allows the user to query much of the data as well as perform actions such as adding users and initiating build requests.
koji-client 是用 Python 写成的命令行终端工具,它提供了对 Koji 系统进行操作的很多命令。它允许用户查询系统中的很多信息,还允许用户向 Koji 提交很多操作,比如:添加用户和初始化编译请求。


=== Kojira ===
=== Kojira ===
kojira is a daemon that keeps the build root repodata updated. It is responsible for removing redundant build roots and cleaning up after a build request is completed.
kojira 是保持编译环境与系统同步更新的一个守护进程。它负责删除多余的编译环境,还负责软件包编译任务结束后的清理工作。


== Package Organization ==
== 软件包组织形式 ==


==== Tags and Targets ====
==== Tags Targets ====


Koji organizes packages using tags:
Koji 用 tag 组织软件包:


* Tags are tracked in the database but not on disk
* tag 保存在数据库中而不是磁盘文件系统中
* Tags support multiple inheritance
* tag 支持多重继承
* Each tag has its own list of valid packages (inheritable)
* 每个 tag 有它自己有效的软件包列表(软件包列表可以被其他的 tag 继承)
* Package ownership can be set per-tag (inheritable)
* 我们可以根据 tag 为软件包设置不同的所有者(所有者关系也可以被其他 tag 继承)
* Tag inheritance is more configurable
* tag 继承过程是可以配置的
* When you build you specify a target rather than a tag
* 当您编译软件包时,您应该指定一个 target 而不是一个 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. You can get a full list of build targets with the following command:
一个 target 表明了软件包的编译过程应该在哪里进行,编译生成的软件包应该放入哪个 tag 中。当 tag 的名称随着所发布系统的版本变化后, target 的名称仍然可以保持不变。您可以通过下面的命令查看系统中的 target 列表:


<pre>
<pre>
Line 61: Line 61:
</pre>
</pre>


You can see just a single target with the --name option:
您可以通过 --name 选项查看单个 target 的信息:


<pre>
<pre>
Line 71: Line 71:
</pre>
</pre>


This tells you a build for target dist-fc7 will use a buildroot with packages from the tag dist-fc7-build and tag the resulting packages as dist-fc7.
这告诉您利用 dist-fc7 这个 target 编译软件包时,编译环境由 dist-fc7-build 这个 tag 中的软件包构成,编译生成的软件包将放入 dist-fc7 这个 tag 中。


You can get a list of tags with the following command:
您可以通过下面的命令查看系统中的 tag 列表:


<pre>
<pre>
Line 79: Line 79:
</pre>
</pre>


==== Package lists ====
==== 软件包列表 ====


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:
前面提到过,每个 tag 都有自己的软件包列表。通过命令 list-pkgs 可以查看一个 tag 中的软件包列表:


<pre>
<pre>
Line 99: Line 99:
</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.
第一列是软件包的名称,第二列告诉您这个软件包从哪个 tag 继承而来。第三列告诉您软件包的所有者是谁。


==== 查看最近的构建任务 ====
==== 查看最近的构建任务 ====


如果您想查看包含某些标签的最近构建任务,请使用 latest-pkg 命令查看:
如果您想查看某个 tag 中软件包的最新版本,请使用 latest-pkg 命令:


<pre>
<pre>
Line 120: Line 120:
</pre>
</pre>


The output gives you not only the latest builds, but which tag they have been inherited from and who built them (note: for builds imported from beehive the "built by" field may be misleading).
输出结果中不仅显示了软件包的最新版本,而且显示了软件包是从哪个 tag 继承而来的,还显示了这个版本的软件包是由谁编译的(注意:对于那些通过 import 命令导入的软件包,"built by" 这个词可能会产生误解)


==== Documentation ====
==== 文档 ====


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 本身包含了使用说明。Koji 命令行终端可以打印出所有的命令列表,并且每一个命令都支持 --help 选项。例如:


<pre>
<pre>
Line 152: Line 152:
</pre>
</pre>


You can see administrator-only command help with --admin. Most users will never use these additional commands, but if you're setting up your own Koji system, you may find them very useful.
使用 --admin 选项,您可以看到需要管理员权限才能执行的命令。大部分用户都用不到这些命令,但是如果您正搭建自己的 Koji 系统,您会发现这些命令非常有用。
<pre>
<pre>
$koji help --admin
$koji help --admin
Line 162: Line 162:
</pre>
</pre>


= 不仅如此 =
= Koji 使用者 =


Koji 本身可被部署在许多地方,我们欢迎您在 [[Koji/RunsHere|这个页面]] 添加您的部署经历。
据我们所知,很多机构部署了 Koji 系统协助完成自己的工作。如果您也用到了 Koji,欢迎您将信息添加到[[Koji/RunsHere|这个页面]]

Latest revision as of 21:05, 19 September 2016

Koji

Koji 是Fedora 社区的编译系统。它使用 Mock 创建编译软件包时需要的编译环境。如果您想下载 Koji 的源代码、反馈问题、加入邮件列表,参见 Koji 项目首页

说明文档

如果您想搭建或者使用 Koji 系统,这里有一些说明文档:

Koji 系统架构

术语

在 Koji 系统中,您有必要区分以下三个概念:一般意义上的软件包、软件包的一次构建、软件包一次构建过程中生成的各个 rpm 包。准确的说,这三个概念可以描述如下:

软件包(Package)
source rpm 的名称。表示一般意义上的软件包,没有指定软件包的具体版本和编译出的子包。比如:kernel、glibc等等。
构建(Build)
特定版本的软件包。表示软件包在一次构建过程中编译出的所有包,包括所有架构的包和编译出的所有包。比如:kernel-2.6.9-34.EL、glibc-2.3.4-2.19。
RPM包(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。

Koji 的组件

Koji 由下列组件构成:

Koji-Hub

koji-hub 是所有 Koji 操作的核心。它是一个运行在 Apache 服务器的 mod_python 模块下的 XML-RPC 服务器。koji-hub 采用被动方式工作,它只接收 XML-RPC 请求,然后依靠编译守护进程以及其他组件来进行通信。Koji-hub 是唯一可以直接访问数据库的组件,也是两个对文件系统具有写权限的组件之一。

Kojid

kojid 是运行在每一台编译机上的编译守护进程。它的主要任务是查询发送过来的编译请求,根据实际情况进行处理。特别地, kojid 通过查询 koji-hub 上的信息进行工作。除了编译软件包 Koji 还支持其他的任务,例如制作系统安装文件,这些任务也由 kojid 进行处理。kojid 利用 mock 创建原始的编译环境,并且为每一次编译任务单独创建一个编译环境。kojid 是用 Python 编写的,并且通过 XML-RPC 与 koji-hub 进行通信。

Koji-Web

koji-web 是一系列运行在 mod_python 模块下,采用 Cheetah 模板引擎生成的可以对 Koji 提供一套 web 页面接口的脚本文件。它作为 koji-hub 的客户端运行,为一些系统管理命令提供了可视化的接口。通过 koji-web,您可以查看 Koji 系统中很多信息。并且 koji-web 提供了一种方式完成系统中的部分操作,如取消软件包编译任务。

Koji Client

koji-client 是用 Python 写成的命令行终端工具,它提供了对 Koji 系统进行操作的很多命令。它允许用户查询系统中的很多信息,还允许用户向 Koji 提交很多操作,比如:添加用户和初始化编译请求。

Kojira

kojira 是保持编译环境与系统同步更新的一个守护进程。它负责删除多余的编译环境,还负责软件包编译任务结束后的清理工作。

软件包组织形式

Tags 和 Targets

Koji 用 tag 组织软件包:

  • tag 保存在数据库中而不是磁盘文件系统中
  • tag 支持多重继承
  • 每个 tag 有它自己有效的软件包列表(软件包列表可以被其他的 tag 继承)
  • 我们可以根据 tag 为软件包设置不同的所有者(所有者关系也可以被其他 tag 继承)
  • tag 继承过程是可以配置的
  • 当您编译软件包时,您应该指定一个 target 而不是一个 tag

一个 target 表明了软件包的编译过程应该在哪里进行,编译生成的软件包应该放入哪个 tag 中。当 tag 的名称随着所发布系统的版本变化后, target 的名称仍然可以保持不变。您可以通过下面的命令查看系统中的 target 列表:

$ koji list-targets

您可以通过 --name 选项查看单个 target 的信息:

$ koji list-targets --name dist-fc7

Name                           Buildroot                      Destination
---------------------------------------------------------------------------------------------
dist-fc7                       dist-fc7-build                 dist-fc7

这告诉您利用 dist-fc7 这个 target 编译软件包时,编译环境由 dist-fc7-build 这个 tag 中的软件包构成,编译生成的软件包将放入 dist-fc7 这个 tag 中。

您可以通过下面的命令查看系统中的 tag 列表:

$ koji list-tags

软件包列表

前面提到过,每个 tag 都有自己的软件包列表。通过命令 list-pkgs 可以查看一个 tag 中的软件包列表:

$ koji list-pkgs --tag dist-fc7

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

第一列是软件包的名称,第二列告诉您这个软件包从哪个 tag 继承而来。第三列告诉您软件包的所有者是谁。

查看最近的构建任务

如果您想查看某个 tag 中软件包的最新版本,请使用 latest-pkg 命令:

$ koji latest-pkg --all dist-fc7

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

输出结果中不仅显示了软件包的最新版本,而且显示了软件包是从哪个 tag 继承而来的,还显示了这个版本的软件包是由谁编译的(注意:对于那些通过 import 命令导入的软件包,"built by" 这个词可能会产生误解)。

文档

我们尽可能让 Koji 本身包含了使用说明。Koji 命令行终端可以打印出所有的命令列表,并且每一个命令都支持 --help 选项。例如:

$ koji help

Koji commands are:
build                Build a package from source
cancel-task          Cancel a task
help                 List available commands
latest-build         Print the latest rpms for a tag
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
--nowait              Don't wait on build
[...] 

使用 --admin 选项,您可以看到需要管理员权限才能执行的命令。大部分用户都用不到这些命令,但是如果您正搭建自己的 Koji 系统,您会发现这些命令非常有用。

$koji help --admin
Available commands:
        add-external-repo         Create an external repo and/or add one to a tag
        add-group                 Add a group to a tag
        add-group-pkg             Add a package to a group's package listing
[...]

Koji 使用者

据我们所知,很多机构部署了 Koji 系统协助完成自己的工作。如果您也用到了 Koji,欢迎您将信息添加到这个页面