Binary package guide/ja

Next to the usual support for ebuilds, Portage supports building and installing binary packages. This guide explains how to create them, install them, and how to setup a binary package server.

はじめに
いくつかのシステム管理者はGentooでバイナリパッケージのインストールを使用するのに多くの理由があります.


 * 1) まず第一に、それは、管理者が更新された同様のシステムを維持することができます.  ソースからすべてをコンパイルするために持つことは時間の浪費になることができます.  唯一のシステムは、ソースからすべてをコンパイルする必要があり、他のシステムにはバイナリパッケージを再利用する場合、いくつかの同様のシステムを維持し、おそらくそれらのいくつかは、古いハードウェアで、はるかに容易にすることができます.
 * 2) 第二の理由は、安全な更新を行うことです.  ミッションクリティカルなシステムのためには、可能な限り使用可能な滞在することが重要です.  これは、それ自体に最初にすべての更新を行い、ステージングサーバーで行うことができます.  ステージングサーバは良好な状態になると更新が次に重要なシステムに適用することができます.  このアプローチの変形は、同じシステム上のchroot環境で更新を行うと、実際のシステムであっ作成したバイナリを使用することです.
 * 3) 第三の理由は、 バックアップの通りです.  多くの場合、バイナリパッケージが壊れたシステム（すなわち、壊れたコンパイラ）を回復する唯一の方法です.  いずれかの周りにプリコンパイルされたバイナリバイナリパッケージサーバ上またはローカルを持つことは、壊れたツールチェーンの場合には大きな助けとすることができます.
 * 4) 最後に、それはまた、 非常に古いシステムの更新をサポートしています.  非常に古いシステムを更新する作業が大幅にバイナリパッケージを使用して緩和することができます.  これらはビルド時の依存関係を更新/インストールする必要はありませんので、古いシステム上でバイナリパッケージをインストールするには、通常は便利です.  彼らは事前にコンパイルされているので、バイナリパッケージもビルドプロセスの失敗を回避します.

This guide will focus on the following topics:


 * How to create binary packages;
 * How to distribute the packages to clients;
 * How to use binary packages;
 * How to maintain the binary packages.

終わり近くにバイナリパッケージを扱うには、いくつかのより高度なトピックがカバーされます.

バイナリーパッケージを作成する
There are three main methods for creating binary packages:


 * 1) After a regular installation, using the  application;
 * 2) Explicitly during an  operation by using the   option;
 * 3) Automatically through the use of the   as a Portage feature.

All three methods will create a binary package in the directory pointed to by the PKGDIR variable (which defaults to ).

quickpkg を利用する
The application takes one or more dependency atoms (or package sets) and creates binary packages for all installed packages that match that atom.

For instance, to create binary packages of all installed GCC versions:

To create binary packages of all installed packages on the system, use the  glob:

There is a caveat with this method: it relies on the installed files, which can be a problem in case of configuration files. Administrators often change configuration files after installing software. Because this could leak out important (perhaps even confidential) data into the packages, by default does not include configuration files that are protected through the CONFIG_PROTECT method. To force inclusion of configuration files, use the  or   options.

emerge のオプションに --buildpkg を使用する
When installing software using, Portage can be asked to create binary packages by using  option:

It is also possible to ask Portage to only create a binary package but not to install the software on the live system. For this, the  option can be used:

The latter approach however requires all build time dependencies to be previously installed.

Implementing buildpkg as a Portage feature
The most common way to automatically create binary packages whenever a package is installed by Portage is to use the  feature, which can be set in  like so:

この機能を有効にすると、Portageがソフトウェアをインストールするたびに、それは同様にバイナリパッケージを作成します.

Excluding creation of some packages
It is possible to tell Portage not to create binary packages for a select few packages or categories. This is done by passing the  option to emerge:

This could be used for packages that have little to no benefit in having a binary package available. Examples would be the Linux kernel source packages or upstream binary packages (those ending with -bin like ).

Setting up a binary package host
Portage supports a number of protocols for downloading binary packages: FTP, FTPS, HTTP, HTTPS and SSH. This leaves room for many possible binary package host implementations.

There is, however, no "out-of-the-box" method provided by Portage for distributing binary packages. Depending on the desired setup additional software will need to be installed.

Web based binary package host
A common approach for distributing binary packages is to create a web-based binary package host.

Use a web server such as lighttpd and configure it to provide read access to 's PKGDIR location.

Then, on the client systems, configure the PORTAGE_BINHOST variable accordingly:

SSH binary package host
To provide a more authenticated approach for binary packages, one can consider using SSH.

When using SSH, it is possible to use the Portage Linux user's SSH key (without passphrase as the installations need to happen in the background) to connect to a remote binary package host.

To accomplish this, make sure that the Portage user's SSH key is allowed on the server. This will need to happen for each machine that will connect to the SSH capable binary host:

The PORTAGE_BINHOST variable could then look like so:

NFS exported
When using binary packages on an internal network, it might be easier to export the packages through NFS and mount it on the clients.

The file could look like so:

On the clients, the location can then be mounted. An example entry would look like so:

バイナリーパッケージを使用する
For binary packages to be usable on other systems they must fulfill some requirements:


 * The client and server architecture and CHOST must match.
 * The CFLAGS and CXXFLAGS variables used to build the binary packages must be compatible with all clients.
 * USE flags for processor specific features (like MMX, SSE,...) have to be carefully selected; all clients need to support them.

Next to these, Portage will check if the binary package is built using the same USE flags as expected on the client. If a package is built with a different USE flag combination, Portage will either ignore the binary package (and use source-based build) or fail, depending on the options passed to the command upon invocation (see Installing binary packages).

On clients, a few configuration changes are needed in order for the binary packages to be used.

バイナリーパッケージをインストールする
There are a few options that can be passed on to the command that inform Portage about using binary packages:

In order to automatically use binary package installations, the appropriate option can be added to the EMERGE_DEFAULT_OPTS variable:

There is a Portage feature that automatically implements the equivalent of  without the need for updating the EMERGE_DEFAULT_OPTS variable:

Pulling packages from a binary package host
When using a binary package host, clients need to have the PORTAGE_BINHOST variable set. Otherwise the client will not know where the binary packages are stored which results in Portage being unable to retrieve them.

The PORTAGE_BINHOST variable uses a space-separated list of URIs. This allows administrators to use several binary package servers simultaneously. The URI must always point to the directory in which the file resides.

改変したバイナリーパッケージを再インストールする
Passing the  option to emerge will reinstall every binary that has been rebuilt since the package was installed. This is useful in case rebuilding tools like or  are run on the binary package server.

A related option is. It causes emerge not to consider binary packages for a re-install if those binary packages have been built before the given time stamp. This is useful to avoid re-installing all packages, if the binary package server had to be rebuild from scratch but  is used otherwise.

Additional client settings
Next to the  feature, Portage also listens to the   feature. This one controls if log files for successful binary package installations should be kept. It is only relevant if the PORT_LOGDIR variable has been set and is enabled by default.

Similar to excluding binary packages for a certain set of packages or categories, clients can be configured to exclude binary package installations for a certain set of packages or categories.

To accomplish this, use the  option:

バイナリーパッケージを管理する
Exporting and distributing the binary packages will lead to useless storage consumption if the binary package list is not actively maintained.

不用なバイナリーパッケージを削除する
In the package an application called  is provided. It allows for maintaining Portage-related variable files, such as downloaded source code files, but also binary packages.

The following command will remove all binary packages that have no corresponding ebuild:

詳細は Eclean の記事を読んでください.

Another tool that can be used is the tool from the  package. However, this tool is a bit less configurable.

To clean up unused binary packages (in the sense of used by the server on which the binary packages are stored):

Packages のファイルを管理する
Inside the packages directory, a file called exists. This file acts as a cache for the metadata of all binary packages in the packages directory. The file is updated whenever Portage adds a binary package to the directory. Similarly, updates it when it removes binary packages.

If for some reason binary packages are simply deleted or copied into the packages directory, or the file gets corrupted or deleted, then it must be recreated. This is done using command:

Creating snapshots of the packages directory
When deploying binary packages for a large number of client systems it might become worthwhile to create snapshots of the packages directory. The client systems then do not use the packages directory directly but use binary packages from the snapshot.

Snapshots can be created using the or  tool. It takes four arguments:


 * 1) A source directory (the path to the packages directory).
 * 2) A target directory (that must not exist).
 * 3) A URI.
 * 4) A binary package server directory.

The files from the package directory are copied to the target directory. A file is then created inside the binary package server directory (fourth argument) with the provided URI.

Client systems need to use an URI that points to the binary package server directory. From there they will be redirected to the URI that was given to. This URI has to refer to the target directory.

Understanding the binary package format
Binary packages created by Portage have the file name ending with. These files consist of two parts:


 * 1) A  archive containing the files that will be installed on the system.
 * 2) A  archive containing package metadata, the ebuild, and the environment file.

See for a description of the format.

In some tools exists that are able to split or create  and  files.

The following command will split the into a  and an  file:

The file can be examined using the  utility.

To list the contents:

The next command will extract a file called which contains the enabled USE flags for this package:

PKGDIR の構成
The currently used format version 2 has the following layout:

The file is the major improvement (and also the trigger for Portage to know that the binary package directory uses version 2) over the first binary package directory layout (version 1). In version 1, all binary packages were also hosted inside a single directory (called ) and the category directories only had symbolic links to the binary packages inside the directory.

quickunpkg を用いて展開する
Zoobab wrote a simple shell tool named quickunpkg to quickly unpack files.