| 1 |
#!/bin/sh |
| 2 |
set -e |
| 3 |
|
| 4 |
UPSTREAM='https://www.nuand.com/fpga/v0.16.0/hostedxA5.rbf' |
| 5 |
CHECKSUM='be0909dc27b48a08c54db33675130f27' |
| 6 |
SHA256SUM='b85b413c0b305a04bd3fdb604ff6c77a1eac427f07d72251920a60b6a2f5b062' |
| 7 |
DATAFILE='/usr/share/Nuand/bladeRF/hostedxA5.rbf' |
| 8 |
DESCRIPT='FPGA bitstream' |
| 9 |
MYNAMEIS='bladerf-fpga-hostedxa5' |
| 10 |
|
| 11 |
checkfile () { |
| 12 |
[ -z "$1" ] && exit 3 |
| 13 |
md5sum --check <<- EOMD5SUM |
| 14 |
${CHECKSUM} $1 |
| 15 |
EOMD5SUM |
| 16 |
sha256sum --check <<- EOMD5SUM |
| 17 |
${SHA256SUM} $1 |
| 18 |
EOMD5SUM |
| 19 |
} |
| 20 |
|
| 21 |
# Fetch firmware if needed |
| 22 |
if [ ! -s ${DATAFILE} ] || ! checkfile ${DATAFILE}; then |
| 23 |
echo "Either your ${DESCRIPT} is missing, or it is out-of-date." |
| 24 |
echo "Downloading ${DESCRIPT} from ${UPSTREAM}..." |
| 25 |
|
| 26 |
# Try downloading it |
| 27 |
NEWFILE=$(mktemp) |
| 28 |
[ -z "${NEWFILE}" ] && (echo "Unable to create temporary file!"; exit 2) |
| 29 |
|
| 30 |
if wget -O ${NEWFILE} ${UPSTREAM} && checkfile ${NEWFILE}; then |
| 31 |
# We're good! Copy it to its new home. |
| 32 |
echo "Download successful, copying to ${DATAFILE}" |
| 33 |
mv ${NEWFILE} ${DATAFILE} |
| 34 |
chmod 0444 ${DATAFILE} |
| 35 |
else |
| 36 |
# It failed! Print an error and nuke the temporary file. |
| 37 |
rm -f ${NEWFILE} |
| 38 |
cat <<- EOMSG 1>&2 |
| 39 |
|
| 40 |
Warning: Failed to download ${DESCRIPT}. |
| 41 |
Please run "dpkg-reconfigure ${MYNAMEIS}" |
| 42 |
again when networking is up, or download the file manually: |
| 43 |
|
| 44 |
URL: ${UPSTREAM} |
| 45 |
File: ${DATAFILE} |
| 46 |
|
| 47 |
EOMSG |
| 48 |
|
| 49 |
# exit successfully, as otherwise the package is left |
| 50 |
# half-configured and the surrounding install/upgrade fails |
| 51 |
exit 0 |
| 52 |
fi |
| 53 |
fi |
| 54 |
|
| 55 |
#DEBHELPER# |