#title Chapter 6. パッケージのアップデート If you have been around Linux distributions for any amount of time, you have realized that there are sometimes bugs in programs. In the Debian and Ubuntu distributions, bugs are often fixed through the packaging by patching the source code. Sometimes there are bugs in the packaging itself that can cause difficulties. ある程度Linuxディストリビューションに触れていると、たまにプログラムの不具合に遭遇することがあるでしょう。DebianやUbuntuのようなディストリビューションでは、パッケージの中でソースコードにパッチを適用することで不具合を修正することがたまにあります。パッケージ自身に不具合がある場合は、原因追求が難しくなるかもしれません。 To patch the program's source code, you could simply download the current Ubuntu source package (with '''apt-get source''') and make the needed changes. You can then add a new entry to the `debian/changelog` using '''dch -i''' or '''dch -v -''' to specify the new revision. When you run '''debuild -S''' from the source directory you will have a new source package with a new `.diff.gz` in the parent directory that contains your changes. A problem with this approach is that the distinction between source and patches is unclear. プログラムのソースコードの不具合を修正する簡単な方法は次のようになります。まず最新のUbuntuソースパッケージをダウンロードし('''apt-get source'''コマンド)、修正を加えます。次に'''dch -i'''や'''dch -v -'''を使って`debian/changelog`に新しいエントリを追加し、新バージョンの情報を書き込みます。あとはソースディレクトリから'''debuild -S'''を実行すれば、今回の変更点を含む`.diff.gz`と共に新しいソースパッケージが作成されます。この方法の問題点は、ソースとパッチの間の違いがはっきりしないことです。 A solution to this problem is to separate the changes to the source code into individual patches stored in the `debian` directory. One such patch system is called '''dpatch'''. The patches are stored in the `debian/patches/` directory and have a special format. この問題を解決する一つの方法は、ソースコードに対する変更点を分離し、個々のパッチを`debian`ディレクトリに格納することです。それを行うパッチシステムの一つは'''dpatch'''と呼ばれています。このシステムを利用すれば、パッチは特別なフォーマットで、`debian/patches/`ディレクトリに格納されます。 To create a '''dpatch''', perform the following steps sequentially. '''dpatch'''ファイルを作成するためには、以下の手順を順に行ってください。 Create a temporary work space and two copies of the current source directory: まず、一時的な作業用ディレクトリを作成し、現在のソースディレクトリを二ヶ所にコピーします: {{{ mkdir tmp cd tmp cp -a ../- . cp -a - -.orig }}} Make the changes in the `-` directory. `-`ディレクトリに変更を加えます。 Create a patch file using '''diff''' and place it in the `debian/patches` directory: '''diff'''コマンドを使ってパッチファイルを作成し、`debian/patches`ディレクトリに配置します: {{{ diff -Nru -.orig - > patch-file }}} Create the '''dpatch''' using '''dpatch patch-template''' and a file named `00list` that lists the dpatches: '''dpatch patch-template'''コマンドを使って'''dpatch'''ファイルを作成し、dpatchファイルのリストである`00list`にその名前を追加します: {{{ dpatch patch-template -p "01_patchname" "patch-file description" \ < patch-file > 01_patchname.dpatch echo 01_patchname.dpatch >00list }}} You can now place `01_patchname.dpatch` and `00list` in the `debian/patches` directory of your source package: `01_patchname.dpatch`ファイルと`00list`ファイルをソースパッケージの`debian/patches`ディレクトリに配置します: {{{ mkdir ../-/debian/patches cp 01_patchname.dpatch 00list ../-/debian/patches cd .. rm -rf tmp }}} . [[attachment:UbuntuPackagingGuideJa/conventions/note.png|{{attachment:UbuntuPackagingGuideJa/conventions/note.png}}]] You can also edit a pre-existing patch using '''dpatch-edit-patch'''. . [[attachment:UbuntuPackagingGuideJa/conventions/note.png|{{attachment:UbuntuPackagingGuideJa/conventions/note.png}}]] '''dpatch-edit-patch'''を使えば、既存のパッチを編集することもできます。 Once all the changes have been made, a changelog entry added, and '''dpatch''' added to the `debian/control` file (if needed), then you can rebuild the source package with '''debuild -S'''. すべての変更が加えられ、changelogファイルにエントリを追加し、(必要なら)`debian/control`ファイルに'''dpatch'''を追加したら、'''debuild -S'''コマンドでソースパッケージをリビルドできます。 To get your fixed source package uploaded to the Ubuntu repositories, you will need to get your source package sponsored by a person who has upload rights. See [[UbuntuPackagingGuideJa/ubuntu-upload|the section called “Uploading and Review”]] for more details. Sometimes, rather than giving the entire source package (.diff.gz, .dsc, and .orig.tar.gz), it is easier and more efficient to just give the difference between the source package that is currently in the repositories and your fixed source package. A tool has been created to do just that called '''debdiff'''. Using '''debdiff''' is similar to using '''diff''' but is made specifically for packaging. You can '''debdiff''' the source package by: 修正したソースパッケージをUbuntuレポジトリにアップロードするためには、アップロード権限のある人に後見人になってもらう必要があります。詳しいことは[[UbuntuPackagingGuideJa/ubuntu-upload|“アップロードとレビュー”セクション]]を参照してください。ソースパッケージそのもの(.diff.gz, .dsc, .orig.tar.gz)を提出するよりも、現在レポジトリにあるソースパッケージと修正したソースパッケージの間の差分を提出した方がいい場合もあります。差分は、'''debdiff'''と呼ばれるツールを使えば作成できます。'''debdiff'''は'''diff'''に似ていますが、パッケージの差分を作成することに特化しています。'''debdiff'''を使ってソースパッケージの差分をとるには次のようにします: {{{ debdiff .dsc .dsc > package.debdiff }}} or the binary package by: バイナリパッケージの差分をとるには: {{{ debdiff .deb .deb > package.debdiff }}} Debdiffs are great to attach to bug reports and have ready for a sponsor to upload. debdiffファイルをバグレポートに添付すれば、後見人がアップロードする準備が整います。 ||<:20%>,,<=,, ||<:60%>||<:20%> ,,=>,,|| ||<:20%>[[UbuntuPackagingGuideJa/ch05s04|他の人が作ったパッケージにパッチする]]||<:60%>'''パッケージのアップデート'''||<:20%> [[UbuntuPackagingGuideJa/ubuntu-chap|Ubuntuでのパッケージング]]||