How to get snap download url
Solution 1:
Retrieve the information with,
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.
which could contain multiple entries for channels and architectures. One among them would be,
"download": {
"deltas": [],
"sha3-384": "b105626b35dbba5eb990125adf557c5a38bf1a793256f35ca89f3d33d81caa608084606f2d39569475f8d880088f79d2",
"size": 391696384,
"url": "https://api.snapcraft.io/api/v1/snaps/download/Nr9K6UJaIOD8wHpDEQl16nabFFt9LLEQ_185.snap"
},
and you got it.
See also snap store api documentation (https://api.snapcraft.io/docs/info.html).
Solution 2:
Expanding on a prior answer...
If this is a machine that you have not installed snaps on before, you will first need the core snap.
For any snap PACKAGE that you want to install, you will need the PACKAGE.assert file to do updates and to avoid using the --dangerous install option.
After you have the PACKAGE.snap and PACKAGE.assert you'll need to use the snap command to ack
the PACKAGE.assert and then install
the PACKAGE.snap.
snap ack PACKAGE.assert
snap install PACKAGE.snap
You can use Pedronis's snap, assert-fetcher to fetch the PACKAGE.assert file. If you download this using snippet example as below, you will need to change the RELEASE from stable to beta. You can then extract the .snap to get the executable assert-fetcher
. The executable is compiled for Ubuntu 16, but I have found that it works in Debian 10 (buster) as well. If this executable doesn't work in your distro, the source is available on launchpad. It will be in the ~/assert-fetcher/bin directory. unsquashfs -d ~/assert-fetcher/ assert-fetcher.snap
Usage syntax is such as ~/assert-fetcher/bin/assert-fetcher PACKAGE.snap
. Modify the 3rd line of the snippet below to point to the assert-fetcher executable.
The script I wrote below, snap-download.sh, downloads PACKAGE.json, PACKAGE.snap, and PACKAGE.assert. I wrote this handy script in-order to resume failed downloads due to flaky network connection. It will fetch and parse the metadata for PACKAGE to get the url. Then it downloads or resumes a partial download for PACKAGE.snap. Once PACKAGE.snap is downloaded successfully, it will fetch the PACKAGE.assert file. This will get packages and data for 64bit stable releases. If you want something different, change the values in the first 2 lines.
An example of installing sublime-text on a machine that has snapd installed, but has never had any snaps installed
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-download.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
Solution 3:
I found this site https://uappexplorer.com/ readding this question Download only with snap, as it says
uApp Explorer is the unofficial viewer for snaps and Ubuntu Touch apps.
You'll probably have to install it with the --dangerous
flag, snap install --dangerous <snap>
Here are some related links:
- https://forum.snapcraft.io/t/install-snap-files-offline/302/5
- https://forum.snapcraft.io/t/offline-snap-installers-and-possibility-to-update/275/2