ヘルプ:パッケージ管理システム Snappy をインストール(AlmaLinux)

提供:すだちWiki

メインページ > Help:目次 > Help:自宅サーバー構築(AlmaLinux)  > パッケージ管理システム Snappy をインストール(AlmaLinux)

Snappy システムで管理される Snap パッケージは、[DNF/YUM/RPM] で管理されるシステムのパッケージに影響を及ぼすことなく、独立してインストール/起動することができます。

Snapd のインストール

  • Snap パッケージの利用には Snapd のインストールと起動が必要になります。
  • EPEL からインストール
[root@host4 ~]# dnf --enablerepo=epel -y install snapd

[root@host4 ~]# ln -s /var/lib/snapd/snap /snap

[root@host4 ~]# echo 'export PATH=$PATH:/var/lib/snapd/snap/bin' > /etc/profile.d/snap.sh

[root@host4 ~]# systemctl enable --now snapd.service snapd.socket

Created symlink /etc/systemd/system/multi-user.target.wants/snapd.service → /usr/lib/systemd/system/snapd.service.
Created symlink /etc/systemd/system/sockets.target.wants/snapd.socket → /usr/lib/systemd/system/snapd.socket.
  • 「/etc/profile.d/snapd.sh」で/snap/binのPATH設定などを行います。よってログインし直してください。

[Snap] コマンドの基本操作

インストール済 Snap パッケージ一覧

[root@host4 ~]# snap list
No snaps are installed yet. Try 'snap install hello-world'.

Snap リポジトリからパッケージをワード検索

[root@host4 ~]# snap find kubernetes
Name                         Version                Publisher              Notes    Summary
kubernetes-worker            0.0.2                  canonical✓             -        A complete Kubernetes worker
kubernetes-test              1.21.1                 canonical✓             classic  tests for kubernetes
kubernetes-test-eks          1.10.3                 canonical-cloud-snaps  classic  tests for kubernetes
.....
.....

[hello-world] パッケージをインストール

[root@host4 ~]# snap install hello-world
2020-07-31T19:23:13+09:00 INFO Waiting for automatic snapd restart...
hello-world 6.4 from Canonical installed

[root@host4 ~]# snap list
Name         Version    Rev   Tracking       Publisher   Notes
core         16-2.45.2  9665  latest/stable  canonical   core
hello-world  6.4        29    latest/stable  canonical   -

パッケージ情報を表示

[root@host4 ~]# snap info hello-world
name:      hello-world
summary:   The 'hello-world' of snaps
publisher: Canonical
store-url: https://snapcraft.io/hello-world
contact:   snappy-devel@lists.ubuntu.com
license:   unset
description: |
  This is a simple hello world example.
commands:
  - hello-world.env
  - hello-world.evil
  - hello-world
  - hello-world.sh
snap-id:      buPKUD3TKqCOgLEjjHx5kSiCpIs5cMuQ
tracking:     latest/stable
refresh-date: today at 16:23 JST
channels:
  latest/stable:    6.4 2019-04-17 (29) 20kB -
  latest/candidate: 6.4 2019-04-17 (29) 20kB -
  latest/beta:      6.4 2019-04-17 (29) 20kB -
  latest/edge:      6.4 2019-04-17 (29) 20kB -
installed:          6.4            (29) 20kB -

アプリケーション実行

[root@host4 ~]# hello-world
Hello World!

実 PATH は以下

[root@host4 ~]# which hello-world
/var/lib/snapd/snap/bin/hello-world

実体はリンク

[root@host4 ~]# ll /var/lib/snapd/snap/bin/hello-world
lrwxrwxrwx 1 root root 13  5月 19 09:50 /var/lib/snapd/snap/bin/hello-world -> /usr/bin/snap

アプリケーションを無効化する

[root@host4 ~]# snap disable hello-world
hello-world disabled

[root@host4 ~]# snap list
Name         Version  Rev    Tracking       Publisher   Notes
core         16-2.50  11081  latest/stable  canonical✓  core
hello-world  6.4      29     latest/stable  canonical✓  disabled 

[root@host4 ~]# hello-world
-bash: /var/lib/snapd/snap/bin/hello-world: No such file or directory

アプリケーションを有効化する

[root@host4 ~]# snap enable hello-world
hello-world enabled

[root@host4 ~]# hello-world
Hello World!

アンインストールする

  1. [snap remove] 実行にはシステムに [tar] コマンドが必要
  2. AlmaLinux Minimal Install には [tar] は含まれていない
[root@host4 ~]# snap remove hello-world
hello-world removed

[root@host4 ~]# snap list
Name  Version    Rev   Tracking       Publisher   Notes
core  16-2.45.2  9665  latest/stable  canonical   core