Debian Codegraph @

debian/bladerf-firmware-fx3.postinst

raw
1 #!/bin/sh
2 set -e
3
4 UPSTREAM='https://www.nuand.com/fx3/bladeRF_fw_v2.6.0.img'
5 CHECKSUM='7cc51b4eedebf54dd01be83745d1c59f'
6 SHA256SUM='a5f65bffd51107c09e36b45eda77593d900d975388bcfd83a9b6c3c45240b54a'
7 DATAFILE='/usr/share/Nuand/bladeRF/bladeRF_fw.img'
8 DESCRIPT='firmware'
9 MYNAMEIS='bladerf-firmware-fx3'
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 1
50 fi
51 fi
52
53 #DEBHELPER#