Zypper 用法

http://zh.opensuse.org/SDB:Zypper_%E7%94%A8%E6%B3%95php

https://blog.csdn.net/haohe1987/article/details/84295440
快速參考
下列是些經常使用的命令:前端

zypper # 列出可用的全局選項和命令
zypper help search # 列出 search 命令的幫助
zypper lp # 列出須要的補丁更新
zypper patch # 安裝所需的補丁
zypper se sqlite # 搜索 sqlite 軟件
zypper rm sqlite2 # 刪除 sqlite2 軟件
zypper in sqlite3 # 安裝 sqlite3 軟件
zypper in yast* # 安裝全部符合 yast* 名稱的軟件
zypper up # 更新全部軟件包到可用的新版本
[編輯] 備忘單
這裏是本頁內容的備忘單,也包含了一些手冊頁裏的內容。建議您瞭解本頁內容以後再使用。node

第一頁(A4 大小)
第二頁(A4 大小)
第一頁(letter 大小)
第二頁(letter 大小)
[編輯] 常規用法
zypper 常規語法:python

# zypper [全局選項] 命令 [命令選項] [參數] ...
方括號部分並不是必需,所以最簡單的形式就是 zypper 後跟一個命令。例如,安裝所需的補丁:linux

# zypper patch
您也能夠選擇一個或多個全局選項,全局選項在命令以前輸入,如(不詢問而執行命令):c++

# zypper --non-interactive patch
命令選項跟在命令後面,如(自動贊成全部協議並安裝所需的補丁):git

# zypper patch --auto-agree-with-licenses
一些命令須要一或多個參數,如(安裝或更新 mplayer):算法

# zypper install mplayer
一些選項也須要參數,如(搜索匹配項 pattern):sql

# zypper search -t pattern
綜合以上所列,如(安裝 Factory 供應源的 mplayer 和 amarok,並列出具體信息):chrome

# zypper -v install --repo factory mplayer amarok
[編輯] 答覆提示
當 zypper 遇到提示信息等待用戶答覆時,會於提示符旁在括號裏列出備擇項。按 Enter 選擇默認答覆(默認答覆選中顯示,非 ASCII 字符則否則)。一些提示信息也包含幫助信息,這種時候就會有一個問號「?」。如欲讓 zypper 直接使用默認答覆不非詢問用戶,使用 --non-interactive 全局選項。

[編輯] 詞彙表
repository 供應源 - 包含軟件包和各類軟件包信息(元數據 metadata)的本地或遠端目錄。供應源之前稱爲安裝源、軟件源、YaST 源或源。
alias 別名 - 供應源別名是供應源名字的簡短代號,用於與供應源相關的命令和選項中,如 removerepo 或 --repo。
package 軟件包 - 如 RPM 軟件包、源碼包等。補丁 (patch)、模式 (pattern) 和成品 (product) 一般也認爲是別種類型的軟件包。
patch 補丁 - 用於安裝更新(一般是修復缺陷)的一個或一組軟件包。
pattern 模式 - 同一模式的一組軟件包。例如 Http Server 模式界定了依賴關係,當安裝該模式時,運行或管理一個 http 服務所需的所有的軟件包都將一塊兒安裝。
product 成品 - 一整個成品,如 openSUSE 11.1。
[編輯] 命令
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
其餘
help, licenses, versioncmp, targetos
[編輯] 幫助信息
首先,應該先了解如何獲取幫助信息。如欲查看基本的幫助信息(命令和全局選項列表)只需不帶任何選項或參數輸入 zypper。如欲查看特定的命令,輸入:

# zypper help [command]
獲取命令的具體幫助信息,輸入:

# zypper [command] --help
可使用 -h 替代 --help。

[編輯] 供應源管理
您能夠以 zypper lr 裏的序號、別名或 URI(Uniform Resource Identifier,統一資源標誌符)代指相應的供應源。使用序號時,須先 zypper lr 確認一番,由於若變動了供應源這些序號也會變動。

[編輯] 列出設定的供應源
repos 或 lr

示例:

$ zypper lr
# | Alias | Name | Enabled | Refresh
--+-----------------------+-----------------------+---------+--------
1 | packman | Packman 11.1 | Yes | No
2 | fate | fate | No | No
3 | openSUSE-11.1-Updates | Updates for 11.1 | Yes | Yes
4 | repo-oss | openSUSE-11.1-Oss | Yes | No
5 | repo-non-oss | openSUSE-11.1-Non-Oss | Yes | No
6 | repo-debug | openSUSE-11.1-Debug | No | No
$ zypper lr 5 4
Alias  : openSUSE-11.3-Non-Oss
Name  : openSUSE-11.3-Non-Oss
URI  : http://download.opensuse.org/distribution/11.3/repo/non-oss/
Enabled  : Yes
Priority  : 99
Auto-refresh  : Off
Keep Packages  : Off
Type  : yast2
GPG Check  : On
GPG Key URI  :
Path Prefix  : /
Parent Service :
MD Cache Path  : /var/cache/zypp/raw/openSUSE-11.3-Non-Oss

Alias  : openSUSE-11.3-Oss
Name  : openSUSE-11.3-Oss
URI  : http://download.opensuse.org/distribution/11.3/repo/oss/
Enabled  : Yes
Priority  : 99
Auto-refresh  : Off
Keep Packages  : Off
Type  : yast2
GPG Check  : On
GPG Key URI  :
Path Prefix  : /
Parent Service :
MD Cache Path  : /var/cache/zypp/raw/openSUSE-11.3-Oss
其餘例子:

zypper lr -u # 列出供應源 URI
zypper lr -d # 列出供應源的其餘數項屬性
zypper lr -P # 列出供應源優先級並依此排序
zypper lr -e my # 導出所有的供應源設定信息至文件 my.repo
[編輯] 添加供應源
addrepo 或 ar

安裝軟件包以前至少得有一個供應源。可使用 addrepo 命令添加供應源:

示例:

# zypper ar http://download.videolan.org/pub/vlc/SuSE/11.1 vlc
Adding 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 # 經過 .repo 文件
zypper ar -c ftp://some.download.site myalias # 添加以前試探供應源
zypper ar my/dir/with/rpms local # 添加含 RPM 文件的本地目錄爲供應源
參見 Libzypp 瞭解支持的媒介與 URI。

[編輯] 刷新供應源
refresh 或 ref

添加了供應源以後或供應源不新之時,就須要刷新供應源。即下載軟件包的元數據 (metadata),並將數據預處理爲 .solv 緩存以便快速讀取。

# zypper refresh
Downloading 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 # 您也能夠只指定特定的供應源刷新
zypper ref -f upd # 強制 upd 供應源刷新
[編輯] 移除供應源
removerepo 或 rr

# zypper rr vlc 1 23 foo
Repository 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 6
Repository 'repo-non-oss' has been sucessfully disabled.
啓用 packman 供應源的自動刷新並緩存 RPM 文件,再設置其優先級爲 70:

# zypper mr -rk -p 70 packman
Autorefresh 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 -Ka
Nothing 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 -ka
RPM 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'.
當前該命令只能更改供應源的別名 (alias),若您想更改顯示的名稱,請參閱 mr 命令。

取一個簡短的別名能夠方便地用於命令參數或 --repo 選項中。使用別名較之序號安全,序號可能變化而使您出錯,較之 URI 簡單,URI 太長複製黏貼不便。

[編輯] 導出導入供應源
repos --export 或 lr -e

您能夠導出您的供應源列表爲一個文件,並於稍後或另外一計算機上導入。

# zypper lr --export backups/repos/foo.repo
# zypper ar backups/repos/foo.repo
[編輯] 服務管理
<待撰>

 

[編輯] 軟件包管理
[編輯] 選擇軟件包
有數種方式選擇要安裝或移除的軟件包。

根據名稱
zypper in eclipse
zypper in qt
根據名稱、構架或版本
zypper in 'zypper<0.12.10'
zypper in zypper.i586=0.12.11
根據確切的軟件包名稱 (--name)
zypper in -n ftp
根據確切的軟件包名稱和供應源 (implies --name)
zypper in factory:zypper
根據含通配符的軟件包名稱
zypper in yast*ftp*
根據指定一個 .rpm 軟件包文件來安裝
[編輯] 安裝軟件包
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* # 安裝所有 yast 模塊
zypper in -t pattern lamp_server # 安裝 lamp_server 模式(LAMP server 所需的軟件包)
zypper in vim -emacs # 安裝 vim 並移除 emacs
zypper in amarok packman:libxine1 # 安裝 packman 供應源的 libxine1 和任何供應源的 amarok
zypper in bitchx-1.1-81.x86_64.rpm # 安裝當前目錄的 bitchx RPM 軟件包
zypper in -f subversion # 強制從新安裝 subversion
[編輯] 移除軟件包
remove 或 rm

remove 命令與 install 命令類似,除了其相反的做用。

# zypper remove sqlite
Reading 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
[編輯] 源碼包和構建依賴
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 # 只安裝源碼包
zypper si -d zypper # 只安裝構建依賴
[編輯] 更新軟件包
update 或 up

如下命令更新軟件包至新版本。參閱更新管理了解詳情。

zypper up # 更新所有已安裝的軟件包至儘量新的版本
zypper up libzypp zypper # 更新 libzypp 和 zypper
zypper in sqlite3 # 安裝或更新 sqlite3
[編輯] 查詢
[編輯] 搜尋軟件包
search 或 se

search 命令默認搜尋匹配的任何類型、狀態或供應源的軟件包(大小寫不敏感):

# zypper se sqlite
Reading installed packages...

S | Name | Summary | Type
--+--------------------------+----------------------------------------------------------------+--------
| libapr-util1-dbd-sqlite3 | DBD driver for SQLite 3 | package
i | libgda-3_0-sqlite | Sqlite Provider for GNU Data Access (GDA) | package
| libqt4-sql-sqlite | Qt 4 sqlite plugin | package
i | libsqlite3-0 | Shared libraries for the Embeddable SQL Database Engine | package
| libsqlite3-0-32bit | Shared libraries for the Embeddable SQL Database Engine | package
| mediatomb-sqlite | UPnP AV MediaServer | package
i | mono-data-sqlite | Database connectivity for Mono | package
| pdns-backend-sqlite2 | SQLite 2 backend for pdns | package
| pdns-backend-sqlite3 | SQLite 3 backend for pdns | package
i | perl-DBD-SQLite | The DBD::SQLite is a self contained RDBMS in a DBI driver | package
i | php5-sqlite | PHP5 Extension Module | package
| python-sqlite2 | Python bindings for sqlite 2 | package
| qt3-sqlite | SQLite Database Plug-In for Qt | package
| rekall-sqlite | Rekall sqlite Database Backend | package
| rubygem-sqlite3 | A Ruby interface for the SQLite3 database engine | package
i | sqlite2 | Embeddable SQL Database Engine | package
| sqlite2-32bit | Embeddable SQL Database Engine | package
| sqlite2-devel | Embeddable SQL Database Engine | package
i | sqlite3 | Embeddable SQL Database Engine | package
| sqlite3-devel | Embeddable SQL Database Engine | package
| sqlite3-tcl | Tcl binding for SQLite | package
| tntdb1-sqlite | Tntdb is a c++-class-library for easy database-access - sqlite | package
| ulogd-sqlite | SQLite output plugin for ulogd | package
首欄的 i 標示已經安裝的軟件包。如欲查看匹配軟件包的所有可選版本,使用 --details 或 -s 選項:

# zypper search -s --match-exact virtualbox-ose
Reading installed packages...

S | Name | Type | Version | Arch | Repository
--+----------------+---------+------------+--------+------------------------------------
v | virtualbox-ose | package | 1.6.2-2.1 | x86_64 | VirtualBox OSE
i | virtualbox-ose | package | 1.5.6-33.1 | x86_64 | openSUSE-11.1-Oss
v | virtualbox-ose | package | 1.5.6-20.5 | x86_64 | VirtualBox OSE (
v | virtualbox-ose | package | 1.6.2-2.1 | i586 | VirtualBox OSE
v | virtualbox-ose | package | 1.5.6-33.1 | i586 | openSUSE-11.1-Oss
v | virtualbox-ose | package | 1.5.6-20.3 | i586 | VirtualBox OSE
此處首欄的 v 標示已安裝了此軟件包的其餘版本。

其餘例子:

zypper se -dC --match-words RSI # 搜尋包括摘要和描述中的匹配 RSI 縮寫的項
zypper se 'yast*' # 搜尋全部含 yast 字符的軟件包(注意 shell 的表達,不肯定就加引號)
zypper se -r packman # 列出全部 packman 供應源的軟件包
zypper se -i sqlite # 列出全部已安裝的其名字包含 sqlite 的軟件包
zypper se -t pattern -r repo-oss # 列出全部 repo-oss 供應源的模式 (pattern)
zypper se -t product # 列出全部可選的成品 (product)
[編輯] 獲取軟件包的信息
info 或 if

顯示名爲 amarok 的軟件包的具體信息:

# zypper info amarok
Reading installed packages...


Information for package amarok:

Repository: Packman 11.1
Name: amarok
Version: 1.4.9.1-103.pm.1
Arch: x86_64
Vendor: packman.links2linux.de
Installed: Yes
Status: up-to-date
Installed Size: 12.1 M
Summary: Media Player for KDE
Description:
Amarok is a media player for all kinds of media, supported by aRts, GStreamer
or Xine (depending on the packages you install). This includes MP3, Ogg
Vorbis, audio CDs and streams.
It also supports audio effects of all kinds that are provided by aRts.
Playlists can be stored in .m3u or .pls files.

Amarok also provides audio file collection management, by using either an
embedded sqlite3, a MySQL or a PostgreSQL database.
其餘例子:

zypper info -t patch MozillaFirefox # 顯示 MozillaFirefox 補丁的信息
zypper patch-info MozillaFirefox # 同上
zypper info -t pattern lamp_server # 顯示 lamp_server 模式的信息
zypper info -t product openSUSE-FTP # 顯示特定成品的信息
[編輯] 依賴關係
what-provides 或 wp

列出全部指定軟件的供應方:

# zypper wp firefox
Reading installed packages...
S | Name | Type | Version | Arch | Repository
--+----------------+---------+-------------+--------+------------------
i | MozillaFirefox | package | 3.0-0.1 | x86_64 | Updates for 11.1
v | MozillaFirefox | package | 2.9.95-25.1 | x86_64 | openSUSE-11.1-Oss
v | MozillaFirefox | package | 3.0-0.1 | i586 | Updates for 11.1
v | MozillaFirefox | package | 2.9.95-25.1 | i586 | openSUSE-11.1-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 開首的軟件包,執行:

# zypper al 'yast2*'
Reading installed packages...
Specified lock has been successfully added.
再次提醒 shell 的表達,若 yast2* 有可能匹配當前目錄(工做目錄)的文件或目錄時,請使用引號。

列出當前有效的鎖定:

# zypper ll
# | Name | Type | Repository
--+------------------+---------+-----------
1 | libpoppler3 | package | (any)
2 | libpoppler-glib3 | package | (any)
3 | yast* | package | (any)
移除鎖定:

# zypper rl yast2-packager
Reading installed packages...
The following query locks some of the objects you want to unlock:

type: package
match_type: glob
case_sensitive: on
solvable_name: yast2*

Do you want remove this lock? [YES/no]: y
Lock count has been succesfully decreased by: 1
其餘例子:

zypper al zypper # 鎖定 zypper 軟件包(精確匹配)
zypper al -r repo-oss virtualbox* # 限制 repo-oss 供應源(容許安裝其餘供應源的軟件包)
zypper rl 3 # 移除對應序號的鎖定
您也能夠直接編輯 locks file 設置鎖定。

[編輯] 工具
[編輯] 驗證依賴關係
verify 或 ve

或許您會因軟件包依賴關係將系統搞得一團糟。如果一些應用程序提示缺乏某些東西而沒法啓動,這些東西正是 zypper 能夠檢查的:

$ rpm -e --nodeps mozilla-xulrunner190
$ 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

此命令顯示使用被最近的更新或移除操做所刪除的文件的進程。

有些正運行的程序使用被最近的更新所刪除的文件,您不妨重啓其中的一些。執行 zypper ps 列出這些程序。

# zypper ps
The following running processes use deleted files:

PID | PPID | UID | Login | Command | Service | Files
------+-------+------+-------+---------------+---------+--------------------------------
10604 | 10603 | 1000 | geeko | chrome | | /usr/share/mime/mime.cache
| | | | | | /usr/share/mime/mime.cache
15304 | 3195 | 1000 | geeko | kio_thumbnail | | /var/tmp/kdecache-geeko/ksycoca4
| | | | | | /var/tmp/kdecache-geeko/ksycoca4

You may wish to restart these processes.
See 'man zypper' for information about the meaning of values in the above table.
[編輯] 更新管理
有兩種方式更新您的系統,一種是補丁方式,一種是軟件包方式。

補丁方式尤爲適合使用穩定發行版的用戶,經過在線的 update 供應源發佈的補丁更新系統。安裝或升級系統時 update 供應源就已默認添加了,您也能夠經過 YaST 控制中心的在線更新設置添加,或使用 zypper 手動添加。這是 openSUSE update 供應源列表。

YaST 中的相應部分是在線更新模塊。

軟件包方式將在軟件包更新中描述,這種方式以任何供應源中的新版本提供通常的軟件包更新服務。

[編輯] 列出所需的補丁
list-patches 或 lp

列出全部所需的補丁,執行:

# zypper lp
Reading installed packages...
Patches

Repository | Name | Version | Category | Status
-----------------+--------------------+---------+-------------+-------
Updates for 11.1 | KDE4-fixes | 38 | recommended | Needed
Updates for 11.1 | MozillaFirefox | 50 | recommended | Needed
Updates for 11.1 | NetworkManager-kde | 49 | recommended | Needed
有時僅列出影響軟件包管理的更新,這是因爲這些應首先更新,更新後,其他的更新纔會列出。

此命令等效於舊版 zypper 的 zypper up -t patch。列出所有的更新,使用:

# zypper lu
[編輯] 安裝補丁
patch

安裝所需的補丁,執行:

# zypper patch
Reading installed packages...

The following packages are going to be upgraded:
NetworkManager-kde mozilla-nss mozilla-nspr kde4-korganizer


The following NEW patches are going to be installed:
NetworkManager-kde MozillaFirefox KDE4-fixes


Overall download size: 2.9 M. After the operation, additional 283.0 K will be used.
Continue? [YES/no]:
[編輯] 列出所有補丁
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

此命令檢查是否有可用的重要的補丁,並反饋補丁數:

# zypper pchk
Reading installed packages...
0 patches needed (0 security patches)
[編輯] 獲取補丁信息
patch-info
info -t patch

# zypper info -t patch MozillaFirefox
Reading installed packages...


Information for patch MozillaFirefox:

Name: MozillaFirefox
Version: 50
Arch: noarch
Vendor: maint-coord@suse.de
Status: Installed
Category: recommended
Created On: Thu 01 Jan 1970 01:00:00 AM CET
Reboot Required: No
Package Manager Restart Required: No
Interactive: No
Summary: Mozilla Firefox 3.0
Description:
This patch updates Mozilla Firefox to the final 3.0 version.

The dependend libraries mozilla-xulrunner190, mozilla-nspr
and mozilla-nss were also brought to their release version.
[編輯] 軟件包更新
list-updates 或 lu
update 或 up

如欲簡單地以新版本更新所安裝的軟件包,執行:

# zypper up
您能夠以此獲取可用的更新列表:

# zypper lu
以上命令僅列出或更新其更新無依賴問題的軟件包。如欲獲取原始的全部的更新列表,而非僅僅已安裝的,執行:

# zypper lu -a
這將列出全部的候選更新,不管是否可裝,不管是否須要用戶介入解決一些問題。

[編輯] 發行版升級
dist-upgrade 或 dup

此命令使用發行版升級算法,處理軟件包分裂 (package splits)、無維護軟件包以及相似的其餘軟件包。使用此命令能夠升級到新的發行版。

# zypper dup
建議在發行版升級過程當中僅啓用您所欲安裝的發行版的主要的供應源和一些您所用的重要的供應源(若其版本對應於主要的供應源則更佳)。您也能夠先禁用舊的供應源 zypper mr -da,添加新的供應源 zypper ar,再 zypper dup 升級。您能夠用 --repo 選項指定所使用的供應源 zypper dup -r repo1 -r repo2 ...。

問:是否 zypper up 僅更新在其供應源中有新版本的軟件包,而 zypper dup 將升級一切,不管其軟件包的來源。

答:zypper up 會更新軟件包到新版本,但不會變動其供應源(注,當前的整個編譯服務具備相同的供應源)。zypper dup 嘗試將您當前的軟件包同步爲您所啓用的(全部)供應源中的版本,這意味着可能將比供應源裏新的軟件包降級下來。

04:好像回答的與實際相反。

 

[編輯] 在腳本和程序裏使用 zypper
zypper 支持多個全局選項故而適合在自動化流程如腳本里使用。而且,在自動化流程裏使用 zypper 時,能夠檢查列在 zypper 手冊頁的多個不一樣的退出代碼。

[編輯] 無交互模式
--non-interactive

此模式下 zypper 不會詢問用戶,而以默認答覆代之。使用此選項能夠保證 zypper 不會停滯在等待用戶輸入的環節,或陷入死循環。

例如,不需人工確認自動更新系統:

# zypper --non-interactive update
此命令執行更新而無需用戶確認,略過所有須要額外確認的交互性補丁,並自動答覆任何提示。

[編輯] 無 GPG 檢查模式
--no-gpg-checks

若使用此選項,zypper 將老是選擇繼續,即便 GPG (GNU Privacy Guard) 檢查不經過,如本該有簽名卻沒有簽名的源文件、有簽名但沒能經過 GPG 檢查的文件等等。

[編輯] 自動接受許可
--auto-agree-with-licenses

這是安裝、移除和更新命令的特殊選項。使用此選項,即聲明接受許可協議,而 zypper 遇到許可確認時自動接受答覆。這對於在多臺機器上(以自動化流程)安裝相同的軟件包的已閱協議的用戶頗有用。

[編輯] 安靜輸出
--quiet

避免輸出過多的信息,諸如程序信息之類的,只輸出操做結果和錯誤信息。

[編輯] XML 輸出
--xmlout

此選項使 zypper 以 XML(eXtensible Markup Language 可擴展標記語言)輸出信息。這容許使用 zypper 的腳本、圖形化前端或其餘類型的程序以良好定義的標準的方式解析 zypper 輸出。zypper XML 輸出的 RNC 架構可於此找到,其位於 /usr/share/zypper/xml/xmlout.rnc。

當前並不是全部的輸出都是 XML 格式(但大部分是),但目標是讓全部的輸出統一爲 XML 格式。

[編輯] 提示
如下是一份完整的列表,在此狀況下 zypper 須要用在無交互模式下的用戶交互答覆。這兒提到的全部的附加選項都較 --non-interactive 有高的優先級,因此如果使用,將自動選用默認答覆,即便沒有使用 --non-interactive。(04:不知所云)

[編輯] GPG 相關提示
若使用了 --no-gpg-checks,將顯示信息或向標準錯誤 (stderr) 寫入警告並記錄。

提示信息 默認答覆 使用 --no-gpgp-checks 選項 備註
是否接受未簽名文件 N Y  
是否接受新鑰密(reject 拒絕、trust temporarily 臨時接受、trust always 接受) R R 只能在交互模式下接受或導入新鑰密
是否接受未知的鑰密 N Y  
簽名文件驗證失敗,是否繼續 N Y  
文件無 digest,是否繼續 N Y  
是否接受未知 digest N Y  
[編輯] 其餘提示
提示信息 默認答覆 其餘答覆 備註
執行安裝/移除/更新 Y   --no-confirm 選項可用於安裝/移除/更新命令,即便沒有全局的 --non-interactive 選項
是否接受第三方許可協議 N Y 若使用 --auto-agree-with-licenses 選項 對於 zypper 更新命令 --skip-interactive option 選項能夠用於排除安裝列表中的交互性補丁(rug 命令的遺傳)
是否確認補丁信息 Y    
安裝/移除過程出錯,Abort 放棄/Retry 重試/Ignore 忽略 ABORT   這很棘手,從此將改進
下載軟件包過程出錯,Abort 放棄/Retry 重試/Ignore 忽略 ABORT   這一樣棘手,從此將某些程度上改進
依賴衝突,#/s/r/c(解決方案序號/跳過/重試/取消) c   老是取消,須要用戶介入解決
媒介變動請求 ABORT    
是否移除有問題的鎖定 Y    
在 XML 輸出中,提示 (prompt) 以 <prompt> 標籤標記,包含 id 屬性。prompt.h 有全部已知的 id 細目,包括了 zypper 軟件包裏的文件 (/usr/include/zypper/prompt.h)。

[編輯] 與 Rug 的兼容Zypper 的語法與 Rug 很接近,但命令和選項集就如輸出和行爲同樣,與 Rug 開始分歧了。然而,Zypper 仍是能夠以兼容於 Rug 的模式來運行,也支持大多數 Rug 的命令。詳細信息能夠參閱 Zypper 手冊頁的 COMPATIBILITY WITH RUG 章節。————————————————版權聲明:本文爲CSDN博主「haohe1987」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處連接及本聲明。原文連接:https://blog.csdn.net/haohe1987/article/details/84295440

相關文章
相關標籤/搜索