有没有办法获取要下载的 snap 文件的 url,而不是使用命令snap download
?,这样就可以用 wget/aria2c 或其他程序来下载?
答案1
检索信息,
curl -H 'Snap-Device-Series: 16' http://api.snapcraft.io/v2/snaps/info/anbox # | jq
# "anbox" is the name of the snap package. change it to what you want.
它可能包含多个通道和架构条目。其中之一是,
"download": {
"deltas": [],
"sha3-384": "b105626b35dbba5eb990125adf557c5a38bf1a793256f35ca89f3d33d81caa608084606f2d39569475f8d880088f79d2",
"size": 391696384,
"url": "https://api.snapcraft.io/api/v1/snaps/download/Nr9K6UJaIOD8wHpDEQl16nabFFt9LLEQ_185.snap"
},
你得到了它。
请注意返回的响应可能包含多个下载部分,所以你应该选择你正在寻找的版本。顺便说一句,不用担心'Snap-Device-Series: 16'
,它与您的设备属性无关。所以,此时,所有人唯一可以接受的值就是 16。
另请参阅 snap store API 文档 (https://api.snapcraft.io/docs/info.html)。
答案2
扩展先前的答案......
如果这是一台您之前没有安装过 snap 的机器,那么您首先需要核心 snap。
对于您想要安装的任何 snap PACKAGE,您都需要 PACKAGE.assert 文件来进行更新,并避免使用 --dangerous 安装选项。
在您拥有 PACKAGE.snap 和 PACKAGE.assert 之后,您需要对ack
PACKAGE.assert 使用 snap 命令,然后对install
PACKAGE.snap 使用 snap 命令。
snap ack PACKAGE.assert
snap install PACKAGE.snap
您可以使用 Pedronis 的 snap、assert-fetcher 来获取 PACKAGE.assert 文件。如果您使用下面的代码片段示例下载此文件,则需要将 RELEASE 从稳定版更改为测试版。然后,您可以提取 .snap 以获取可执行文件assert-fetcher
。该可执行文件是为 Ubuntu 16 编译的,但我发现它也可以在 Debian 10 (buster) 中运行。如果此可执行文件在您的发行版中不起作用,则可以使用源代码在启动板上。它将位于 ~/assert-fetcher/bin 目录中。unsquashfs -d ~/assert-fetcher/ assert-fetcher.snap
使用语法如下~/assert-fetcher/bin/assert-fetcher PACKAGE.snap
。修改下面代码片段的第 3 行以指向 assert-fetcher 可执行文件。
下面我编写的脚本 snap-download.sh 会下载 PACKAGE.json、PACKAGE.snap 和 PACKAGE.assert。我编写这个方便的脚本是为了恢复由于网络连接不稳定而失败的下载。它将获取并解析 PACKAGE 的元数据以获取 URL。然后它会下载或恢复 PACKAGE.snap 的部分下载。成功下载 PACKAGE.snap 后,它将获取 PACKAGE.assert 文件。这将获取 64 位稳定版本的软件包和数据。如果您想要不同的内容,请更改前两行中的值。
在已安装 snapd 但从未安装过任何 snap 的机器上安装 sublime-text 的示例
snap-download.sh assert-fetcher # Download assert-fetcher.snap and assert-fetcher.json. Getting the assert file will fail.
unsquashfs -d ~/assert-fetcher/ assert-fetcher.snap # Extract the assert-snapper snap to use the executable
~/assert-fetcher assert-fetcher # Download the assert file for assert-fetcher
snap ack assert-fetcher.assert # Register the assert file
snap install assert-fetcher.snap # Install the snap
rm -rf ~/assert-fetcher/ assert-fetcher.assert assert-fetcher.snap assert-fetcher.json # Don't need these files anymore, it is installed as a snap now
snap-download core # Downloads core.snap, core.json, and core.assert
snap ack core.assert
snap install core.snap
rm core.assert core.snap core.json
snap-download sublime-text
snap ack sublime-text.assert
snap install sublime-text.snap
rm sublime-text.assert sublime-text.snap sublime-text.json
snap-下载.sh
#!/bin/bash
ARCH=amd64
RELEASE=stable
#export PATH="$PATH:/snap/bin/"
eval assert_fetcher_path="~/assert-fetcher/bin/assert-fetcher"
PACKAGE=$1
echo "Checking for jq..."
which jq
nojq=$?
if [ $nojq -gt 0 ]; then
echo "This snippet requires jq to function. Please install jq and try again"
exit 1
fi
if [ -z $PACKAGE ]; then
echo "Enter name of snap package to manually download:"
read PACKAGE
fi
meta_url="http://api.snapcraft.io/v2/snaps/info/${PACKAGE}"
echo "Fetching metadata from ${meta_url}..."
curl -H 'Snap-Device-Series: 16' -o ${PACKAGE}.json ${meta_url}
grep -v "error-list" ${PACKAGE}.json > /dev/null
curl_stat=$?
if [ $curl_stat -gt 0 ]; then
echo "Problem fetching ${PACKAGE} metadata."
echo "See file ${PACKAGE}.json for details."
exit
fi
url=$( cat ${PACKAGE}.json | jq '."channel-map"' | jq '.[]' | jq '[."channel"."architecture", ."channel"."name", ."download"."url"]' | grep -A2 ${ARCH} | grep -A1 ${RELEASE} | grep http | tr -d ' ' | tr -d '"' )
echo "Downloading '$url'..."
curl -L -o "${PACKAGE}.snap" -C - "$url"
curl2_stat=$?
ls -lh ${PACKAGE}.snap
if [ $curl2_stat -gt 0 ]; then
echo "Download failed. Re-run this snippet to attempt to resume download"
exit 1
fi
echo "Downloaded ${PACKAGE}.snap successfully. Attempting to fetch ${PACKAGE}.assert now."
echo "Checking for assert-fetcher..."
which ${assert_fetcher_path}
noassert_fetcher=$?
if [ $noassert_fetcher -gt 0 ]; then
echo "assert-fetcher executable not found at ${assert_fetcher_path}. Checking system path."
SNAP_PATH=$( which assert-fetcher )
noassert_fetcher2=$?
if [ $noassert_fetcher2 -gt 0 ]; then
echo "assert-fetcher not found in system path. You will need to run asset-fetcher manually or install your snap with --dangerous (not recomended)."
exit 1
fi
assert_fetcher_path="$SNAP_PATH"
fi
${assert_fetcher_path} ${PACKAGE}.snap
assert_fetcher_stat=$?
if [ $assert_fetcher_stat -gt 0 ]; then
echo "Failed to fetch ${PACKAGE}.assert."
exit 1
fi
ls -lh ${PACKAGE}.*
echo "Snap and Assert file for ${PACKAGE} downloaded successfully."
exit 0
答案3
我找到了这个网站https://uappexplorer.com/重新添加这个问题仅使用 snap 下载,正如它所说
uApp Explorer 是快照和 Ubuntu Touch 应用程序的非官方查看器。
您可能需要使用标志来安装它--dangerous
,snap install --dangerous <snap>
以下是一些相关链接: