快速下载Snap软件

在云服务器上使用snap时, 遇到了这样的问题:

  1. snap install的下载速度太慢。
  2. snap没有镜像站。
  3. https://uappexplorer.com/snaps已经不能用了。
  4. 运行环境不能够 (不敢) 使用代理。

参考Ask Ubuntu上的How to get snap download url:

  1. 通过snapcraft.io页面找到需要的snap包的名称, 以Redis Desktop Manager为例, 其PackageNameredis-desktop-manager

  2. 使用一个HTTP Headers中带有Snap-Device-SeriesGET请求api.snapcaft.io获取相应snap包的下载链接, 比如:

    1
    
    curl -H 'Snap-Device-Series: 16' http://api.snapcraft.io/v2/snaps/info/redis-desktop-manager
    

    得到返回信息如下:

      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
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    
    {
        "channel-map": [{
            "channel": {
                "architecture": "amd64",
                "name": "stable",
                "released-at": "2022-04-11T08:42:55.242579+00:00",
                "risk": "stable",
                "track": "latest"
            },
            "created-at": "2022-04-07T06:42:10.696195+00:00",
            "download": {
                "deltas": [],
                "sha3-384": "bd46915580ab10393d290efd83d3bad25ce62afa8e60f72eb46b637c487ce56e027f82997d2c077a7f2f588175491cb4",
                "size": 274452480,
                "url": "https://api.snapcraft.io/api/v1/snaps/download/Iw3a6EauULwaud5DO0ixtrJg8o6VXaey_617.snap"
            },
            "revision": 617,
            "type": "app",
            "version": "2022.2+c787819a"
        }, {
            "channel": {
                "architecture": "arm64",
                "name": "stable",
                "released-at": "2019-05-08T16:06:17.202784+00:00",
                "risk": "stable",
                "track": "latest"
            },
            "created-at": "2018-11-02T13:22:00.292564+00:00",
            "download": {
                "deltas": [],
                "sha3-384": "da6611902f6e6e30f91c9f0e59148d5caf3c528b8f4ce0ca4927e9c46c9347bcb36472505568b0975e371eb6f7481ccb",
                "size": 405401600,
                "url": "https://api.snapcraft.io/api/v1/snaps/download/Iw3a6EauULwaud5DO0ixtrJg8o6VXaey_180.snap"
            },
            "revision": 180,
            "type": "app",
            "version": "0.9.8+git"
        }, {
            "channel": {
                "architecture": "armhf",
                "name": "stable",
                "released-at": "2019-05-08T16:06:18.459411+00:00",
                "risk": "stable",
                "track": "latest"
            },
            "created-at": "2018-11-23T11:25:27.569032+00:00",
            "download": {
                "deltas": [],
                "sha3-384": "db1b4288e4ef113427a529ed8c0c7eeb9a880c21d56d569e9345d5fd0d1562d4b24690692b68b1c3df8857f6c3b78fec",
                "size": 402309120,
                "url": "https://api.snapcraft.io/api/v1/snaps/download/Iw3a6EauULwaud5DO0ixtrJg8o6VXaey_187.snap"
            },
            "revision": 187,
            "type": "app",
            "version": "0.9.8+git"
        }, {
            "channel": {
                "architecture": "i386",
                "name": "stable",
                "released-at": "2019-05-08T16:06:17.796650+00:00",
                "risk": "stable",
                "track": "latest"
            },
            "created-at": "2018-11-23T11:24:37.772099+00:00",
            "download": {
                "deltas": [],
                "sha3-384": "07bc1be5689009fecb82fadc6f3359e9e4923817c5cfcca8e0fb27821b4366bcee9c54b1b91e70b2773d9c620cb2b8ea",
                "size": 413761536,
                "url": "https://api.snapcraft.io/api/v1/snaps/download/Iw3a6EauULwaud5DO0ixtrJg8o6VXaey_186.snap"
            },
            "revision": 186,
            "type": "app",
            "version": "0.9.8+git"
        }, {
            "channel": {
                "architecture": "amd64",
                "name": "edge",
                "released-at": "2022-05-31T07:31:31.925793+00:00",
                "risk": "edge",
                "track": "latest"
            },
            "created-at": "2022-05-31T07:29:29.187719+00:00",
            "download": {
                "deltas": [],
                "sha3-384": "95eb6cea54334d8337c5014c7d34a8793c50450c578946055a13bed1612eb3f8a6c7cded1918d7291c3b8b30e60e4d32",
                "size": 274501632,
                "url": "https://api.snapcraft.io/api/v1/snaps/download/Iw3a6EauULwaud5DO0ixtrJg8o6VXaey_625.snap"
            },
            "revision": 625,
            "type": "app",
            "version": "2022.3+8bd6667f"
        }, {
            "channel": {
                "architecture": "arm64",
                "name": "edge",
                "released-at": "2018-11-02T13:27:43.086596+00:00",
                "risk": "edge",
                "track": "latest"
            },
            "created-at": "2018-11-02T13:22:00.292564+00:00",
            "download": {
                "deltas": [],
                "sha3-384": "da6611902f6e6e30f91c9f0e59148d5caf3c528b8f4ce0ca4927e9c46c9347bcb36472505568b0975e371eb6f7481ccb",
                "size": 405401600,
                "url": "https://api.snapcraft.io/api/v1/snaps/download/Iw3a6EauULwaud5DO0ixtrJg8o6VXaey_180.snap"
            },
            "revision": 180,
            "type": "app",
            "version": "0.9.8+git"
        }, {
            "channel": {
                "architecture": "armhf",
                "name": "edge",
                "released-at": "2018-11-23T11:40:13.961025+00:00",
                "risk": "edge",
                "track": "latest"
            },
            "created-at": "2018-11-23T11:25:27.569032+00:00",
            "download": {
                "deltas": [],
                "sha3-384": "db1b4288e4ef113427a529ed8c0c7eeb9a880c21d56d569e9345d5fd0d1562d4b24690692b68b1c3df8857f6c3b78fec",
                "size": 402309120,
                "url": "https://api.snapcraft.io/api/v1/snaps/download/Iw3a6EauULwaud5DO0ixtrJg8o6VXaey_187.snap"
            },
            "revision": 187,
            "type": "app",
            "version": "0.9.8+git"
        }, {
            "channel": {
                "architecture": "i386",
                "name": "edge",
                "released-at": "2018-11-23T11:36:57.430143+00:00",
                "risk": "edge",
                "track": "latest"
            },
            "created-at": "2018-11-23T11:24:37.772099+00:00",
            "download": {
                "deltas": [],
                "sha3-384": "07bc1be5689009fecb82fadc6f3359e9e4923817c5cfcca8e0fb27821b4366bcee9c54b1b91e70b2773d9c620cb2b8ea",
                "size": 413761536,
                "url": "https://api.snapcraft.io/api/v1/snaps/download/Iw3a6EauULwaud5DO0ixtrJg8o6VXaey_186.snap"
            },
            "revision": 186,
            "type": "app",
            "version": "0.9.8+git"
        }],
        "default-track": null,
        "name": "redis-desktop-manager",
        "snap": {
            "license": "GPL-3.0",
            "name": "redis-desktop-manager",
            "prices": {},
            "publisher": {
                "display-name": "Igor Malinovskiy",
                "id": "EYGqoNaJFRPwVKQstqp8WYex02yg31Wj",
                "username": "uglide",
                "validation": "unproven"
            },
            "snap-id": "Iw3a6EauULwaud5DO0ixtrJg8o6VXaey",
            "store-url": "https://snapcraft.io/redis-desktop-manager",
            "summary": "RESP.app - GUI for Redis \u00ae (formerly RedisDesktopManager)",
            "title": "redis-desktop-manager"
        },
        "snap-id": "Iw3a6EauULwaud5DO0ixtrJg8o6VXaey"
    }
    
  3. 从返回信息中找到对应平台的下载链接, 使用命令下载:

    1
    
    wget https://api.snapcraft.io/api/v1/snaps/download/Iw3a6EauULwaud5DO0ixtrJg8o6VXaey_617.snap
    
  4. 下载完成后安装即可:

    1
    
    sudo snap install xxx.snap --dangerous