SDB:Zypper 使用方法
版本:13.2 本文档介绍 zypper 1.11.23,如其在 openSUSE 13.2 中出现时的状态。有关其他版本,请参阅 Zypper 版本。
快速参考
这是您最常使用的内容。
zypper # to print the list of available global options and commands zypper help search # to print help for the search command zypper lp # to see what patch updates are needed zypper patch # to apply the needed patches zypper se sqlite # to search for sqlite zypper rm sqlite2 # to remove sqlite2 zypper in sqlite3 # to install sqlite3 zypper in yast* # to install all packages matching 'yast*' zypper up # to update all installed packages with newer versions, where possible
如果您熟悉来自其他 Linux 发行版的 apt、yum、emerge 等软件包管理器,请参阅此链接,以了解它们与 zypper 之间的比较/差异。
备忘单
您可以在此页面上找到的信息,但以备忘单的形式进行了压缩。建议您在分析了此处显示的信息后使用它。它还包含一些摘自手册页面的参考。
| A4 页面. |
| A4 页面. |
| 信纸页面. |
| 信纸页面. |
常规用法
Zypper 的一般语法是
zypper [global-options] command [command-options] [arguments] ...方括号中的组件不是必需的,因此执行 zypper 的最简单方法是键入其名称,后跟一个 命令。请参阅 zypper help 以获取常规选项和所有命令的列表。要获取特定命令的帮助,请键入 zypper help command。例如,要应用所需的补丁到系统,请键入
sudo zypper patch要获取补丁命令的帮助
sudo zypper help patch此外,您可以通过在命令之前键入它们来选择一个或多个 全局选项:(运行命令,但不要问我任何问题,自行决定)
sudo zypper --non-interactive patch要使用特定命令的选项,请在命令之后键入它们:(应用所需的补丁到系统,但不要要求我确认任何许可证,我之前已经阅读过它们)
sudo zypper patch --auto-agree-with-licenses有些命令需要一个或多个参数:(安装或更新 mplayer 软件包)
sudo zypper install mplayer有些选项也需要一个参数:(搜索模式)
sudo zypper search -t pattern以上所有内容组合:(仅使用 factory 仓库安装 mplayer 和 amarok,并显示详细信息)
sudo zypper -v install --repo factory mplayer amarok用户提示
每当 zypper 需要您的输入时,它都会在提示文本旁边用方括号列出可能的答案。要选择默认答案,只需按 <enter>(默认答案以大写字母打印(非 ASCII 字符除外))。有些提示也有帮助,在这种情况下,将问号 '?' 列为可能的答案。要使 zypper 使用默认答案而无需用户交互,请使用 --non-interactive 全局选项。
词汇
- 仓库 - 包含软件包和各种软件包信息(软件包元数据)的本地或远程目录。仓库以前被称为安装源、服务或目录)。
- 别名 - 仓库别名是仓库名称的简短版本,用于仓库处理命令和选项,例如removerepo或--repo.
- 软件包 - 软件软件包(RPM 软件包、源代码软件包)。补丁、模式和产品也通常被称为不同类型的软件包。
- 补丁 - 表示一个软件包或一组软件包,用于安装更新(主要是错误修复)。
- 模式 - 表示一组软件包。例如,Http 服务器模式将定义依赖项,以便安装该模式时将触发所有运行和管理 http 服务器所需的软件包的安装。
- 产品 - 表示整个产品(例如“openSUSE 12.2”)。
命令
zypper 提供许多可以分为以下类别的命令
- 仓库管理
refresh, repos, addrepo, removerepo, modifyrepo, namerepo
refresh-services, services, addservice, removeservice, modifyservice - 软件包管理
install, remove, source-install - 更新管理
patch, list-patches, patch-check, patches, update, list-updates, dist-upgrade - 查询
search, info, what-provides, list-updates, patch-check, patches, packages, patterns, products - 锁定
locks, addlock, removelock, cleanlocks - 实用工具
verify, install-new-recommends - other
help, licenses, versioncmp, targetos
打印帮助
首先,了解如何获取帮助很重要。要打印常规帮助(命令和全局选项的列表),只需键入zypper不带任何选项或参数。要打印特定命令的帮助,请使用
zypper help [command]
要获取特定命令的帮助,请使用
zypper [command] --help
请注意,使用-h代替--help为了方便起见也是可能的。
仓库管理
您可以指定现有仓库,通过使用zypper lr生成的列表中的编号、别名或 URI。使用编号时,请务必始终检查zypper lr首先,因为您对仓库进行了一些更改后,编号可能会发生变化。
列出已定义的仓库
repos 或 lr
示例输出
zypper lr# | Alias | Name | Enabled | Refresh ---+----------------------------------+------------------------------------+---------+-------- 1 | Mewtwo:KDE:Extra | KDE:Extra | Yes | Yes 2 | Mewtwo:repo-ati | repo-ati | Yes | Yes 3 | Mewtwo:repo-debug | openSUSE-12.2-Debug | No | Yes 4 | Mewtwo:repo-debug-update | openSUSE-12.2-Update-Debug | No | Yes 5 | Mewtwo:repo-debug-update-non-oss | openSUSE-12.2-Update-Debug-Non-Oss | No | Yes 6 | Mewtwo:repo-libdvdcss | repo-libdvdcss | Yes | Yes 7 | Mewtwo:repo-non-oss | openSUSE 12.2 Oss | No | Yes 8 | Mewtwo:repo-oss | openSUSE-12.2-Oss | Yes | Yes 9 | Mewtwo:repo-packman | packman | Yes | Yes 10 | Mewtwo:repo-source | openSUSE-12.2-Source | Yes | Yes 11 | Mewtwo:repo-update | openSUSE-12.2-Update | Yes | Yes 12 | Mewtwo:repo-update-non-oss | openSUSE-12.2-Update-Non-Oss | Yes | Yes 13 | Mewtwo:security | security | Yes | Yes
zypper lr 5 4Alias : Mewtwo:repo-debug-update-non-oss Name : openSUSE-12.2-Update-Debug-Non-Oss URI : http://download.opensuse.org/debug/update/12.2-non-oss/ Enabled : No Priority : 99 Auto-refresh : On Keep Packages : Off Type : rpm-md GPG Check : On GPG Key URI : Path Prefix : Parent Service : Mewtwo MD Cache Path : /var/cache/zypp/raw/Mewtwo:repo-debug-update-non-oss Alias : Mewtwo:repo-debug-update Name : openSUSE-12.2-Update-Debug URI : http://download.opensuse.org/debug/update/12.2/ Enabled : No Priority : 99 Auto-refresh : On Keep Packages : Off Type : rpm-md GPG Check : On GPG Key URI : Path Prefix : Parent Service : Mewtwo MD Cache Path : /var/cache/zypp/raw/Mewtwo:repo-debug-update
其他示例
zypper lr -u # to include also repo URI in the table zypper lr -d # to include several other repo properties in the table zypper lr -P # to include also repo priority and sort the list by it zypper lr -e my # export all repository definitions into file named 'my.repo'
添加仓库
addrepo 或 ar
在添加任何仓库之前,必须定义至少一个仓库。要添加仓库,请使用addrepo命令
示例输出
zypper ar http://download.videolan.org/pub/vlc/SuSE/11.1 vlcAdding repository 'vlc' [done] Repository 'vlc' successfully added Enabled: Yes Autorefresh: No URI: http://download.videolan.org/pub/vlc/SuSE/11.1
其他示例
zypper ar http://download.opensuse.org/repositories/X11:/XGL/openSUSE_11.1/X11:XGL.repo # via .repo file zypper ar -c ftp://some.download.site myalias # probe the repository upon adding zypper ar my/dir/with/rpms local # add your local directory with rpm files as repository
请参阅 Libzypp,了解支持的媒体类型和 URI 列表。
刷新仓库
refresh 或 ref
添加仓库后或当仓库过时时,需要刷新它。这意味着从仓库下载软件包元数据并将数据预处理为.solv缓存以进行快速读取。
zypper refreshDownloading repository 'Packman 11.1' metadata [done] Building repository 'Packman 11.1' cache [done] Downloading repository 'Updates for 11.1' metadata [done] Building repository 'Updates for 11.1' cache [done] Repository 'openSUSE-11.1-Oss' is up to date. All repositories have been refreshed.
如果仓库的自动刷新已启用,则无需担心刷新,它会在需要时自动发生。但是,有些人更喜欢控制何时进行刷新(例如,为了避免在只想查看“zypper info krusader”时等待刷新完成),因此他们会禁用自动刷新。请参阅man zypper了解更多详细信息。
其他示例
zypper ref packman main # you can also specify which repositories to refresh zypper ref -f upd # force refresh of the 'upd' repository
删除仓库
removerepo 或 rr
zypper rr vlc 1 23 fooRepository 23 not found by alias, number or URI. Repository foo not found by alias, number or URI. Removing repository 'repo-debug' [done] Repository 'repo-debug' has been removed. Removing repository 'vlc' [done] Repository 'vlc' has been removed.
修改仓库
modifyrepo 或 mr
禁用仓库 #6
zypper mr -d 6Repository 'repo-non-oss' has been sucessfully disabled.
启用“packman”仓库的自动刷新和 rpm 文件缓存,并将其优先级设置为 70
zypper mr -rk -p 70 packmanAutorefresh has been enabled for repository 'packman'. RPM files caching has been enabled for repository 'packman'. Repository 'packman' priority has been set to 70.
禁用所有仓库的 RPM 文件缓存
zypper mr -KaNothing to change for repository 'local'. RPM files caching has been disabled for repository 'packman'. Nothing to change for repository 'fate'. Nothing to change for repository 'upd'. Nothing to change for repository 'repo-oss'. Nothing to change for repository 'repo-non-oss'.
启用所有仓库的 RPM 文件缓存
zypper mr -kaRPM files caching has been enabled for repository 'repo-non-oss'. RPM files caching has been enabled for repository 'Main Repository (OSS)'. RPM files caching has been enabled for repository 'Main Repository (NON-OSS)'. RPM files caching has been enabled for repository 'openSUSE-11.1-Updates'.
重命名仓库
renamerepo 或 nr
# zypper nr 3 upd Repository 'openSUSE-11.1-Updates' renamed to 'upd'.
目前该命令只能更改仓库的别名。如果您希望更改仓库的显示名称,请查看mr命令。
为了方便作为命令参数和 --repo 选项使用,请保持别名简短简单。使用别名比使用仓库编号(因为编号可能会更改并且容易出错)和使用 URI(因为 URI 很长,需要复制粘贴)更安全、更方便。
导出/导入仓库
repos --export 或 lr -e
您可以将完整的仓库列表导出到文件,并在以后或另一台机器上导入它。
# zypper lr --export backups/repos/foo.repo # zypper ar backups/repos/foo.repo
服务管理
服务比仓库高一个级别,用于管理仓库。Libzypp 实际上仅支持一种类型的服务,即 仓库索引服务,也称为 RIS。
添加服务
addservice 或 as
要添加服务类型,请使用 addservice
示例
celebi:~ # zypper as -t RIS http://mewtwo.domain/ Mewtwo
El servicio 'Mewtwo' se agregó correctamente.
刷新服务
refresh-services 或 refs
除了添加服务之外,还必须刷新它以设置它提供的仓库
celebi:~ # zypper refs
Actualizando servicio 'Mewtwo'. Añadiendo el repositorio 'KDE:Extra' .......................................................[hecho] Añadiendo el repositorio 'repo-ati' ........................................................[hecho] Añadiendo el repositorio 'openSUSE-12.2-Debug' .............................................[hecho] Añadiendo el repositorio 'openSUSE-12.2-Update-Debug' ......................................[hecho] Añadiendo el repositorio 'openSUSE-12.2-Update-Debug-Non-Oss' ..............................[hecho] Añadiendo el repositorio 'repo-libdvdcss' ..................................................[hecho] Añadiendo el repositorio 'openSUSE-12.2-Oss' ...............................................[hecho] Añadiendo el repositorio 'packman' .........................................................[hecho] Añadiendo el repositorio 'openSUSE-12.2-Source' ............................................[hecho] Añadiendo el repositorio 'openSUSE-12.2-Update' ............................................[hecho] Añadiendo el repositorio 'openSUSE-12.2-Update-Non-Oss' ....................................[hecho] Añadiendo el repositorio 'security' ........................................................[hecho] Todos los servicios fueron actualizados.
首次刷新服务时,必须使用命令 zypper mr -e -a 启用仓库
删除服务
removeservice 或 rs
可以使用命令 rs 删除服务。
示例
celebi:~ # zypper rs Mewtwo
Eliminado servicio 'Mewtwo': Eliminado el repositorio 'KDE:Extra' .......................................................[hecho] Eliminado el repositorio 'repo-ati' ........................................................[hecho] Eliminado el repositorio 'openSUSE-12.2-Debug' .............................................[hecho] Eliminado el repositorio 'openSUSE-12.2-Update-Debug' ......................................[hecho] Eliminado el repositorio 'openSUSE-12.2-Update-Debug-Non-Oss' ..............................[hecho] Eliminado el repositorio 'repo-libdvdcss' ..................................................[hecho] Eliminado el repositorio 'openSUSE-12.2-Oss' ...............................................[hecho] Eliminado el repositorio 'packman' .........................................................[hecho] Eliminado el repositorio 'openSUSE-12.2-Source' ............................................[hecho] Eliminado el repositorio 'openSUSE-12.2-Update' ............................................[hecho] Eliminado el repositorio 'openSUSE-12.2-Update-Non-Oss' ....................................[hecho] Eliminado el repositorio 'security' ........................................................[hecho] Se eliminó el servicio 'Mewtwo'.
软件包管理
选择软件包
您可以选择用于安装或删除的软件包的几种方法。
- 按功能名称
zypper in eclipse zypper in qt
- 按功能名称和/或架构和/或版本
zypper in 'zypper<0.12.10' zypper in zypper.i586=0.12.11
- 按确切的软件包名称 (--name)
zypper in -n ftp
- 按确切的软件包名称和仓库(意味着 --name)
zypper in factory:zypper
- 使用通配符按软件包名称
zypper in yast*ftp*
- 通过指定要安装的 .rpm 软件包文件。路径可以是相对路径或绝对路径
zypper in foo.rpm #Relative path. zypper in /path/to/somewhere/foo.rpm #Absolute path
安装软件包
install 或 in
您可以按名称安装软件包...
# zypper install git
Reading installed packages... The following NEW packages are going to be installed: subversion-perl sqlite3 perl-DBD-SQLite git-svn git-cvs git Overall download size: 1.1 M. After the operation, additional 4.6 M will be used. Continue? [YES/no]: Downloading package subversion-perl-1.5.0-96.1.x86_64 (1/6), 950.0 K (4.1 M unpacked) Downloading: subversion-perl-1.5.0-96.1.x86_64.rpm [done] Installing: subversion-perl-1.5.0-96.1 [done] Downloading package sqlite3-3.5.7-17.1.x86_64 (2/6), 30.0 K (40.0 K unpacked) Downloading: sqlite3-3.5.7-17.1.x86_64.rpm [done] Installing: sqlite3-3.5.7-17.1 [done] Downloading package perl-DBD-SQLite-1.14-41.1.x86_64 (3/6), 44.0 K (103.0 K unpacked) Downloading: perl-DBD-SQLite-1.14-41.1.x86_64.rpm [done] Installing: perl-DBD-SQLite-1.14-41.1 [done] Downloading package git-svn-1.5.4.5-26.1.x86_64 (4/6), 66.0 K (195.0 K unpacked) Downloading: git-svn-1.5.4.5-26.1.x86_64.rpm [done] Installing: git-svn-1.5.4.5-26.1 [done] Downloading package git-cvs-1.5.4.5-26.1.x86_64 (5/6), 63.0 K (205.0 K unpacked) Downloading: git-cvs-1.5.4.5-26.1.x86_64.rpm [done] Installing: git-cvs-1.5.4.5-26.1 [done] Downloading package git-1.5.4.5-26.1.x86_64 (6/6), 10.0 K (3.0 K unpacked) Downloading: git-1.5.4.5-26.1.x86_64.rpm [done] Installing: git-1.5.4.5-26.1 [done]
...或它们提供的功能
# zypper in MozillaFirefox \< 3
Reading installed packages... 'MozillaFirefox' providing 'MozillaFirefox<3' is already installed. Nothing to do.
# zypper in MozillaFirefox \>= 3
Reading installed packages... The following packages are going to be upgraded: mozilla-xulrunner190-translations MozillaFirefox mozilla-xulrunner190-gnomevfs mozilla-xulrunner190 MozillaFirefox-translations The following package is going to be REMOVED: mozilla-xulrunner190-lang Overall download size: 11.0 M. After the operation, 12.9 M will be freed. Continue? [Y/n/p/?]:
# zypper in 'libqtiff.so()(64bit)'
Reading installed packages... 'libqt4-x11' providing 'libqtiff.so()(64bit)' is already installed. Nothing to do.
其他示例
zypper in yast* # install all yast modules zypper in -t pattern lamp_server # install lamp_server pattern (packages needed for a LAMP server) zypper in emacs pattern:lamp_server # install the emacs package and lamp_server pattern zypper in vim -emacs # install vim and remove emacs in one go zypper in amarok packman:libxine1 # install libxine1 from packman and amarok from any repo zypper in bitchx-1.1-81.x86_64.rpm # install bitchx rpm from local directory zypper in -f subversion # force reinstallation of subversion
删除软件包
remove 或 rm
该remove命令与 install 命令非常相似,只是效果相反 :O)
zypper remove sqliteReading installed packages... The following packages are going to be REMOVED: sqlite3 perl-DBD-SQLite git-cvs git After the operation, 351.0 K will be freed. Continue? [YES/no]: n
自动删除不需要的软件包
上面的命令可能只会删除目标软件包。要确保删除作为sqlite的依赖项安装的软件包,并且系统中任何其他软件包都不需要这些软件包,请使用选项--clean-deps,或者-u简写。
zypper rm solaarReading installed packages... Resolving package dependencies... The following package is going to be REMOVED: solaar 1 package to remove. After the operation, 2.0 MiB will be freed. Continue? [y/n/v/...? shows all options] (y): n
zypper rm -u solaarReading installed packages... Resolving package dependencies... The following 7 packages are going to be REMOVED: python311-evdev python311-hid-parser python311-python-xlib python311-PyYAML python311-typing_extensions solaar solaar-udev 7 packages to remove. After the operation, 5.0 MiB will be freed. Continue? [y/n/v/...? shows all options] (y): y (1/7) Removing solaar-1.1.10-2.1.noarch ............................................................[done] (2/7) Removing solaar-udev-1.1.10-2.1.noarch .......................................................[done] (3/7) Removing python311-typing_extensions-4.8.0-1.1.noarch ........................................[done] (4/7) Removing python311-python-xlib-0.33-2.1.noarch ...............................................[done] (5/7) Removing python311-hid-parser-0.0.3-1.6.noarch ...............................................[done] (6/7) Removing python311-evdev-1.6.1-2.3.x86_64 ....................................................[done] (7/7) Removing python311-PyYAML-6.0.1-2.1.x86_64 ...................................................[done] Running post-transaction scripts ...................................................................[done]
如果您已经删除了软件包,则需要先检查已安装的不再需要的软件包
zypper pa --unneeded
作为一个单行命令,您可以使用以下命令删除它们,类似于基于 Debian 的 `apt-get autoremove`
sudo zypper rm (zypper pa --unneeded | awk '/i / {print $3}' FS='|' | uniq | tr '\n')
源代码和构建依赖项
source-install 或 si
# zypper si zypper
Reading installed packages... The following NEW packages are going to be installed: libzypp-devel libsatsolver-devel The following source package is going to be installed: zypper Overall download size: 1.5 M. After the operation, additional 6.7 M will be used. Continue? [YES/no]:
您还可以仅安装构建依赖项或仅源代码包
zypper si -D zypper # only the source packages (no build deps) zypper si -d zypper # only the build deps (no source package)
更新软件包
update 或 up
以下命令使用可用更新版本更新软件包。有关更多信息,请参阅 更新管理。
zypper up # update all installed packages with newer version as far as possible zypper up libzypp zypper # update libzypp and zypper zypper in sqlite3 # update sqlite3 or install it if not yet installed
查询
搜索软件包
search 或 se
默认情况下,search 命令查找任何类型、状态或仓库的软件包,这些软件包的名称包含指定的字符串(不区分大小写)
celebi:~ # zypper se sqlite
Loading repository data... Reading installed packages... S | Name | Summary | Type --+-----------------------------+----------------------------------------------------------------+----------- | dovecot21-backend-sqlite | SQLite support for Dovecot | package | go-gosqlite | Trivial SQLite binding for Go | package | go-gosqlite | Trivial SQLite binding for Go | srcpackage | go-gosqlite-doc | API documenation | package | libapr-util1-dbd-sqlite3 | DBD driver for SQLite 3 | package | libdbi-drivers-dbd-sqlite3 | SQLite3 driver for libdbi | package | libgda-3_0-sqlite | Sqlite Provider for GNU Data Access (GDA) | package | libgda-5_0-sqlite | Sqlite Provider for GNU Data Access (GDA) | package i | libqt4-sql-sqlite | Qt 4 sqlite plugin | package i | libqt4-sql-sqlite-32bit | Qt 4 sqlite plugin | package i | libsqlite3-0 | Shared libraries for the Embeddable SQL Database Engine | package i | libsqlite3-0-32bit | Shared libraries for the Embeddable SQL Database Engine | package | mono-data-sqlite | Database connectivity for Mono | package | pdns-backend-sqlite2 | SQLite 2 backend for pdns | package i | perl-DBD-SQLite | Self-contained RDBMS in a DBI Driver | package | perl-DBD-SQLite | Self-contained RDBMS in a DBI Driver | srcpackage | perl-DBD-SQLite-devel | Development files for perl-DBD-SQLite | package i | php5-sqlite | PHP5 Extension Module | package | proftpd-sqlite | SQLite Module for ProFTPD | package | python-pysqlite | DB-API 2.0 interface for SQLite 3.x | package | python-pysqlite | DB-API 2.0 interface for SQLite 3.x | srcpackage | python-pysqlite-debuginfo | Debug information for package python-pysqlite | package | python-pysqlite-debugsource | Debug sources for package python-pysqlite | package | qt3-sqlite | SQLite Database Plug-In for Qt | package | rubygem-sqlite3 | A Ruby interface for the SQLite3 database engine | package | rubygem-sqlite3 | A Ruby interface for the SQLite3 database engine | srcpackage | rubygem-sqlite3-doc | RDoc documentation for sqlite3 | package | rubygem-sqlite3-testsuite | Test suite for sqlite3 | package i | sqlite2 | Embeddable SQL Database Engine | package | sqlite2 | Embeddable SQL Database Engine | srcpackage | sqlite2-32bit | Embeddable SQL Database Engine | package | sqlite2-devel | Embeddable SQL Database Engine | package | sqlite3 | Embeddable SQL Database Engine | package | sqlite3 | Embeddable SQL Database Engine | srcpackage i | sqlite3-devel | Embeddable SQL Database Engine | package | sqlite3-tcl | Tcl binding for SQLite | package | strongswan-sqlite | OpenSource IPsec-based VPN Solution | package | tntdb3-sqlite | Tntdb is a c++-class-library for easy database-access - sqlite | package | tntdb3-sqlite-debuginfo | Debug information for package tntdb3-sqlite | package | ulogd2-sqlite3 | SQLite3 output target for ulogd2 | package
列中的字母 "i" (1) 表示该软件包已安装在本地机器上。要查看匹配软件包的所有可用版本,请使用"--details/-s"选项
celebi:~ # zypper search -s --match-exact VirtualBox
Loading repository data... Reading installed packages... S | Name | Type | Version | Arch | Repository --+------------+------------+--------------+--------+--------------------- | virtualbox | package | 4.1.18-1.3.1 | x86_64 | openSUSE-12.2-Oss | virtualbox | package | 4.1.18-1.3.1 | i586 | openSUSE-12.2-Oss | virtualbox | srcpackage | 4.1.18-1.3.1 | noarch | openSUSE-12.2-Source
列中的字母 "i" (1) 表示所选软件已安装在本地机器上,而列中的字母 "v" (1) 表示本地机器上安装了该产品的其他版本。
其他示例
zypper se -dC --match-words RSI # look for RSI acronym (case-sensitively), also in summaries and descriptions zypper se 'yast*' # show all packages starting with 'yast' (beware of shell expansion, quote the strings if unsure!) zypper se -r packman # list all packages from 'packman' repository zypper se -i sqlite # show all installed packages containing 'sqlite' in their name zypper se -t pattern -r repo-oss # list all patterns available in the 'repo-oss' repository zypper se -t product # list all available products
获取有关软件包的信息
info 或 if
celebi:~ # zypper info amarok
Loading repository data... Reading installed packages... Information for package amarok: Repository: packman Name: amarok Version: 2.6.0-7.3 Arch: x86_64 Vendor: http://packman.links2linux.de Installed: Yes Status: out-of-date (version 2.6.0-6.9 installed) Installed Size: 31.0 MiB 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.
此命令显示有关名为“amarok”的软件包的详细信息。
其他示例
zypper info -t patch MozillaFirefox # show information about 'MozillaFirefox' patch zypper patch-info MozillaFirefox # the same as above zypper info -t pattern lamp_server # show info about 'lamp_server' pattern zypper info -t product openSUSE-FTP # show info about specified product
依赖关系
what-provides 或 wp
要列出指定功能的所有提供者,请执行
celebi:~ # zypper wp firefox
Loading repository data... Reading installed packages... S | Name | Type | Version | Arch | Repository --+----------------+---------+---------------+--------+--------------------- i | MozillaFirefox | package | 15.0.1-2.11.1 | x86_64 | openSUSE-12.2-Update v | MozillaFirefox | package | 15.0-2.7.1 | x86_64 | openSUSE-12.2-Update v | MozillaFirefox | package | 14.0.1-2.4.1 | x86_64 | openSUSE-12.2-Oss v | MozillaFirefox | package | 15.0.1-2.11.1 | i586 | openSUSE-12.2-Update v | MozillaFirefox | package | 15.0-2.7.1 | i586 | openSUSE-12.2-Update v | MozillaFirefox | package | 14.0.1-2.4.1 | i586 | openSUSE-12.2-Oss
此命令类似于rpm -q --whatprovides firefox,但rpm只能查询 RPM 数据库(已安装软件包的数据库)。另一方面,Zypper 会告诉您来自任何仓库的功能提供者,而不仅仅是已安装的仓库。
其他查询
patches、packages、patterns 和 products 命令类似于 search -s -t [patch,package,pattern,product],除了它们显示特定于相应软件包类型的其他信息。例如patches还显示补丁的状态(需要/安全/不适用)。
list-updates 和 patch-check 命令在 更新管理 中讨论。
软件包锁定
locks 或 ll addlock 或 al removelock 或 rl cleanlocks 或 cl
软件包锁的作用是防止系统上软件包的更改。匹配活动锁的软件包无法更改其安装状态;已安装的软件包无法删除或升级,尚未安装的软件包无法安装。
要锁定所有以“yast2”开头的软件包,请执行
celebi:~ # zypper al nano
Specified lock has been successfully added.
再次注意 shell 扩展,如果 yast* 可能会匹配工作目录中的某些文件或目录,请使用引号。
要列出当前活动的锁
celebi:~ # zypper ll
# | Name | Type | Repository ---+-------------------------------+---------+----------- 1 | PackageKit-gstreamer-plugin | package | (any) 2 | PackageKit-backend-zypp | package | (any) 3 | PackageKit-branding-openSUSE | package | (any) 4 | apper | package | (any) 5 | PackageKit-browser-plugin | package | (any) 6 | libpackagekit-glib2-14 | package | (any) 7 | PackageKit-gtk3-module | package | (any) 8 | libpackagekit-qt2-2 | package | (any) 9 | pk-update-icon | package | (any) 10 | libpackagekit-qt2-2-32bit | package | (any) 11 | libpackagekit-qt2-devel-32bit | package | (any) 12 | gnome-packagekit | package | (any) 13 | libpackagekit-qt2-devel | package | (any) 14 | PackageKit | package | (any)
要删除锁,请执行
# zypper rl nano
1 lock has been successfully removed.
其他示例
zypper al zypper # lock package 'zypper' (exact match) zypper al -r repo-oss virtualbox* # restrict the lock to 'repo-oss' repository (allowing installation from others) zypper rl 3 # remove lock by number
您还可以通过直接编辑 锁文件 来操作锁。
实用工具
验证依赖项
verify 或 ve
您偶尔可能会遇到一个在软件包依赖项方面出现问题的系统。如果您的应用程序在显示缺少某些内容的错误消息的情况下无法启动,这是 zypper 需要检查的事情
$ firefox
Could not find compatible GRE between version 1.9.0 and 1.9.0.
# zypper ve
Reading installed packages... Some of the dependencies of installed packages are broken. In order to fix these dependencies, the following actions need to be taken: The following NEW package is going to be installed: mozilla-xulrunner190 Overall download size: 6.5 M. After the operation, additional 23.5 M will be used. Continue? [YES/no]: y
安装新的推荐软件包
install-new-recommends 或 inr
此命令查找并安装您已安装的软件包新添加的推荐软件包。这提供了一种轻松获取软件的新语言包或新添加硬件的驱动程序的方法。
# zypper inr
Reading installed packages... The following NEW packages are going to be installed: kdebase4-openSUSE-lang bundle-lang-common-cs Overall download size: 534.0 K. After the operation, additional 1.9 M will be used. Continue? [YES/no]:
检查进程
ps
此命令显示使用最近软件包升级或删除时删除的文件进程
There are some running programs that use files deleted by recent upgrade. You may wish to restart some of them. Run 'zypper ps' to list these programs.
celebi:~ # zypper ps
The following running processes use deleted files: PID | PPID | UID | Login | Command | Service | Files ------+------+------+---------+-------------------------------+---------+----------------------------- 1 | 0 | 0 | root | systemd | | /lib64/libudev.so.0.13.1 759 | 1 | 0 | root | systemd-logind | | /lib64/libudev.so.0.13.1 1827 | 1696 | 0 | root | Xorg | | /lib64/libudev.so.0.13.1 You may wish to restart these processes. See 'man zypper' for information about the meaning of values in the above table.
更新管理
有两种方法可以使您的系统保持最新。一种是按补丁,另一种是按软件包。
按补丁方法对于使用稳定版本并希望使用通过在线更新仓库发布的补丁更新系统的人员特别有用。更新仓库在系统安装或升级期间默认添加,也可以通过 YaST 控制中心的软件选项卡中的在线更新配置或使用 zypper 手动添加。以下是 可用 openSUSE 更新仓库的列表。
YaST 等效于此功能的是 在线更新 模块。
第二种,按软件包更新在 软件包更新 部分中描述,用于从任何仓库使用其更新版本进行常规软件包更新。
列出需要的补丁
list-patches 或 lp
要列出所有需要的补丁更新,请执行
celebi:~ # zypper lp
Loading repository data... Reading installed packages... Repository | Name | Version | Category | Status | Summary ---------------------+-------------------+---------+-------------+--------+--------------------------------------------------------------------- openSUSE-12.2-Update | openSUSE-2012-651 | 1 | recommended | needed | udev: create /dev/root symlink with dynamic rule for systemd openSUSE-12.2-Update | openSUSE-2012-655 | 1 | recommended | needed | clamav: update to version 0.97.6 openSUSE-12.2-Update | openSUSE-2012-657 | 1 | recommended | needed | NetworkManager: Several Bug fixes openSUSE-12.2-Update | openSUSE-2012-659 | 1 | recommended | needed | timezone: update to 2012f openSUSE-12.2-Update | openSUSE-2012-660 | 1 | security | needed | security update for tor openSUSE-12.2-Update | openSUSE-2012-662 | 1 | recommended | needed | coreutils: re-enable multithreaded sort(1) if OMP_NUM_THREADS is set openSUSE-12.2-Update | openSUSE-2012-663 | 1 | recommended | needed | suspend: Fixed double suspend issue openSUSE-12.2-Update | openSUSE-2012-665 | 1 | recommended | needed | mdadm update for openSUSE 12.2 openSUSE-12.2-Update | openSUSE-2012-666 | 1 | recommended | needed | module-init-tools: Fix modprobe when /usr/local is managed by AutoFS
有时仅列出影响软件包管理的更新,因为这些更新应首先应用。应用后,此命令将列出所有可用的更新。
此命令等效于旧版本 zypper 中的 zypper up -t patch。要列出所有可用的软件包更新,请使用
celebi:~ # zypper lu
应用补丁
patch
要应用需要的补丁,请执行
celebi:~ # zypper patch
Loading repository data... Reading installed packages... Resolving package dependencies... The following NEW patches are going to be installed: openSUSE-2012-651 openSUSE-2012-655 openSUSE-2012-657 openSUSE-2012-659 openSUSE-2012-660 openSUSE-2012-662 openSUSE-2012-663 openSUSE-2012-665 openSUSE-2012-666 The following packages are going to be upgraded: NetworkManager NetworkManager-devel clamav coreutils libgudev-1_0-0 libnm-glib-vpn1 libnm-glib4 libnm-util2 libudev-devel libudev0 mdadm module-init-tools suspend timezone timezone-java tor typelib-1_0-NMClient-1_0 typelib-1_0-NetworkManager-1_0 udev 19 packages to upgrade. Overall download size: 9.2 MiB. After the operation, additional 4.3 KiB will be used. Continue? [y/n/?] (y):
列出所有补丁
patches
该list-updates命令仅列出需要的补丁。要列出所有可用的补丁,请使用
# zypper patches
Reading installed packages... Catalog | Name | Version | Category | Status -----------------+--------------------+---------+-------------+--------------- Updates for 11.1 | KDE4-fixes | 38 | recommended | Installed Updates for 11.1 | MozillaFirefox | 50 | recommended | Installed Updates for 11.1 | NetworkManager-kde | 49 | recommended | Installed Updates for 11.1 | autoyast2 | 37 | recommended | Installed Updates for 11.1 | courier-authlib | 42 | security | Not Applicable Updates for 11.1 | insserv | 47 | recommended | Installed Updates for 11.1 | opera | 43 | security | Installed
检查补丁
patch-check
此命令会告诉您系统是否有任何重要的补丁可用以及这些补丁的数量
celebi:~ # zypper pchk
Loading repository data... Reading installed packages... 9 patches needed (1 security patch)
获取有关补丁的信息
patch-info
info -t patch
celebi:~ # zypper info -t patch openSUSE-2012-651
Loading repository data... Reading installed packages... Information for patch openSUSE-2012-651: Name: openSUSE-2012-651 Version: 1 Arch: noarch Vendor: maint-coord@suse.de Status: Installed Category: recommended Created On: Wed Sep 19 14:03:20 2012 Reboot Required: No Package Manager Restart Required: No Interactive: No Summary: udev: create /dev/root symlink with dynamic rule for systemd Description: This update fixes the following issue for udev: - bnc#776882: create /dev/root symlink with dynamic rule for systemd Provides: patch:openSUSE-2012-651 == 1 Conflicts: libgudev-1_0-0.i586 < 182-4.17.1 libgudev-1_0-0-32bit.x86_64 < 182-4.17.1 libgudev-1_0-0-debuginfo.i586 < 182-4.17.1 libgudev-1_0-0-debuginfo-32bit.x86_64 < 182-4.17.1 libgudev-1_0-devel.i586 < 182-4.17.1 libudev-devel.i586 < 182-4.17.1 libudev0.i586 < 182-4.17.1 libudev0-32bit.x86_64 < 182-4.17.1 libudev0-debuginfo.i586 < 182-4.17.1 libudev0-debuginfo-32bit.x86_64 < 182-4.17.1 typelib-1_0-GUdev-1_0.i586 < 182-4.17.1 udev.i586 < 182-4.17.1 srcpackage:udev < 182-4.17.1 udev-debuginfo.i586 < 182-4.17.1 udev-debugsource.i586 < 182-4.17.1 libgudev-1_0-0.x86_64 < 182-4.17.1 libgudev-1_0-0-debuginfo.x86_64 < 182-4.17.1 libgudev-1_0-devel.x86_64 < 182-4.17.1 libudev-devel.x86_64 < 182-4.17.1 libudev0.x86_64 < 182-4.17.1 libudev0-debuginfo.x86_64 < 182-4.17.1 typelib-1_0-GUdev-1_0.x86_64 < 182-4.17.1 udev.x86_64 < 182-4.17.1 udev-debuginfo.x86_64 < 182-4.17.1 udev-debugsource.x86_64 < 182-4.17.1
软件包更新
list-updates 或 lu
update 或 up
要简单地使用可用更新版本更新已安装的软件包,请执行
# zypper up
您可以使用以下命令获取可用更新的列表:
# zypper lu
上面的命令只会列出或更新那些更新没有依赖问题时才更新的软件包。要获取具有比已安装版本更新版本的软件包的原始列表,请执行
# zypper lu -a
这将列出所有更新候选者,无论它们是否可安装或是否需要用户的交互来解决某些问题。
发行版升级
dist-upgrade 或 dup
此命令使用发行版升级算法,该算法处理软件包拆分、未维护的软件包等。使用它来切换到另一个发行版版本。
# zypper dup
建议在 dist-upgrade 期间仅启用要安装的发行版的主仓库以及您正在使用的几个重要仓库(最好是与当前主仓库对应的版本)。您可以使用 zypper mr -da 禁用旧仓库,使用 zypper ar 添加新仓库,并发出 zypper dup 来实现此目的。您还可以使用 --repo 选项指定要使用的仓库:zypper dup -r repo1 -r repo2 ...。
问: “zypper up” 仅在较新版本位于与过时软件包相同的仓库中时才升级软件包,而 “zypper dup” 会升级所有内容,无论较新软件包位于哪个仓库中,这是否正确?
答: “zypper up” 更新软件包(如果可用),但不会更改供应商(注意:整个构建服务当前具有相同的供应商)。“zypper dup” 将尝试将您当前安装的软件包与从 (所有) 您启用的仓库中可用的软件包同步。这意味着如果您的安装版本比仓库中可用的版本更新,它也会降级软件包。
在脚本和应用程序中使用 zypper
Zypper 支持几种全局选项,使其适合在自动化流程(如脚本)中使用。此外,zypper 手册页中列出的几种不同的退出代码可以在自动化流程中使用 zypper 时进行检查。
非交互模式
--non-interactive
在此模式下,zypper 不会提示用户回答任何问题,而是使用默认答案。使用此选项时,保证 zypper 不会因在 stdin 上提示答案或陷入无限循环而挂起。
例如,要自动更新系统而无需确认,您可以键入
# zypper --non-interactive update
此命令不需要用户确认即可继续更新,跳过所有需要额外确认的交互式补丁,并自动回答任何其他提示。
无 GPG 检查模式
--no-gpg-checks
如果使用此选项,zypper 将始终选择继续,如果某些 gpg 检查失败,例如,仓库文件未签名应该签名,文件已签名并且 gpg 检查失败等。
自动同意许可协议
--auto-agree-with-licenses
这是 install、remove 和 update 命令的特殊选项。通过使用此选项,用户声明他/她同意该命令将安装的许可协议的条款,zypper 将自动对许可确认提示说“是”。这对于人们在多台机器上安装相同的软件包集(通过自动化流程)并阅读所有许可协议之前很有用。
安静输出
--quiet
避免显示过多的文本,例如进度信息,仅显示操作结果和错误消息。
XML 输出
--xmlout
此选项使 zypper 以 XML 形式进行通信。这允许脚本、图形前端或其他希望使用 zypper 的应用程序以定义明确的标准方式解析 zypper 的输出。zypper 的 XML 输出的 RNC 模式可在 此处 和/usr/share/zypper/xml/xmlout.rnc.
可用。并非所有(但大部分)输出当前以 XML 形式显示;目标是将所有可能的输出都以 XML 形式显示。
提示
以下应该是 zypper 需要用户交互的完整列表,以及在非交互模式下使用的回复。此处提到的所有其他选项都优先于 --non-interactive,因此如果使用,它们所暗示的答案将自动使用,即使未使用 --non-interactive。
如果应用了 --no-gpg-checks,则会显示一条消息或将警告写入 stderr 并记录。
| prompt | 默认答案 | 在应用 --no-gpgp-checks 时 | 备注 |
|---|---|---|---|
| 接受未签名的文件? | N | Y | |
| 接受新密钥(拒绝密钥、临时信任或始终信任?[r/t/a]) | R | R | 只能在交互模式下信任或导入新密钥 |
| 接受未知密钥? | N | Y | |
| 签名文件的验证失败,继续? | N | Y | |
| 文件没有摘要,继续? | N | Y | |
| 接受未知摘要? | N | Y |
其他提示
| prompt | 默认答案 | 其他答案 | 备注 |
|---|---|---|---|
| 继续安装/删除/更新? | Y | 此外,--no-confirm选项即使在没有全局--non-interactive | |
| 确认第三方许可 | N | Y 如果--auto-agree-with-licenses使用 | 此外,对于 zypper update,可以使用 --skip-interactive 选项从要安装的列表中排除交互式补丁(rug 的遗产) |
| 确认补丁消息 | Y | ||
| 在安装/删除可解析的内容时出现问题,中止/重试/忽略? | ABORT | 这很糟糕,将来可以改进 | |
| 在下载软件包时出现问题,中止/重试/忽略? | ABORT | 这也很糟糕,将来可以进行改进 | |
| 依赖冲突,#/s/r/c(解决方案编号、跳过、重试或取消) | c | 始终取消,需要用户交互才能解决依赖关系 | |
| 媒体更改请求 | ABORT | ||
| 删除有问题锁? | Y |
在 XML 输出中,提示由 <prompt> 标签表示,其中包含 id 属性。所有已知 ID 的枚举可在 zypper 随附的 prompt.h 包含文件中找到(/usr/include/zypper/prompt.h).
与 Rug 的兼容性
Zypper 的语法与 Rug 类似,但其命令和选项集也已开始与 Rug 的输出和行为不同。