Imported Debian patch 3.0-1
[debian/gnuradio] / debian / usrp.postinst
1 #! /bin/sh
2
3 set -e
4
5 if [ "$1" != "configure" ]; then
6         exit 0
7 fi
8
9 #
10 # The debhelper udev fragments are broken; they only check for -z "$2",
11 # not for upgrades from versions without the udev script.
12 #
13 if [ -z "$2" ] || dpkg --compare-versions "$2" lt "0.10-3"; then
14     ln -sf ../usrp.rules /etc/udev/rules.d/z60_usrp.rules
15 fi
16
17 # Create usrp group.
18 if ! getent group usrp >/dev/null; then
19     addgroup --system usrp
20 fi
21
22 #
23 # Activate any unactivated USRPs that are plugged in at install time.
24 # This is basically a duplication of the loop in /etc/hotplug/usb.rc,
25 # but Md claims it's the best solution for synthesizing hotplug events
26 # for the USRPs plugged in at installation time.
27 #
28
29 #
30 # Don't bother doing this unless we have all the firmware we need, and
31 # hotplugging working. (Rationale: If we don't have hotplug working,
32 # this will not work next boot/plugin anyhow, so it would be very confusing
33 # for the user to have it all work up _until_ the next boot/plugin.)
34 #
35 [ -r /usr/share/usrp/rev2/std_4rx_0tx.rbf ] || exit 0
36 [ -x /sbin/hotplug ] || [ -x /sbin/udevd ] || exit 0
37
38 # We need sysfs to do this.
39 [ -d /sys/bus/usb/devices/ ] || exit 0
40
41 # Go through all USB devices and find unconfigured USRPs (ie. FX2 chips).
42 for device in /sys/bus/usb/devices/[0-9]*:*; do
43     devlink=$(readlink -f $device)
44     DEVPATH=${devlink#/sys}
45
46     [ -f $devlink/../idVendor ] || continue
47     PRODUCT="$(cat $devlink/../idVendor)/$(cat $devlink/../idProduct)/$(cat $devlink/../bcdDevice)"
48
49     if [ "$PRODUCT" = "fffe/0002/0002" ] || [ "$PRODUCT" = "fffe/0002/0004" ]; then
50         /usr/bin/usrper load_standard_bits
51     fi
52 done
53
54 #DEBHELPER#
55
56 exit 0