IT ETC

Snapd - Linux 통합 패키지 관리 툴

진윤호 2021. 7. 30. 10:51
728x90


 

linuxOpen Source 로 구성된 OS 이기 때문에 그 기반으로 확장되어 개발사에 따라 Ubuntu, Fedora, Debian, Cent 등 다양하게 파편화 되었다.

그 상황에서 패키지 관리 툴은 apt, yum 등으로 해당 OS에 맞는 버전의 패키지만 관리할 수 있도록 함께 파편화 되었다.

따라서 linux 관리자는 다양한 패키지 관리 툴을 익혀야 하는 불편한 상황이 연출되었다.

이에 따라 Ubuntu 에서는 일원화된 패키지 관리 툴을 발표하는데 그것이 Snapd 이다.

 

-       https://snapcraft.io/docs/getting-started

 

Getting started | Snapcraft documentation

Snaps are containerised software packages that are simple to create and install. They auto-update and are safe to run. And because they bundle their dependencies, they work on all major Linux systems without modification.

snapcraft.io

snap version

snap    2.48.3+20.04

snapd   unavailable

series  -

 

위와 같이 snapd unabailable로 되어 있다면 snapd를 설치해야 한다.

-       https://snapcraft.io/docs/installing-snapd

 

Installing snapd | Snapcraft documentation

Snaps are containerised software packages that are simple to create and install. They auto-update and are safe to run. And because they bundle their dependencies, they work on all major Linux systems without modification.

snapcraft.io

 

아래 설치 예제는 Ubuntu 20.04 LTS(WSL) 를 기준으로 한다.

sudo apt update

sudo apt install snapd

 

위의 명령어를 설치 후 다음과 같이 확인한다.

sudo snap install hello-world

 

하지만 가이드와 다르게 WSL 환경에서는 다음과 같은 오류가 발생되는 것을 확인할 수 있다.

error: cannot communicate with server: Post http://localhost/v2/snaps/hello-world: dial unix /run/snapd.socket: connect: no such file or directory

 

이에 따른 이슈는 이미 WSL git을 통해 공론화 되었고 다음과 같은 해결책을 가이드되어 있다.

-       https://github.com/microsoft/WSL/issues/5126

 

WSL2- Ubuntu 20.04 Snap store doesn't work due to systemd dependency · Issue #5126 · microsoft/WSL

I just reinstalled ubuntu on WSL2 from scratch in order to upgrade to 20.04 with a clean slate. The main issue I've noticed has to do with a lot of packages moving to snap rather than being mai...

github.com

 

sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig

sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target

exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME

 

이후 다시 확인 하면 다음과 같이 진행된다.

sudo snap install hello-world

Download snap "core" (11420) from channel "stable"

hello-world 6.4 from Canonical installed

 

snap version

snap    2.49.2+20.04

snapd   2.49.2+20.04

series  16

ubuntu  20.04

kernel  5.10.16.3-microsoft-standard-WSL2

 

snapdcommand는 다음과 같이 확인할 수 있다.

snap help --all

 

아래는 snapd의 간단한 사용법을 소개 하고자 한다.

 

n  패키지 검색

snap find "media player"

다른 패키지 패키지 관리 툴과 마찬가지로 검색어로 설치 가능한 패키지를 조회할 수 있다.

 

n  패키지 상세 정보 조회

snap info mysql-workbench-community

 

name:      mysql-workbench-community

summary:   MySQL Workbench

publisher: Tonin Bolzan (tonybolzan)

store-url: https://snapcraft.io/mysql-workbench-community

license:   GPL-2.0

description: |

  MySQL Workbench is development, administration and data modeling tool for MySQL. Besides editing

  and running SQL queries and scripts, it supports the design of MySQL databases through a EER

  diagram, which is then used to generate SQL scripts. Workbench also supports migration from many

  RDBMS products to MySQL.

 

  If you use connections, Workbench use Password Manager and ssh to work properly.

  So it is necessary to give this permission explicitly.

  * snap connect mysql-workbench-community:password-manager-service

  * snap connect mysql-workbench-community:ssh-keys

 

  Or if you use files on external disks or need to print files, too.

  * snap connect mysql-workbench-community:cups-control

  * snap connect mysql-workbench-community:removable-media

snap-id: pUWVn08DAhza4Mmf86IrIfdXYrxEiI95

channels:

  latest/stable:    8.0.22 2020-11-13 (7) 116MB -

  latest/candidate: ↑

  latest/beta:      ↑

  latest/edge:      8.0.25 2021-06-20 (9) 130MB -

 

find로 검색된 패키지의 명을 정확하게 info 로 입력하면 license 등의 정보까지도 상세하게 조회할 수 있도록 지원해 준다.

 

n  설치

snap install vlc

snap install --channel=stable vlc

다음과 같이 다른 패키지 시스템과 같은 명령어로 설치가 가능한데 다른 패키진 tool과 다른데 channel 이라는 옵션을 통해 원하는 버전으로 설치가 가능하고 info로 지원하는 channel을 확인할 수 있다.

 

n  버전 변경

sudo snap switch --channel=edge vlc

해당 버전을 변경하고 싶다면 witch 명령어로 변경할 수 있다.

 

n  설치된 패키지 조회

snap list

Name         Version    Rev    Tracking       Publisher   Notes

core         16-2.51.3  11420  latest/stable  canonical  core

core18       20210128   1988   latest/stable  canonical  base

hello-world  6.4        29     latest/stable  canonical  -

lxd          4.0.5      19188  4.0/stable/…   canonical  -

snapd        2.48.2.1   11036  latest/stable  canonical  snapd

vlc          3.0.16     2344   latest/edge    videolan   -

 

n  삭제

snap remove vlc

 

vlc removed

 

728x90