|
|
|
#!/bin/sh
|
|
|
|
# Bare Metal Alchemist, 2022
|
|
|
|
|
|
|
|
#############################################
|
|
|
|
# Tin - ♃ #
|
|
|
|
#############################################
|
|
|
|
|
|
|
|
# Tin is frequently combined with lead to form solder, which is an
|
|
|
|
# important component of wiring up hardware.
|
|
|
|
|
|
|
|
# This ingredient is to be used when you're interacting with physical
|
|
|
|
# hardware like GPIO pins or USB drives
|
|
|
|
|
|
|
|
# Start with lead...
|
|
|
|
if [ -z "$LEAD" ]; then
|
|
|
|
. ingredients/lead
|
|
|
|
fi
|
|
|
|
|
|
|
|
sha256_check() {
|
|
|
|
# Args: <sha256_hash> <filename>
|
|
|
|
#
|
|
|
|
if check_for sha256sum; then
|
|
|
|
echo "${1} ${2}" | sha256sum -c
|
|
|
|
elif check_for sha256; then
|
|
|
|
if [ "$(uname)" = "FreeBSD" ]; then
|
|
|
|
sha256 -c "${1}" "${2}"
|
|
|
|
else
|
|
|
|
echo "${1} ${2}" | sha256 -c
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "${1} ${2}" | shasum -a 256 -c
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
http_get() {
|
|
|
|
# Args: <url> <filename> <sha256_hash>
|
|
|
|
#
|
|
|
|
# It's acceptable that we don't require SSL here because we manually verify
|
|
|
|
# content hashes below.
|
|
|
|
#
|
|
|
|
if [ -f "${2}" ]; then
|
|
|
|
echo "File ${2} already exists; not downloading again"
|
|
|
|
elif check_for curl; then
|
|
|
|
curl --insecure --retry 5 "${1}" -o "${2}"
|
|
|
|
else
|
|
|
|
wget --no-check-certificate "${1}" -O "${2}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
sha256_check "${3}" "${2}"
|
|
|
|
}
|
|
|
|
|
|
|
|
TIN=1
|