Linux - 共通事項 - パッケージ管理 - openSUSE zypper

クラウディア 
1. 概要
2. リポジトリ操作
3. パッケージ検索
4. パッケージインストール
5. システムパッケージ変更

1. 概要

 「zypper」は、「openSUSE」のパッケージ管理(?インストールだけかしら)プログラムです。  「yast」と違って、完全にコマンドラインでの操作のようです。  本項は、下記のサイトを参考にさせていただきました。
追加のパッケージ・リポジトリ - openSUSE Wiki」
「SDB:Zypper の使い方 - openSUSE Wiki」
「Zypper コマンドの使い方

2. リポジトリ操作

 そもそも

zypper
 とだけ打ちゃ、使い方が出てきます。  長いので書きませんが、要望があれば、掲載します。  リポジトリ表示。

zypper lr
 こんなん出ました。  (以降、同様ですが、色合いは異なります)

Repository priorities are without effect. All enabled repositories share the same priority.

#  | Alias                                 | Name                                                                                        | Enabled | GPG Check | Refresh
---+---------------------------------------+---------------------------------------------------------------------------------------------+---------+-----------+--------
 1 | ftp.gwdg.de-openSUSE_Leap_$releasever | Packman Repository                                                                          | Yes     | (r ) Yes  | Yes
 2 | openSUSE-Leap-15.3-1                  | openSUSE-Leap-15.3-1                                                                        | No      | ----      | ----
 3 | repo-backports-debug-update           | Update repository with updates for openSUSE Leap debuginfo packages from openSUSE Backports | No      | ----      | ----
 4 | repo-backports-update                 | Update repository of openSUSE Backports                                                     | Yes     | (r ) Yes  | Yes
 5 | repo-debug                            | Debug Repository                                                                            | No      | ----      | ----
 6 | repo-debug-non-oss                    | Debug Repository (Non-OSS)                                                                  | No      | ----      | ----
 7 | repo-debug-update                     | Update Repository (Debug)                                                                   | No      | ----      | ----
 8 | repo-debug-update-non-oss             | Update Repository (Debug, Non-OSS)                                                          | No      | ----      | ----
 9 | repo-non-oss                          | 非オープンソースリポジトリ                                                                  | Yes     | (r ) Yes  | Yes
10 | repo-oss                              | メインリポジトリ                                                                            | Yes     | (r ) Yes  | Yes
11 | repo-sle-debug-update                 | Update repository with debuginfo for updates from SUSE Linux Enterprise 15                  | No      | ----      | ----
12 | repo-sle-update                       | Update repository with updates from SUSE Linux Enterprise 15                                | Yes     | (r ) Yes  | Yes
13 | repo-source                           | Source Repository                                                                           | No      | ----      | ----
14 | repo-update                           | メインの更新用リポジトリ                                                                    | Yes     | (r ) Yes  | Yes
15 | repo-update-non-oss                   | 更新リポジトリ (非オープンソース)                                                           | Yes     | (r ) Yes  | Yes
 リポジトリの「URI」を表示。

zypper lr -u
 こんなん出ました。  横幅がさらに広がるので見にくい。

Repository priorities are without effect. All enabled repositories share the same priority.

#  | Alias                                 | Name                                                                                        | Enabled | GPG Check | Refresh | URI
---+---------------------------------------+---------------------------------------------------------------------------------------------+---------+-----------+---------+------------------------------------------------------------------------
 1 | ftp.gwdg.de-openSUSE_Leap_$releasever | Packman Repository                                                                          | Yes     | (r ) Yes  | Yes     | http://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Leap_15.3/
 2 | openSUSE-Leap-15.3-1                  | openSUSE-Leap-15.3-1                                                                        | No      | ----      | ----    | cd:/?devices=/dev/disk/by-id/ata-VBOX_CD-ROM_VB1-1a2b3c4d
 3 | repo-backports-debug-update           | Update repository with updates for openSUSE Leap debuginfo packages from openSUSE Backports | No      | ----      | ----    | http://download.opensuse.org/update/leap/15.3/backports_debug/
 4 | repo-backports-update                 | Update repository of openSUSE Backports                                                     | Yes     | (r ) Yes  | Yes     | http://download.opensuse.org/update/leap/15.3/backports/
 5 | repo-debug                            | Debug Repository                                                                            | No      | ----      | ----    | http://download.opensuse.org/debug/distribution/leap/15.3/repo/oss/
 6 | repo-debug-non-oss                    | Debug Repository (Non-OSS)                                                                  | No      | ----      | ----    | http://download.opensuse.org/debug/distribution/leap/15.3/repo/non-oss/
 7 | repo-debug-update                     | Update Repository (Debug)                                                                   | No      | ----      | ----    | http://download.opensuse.org/debug/update/leap/15.3/oss/
 8 | repo-debug-update-non-oss             | Update Repository (Debug, Non-OSS)                                                          | No      | ----      | ----    | http://download.opensuse.org/debug/update/leap/15.3/non-oss/
 9 | repo-non-oss                          | 非オープンソースリポジトリ                                                                  | Yes     | (r ) Yes  | Yes     | http://download.opensuse.org/distribution/leap/15.3/repo/non-oss/
10 | repo-oss                              | メインリポジトリ                                                                            | Yes     | (r ) Yes  | Yes     | http://download.opensuse.org/distribution/leap/15.3/repo/oss/
11 | repo-sle-debug-update                 | Update repository with debuginfo for updates from SUSE Linux Enterprise 15                  | No      | ----      | ----    | http://download.opensuse.org/debug/update/leap/15.3/sle/
12 | repo-sle-update                       | Update repository with updates from SUSE Linux Enterprise 15                                | Yes     | (r ) Yes  | Yes     | http://download.opensuse.org/update/leap/15.3/sle/
13 | repo-source                           | Source Repository                                                                           | No      | ----      | ----    | http://download.opensuse.org/source/distribution/leap/15.3/repo/oss/
14 | repo-update                           | メインの更新用リポジトリ                                                                    | Yes     | (r ) Yes  | Yes     | http://download.opensuse.org/update/leap/15.3/oss
15 | repo-update-non-oss                   | 更新リポジトリ (非オープンソース)                                                           | Yes     | (r ) Yes  | Yes     | http://download.opensuse.org/update/leap/15.3/non-oss/
 リポジトリの更新。

zypper refresh
 状況により、表示は異なりますが、今回、こんなん出ました。

Repository 'Update repository of openSUSE Backports' is up to date.
Repository '非オープンソースリポジトリ' is up to date.
Repository 'メインリポジトリ' is up to date.
Retrieving repository 'Update repository with updates from SUSE Linux Enterprise 15' metadata ...............[done]
Building repository 'Update repository with updates from SUSE Linux Enterprise 15' cache ....................[done]
Repository 'メインの更新用リポジトリ' is up to date.
Repository '更新リポジトリ (非オープンソース)' is up to date.
All repositories have been refreshed.
 リポジトリ追加。

zypper ar [URI] [リポジトリ名]
 これは、ちょっとやってみないけど。  リポジトリ削除。

zypper rr リポジトリ名
 これもやりませんが・・・。

3. パッケージ検索

 「zypper」コマンドでは

zypper search リポジトリ名
 です。  こんなんなります。

$ zypper search gnome-screenshot
Loading repository data...
Reading installed packages...

S | Name                  | Summary                                   | Type
--+-----------------------+-------------------------------------------+--------
  | gnome-screenshot      | Utility to take pictures of your screen   | package
  | gnome-screenshot-lang | Translations for package gnome-screenshot | package
 だがしかし、「chf」(command not found)というコマンドもあります。  これ、「zypper」とおそろいなのかは、定かではありませんが、「openSUSE」では、よく出てきます。  「gnome-screenshot」を例にとります。  コマンドで「gnome-screenshot」と打つと

$ gnome-screenshot
If 'gnome-screenshot' is not a typo you can use command-not-found to lookup the package that contains it, like this:
    cnf gnome-screenshot
 とまぁ、「typo」でないか?そうでないとしたら「cnf gnome-screenshot」しなさいと言われます。  で「cnf」です。

$ cnf gnome-screenshot

The program 'gnome-screenshot' can be found in the following package:
  * gnome-screenshot [ path: /usr/bin/gnome-screenshot, repository: zypp (repo-oss) ]

Try installing with:
    zypper install gnome-screenshot
 と「zypper」でインストールしなさいってことになるわけです。

4. パッケージインストール


zypper install -y パッケージ名
 「-y」オプションは、どうせ打つ予定の、y を前もって打っているだけのことです。

5. システムパッケージ変更

 この記事は、2021年6月16日に書いておりますが。  「openSUSE 15.3 Leap」の「IceWM」をさわっており、「Packman」リポジトリを追加して、システムパッケージへ変更しようとしたら、「YaST」がこけちゃうのです。  これは、コマンドラインから、やるしかないかな。  パッケージの追加。  (以降、同様ですが、バージョンはターゲットによって異なります)

zypper ar -cf http://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Leap_15.3/ packman
 一瞬で終わります。  こんなん出ます。

Adding repository 'packman' .................................................................................[done]
Repository 'packman' successfully added

URI         : http://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Leap_15.3/
Enabled     : Yes
GPG Check   : Yes
Autorefresh : Yes
Priority    : 99 (default priority)

Repository priorities are without effect. All enabled repositories share the same priority.
 システムパッケージの変更。

zypper dup --from packman --allow-vendor-change
 こんなん出ます。

Retrieving repository 'packman' metadata -----------------------------------------------------------------------[|]

New repository or package signing key received:

  Repository:       packman
  Key Fingerprint:  F887 5B88 0D51 8B6B 8C53 0D13 45A1 D067 1ABD 1AFB
  Key Name:         PackMan Project (signing key) <packman@links2linux.de>
  Key Algorithm:    RSA 4096
  Key Created:      Tue Sep 16 07:18:00 2014
  Key Expires:      Fri Sep 13 07:17:21 2024
  Rpm Name:         gpg-pubkey-1abd1afb-54176598



    Note: Signing data enables the recipient to verify that no modifications occurred after the data
    were signed. Accepting data with no, wrong or unknown signature can lead to a corrupted system
    and in extreme cases even to a system compromise.

    Note: A GPG pubkey is clearly identified by it's fingerprint. Do not rely the keys name. If you
    are not sure whether the presented key is authentic, ask the repository provider or check his
    web site. Many provider maintain a web page showing the fingerprints of the GPG keys they are
    using.

Do you want to reject the key, trust temporarily, or trust always? [r/t/a/?] (r):
 ここで、デフォルトが r 「reject」になってるので、最初失敗しました。  ここは、a 「trust always」です。

Retrieving repository 'packman' metadata ....................................................................[done]
Building repository 'packman' cache .........................................................................[done]
Loading repository data...
Reading installed packages...
Computing distribution upgrade...

The following 8 NEW packages are going to be installed:
  libopencore-amrnb0 libopencore-amrwb0 librtmp1 libvo-amrwbenc0 libx264-161 libx265-199 libxvidcore4 libzvbi0

The following 8 packages are going to be upgraded:
  libavcodec57 libavcodec58_134 libavformat57 libavformat58_76 libavutil55 libavutil56_70 libswresample2
  libswresample3_9

The following 8 packages are going to change vendor:
  libavcodec57      SUSE LLC <https://www.suse.com/> -> http://packman.links2linux.de
  libavcodec58_134  openSUSE -> http://packman.links2linux.de
  libavformat57     SUSE LLC <https://www.suse.com/> -> http://packman.links2linux.de
  libavformat58_76  openSUSE -> http://packman.links2linux.de
  libavutil55       SUSE LLC <https://www.suse.com/> -> http://packman.links2linux.de
  libavutil56_70    openSUSE -> http://packman.links2linux.de
  libswresample2    SUSE LLC <https://www.suse.com/> -> http://packman.links2linux.de
  libswresample3_9  openSUSE -> http://packman.links2linux.de

8 packages to upgrade, 8 new, 8  to change vendor.
Overall download size: 13.1 MiB. Already cached: 0 B. After the operation, additional 31.5 MiB will be used.
Continue? [y/n/v/...? shows all options] (y):
 ここは、y だな。  後の表示は、省略しますが、うまくいったようです。
earthcar(アースカー)