build_tools/install_firwmare: Try to extract the .bin file from .tar.gz
[dahdi/linux.git] / build_tools / install_firmware
1 #!/bin/sh
2 # This is a helper script intended to be called from
3 # drivers/dahdi/firmware/Makefile to install the different firmware version.
4
5 FIRMWARE_PATTERN=$1
6 FIRMWARE_VERSION=$2
7 DESTDIR=$3
8
9 if ! test -f ${DESTDIR}/usr/lib/hotplug/firmware/.${FIRMWARE_PATTERN}-${FIRMWARE_VERSION} || ! test -f ${DESTDIR}/lib/firmware/.${FIRMWARE_PATTERN}-${FIRMWARE_VERSION}; then
10         echo "Installing ${FIRMWARE_PATTERN}.bin to hotplug firmware directories"
11         tar --no-same-owner -xf ${FIRMWARE_PATTERN}-${FIRMWARE_VERSION}.tar.gz || exit 1
12         install -m 644 ${FIRMWARE_PATTERN}.bin ${DESTDIR}/usr/lib/hotplug/firmware || exit 1
13         rm -rf ${DESTDIR}/usr/lib/hotplug/firmware/.${FIRMWARE_PATTERN}-*
14         touch ${DESTDIR}/usr/lib/hotplug/firmware/.${FIRMWARE_PATTERN}-${FIRMWARE_VERSION}
15         install -m 644 ${FIRMWARE_PATTERN}.bin ${DESTDIR}/lib/firmware || exit 1
16         rm -rf ${DESTDIR}/lib/firmware/.${FIRMWARE_PATTERN}-*
17         touch ${DESTDIR}/lib/firmware/.${FIRMWARE_PATTERN}-${FIRMWARE_VERSION}
18         # Remove the .bin file so that if the version is reverted, it will not
19         # be installed with a non-matching ${FIRMARE_VERSION} file.
20         rm ${FIRMWARE_PATTERN}.bin
21 else
22         echo "Firmware ${FIRMWARE_PATTERN}.bin is already installed with required version ${FIRMWARE_VERSION}"
23 fi