Debian Codegraph @

debian/bladerf-fpga-hostedxa9.postinst

raw
1 #!/bin/sh
2 set -e
3
4 UPSTREAM='https://www.nuand.com/fpga/v0.16.0/hostedxA9.rbf'
5 CHECKSUM='1ab3bc8bdcf16a5f0ddf3fcdbaa6556b'
6 SHA256SUM='3004467110e2b2790c8f6128f998c2149905a88eed91a87f11af3db524d60c65'
7 DATAFILE='/usr/share/Nuand/bladeRF/hostedxA9.rbf'
8 DESCRIPT='FPGA bitstream'
9 MYNAMEIS='bladerf-fpga-hostedxa9'
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#