apt-get source source-package-name
command. This command requires a deb-src
line in the /etc/apt/sources.list
file, and up-to-date index files (i.e. apt-get update
). These conditions should already be met if you followed the instructions from the chapter dealing with APT configuration (see 第 6.1 節「sources.list
ファイルの内容」). Note, however, that you will be downloading the source packages from the Debian version mentioned in the deb-src
line. If you need another version, you may need to download it manually from a Debian mirror or from the web site. This involves fetching two or three files (with extensions *.dsc
— for Debian Source Control — *.tar.comp
, and sometimes *.diff.gz
or *.debian.tar.comp
— comp taking one value among gz
, bz2
or xz
depending on the compression tool in use), then run the dpkg-source -x file.dsc
command. If the *.dsc
file is directly accessible at a given URL, there is an even simpler way to fetch it all, with the dget URL
command. This command (which can be found in the devscripts package) fetches the *.dsc
file at the given address, then analyzes its contents, and automatically fetches the file or files referenced within. Once everything has been downloaded, it verifies the integrity of the downloaded source packages using dscverify
, and it extracts the source package (unless the -d
or --download-only
option is used). The Debian keyring is needed, unless the option -u
is supplied.
$
apt source samba
Reading package lists... Done NOTICE: 'samba' packaging is maintained in the 'Git' version control system at: https://salsa.debian.org/samba-team/samba.git Please use: git clone https://salsa.debian.org/samba-team/samba.git to retrieve the latest (possibly unreleased) updates to the package. Need to get 11.7 MB of source archives. Get:1 http://security.debian.org/debian-security buster/updates/main samba 2:4.9.5+dfsg-5+deb10u1 (dsc) [4,316 B] Get:2 http://security.debian.org/debian-security buster/updates/main samba 2:4.9.5+dfsg-5+deb10u1 (tar) [11.4 MB] Get:3 http://security.debian.org/debian-security buster/updates/main samba 2:4.9.5+dfsg-5+deb10u1 (diff) [252 kB] Fetched 11.7 MB in 1s (9,505 kB/s) dpkg-source: info: extracting samba in samba-4.9.5+dfsg dpkg-source: info: unpacking samba_4.9.5+dfsg.orig.tar.xz dpkg-source: info: unpacking samba_4.9.5+dfsg-5+deb10u1.debian.tar.xz dpkg-source: info: using patch list from debian/patches/series dpkg-source: info: applying 07_private_lib dpkg-source: info: applying bug_221618_precise-64bit-prototype.patch [...]
2:4.9.5+dfsg-5
, we can create version 2:4.9.5+dfsg-5falcot1
, which clearly indicates the origin of the package. This makes the package version number higher than the one provided by Debian, so that the package will easily install as an update to the original package. Such a change is best effected with the dch
command (Debian CHangelog) from the devscripts package.
The last command invokes a text editor ($
cd samba-4.9.5+dfsg
$
dch --local falcot
sensible-editor
— this should be your favorite editor if it is mentioned in the VISUAL
or EDITOR
environment variables, and the default editor otherwise) to allow documenting the differences brought by this rebuild. This editor shows us that dch
really did change the debian/changelog
file.
debian/rules
を修正します。debian/rules
はパッケージビルド作業の各段階を動作させるものです。debian/rules
が最も単純に書かれている場合、初期設定 (./configure …
) や実際のビルド ($(MAKE) …
や make …
) を実行するコマンドを簡単に見つけられるでしょう。ファイル内にこれらのコマンドが明示的に書かれていない場合、このファイルの内容は別のコマンドに対する作用を書いているのかもしれません。このような場合、デフォルト挙動を変える方法をより詳細に学ぶために文書を参照してください。dh
を使っているパッケージのビルドオプションを変更する場合、dh_auto_configure
や dh_auto_build
コマンドを再定義する必要があるかもしれません (これを行う方法に関する説明は各コマンドのマニュアルページをご覧ください)。
debian/control
ファイルの内容もまた更新する必要があります。debian/control
ファイルには生成されるパッケージの説明が含まれます。特に、debian/control
ファイルにはパッケージのビルド時点で満足されなければいけない依存関係のリストを制御する Build-Depends
行が含まれます。Build-Depends
行で指定されているパッケージのバージョンはソースパッケージが提供されるディストリビューションに含まれるパッケージのバージョンと一致している場合が多いです。しかし、再ビルドを行うディストリビューションではここで指定されているバージョンが利用できないかもしれません。依存関係が本物か、それともビルド時にライブラリの最新版を試すことを保証するためだけ指定されているかを決定する自動的な方法はありません。Build-Depends
行を使うことが自動ビルドロボットにビルド中に与えられたパッケージバージョンを使うことを強制するための唯一の方法なので、Debian メンテナはバージョンを厳しく指定したビルド依存関係を使うことが多いです。
INSTALL
と名付けられていることが多いです) を読むことは適切な依存関係を明らかにする助けになります。理想的に言えば、再ビルドに使うディストリビューションの要素を使ってすべての依存関係を満足させるべきです。しかしそれが無理ならば、対象のパッケージをバックポートする前に、再帰的に Build-Depends
フィールドで言及されているパッケージを必ずバックポートしなければいけません。一部のパッケージはバックポートの必要がなく、ビルド作業中に現状のままインストールできます (特筆すべき例は debhelper です)。バックポート作業は気を付けないとすぐに複雑になる点に注意してください。それゆえ、バックポートは可能な限り厳密に必要最低限に留めるべきです。
.deb
ファイル) を生成します。すべてのプロセスは dpkg-buildpackage
コマンドで管理されます。
Build-Depends
フィールドが更新されていなかったり、関連するパッケージがインストールされていなかった場合、dpkg-buildpackage
コマンドは失敗します。そのような場合、dpkg-buildpackage
に -d
オプションを指定して、依存関係確認を行わないようにすることも可能です。しかしながら、依存関係を明示的に無視すると後々の段階でビルド作業が失敗する恐れがあります。さらに悪いことに、パッケージが正常にビルドされたように見えても正しく動かない可能性があります。なぜなら一部のプログラムは必要なライブラリがビルド時に利用できない場合に一部の機能を自動的に無効化するからです。
debuild
などの高レベルプログラムを使います。debuild
は通常通り dpkg-buildpackage
を実行するだけでなく、生成されたパッケージの Debian ポリシーに対する妥当性を確認するプログラムも実行します。debuild
スクリプトは、手元の環境変数がパッケージビルドを「汚染」しないように、ビルド環境を整えます。debuild
コマンドは devscripts スイートに含まれるツールの 1 つで、メンテナの作業を簡単にするためのいくつかの一貫性と設定を共有します。