Zypper/Usage/Factory
From openSUSE
| This article needs to be expanded. If you can help please do so in line with the openSUSE Style Guide.
If you are looking for something to do, see the other articles that need expanding |
| Version: Factory
| This article is about the newest development version of zypper which gradually appears in the Factory distribution. Current Factory version is 0.10.x. For other versions see Zypper/Versions |
General Usage
The general syntax of zypper command is:
# zypper [global-options] command [command-options] [arguments] ...
The components enclosed in brackets are not required, thus the simplest way to execute zypper is to type its name followed by a command. For example, to apply needed patches to the system type:
# zypper update
Additionally, you can choose from one or more global options by typing them just before the command: (run the command, but don't ask me anything, decide on your own)
# zypper --non-interactive update
To use the options specific to particular command, type them right after the command: (apply needed patches to the system but don't ask me to confirm any licenses, i've read them all before)
# zypper update --auto-agree-with-licenses
Some of the commands require one or more arguments: (install or update mplayer package)
# zypper install mplayer
Some of the options also require an argument: (update the system with newer packages)
# zypper update -t package
All of the above combined: (install mplayer and amarok by using the factory repository only, be verbose)
# zypper -v install --repo factory mplayer amarok
Vocabulary
- repository - local or remote directory containing packages and various package information (package meta-data). Repositories were formerly known as installation sources , services or catalogs).
- alias - repository alias is a short version of repository name for use in repository handling commands and options such as removerepo or --repo.
- resolvable - a package, patch, pattern, product. These are the objects the dependency resolver works with, thus the name resolvable. The most commonly used type of resolvable is a package and patch.
- pattern - represents a group of packages. For example an Http Server pattern would have the dependencies defined so that all packages needed to run and manage an http server would have been triggered for installation when upon installing the pattern.
- product - represents the whole product (e.g. openSUSE 10.3)
Global Options
The following options can be applied to any zypper transaction:
- -V, --version
Output the version number
- -v, --verbose
Debug output, prints full exception traces.
- -t, --terse
Terse output. Currently not supported, used only internally by the Updater_Applet.
- -q, --quiet
Suppress normal output. Brief (esp. result notification) messages and error messages will still be printed, though. If used together with conflicting --verbose option, the --verbose option takes preference.
- -s, --table-style
Table style (integer).
- -r, --rug-compatible
Turn on rug compatibility.
- -n, --non-interactive
Turn on non-interactive mode. In this mode does not prompt the user to make any decisions, but uses reasonable defaults automatically. This is useful to run zypper as a cron job, or as a part of a script. See section Using Zypper in Scripts for further details.
- --no-gpg-checks
Ignore GPG check failures and continue. If a GPG issue occurs when using this option zypper prints and logs a warning and automatically continues without interrupting the operation. Use this option with causion, as you can easily overlook security problems by using it.
- -R, --root <dir>
Operate on a different root directory.
Commands
zypper provides a number of commands. The most commonly used command is zypper update which downloads and installs updates (needed patches) from the repositories you have defined. If you only want to update your software, this is the only command you need.
Printing Help
The general syntax is:
help, -h
Print help. To print general help, use:
# zypper -h
To print help for a command, use:
# zypper -h [command]
Listing Defined Repositories
The general syntax is:
repos, lr
Example of the output:
# 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)
To include also the respoitory URL in the listing, use the -v global option together with zypper lr.
Adding Repositories
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
Example:
# 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
Removing Repositories
removerepo, rr <URI|alias>
Example:
zypper rr http://packman.iu-bremen.de/suse/10.3
or
zypper rr pm
Renaming Repositories
The general syntax is:
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).
Installing Resolvables
The general syntax is:
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
- -R, --force-resolution - Force the solver to find a solution, even if it would mean removing all packages with unfulfilled requirements.
Removing Resolvables
The general syntax is:
remove, rm <packagename> ... remove, rm --capability <capability> ...
Accepts the same options as the install command except of the --force.
Searching Resolvables
The general syntax is:
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.
Example:
# 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.
Checking Patches
The general syntax is:
patch-check, pchk
This command will tell you if there are any important patches available for your system and the number of such patches.
Example:
# 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)
Listing Patches
The general syntax is:
patches, pch
List all available patches, including those not needed or applicable.
Example:
# 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
Obtaining Detailed Information About a Patch
The general syntax is:
patch-info [patchname] ... info -t patch [patchname] ...
Show full information about specified patches.
Example:
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
Listing Updates
The general syntax is:
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.
Example:
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
Updating
The general syntax is:
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.
- -R, --force-resolution - Force the solver to find a solution, even if it would mean removing all packages with unfulfilled requirements.
Example:
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%] ...
Obtaining Information about Packages
The general syntax is:
info, if [packagename] ...
Show full information for specified packages.
Example:
# 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>
Export/Import
You can export your complete repository list to a file and import it later or on another machine.
Export:
zypper repos --export /tmp/foo.repo
Import:
zypper addrepo --repo file:///tmp/foo.repo
Using zypper in Scripts
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 Mode
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.
Prompts
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-related prompts
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 |
Other Prompts
| 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 |

