Forked from richbeales/patch_openhab_bluetooth.sh
Last active
February 13, 2016 18:28
-
-
Save lennysh/21dec7e73a37b3780a47 to your computer and use it in GitHub Desktop.
BASH Script to Patch OpenHAB Bluetooth Binding For Raspbian
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Patch OpenHAB Bluetooth Binding For Raspbian (by building the BlueCove GPL on the target machine) | |
# | |
# Description: Patches the bluetooth binding compiled for OpenHAB with the | |
# libraries needed to run on Raspbian. You should change the path to Java below | |
# in the JAVA_BIN environmental variable. | |
# | |
# PLACE THIS SCRIPT IN AN EMPTY DIRECTORY WITH THE OPENHAB BLUETOOTH BINDING! | |
# | |
# Filename: patch_pi_openhab_bluetooth.sh | |
# | |
# Usage: ./patch_pi_openhab_bluetooth.sh org.openhab.binding.bluetooth-[VERSION].jar | |
# Set-up environment variables | |
BINDING_JAR=$1 | |
BLUECOVE_VERSION_IN_BINDING=2.1.1 | |
BLUECOVE_VERSION=2.1.1-SNAPSHOT | |
BLUECOVE_REVISION=.63 | |
# Command line parameter check | |
if [ -z "$BINDING_JAR" ]; then | |
echo "usage $0 org.openhab.binding.bluetooth-[VERSION].jar" | |
exit 1; | |
fi | |
# Extract and remove the bindings jar file | |
jar -xvf $BINDING_JAR | |
rm -f $BINDING_JAR | |
# Install dependencies if needed... | |
apt-get install libbluetooth-dev subversion ant -y | |
# Download the BlueCove main JAR that's needed for the GPL compile process | |
mkdir bluecove | |
mkdir bluecove/target | |
wget http://snapshot.bluecove.org/distribution/download/${BLUECOVE_VERSION}/${BLUECOVE_VERSION}${BLUECOVE_REVISION}/bluecove-${BLUECOVE_VERSION}.jar -O bluecove/target/bluecove-${BLUECOVE_VERSION}.jar | |
# Download and Compile BlueCove GPL | |
svn checkout http://bluecove.googlecode.com/svn/trunk/bluecove-gpl bluecove-gpl | |
cd bluecove-gpl | |
echo "Building bluecove-gpl... Please wait..." | |
ant all -logger org.apache.tools.ant.DefaultLogger -verbose -logfile ../bluecove-gpl.log | |
echo "Done building bluecove-gpl... Please see bluecove-gpl.log for the output." | |
cd .. | |
# Download the BlueCove Bluez JAR (since building it fails) | |
mkdir bluecove-bluez | |
mkdir bluecove-bluez/target | |
wget http://snapshot.bluecove.org/distribution/download/${BLUECOVE_VERSION}/${BLUECOVE_VERSION}${BLUECOVE_REVISION}/bluecove-bluez-${BLUECOVE_VERSION}.jar -O bluecove-bluez/target/bluecove-bluez-${BLUECOVE_VERSION}.jar | |
# Clean-up any pre-existing JARS in lib folder | |
rm -f lib/*.jar | |
# Copy the newly compiled BlueCove JARs to LIB folder | |
cp bluecove/target/*.jar lib | |
cp bluecove-gpl/target/*.jar lib | |
cp bluecove-bluez/target/*.jar lib | |
# Modify the Manifest file to know about the added libraries | |
cd META-INF | |
sed -i "s|.,lib/bluecove-${BLUECOVE_VERSION_IN_BINDING}.jar|.,lib/bluecove-gpl-${BLUECOVE_VERSION}.jar,lib/bluecove-bluez-${BLUECOVE_VERSION}.jar,lib/bluecove-${BLUECOVE_VERSION}.jar|g" MANIFEST.MF | |
cd .. | |
# Bundle the binding back up into a JAR file and remove source files | |
jar -cmf0 META-INF/MANIFEST.MF $BINDING_JAR lib META-INF org OSGI-INF | |
rm -rf ./lib ./META-INF ./org ./OSGI-INF ./bluecove ./bluecove-gpl ./bluecove-bluez |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script allows the OpenHab bluetooth binding to work on the Raspberry Pi by building the BlueCove GPL JAR instead of using the online copy of the JAR.