snap/snapcraft 使用指南

为每个 Linux 桌面、服务器、云端或设备打包任何应用程序,并且直接交付更新。

snapcraft 是一个正在为其在 Linux 中的地位而奋斗的包管理系统,它为你重新设想了分发软件的方式。这套新的跨发行版的工具可以用来帮助你构建和发布 snap 软件包。接下来我们将会讲述怎么使用 CircleCI 2.0 来加速这个过程以及一些在这个过程中的可能遇到的问题。

# 介绍

> Channels

Channels allow users to subscribe to different release cadences for an app, be it by major version bumps or in-development releases.

$ sudo snap install docker –channel=17.03/stable

# 常用使用说明

1
2
3
4
5
6
7
8
9
$ snap download hello-world

# Fetching snap "hello-world”
# Fetching assertions for "hello-world”

# $ sudo snap ack hello-world_27.assert
# $ sudo snap install hello-world_27.snap

hello-world 6.3 from 'canonical' installed
1
2
3
4
5
$ snap list

# Name Version Rev Developer Notes
# <snip>
# hello-world 6.3 27 canonical -

# 背后的原理

现在系统装软件,都是用这个装的了。

/snap 目录下。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
:/snap$ tree -L 1
.
├── bin
├── chromium
├── core
├── core18
├── gnome-3-26-1604
├── gnome-calculator
├── gnome-characters
├── gnome-logs
├── gnome-system-monitor
├── gtk-common-themes
├── node
├── postman
└── README

# 常用软件安装

Package any app for every Linux desktop, server, cloud or device, and deliver updates directly.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
find
abort Abort a pending change
ack Adds an assertion to the system
alias Sets up a manual alias
aliases Lists aliases in the system
buy Buys a snap
changes List system changes
connect Connects a plug to a slot
disable Disables a snap in the system
disconnect Disconnects a plug from a slot
download Downloads the given snap
enable Enables a snap in the system
find Finds packages to install
get Prints configuration options
help Help
info show detailed information about a snap
install Installs a snap to the system
interfaces Lists interfaces in the system
known Shows known assertions of the provided type
list List installed snaps
login Authenticates on snapd and the store
logout Log out of the store
prefer Prefer aliases from a snap and disable conflicts
refresh Refreshes a snap in the system
remove Removes a snap from the system
revert Reverts the given snap to the previous state
run Run the given snap command
set Changes configuration options
tasks List a change's tasks
try Tests a snap in the system
unalias Unalias a manual alias or an entire snap
version Shows version details
watch Watch a change in progress
  • Download snap “core” (3017) from channel “stable” (The download has been cancelled: context canceled)

core 16-2.28.1 canonical - snapd runtime environment

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$ sudo snap install --help
Usage:
snap [OPTIONS] install [install-OPTIONS] <snap>...

The install command installs the named snap in the system.

Application Options:
--version Print the version and exit

Help Options:
-h, --help Show this help message

[install command options]
--channel= Use this channel instead of stable
--edge Install from the edge channel
--beta Install from the beta channel
--candidate Install from the candidate channel
--stable Install from the stable channel
--devmode Put snap in development mode and disable security confinement
--jailmode Put snap in enforced confinement mode
--classic Put snap in classic mode and disable security confinement
--revision= Install the given revision of a snap, to which you must have developer access
--dangerous Install the given snap file even if there are no pre-acknowledged signatures for it, meaning it was not
verified and could be dangerous (--devmode implies this)
--unaliased Install the given snap without enabling its automatic aliases

一个问题,这玩意太慢了,有没有办法加个代理,换个 mirror
或者先离线下载,然后再手动安装呢????

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Usage:
snap [OPTIONS] <command>

Install, configure, refresh and remove snap packages. Snaps are
'universal' packages that work across many different Linux systems,
enabling secure distribution of the latest apps and utilities for
cloud, servers, desktops and the internet of things.

This is the CLI for snapd, a background service that takes care of
snaps on the system. Start with 'snap list' to see installed snaps.


Application Options:
--version Print the version and exit

Help Options:
-h, --help Show this help message

Available commands:
abort Abort a pending change
ack Adds an assertion to the system
alias Sets up a manual alias
aliases Lists aliases in the system
buy Buys a snap
changes List system changes
connect Connects a plug to a slot
disable Disables a snap in the system
disconnect Disconnects a plug from a slot
download Downloads the given snap
enable Enables a snap in the system
find Finds packages to install (aliases: search)
get Prints configuration options
help Help
info show detailed information about a snap
install Installs a snap to the system
interface Lists snap interfaces
interfaces Lists interfaces in the system
known Shows known assertions of the provided type
list List installed snaps
login Authenticates on snapd and the store
logout Log out of the store
logs Retrieve logs of services
prefer Prefer aliases from a snap and disable conflicts
refresh Refreshes a snap in the system
remove Removes a snap from the system
restart Restart services
revert Reverts the given snap to the previous state
run Run the given snap command
services Query the status of services
set Changes configuration options
start Start services
stop Stop services
switch Switches snap to a different channel
tasks List a change's tasks (aliases: change)
try Tests a snap in the system
unalias Unalias a manual alias or an entire snap
version Shows version details
watch Watch a change in progress
whoami Prints the email the user is logged in with.

# 实例

安装 Node 10 LTS

https://snapcraft.io/node

sudo snap install node –channel=10/stable —classic

竟然自带了 yarn

删除呢?