bionic (1) update-alternatives.1.gz

Provided by: dpkg_1.19.0.5ubuntu2.4_amd64 bug

名前

       update-alternatives - シンボリックリンクを管理してデフォルトのコマンドを決定する

書式

       update-alternatives [option...] command

説明

       update-alternatives  は Debian の alternatives システムを構成するシンボリックリンクを生成・削除・管理した
       り、リンクの情報を表示したりするツールである。

       同一の、あるいは類似の機能を持つ複数のプログラムを一つのシステムに同時にインストールし、共存させることが
       できる。例えば多くのシステムでは、複数のテキストエディタを共存させている。これにより、システムのユーザは
       好みに応じて別々のエディタを使うことができるようになる。しかしプログラムからすると、特に指定がなかったと
       きにどのエディタを起動すれば良いのかという、なかなか難しい問題を抱えることになる。

       Debian の alternatives システムは、この問題を解決するためのものである。互いに置き換え可能な機能を提供する
       全てのファイルは、ファイルシステム中の「一般名 (generic name)」を共有する。その一般名が実際にどのファイル
       を参照するかは、  alternatives システムとシステム管理者とが決定する。例えば、テキストエディタである ed(1)
       と nvi(1) の両方がシステムにインストールされていたとすると、一般名である /usr/bin/editor は、デフォルトで
       は /usr/bin/nvi を参照する。システム管理者はこれを上書きし、 /usr/bin/ed を参照させるようにすることもでき
       る。こうすると、その後明示的な設定がなければ、 alternatives システムはその設定を変更しない。

       一般名は、選ばれた「選択肢 (alternative)」への直接のシンボリックリンクではなく、 alternatives  ディレクト
        にある名前へのシンボリックリンクになっており、その名前が実際に参照されるファイルへのシンボリックリンク
       になっている。こうなっている理由は、システム管理者による変更を /etc  ディレクトリ以下で完結させるためであ
       る。なぜこうするのが良いかについては FHS に説明がある。

       When  each  package  providing  a  file with a particular functionality is installed, changed or removed,
       update-alternatives is called  to  update  information  about  that  file  in  the  alternatives  system.
       update-alternatives  is  usually  called  from the postinst (configure) or prerm (remove and deconfigure)
       scripts in Debian packages.

       複数の選択肢を同期させ、グループとして変更すると便利なことが多い。例えば vi(1) エディタのいろいろな派生シ
       ステムが同時にインストールされていたとすると、   /usr/share/man/man1/vi.1   が参照する   man   ページは、
       /usr/bin/vi が参照する実行ファイルに対応しているべきであろう。 update-alternatives は、  master  リンクと
       slave リンクによってこれを取り扱う。 master が変更されると、それに関連づけされた各 slave も同時に変更され
       る。 master リンクとそれに関連づけされた slave とは、 リンクグループ を形成する。

       各リンクグループは、いかなる時点においても、 automatic または manual の 2  つのモードのいずれかにある。グ
       ループが automatic モードにある場合は、パッケージのインストール・削除の際にリンクを更新するか、どのように
       更新するかは、 alternatives システムが自動的に決定する。 manual モードでは、 alternatives システムは  (何
       らかの問題が発生した場合を除き) リンクを変更せず、システム管理者の行った設定が保持される。

       リンクグループがシステムに導入されると、まず automatic モードとして機能する。システム管理者がその設定を変
       更すると、次に  update-alternatives  がリンクグループに対して実行されたときに変更が認識され、そのリンクグ
       ループは自動的に manual モードに切り換わる。

       各選択肢は priority 属性を持っている。リンクグループが automatic モードにあるときは、 priority のもっとも
       高いものが、そのグループのメンバーが参照する選択肢になる。

       When using the --config option, update-alternatives will list all of the choices for the  link  group  of
       which given name is the master alternative name.  The current choice is marked with a ‘*’.  You will then
       be prompted for your choice regarding this link group.  Depending on the  choice  made,  the  link  group
       might  no  longer  be  in  auto  mode.  You  will need to use the --auto option in order to return to the
       automatic mode (or you can rerun --config and select the entry marked as automatic).

       非対話的に設定をしたい場合は --set オプションを代わりに使用する (以下を参照)。

       同一のファイルを提供する異なるパッケージは、これを   協調して    行う必要がある。言い換えると、こうした場
       合、関連するパッケージのすべてで update-alternatives の使用が必須となる。update-alternatives 機構を使用し
       ていないパッケージのファイルを上書きすることはできない。

用語

       update-alternatives  の動作は極めて複雑なので、ここでいくつかの固有の用語を説明し、動作の理解の助けとした
       い。

       一般名 (generic name / alternative link)
              /usr/bin/editor のような名前。 alternatives システムによって、類似の機能を持つ複数のファイルのいず
              れかを参照する。

       選択肢名 (alternative name)
              alternatives ディレクトリに存在するシンボリックリンク名

       選択肢 (alternative / alternative path)
              ファイルシステム中の特定ファイルの名称、alternatives  システムによって、一般名からのアクセスが可能
              となる。

       alternatives ディレクトリ
              シンボリックリンクを保持するディレクトリ。デフォルトは /etc/alternatives。

       administrative ディレクトリ
              update-alternatives の状態情報を保持するディレクトリ。デフォルトは /var/lib/dpkg/alternatives。

       リンクグループ
              関連するシンボリックリンクのセットで、グループ単位での更新を行うためのもの。

       master リンク
              リンクグループに属する選択肢のリンクで、グループ内の他のリンクの設定を決定するもの。

       slave リンク
              リンクグループに属する選択肢のリンクで、 master リンクの設定によって設定されるもの。

       automatic モード
              リンクグループが   automatic   モードにある場合、alternatives   システムは、グループ内の各リンクが
              priority のもっとも高い選択肢を参照することを担保する。

       manual モード
              リンクグループが manual モードにある場合、alternatives  システムはシステム管理者の行った設定を一切
              変更しない。

コマンド

       --install link name path priority [--slave link name path]...
              選択肢のグループをシステムに追加する。link は master リンクの一般名、name は alternatives ディレク
              トリにおけるシンボリックリンクの名前、 path は master リンクとなる選択肢の名前となる。--slave オプ
              ションに続く引数は、alternatives ディレクトリでの一般名およびシンボリックリンクの名前と slave リン
              クとなる選択肢のパスの順となる。--slave オプションと、それにに続く 3  つの引数のセットは、いくつ設
              定してもよく、まったく設定しないこともできる。master  となる選択肢は必ず存在している必要があり、存
              在していない場合は失敗となるが、slave  の選択肢がインストールされていない場合は、(依然として警告が
              表示されるものの)  対応する slave の選択肢のリンクが単にインストールされないだけである。選択肢のリ
              ンクがインストールされるパスに、何らかの実ファイルがインストールされている場合、--force が指定され
              ない限り、それらのファイルは保持される。

              指定された選択肢の名前が既に alternatives システム内に存在している場合、与えられた情報は、グループ
              に対する新たな選択肢として追加される。それ以外の場合は、与えられた情報を用いて、新しいグループが
              automatic モードで追加される。グループが automatic モードにあり、新たに追加された選択肢の priority
              がそのグループに対してインストールされている他の選択肢のものより高い場合、シンボリックリンクは新た
              に追加された選択肢を参照するように更新される。

       --set name path
              プログラム  pathname  の選択肢として設定する。 --config と同等だが、こちらは非対話的であるた
              め、スクリプト向けである。

       --remove name path
              (master の) 選択肢とそれに関連する全ての slave リンクを削除する。 name は alternatives  ディレクト
              リ内の名前であり、 pathname のリンク先に指定されうるファイル名の絶対パスである。 name が実際に
              path  にリンクされている場合には、  name  は他の適切な選択肢を参照するよう更新される   (グループは
              automatic  モードに戻される) が、そのような選択肢が残っていなければ削除される。関連する slave リン
              クも対応して更新 (削除) される。 name が現在その path を参照していなければ、リンクの変更は行われな
              い。その選択肢の情報が削除されるだけである。

       --remove-all name
              すべての選択肢と、それに関連するすべての slave リンクを削除する。 name は、alternatives ディレクト
              リ内の名前である。

       --all  すべての選択肢に対して  --config  を呼び出す。これは  --skip-auto  と組み合わせることで、automatic
              モードで設定されていないすべての選択肢を確認、設定する際に有用である。問題のある選択肢も表示され
              る。問題のある選択肢をすべて修正するためには yes  | update-alternatives --force --all  を実行すれ
              ばよい。

       --auto name
              name  で指定される選択肢のリンクグループを、automatic モードに変更する。この処理を行う際に、master
              のシンボリックリンクと対応する各    slave     は、現在インストールされている選択肢のうち、もっとも
              priority の高いものを参照するように更新される。

       --display name
              Display  information  about the link group.  Information displayed includes the group's mode (auto
              or manual), the master and slave links, which alternative the master  link  currently  points  to,
              what  other  alternatives  are  available  (and  their  corresponding slave alternatives), and the
              highest priority alternative currently installed.

       --get-selections
              List all master alternative names (those controlling  a  link  group)   and  their  status  (since
              version  1.15.0).   Each line contains up to 3 fields (separated by one or more spaces). The first
              field is the alternative name, the second one is the status (either auto or manual), and the  last
              one contains the current choice in the alternative (beware: it's a filename and thus might contain
              spaces).

       --set-selections
              Read configuration of alternatives on standard input in the format generated  by  --get-selections
              and reconfigure them accordingly (since version 1.15.0).

       --query name
              Display  information  about  the  link  group  like --display does, but in a machine parseable way
              (since version 1.15.0, see section QUERY FORMAT below).

       --list name
              リンクグループのすべての対象を表示する。

       --config name
              リンクグループで利用可能なすべての選択肢を表示し、対話的に選択肢の 1  つを選択できるようにする。こ
              れにより、リンクグループが更新される。

       --help 利用方法を表示して終了する。

       --version
              バージョン情報を表示して終了する。

オプション

       --altdir directory
              alternatives ディレクトリをデフォルトから変えたいときに指定する。

       --admindir directory
              administrative ディレクトリをデフォルトから変えたいときに指定する。

       --log file
              Specifies  the  log  file  (since  version  1.15.0), when this is to be different from the default
              (/var/log/alternatives.log).

       --force
              Allow replacing or dropping any real file that is installed where an alternative link  has  to  be
              installed or removed.

       --skip-auto
              automatic       モードで適切に設定されている選択肢について、設定の確認を行わない。このオプションは
              --config および --all とともに指定した場合のみ有効である。

       --verbose
              Generate more comments about what is being done.

       --quiet
              エラー以外のコメントを出力しない。

終了ステータス

       0      指定したアクションが正しく実行された。

       2      コマンドラインの解釈か、アクションの実行時に問題が発生した。

環境変数

       DPKG_ADMINDIR
              --admindir オプションが指定されていない場合に、この変数が設定されていると、この値が administrative
              ディレクトリの起点として使用される。

ファイル

       /etc/alternatives/
              デフォルトの alternatives ディレクトリ。 --altdir オプションによって変更できる。

       /var/lib/dpkg/alternatives/
              デフォルトの administration ディレクトリ。 --admindir オプションによって変更できる。

QUERY FORMAT

       The  --query  format is using an RFC822-like flat format. It's made of n + 1 blocks where n is the number
       of alternatives available in the queried link group. The first block contains the following fields:

       Name: name
              alternative ディレクトリに存在する選択肢の名前

       Link: link
              選択肢の一般名

       Slaves: list-of-slaves
              このヘッダが存在している場合、以降の 行には、この選択肢の master リンクに対応するすべての slave リ
              ンクが記述される。これは、slave  毎に 1 行ずつ記述され、各行は、1 文字のスペースに続き、slave の選
              択肢の一般名、スペース、slave リンクのパスが記述される。

       Status: status
              選択肢の状況 (auto もしくは manual)

       Best: best-choice
              このリンクグループで最適な選択肢のパス。利用可能な選択肢が存在しない場合、存在しない。

       Value: currently-selected-alternative
              現在選択されている選択肢のパス。リンクが存在しない場合、none    という特別な値が設定される場合があ
              る。

       これ以外のブロックは、クエリ対象のリンクグループにおいて利用可能な選択肢を表示する。

       Alternative: path-of-this-alternative
              このブロックの選択肢のパス。

       Priority: priority-value
              この選択肢の priority の値。

       Slaves: list-of-slaves
              このヘッダが存在している場合、以降の 行には、この選択肢の master リンクに対応するすべての slave の
              選択肢が記述される。これは、slave 毎に 1 行ずつ記述され、各行は、1 文字のスペースに続き、slave  の
              選択肢の一般名、スペース、slave の選択肢のパスが記述される。

   Example
       $ update-alternatives --query editor
       Name: editor
       Link: /usr/bin/editor
       Slaves:
        editor.1.gz /usr/share/man/man1/editor.1.gz
        editor.fr.1.gz /usr/share/man/fr/man1/editor.1.gz
        editor.it.1.gz /usr/share/man/it/man1/editor.1.gz
        editor.pl.1.gz /usr/share/man/pl/man1/editor.1.gz
        editor.ru.1.gz /usr/share/man/ru/man1/editor.1.gz
       Status: auto
       Best: /usr/bin/vim.basic
       Value: /usr/bin/vim.basic

       Alternative: /bin/ed
       Priority: -100
       Slaves:
        editor.1.gz /usr/share/man/man1/ed.1.gz

       Alternative: /usr/bin/vim.basic
       Priority: 50
       Slaves:
        editor.1.gz /usr/share/man/man1/vim.1.gz
        editor.fr.1.gz /usr/share/man/fr/man1/vim.1.gz
        editor.it.1.gz /usr/share/man/it/man1/vim.1.gz
        editor.pl.1.gz /usr/share/man/pl/man1/vim.1.gz
        editor.ru.1.gz /usr/share/man/ru/man1/vim.1.gz

診断メッセージ

       --verbose  を指定した場合、update-alternatives は、実行中の処理内容を逐一標準出力に出力する。問題が起きる
       と、 update-alternatives はエラーメッセージを標準エラー出力に出力し、終了ステータス 2  を返す。これらの診
       断メッセージは、読めばわかるはずである。もしわからなければ、バグとして報告して欲しい。

       例えば  nvivim  のように、テキストエディタ  vi と互換性のあるプログラムを提供するパッケージが複数あ
       る。どのパッケージが使われるかは、リンクグループ vi によって制御される。リンクグループ vi  にはプログラム
       自身のリンクと、関連する man ページのリンクが含まれる。

       vi を提供するパッケージとその現在の設定を表示するには、--display アクションを使用する:

              update-alternatives --display vi

       特定の vi の実装を選ぶには、root としてこのコマンドを実行し、一覧から数字を選ぶ:

              update-alternatives --config vi

       vi 実装の選択を自動的に行なうように戻すには、root としてこのコマンドを実行する:

              update-alternatives --auto vi

関連項目

       ln(1), FHS, the Filesystem Hierarchy Standard.

翻訳者

       高橋  基信 <monyo@monyo.com>.  喜瀬 浩 <kise@fuyuneko.jp>.  関戸 幸一 <sekido@mbox.kyoto-inet.or.jp>.  鍋
       谷 栄展 <nabe@debian.or.jp>.  倉澤 望 <nabetaro@debian.or.jp>.  石川 睦 <ishikawa@linux.or.jp>.  鵜飼  文
       敏 <ukai@debian.or.jp>.  中野 武雄 <nakano@apm.seikei.ac.jp>.

翻訳校正

       Debian JP Documentation ML <debian-doc@debian.or.jp>.