Zypper/Usage/10.3

< Zypper‎ | Usage
移動先: 案内, 検索
Geeko この文書は Zypper の使用方法に関するものです。Zypper とは Libzypp というパッケージ管理ライブラリを使用するコマンドラインのパッケージ管理ツールです。Zypper の構文は rug のものと似ていますが、Zypper のコマンドとオプションは出力や動作を多様化させるだけでなく、rug からも多様化させるために始まったからです。けれども、Zypper は rug の互換モードでも動作させることができます。


Susemini.png
バージョン:
10.3
この記事は openSUSE 10.3 に入っている zypper 0.8.23 に関するものです。10.2 に関しては Zypper/Versions を参照してください


一般的な使い方


zypper のコマンドの一般的な構文:

# zypper [global-options] command [command-options] [arguments] ...

かっこに囲まれている要素はなくてもかまいません。つまり、zypper という名前の後に command を入力するだけで zypper を実行できます。例えば、システムに必要なパッチを適用するには

# zypper update

さらに、1つ、またはそれ以上の global options を選択することができます。以下のようにコマンドを入力する前にオプションを入力してください:(コマンドを実行する。その際、非対話式に実行する)

# zypper --non-interactive update

いくつかの特別なオプションを使うためには、以下のようにコマンドを入力した後にオプションを入力してください:(システムに必要なパッチを適用する。その際、以前に読んだライセンスについては確認なしで認証する)

# zypper update --auto-agree-with-licenses

いくつかのコマンドは1つ、またはそれ以上の引数を必要とします:(mplayer パッケージをインストール、もしくはアップデートする場合)

# zypper install mplayer

いくつかのオプションは1つ、またはそれ以上の引数を必要とします:(最新パッケージにシステムをアップデートする)

# zypper update -t package

コマンドやオプションは組み合わせて使うこともできます:(factory リポジトリのみを使用して mplayer と amarok をインストールする。また、実行結果を詳細に表示する)

# zypper -v install --repo factory mplayer amarok 


語彙


  • repository - パッケージや様々なパッケージ情報(パッケージの meta-data)が入っているローカルまたはリモートディレクトリのことです。リポジトリは以前はinstallation sourcesservicescatalogsという名前で知られていました。
  • alias - リポジトリのエイリアスはremoverepo--repo のようなコマンドやオプションでリポジトリを扱いやすくするためにリポジトリ名を短くしたものです。
  • resolvable - パッケージ、パッチ、パターン、プロダクト。これらの依存関係を解決するためのオブジェクトがあり、resolvableと呼んでいます。最も一般に使用されるresolvablepackagepatchです。
  • pattern - パッケージのグループを表します。例えば、Http Server というパターンはインストールする際にhttpサーバを動作、管理するのに必要な全てのパッケージをインストールできるように依存関係を定義しています。
  • product - 全てのプロダクトを表します。(例えば openSUSE 10.3)

zypper のオプション


次のオプションはいつでも用いることができます。


  • -V, --version
    ヴァージョンを表示します。
  • -v, --verbose
    デバッグ出力。すべての例外をトレースして出力します。
  • -t, --terse
    簡潔な出力。現在はサポートされていませんが、Updater_Applet 内部で使われています。
  • -q, --quiet
    標準出力をしないようにします。しかしながら、要約された(特に、結果の通知)メッセージやエラーメッセージは出力されます。このオプションは--verbose オプションと競合するので、一緒に用いた場合は --verbose オプションが有線されるようになっています。
  • -s, --table-style
    Table style (integer).
  • -r, --rug-compatible
    rug と互換できるように切り替えます。
  • -n, --non-interactive
    非対話モードに切り替えます。このモードでは、利用者に何かしらの判断を求めなくなるということではなく、自動的に適切な初期設定を用います。これは cron job で zypper を実行したり、またはスクリプトの一部に使いたいときに役に立ちます。さらなる詳細については、Using Zypper in Scripts をご覧ください。
  • --no-gpg-checks
    GPG キーの確認を失敗しても無視して続けるようにします。このオプションを使用しているときに GPGに問題が発生したら、zypper は警告を出力してログを取り、割り込み操作なしで自動的に処理を再開します。このオプションを使用することでセキュリティーに関する問題を容易に見逃してしまうということに注意して使用してください。
  • -R, --root <dir>
    別の root ディレクトリを操作します。


コマンド


zypper は多くのコマンドを持っています。よく使われるコマンドはzypper updateでしょう。このコマンドは利用者が定めたディレクトリからアップデート(必要なパッチ)をダウンロードしてインストールします。もしソフトウェアをアップデートしたいだけなら、必要なのはこのコマンドだけです。

ヘルプを表示する

一般的な構文:

help, -h

ヘルプを表示します. 全てのヘルプを表示する方法:

# zypper -h

コマンドのヘルプを表示する方法:

# zypper -h [command]

現在のリポジトリを表示する

一般的な構文:

repos, lr

出力例:

# zypper lr
# | Enabled | Refresh | Type   | Alias   | Name
--+---------+---------+--------+---------+--------------------------
1 | Yes     | No      | rpm-md | factory | factory
2 | Yes     | Yes     | yast2  | guru    | guru
3 | Yes     | No      | rpm-md | packman | Packman 10.3
4 | Yes     | No      | rpm-md | updates | openSUSE-10.3-Updates
5 | Yes     | Yes     | yast2  | main-no | Main Repository (NON-OSS)
6 | No      | Yes     | yast2  | main    | Main Repository (OSS)

この表にリポジトリのURLを加えるには、zypper lr と共に-vオプションを使用してください。

リポジトリを追加する

Before any packages can be installed at least one package repository must be defined. To add a repository, use the addrepo command:

addrepo, ar <URI> <alias>

This command accepts the following options:

  • -r, --repo <FILE.repo> - add the repositories defined in the specified .repo file

例:

# zypper ar http://packman.iu-bremen.de/suse/10.3 pm
* Adding repository 'pm'
Repository 'pm' successfully added:
Enabled: Yes
Autorefresh: Yes
URL: http://packman.iu-bremen.de/suse/10.3

リポジトリを削除する

removerepo, rr <URI|alias>

例:

zypper rr http://packman.iu-bremen.de/suse/10.3

もしくは

zypper rr pm

リポジトリ名を変更する

一般的な構文:

renamerepo, nr <alias> <new-alias>

This command is currently only able to change the alias of the repository. If you wish to change the displayed name of the repository, edit the corresponding .repo file in /etc/zypp/repos.d directory (the name= key).

パッケージをインストールする

一般的な構文:

install, in <packagename> ...
install, in --capability  <capability> ...

The former form selects the packages for installation by the names you specified:

# zypper install subversion gcc

installs packages named subversion and gcc

The latter form selects the packages by capability they provide:

# zypper install -C /usr/bin/svn file

installs packages which provide the /usr/bin/svn

# zypper install -C subversion=1.4.4

installs a package which provides this specific version of subversion

Accepts the following option flags:

  • -r, --repo <alias> - Consider only resolvables from the repository specified by the alias.
  • -t, --type <resolvable> - Type of resolvable (default: package)
  • -n, --name - Select resolvables by plain name, not by capability (default)
  • -C, --capability - Select resolvables by capability they provide
  • -l, --auto-agree-with-licenses - Automatically say 'yes' to third party license confirmation prompt.
  • See 'man zypper' for more details.
  • --debug-solver - Create solver test case for debugging

パッケージを削除する

一般的な構文:

remove, rm <packagename> ...
remove, rm --capability <capability> ...

Accepts the same options except of the --force.

パッケージを探す

一般的な構文:

search, se [pattern] ...

Accepts the following option flags:

  • --match-all - Search for a match to all search strings (default)
  • --match-any - Search for a match to any of the search strings
  • --match-substrings - Matches for search strings may be partial words (default)
  • --match-words - Matches for search strings may only be whole words
  • --match-exact - Searches for an exact package name
  • -d, --search-descriptions - Search also in package summaries and descriptions.
  • -c, --case-sensitive - Perform case-sensitive search.
  • -i, --installed-only - Show only packages that are already installed.
  • -u, --uninstalled-only - Show only packages that are not curenly installed.
  • -t, --type - Search only for packages of specified type.
  • --sort-by-name - Sort packages by name (default).
  • --sort-by-catalog - Sort packages by catalog.

The * and ? wildcards are also supported.

例:

# zypper se zypper
* Reading installed packages [100%]

S | Repository | Type    | Name   | Version  | Arch
--+------------+---------+--------+----------+-------
  | factory    | package | zypper | 0.8.23-3 | i586
i | factory    | package | zypper | 0.8.23-2 | x86_64

Currently, the search functionality is a bit broken due to libzypp refactoring, especially the special search options. The basic search has should work well and fast however.

パッチを確認する

一般的な構文:

patch-check, pchk

This command will tell you if there are any important patches available for your system and the number of such patches.

例:

# zypper pchk
* Reading repository '10.3 - Main Repository (NON-OSS)' cache
* Reading repository 'openSUSE-10.3-DVD 10.3' cache
* Reading repository 'openSUSE-10.3-Updates' cache
* Reading installed packages [100%]

9 patches needed (0 security patches)

パッチを表示する

一般的な構文:

patches, pch

List all available patches, including those not needed or applicable.

例:

# zypper pch
* Reading repository '10.3 - Main Repository (NON-OSS)' cache
* Reading repository 'openSUSE-10.3-DVD 10.3' cache
* Reading repository 'openSUSE-10.3-Updates' cache
* Reading installed packages [100%]

Repository:           | Name               | Version | Category    | Status        
----------------------+--------------------+---------+-------------+---------------
openSUSE-10.3-Updates | amarok             | 4492-0  | recommended | Not Applicable
openSUSE-10.3-Updates | cpio               | 4474-0  | recommended | Needed        
openSUSE-10.3-Updates | evince             | 4465-0  | recommended | Needed        
openSUSE-10.3-Updates | fetchmsttfonts.sh  | 4347-0  | optional    | Not Needed    
openSUSE-10.3-Updates | fvwm2              | 4475-0  | recommended | Needed        
openSUSE-10.3-Updates | glibc              | 4467-0  | recommended | Needed        
openSUSE-10.3-Updates | gnome-main-menu    | 4491-0  | recommended | Needed        
openSUSE-10.3-Updates | gtk2               | 4466-0  | recommended | Needed        
openSUSE-10.3-Updates | jfbterm            | 4460-0  | recommended | Not Applicable
openSUSE-10.3-Updates | ksh                | 4489-0  | recommended | Needed        
openSUSE-10.3-Updates | libiniparser-32bit | 4488-0  | optional    | Not Applicable
openSUSE-10.3-Updates | release-notes      | 4464-0  | recommended | Needed        
openSUSE-10.3-Updates | wvdial             | 4461-0  | recommended | Needed

パッチに関する詳細な情報を表示する

一般的な構文:

patch-info [patchname] ...
info -t patch [patchname] ...

Show full information about specified patches.

例:

testicek2:~ # zypper patch-info amarok
* Reading repository '10.3 - Main Repository (NON-OSS)' cache
* Reading repository 'openSUSE-10.3-DVD 10.3' cache
* Reading repository 'openSUSE-10.3-Updates' cache
* Reading installed packages [100%]

Information for patch amarok:

Name: amarok
Version: 4492-0
Arch: noarch
Status: Not Applicable
Category: recommended
Created On: Thu 04 Oct 2007 05:48:07 PM CEST
Reboot Required: No
Package Manager Restart Required: No
Interactive: No
Summary: Fixes to improve stability and playback with yauap
Description: This patch includes fixes to increase the stability of
Amarok when playing  music and improves the collaboration
with the GStreamer/Yauap engine.

Provides:
patch: amarok == 4492-0

Requires:
atom: amarok-yauap == 1.4.7-37.2
atom: amarok-lang == 1.4.7-37.2
atom: amarok-xine == 1.4.7-37.2
atom: amarok == 1.4.7-37.2
atom: yauap == 0.2.1-21.2
atom: amarok-libvisual == 1.4.7-37.2

アップデートを表示する

一般的な構文:

list-updates, lu

List all available updates. By default this command lists all available needed and security patches. Use the -t option to choose which type of resolvables do you want to work with.

Accepts the following option flags:

  • -t, --type <type> - Type of resolvable (default: patch)
  • -r, --repo <alias> - List only updates from the repository specified by the alias.
  • --best-effort - Do a 'best effort' approach to update, updates to lower than the latest-and-greatest version are also possible.

例:

testicek2:~ # zypper lu
* Reading repository '10.3 - Main Repository (NON-OSS)' cache
* Reading repository 'openSUSE-10.3-DVD 10.3' cache
* Reading repository 'openSUSE-10.3-Updates' cache
* Reading repository 'factory' cache
* Reading installed packages [100%]
Repository:           | Name            | Version | Category    | Status
----------------------+-----------------+---------+-------------+-------
openSUSE-10.3-Updates | cpio            | 4474-0  | recommended | Needed
openSUSE-10.3-Updates | evince          | 4465-0  | recommended | Needed
openSUSE-10.3-Updates | fvwm2           | 4475-0  | recommended | Needed
openSUSE-10.3-Updates | glibc           | 4467-0  | recommended | Needed
openSUSE-10.3-Updates | gnome-main-menu | 4491-0  | recommended | Needed
openSUSE-10.3-Updates | gtk2            | 4466-0  | recommended | Needed
openSUSE-10.3-Updates | ksh             | 4489-0  | recommended | Needed
openSUSE-10.3-Updates | release-notes   | 4464-0  | recommended | Needed
openSUSE-10.3-Updates | wvdial          | 4461-0  | recommended | Needed

アップデートを行なう

一般的な構文:

update, up

Update the system. By default this command applies all needed patches. To update other types of resolvables (e.g. packages) use the -t option.

  • -t, --type - Type of resolvable (default: patch)
  • -r, --repo <alias> - List only updates from the repository specified by the alias.
  • --skip-interactive - Skip interactive updates.
  • -l, --auto-agree-with-licenses - Automatically say 'yes' to the third party license agreement prompt. See man zypper for more details.
  • --best-effort - Do a 'best effort' approach to update, updates to lower than the latest-and-greatest version are also possible.
  • --debug-solver - Create a solver test case for debugging.


例:

testicek2:~ # zypper update
* Reading repository '10.3 - Main Repository (NON-OSS)' cache
* Reading repository 'openSUSE-10.3-DVD 10.3' cache
* Reading repository 'openSUSE-10.3-Updates' cache
* Reading installed packages [100%]


The following packages are going to be upgraded:
  cpio fvwm2 evince glibc-i18ndata glibc-locale nscd glibc release-notes wvdial 
gnome-main-menu gtk2 ksh 

The following NEW packages are going to be installed:
  evince-lang gnome-main-menu-lang 

The following NEW patches are going to be installed:
  gnome-main-menu release-notes evince gtk2 glibc ksh fvwm2 wvdial cpio 

Overall download size: 28.0 M. After the operation, additional 2.9 M will be used.
Continue? [yes/no]: y
Downloading package evince-lang-2.20.0-5.2.i586, 519.4 K (2.0 M unpacked)
Downloading: evince-lang-2.20.0-5.2.i586.rpm
* Downloading [100%]
* Installing: evince-lang-2.20.0-5.2 [100%]
Downloading package glibc-i18ndata-2.6.1-18.2.i586, 3.6 M (10.0 M unpacked)
Downloading patch rpm: ./rpm/i586/glibc-i18ndata-2.6.1-18.2.i586.patch.rpm, 111.5 K
Downloading: glibc-i18ndata-2.6.1-18.2.i586.patch.rpm
* Downloading [100%]
* Installing: glibc-i18ndata-2.6.1-18.2 [100%]
Downloading package glibc-2.6.1-18.2.i686, 1.7 M (3.9 M unpacked)
Downloading delta: ./rpm/i686/glibc-2.6.1-18_18.2.i686.delta.rpm, 89.2 K
Downloading: glibc-2.6.1-18_18.2.i686.delta.rpm
* Downloading [100%]
Applying delta: /var/adm/mount/AP_0x00000001/rpm/i686/glibc-2.6.1-18_18.2.i686.delta.rpm
* Installing: glibc-2.6.1-18.2 [100%]
Downloading package release-notes-10.3.17-0.1.noarch, 113.6 K (608.5 K unpacked)
Downloading delta: ./rpm/noarch/release-notes-10.3.16_10.3.17-2_0.1.noarch.delta.rpm, 42.8 K
Downloading: release-notes-10.3.16_10.3.17-2_0.1.noarch.delta.rpm
* Downloading [100%]
Applying delta: /var/adm/mount/AP_0x00000001/rpm/noarch/release-notes-10.3.16_10.3.17-2_0.1.noarch.delta.rpm
* Installing: release-notes-10.3.17-0.1 [100%]
...

パッケージに関する情報を表示する

一般的な構文:

info, if [packagename] ...

Show full information for specified packages.

例:

# zypper info suspend
* Reading repository '10.3 - Main Repository (NON-OSS)' cache
* Reading repository 'openSUSE-10.3-DVD 10.3' cache
* Reading repository 'openSUSE-10.3-Updates' cache
* Reading installed packages [100%]


Information for package amarok:

Repository: openSUSE-10.3-Updates
Name: amarok
Version: 1.4.7-37.2
Arch: i586
Installed: No
Status: not installed
Installed Size: 8.3 M
Summary: Media Player for KDE
Description: 
Amarok is a media player for all kinds of media. This includes MP3, Ogg
Vorbis, audio CDs, podcasts and streams. Play lists can be stored in
.m3u or .pls files.



Authors:
--------
    Christian Muehlhaeuser <chris@chris.de>
    Mark Kretschmann <markey@web.de>
    Max Howell <max.howell@methylblue.com>
    Stanislav Karchebny <berk@inbox.ru>

スクリプトで zypper を使用する


Zypper supports several global options which make it suitable for use within automated processes like scripts. Also, several different exit codes listed in zypper's manual page can be checked for when using zypper in an automated process. See the following for details.

--non-interactive

In this mode zypper does not prompt the user for any answers and uses default answers instead. When using this option it is guaranteed that zypper will not hang prompting for an answer on stdin, or in an endless loop.

For example, to update your system automatically without confirmation, you can type

# zypper --non-interactive update

This command does not require confirmation from the user to proceed with update, skips all interactive patches which would need an additional confirmation and also automatically answers any other prompts.

--no-gpg-checks

If this option is used, zypper will always choose to continue if some of the gpg checks fails, e.g. a repository file is not signed and should be, a file is signed and the gpg check fails, etc.

--auto-agree-with-licenses

This is special option for the install, remove and update commands. By using this, the user declares he/she agrees with the terms of licenses the command will install, and zypper will automatically say 'yes' to the license confirmation prompt. This is useful for people installing the same set of packages on multiple machines (by an automated process) and have read all the licenses before.

プロンプト

The following should be a complete list of cases where zypper needs user interaction together with the answers in non-interactive mode. All the additional options mentioned here have higher priority over --non-interactive, so if used, the answer they imply are automatically used even if --non-interactive isn't used.

GPG に関するプロンプト

Where --no-gpg-checks is applied, a message is displayed or a warning is written to stderr and logged.

prompt default answer with --no-gpgp-checks note
accept unsigned file? N Y
import key into keyring? N N a new key can be imported in the interactive mode only
accept unknown key? N Y
trust key? N Y
verification of signed file failed, continue? N Y
no digest for a file, continue? N Y
accept unknown digest? N Y

その他のプロンプト

prompt default answer other answer note
proceed with installation/removal/update? Y in addition, the --no-confirm option can be used with the install/remove/update commands even without the global --non-interactive
confirm 3rd party license N Y if --auto-agree-with-licenses is used in addition, for zypper update, --skip-interactive option can be used to exclude interactive patches from to-be-installed list (a heritage of rug)
problem while installing/removing a resolvable, Abort/Retry/Ignore? ABORT this is ugly and can be improved in future
problem while downloading a package, Abort/Retry/Ignore? ABORT this is also ugly, can be enhanced somehow in the future
dependency conflict. Prompt for solution number, (c)ancel, or (r)etry c
media change request ABORT