「DeveloperWiki:クリーンな chroot 内でビルドする」の版間の差分
(セクション見出しの訳出) |
|||
1行目: | 1行目: | ||
[[Category: DeveloperWiki]] |
[[Category: DeveloperWiki]] |
||
− | [[Category: |
+ | [[Category: パッケージ開発]] |
+ | [[en:DeveloperWiki:Building in a clean chroot]] |
||
− | == Introduction == |
||
+ | == 導入 == |
||
− | This article is part of the [[DeveloperWiki]]. |
+ | This article is part of the [[:en:DeveloperWiki]]. |
− | == |
+ | == 理由 == |
Building in a clean chroot prevents missing dependencies in packages, whether due to unwanted linking or packages missing in the depends array in the PKGBUILD. It also allows users to build a package for the stable repositories (core, extra, community) while having packages from [testing] installed. |
Building in a clean chroot prevents missing dependencies in packages, whether due to unwanted linking or packages missing in the depends array in the PKGBUILD. It also allows users to build a package for the stable repositories (core, extra, community) while having packages from [testing] installed. |
||
− | == |
+ | == 便利な方法 == |
To quickly build a package in a clean chroot without any further tinkering, one can use the helper scripts from the {{Pkg|devtools}} package. |
To quickly build a package in a clean chroot without any further tinkering, one can use the helper scripts from the {{Pkg|devtools}} package. |
||
36行目: | 37行目: | ||
|} |
|} |
||
− | == |
+ | == 従来の方法 == |
− | === |
+ | === chroot のセットアップ === |
The {{Pkg|devtools}} package provides tools for creating and building within clean chroots. Install it if not done already. |
The {{Pkg|devtools}} package provides tools for creating and building within clean chroots. Install it if not done already. |
||
60行目: | 61行目: | ||
{{Note|The {{ic|~}} and {{ic|$HOME}} variable are resolved to {{ic|/root/}} by the ''makechrootpkg'' script (described below).}} |
{{Note|The {{ic|~}} and {{ic|$HOME}} variable are resolved to {{ic|/root/}} by the ''makechrootpkg'' script (described below).}} |
||
− | ==== |
+ | ==== pacman.conf のカスタマイズ ==== |
Alternatively, provide a custom {{ic|pacman.conf}} and {{ic|makepkg.conf}} with the following: |
Alternatively, provide a custom {{ic|pacman.conf}} and {{ic|makepkg.conf}} with the following: |
||
69行目: | 70行目: | ||
Using a custom {{ic|pacman.conf}} or {{ic|makepkg.conf}} during the initial creation of clean chroot can result in unintended custom adjustments to the chroot environment. ''Use with caution.''}} |
Using a custom {{ic|pacman.conf}} or {{ic|makepkg.conf}} during the initial creation of clean chroot can result in unintended custom adjustments to the chroot environment. ''Use with caution.''}} |
||
− | === |
+ | === chroot の中でビルドする === |
Firstly, make sure the base chroot ({{ic|$CHROOT/root}}) is up to date: |
Firstly, make sure the base chroot ({{ic|$CHROOT/root}}) is up to date: |
||
81行目: | 82行目: | ||
{{Note|Passing the {{ic|-c}} flag to {{ic|makechrootpkg}} ensures that the working chroot ({{ic|$CHROOT/$USER}}) is cleaned before building.}} |
{{Note|Passing the {{ic|-c}} flag to {{ic|makechrootpkg}} ensures that the working chroot ({{ic|$CHROOT/$USER}}) is cleaned before building.}} |
||
+ | ==== 必要なパッケージを事前にインストールする ==== |
||
− | ==== Pre-install required packages ==== |
||
To build a package with dependencies unavailable from the repositories enabled in {{ic|$CHROOT/root/pacman.conf}}, pre-install them to the working chroot with {{ic|-I <package>}}: |
To build a package with dependencies unavailable from the repositories enabled in {{ic|$CHROOT/root/pacman.conf}}, pre-install them to the working chroot with {{ic|-I <package>}}: |
||
87行目: | 88行目: | ||
$ makechrootpkg -c -r $CHROOT -I build-dependency-1.0-1-x86_64.pkg.tar.xz -I required-package-2.0-2-x86_64.pkg.tar.xz |
$ makechrootpkg -c -r $CHROOT -I build-dependency-1.0-1-x86_64.pkg.tar.xz -I required-package-2.0-2-x86_64.pkg.tar.xz |
||
− | ==== |
+ | ==== makepkg に引数を渡す ==== |
To pass arguments to [[Makepkg#Usage|makepkg]], list them after an [http://wiki.bash-hackers.org/dict/terms/end_of_options end-of-options marker]; e.g., to force a check(): |
To pass arguments to [[Makepkg#Usage|makepkg]], list them after an [http://wiki.bash-hackers.org/dict/terms/end_of_options end-of-options marker]; e.g., to force a check(): |
||
$ makechrootpkg -c -r $CHROOT -- --check |
$ makechrootpkg -c -r $CHROOT -- --check |
||
+ | == 一般的なリビルドを扱う == |
||
− | == Handling major rebuilds == |
||
The cleanest way to handle a major rebuild is to use the [staging] repositories. Build the first package against [extra] and push it to [staging]. Then rebuild all following packages against [staging] and push them there. |
The cleanest way to handle a major rebuild is to use the [staging] repositories. Build the first package against [extra] and push it to [staging]. Then rebuild all following packages against [staging] and push them there. |
||
112行目: | 113行目: | ||
Running namcap (the -n argument) implies installing the package in the chroot. *-build also does this by default. |
Running namcap (the -n argument) implies installing the package in the chroot. *-build also does this by default. |
||
+ | == ヒントとテクニック == |
||
− | == Tips and tricks == |
||
− | === |
+ | === tmpfs 内でビルドする === |
If the system has enough RAM, it is possible to specify a [[tmpfs]] for the {{Pkg|devtools}} build scripts. |
If the system has enough RAM, it is possible to specify a [[tmpfs]] for the {{Pkg|devtools}} build scripts. |
2020年5月25日 (月) 13:43時点における版
目次
導入
This article is part of the en:DeveloperWiki.
理由
Building in a clean chroot prevents missing dependencies in packages, whether due to unwanted linking or packages missing in the depends array in the PKGBUILD. It also allows users to build a package for the stable repositories (core, extra, community) while having packages from [testing] installed.
便利な方法
To quickly build a package in a clean chroot without any further tinkering, one can use the helper scripts from the devtools package.
These helper scripts should be called in the same directory where the PKGBUILD is, just like with makepkg. For instance, extra-x86_64-build
automatically sets up a chroot from a clean chroot matrix in /var/lib/archbuild
, updates it, and builds a package for the extra repository. For multilib builds there is just multilib-build
without an architecture. Consult the table below for information on which script to use when building for a specific repository and architecture.
The -c
parameter resets the chroot matrix, which can be useful in case of breakage. It is not needed for building in a clean chroot.
Target repository | Architecture | Build script to use | Pacman configuration file used |
---|---|---|---|
extra / community | x86_64 | extra-x86_64-build | /usr/share/devtools/pacman-extra.conf |
testing / community-testing | x86_64 | testing-x86_64-build | /usr/share/devtools/pacman-testing.conf |
staging / community-staging | x86_64 | staging-x86_64-build | /usr/share/devtools/pacman-staging.conf |
multilib | x86_64 | multilib-build | /usr/share/devtools/pacman-multilib.conf |
multilib-testing | x86_64 | multilib-testing-build | /usr/share/devtools/pacman-multilib-testing.conf |
multilib-staging | x86_64 | multilib-staging-build | /usr/share/devtools/pacman-multilib-staging.conf |
従来の方法
chroot のセットアップ
The devtools package provides tools for creating and building within clean chroots. Install it if not done already.
To make a clean chroot, create a directory in which the chroot will reside. For example, $HOME/chroot
.
$ mkdir ~/chroot
Define the CHROOT
variable:
$ CHROOT=$HOME/chroot
Now create the chroot (the sub directory root
is required because the $CHROOT
directory will get other sub directories for clean working copies):
$ mkarchroot $CHROOT/root base-devel
Edit ~/.makepkg.conf
to set the packager name and any makeflags. Also adjust the mirrorlist in $CHROOT/root/etc/pacman.d/mirrorlist
and enable the testing repository in $CHROOT/root/etc/pacman.conf
, if desired.
pacman.conf のカスタマイズ
Alternatively, provide a custom pacman.conf
and makepkg.conf
with the following:
$ mkarchroot -C <pacman.conf> -M <makepkg.conf> $CHROOT/root base-devel
chroot の中でビルドする
Firstly, make sure the base chroot ($CHROOT/root
) is up to date:
$ arch-nspawn $CHROOT/root pacman -Syu
Then, build a package by calling makechrootpkg
in the directory containing its PKGBUILD:
$ makechrootpkg -c -r $CHROOT
必要なパッケージを事前にインストールする
To build a package with dependencies unavailable from the repositories enabled in $CHROOT/root/pacman.conf
, pre-install them to the working chroot with -I <package>
:
$ makechrootpkg -c -r $CHROOT -I build-dependency-1.0-1-x86_64.pkg.tar.xz -I required-package-2.0-2-x86_64.pkg.tar.xz
makepkg に引数を渡す
To pass arguments to makepkg, list them after an end-of-options marker; e.g., to force a check():
$ makechrootpkg -c -r $CHROOT -- --check
一般的なリビルドを扱う
The cleanest way to handle a major rebuild is to use the [staging] repositories. Build the first package against [extra] and push it to [staging]. Then rebuild all following packages against [staging] and push them there.
If you can't use [staging], you can build against custom packages using a command like this:
# extra-x86_64-build -- -I ~/packages/foobar/foobar-2-1-any.pkg.tar.xz
You can specify more than one package to be installed using multiple -I arguments.
A simpler, but dirtier way to handle a major rebuild is to install all built packages in the chroot, never cleaning it. Build the first package using:
# extra-x86_64-build
And build all following packages using:
# makechrootpkg -n -r /var/lib/archbuild/extra-x86_64
Running namcap (the -n argument) implies installing the package in the chroot. *-build also does this by default.
ヒントとテクニック
tmpfs 内でビルドする
If the system has enough RAM, it is possible to specify a tmpfs for the devtools build scripts.
# mkdir -p /mnt/chroots/arch # mount -t tmpfs -o defaults,size=20G /mnt/chroots/arch # extra-x86_64-build -c -r /mnt/chroots/arch