Skip to content

Commit

Permalink
Refactors script/setup_docker_prereqs (home-assistant#5506)
Browse files Browse the repository at this point in the history
* Refactors script/setup_docker_prereqs

Refactors script/setup_docker_prereqs to allow toggling of packages
to being installed

* Adds support for openalpr to Docker

* Updates Dockerfile

Comments ENV directives in order to preserve cache.

* Fixes incorrect position of echo

* Fixes telldus installer by updating apt before pkg install
  • Loading branch information
mathewpeterson authored and michaelarnauts committed Jan 31, 2017
1 parent bbda2a7 commit d65f078
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 19 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
FROM python:3.5
MAINTAINER Paulus Schoutsen <[email protected]>

# Uncomment any of the following lines to disable the installation.
#ENV INSTALL_TELLSTICK no
#ENV INSTALL_OPENALPR no
#ENV INSTALL_FFMPEG no
#ENV INSTALL_PHANTOMJS no

VOLUME /config

RUN mkdir -p /usr/src/app
Expand Down
96 changes: 77 additions & 19 deletions script/setup_docker_prereqs
Original file line number Diff line number Diff line change
@@ -1,59 +1,117 @@
#!/bin/bash
# Install requirements and build dependencies for Home Assinstant in Docker.

INSTALL_TELLSTICK="${INSTALL_TELLSTICK:-yes}"
INSTALL_OPENALPR="${INSTALL_OPENALPR:-yes}"
INSTALL_FFMPEG="${INSTALL_FFMPEG:-yes}"
INSTALL_PHANTOMJS="${INSTALL_PHANTOMJS:-yes}"

# Required debian packages for running hass or components
PACKAGES=(
# build-essential is required for python pillow module on non-x86_64 arch
build-essential
# libxrandr-dev is required for openalpr
libxrandr-dev
# homeassistant.components.device_tracker.nmap_tracker
nmap net-tools
nmap net-tools libcurl3-dev
# homeassistant.components.device_tracker.bluetooth_tracker
bluetooth libglib2.0-dev libbluetooth-dev
# homeassistant.components.tellstick
libtelldus-core2
)

# Required debian packages for running hass or components from jessie-backports
PACKAGES_BACKPORTS=(
# homeassistant.components.ffmpeg
ffmpeg
)

# Required debian packages for building dependencies
PACKAGES_DEV=(
cmake git
# python-openzwave
cython3 libudev-dev
# libcec
cmake swig libxrandr-dev
swig
)

install_tellstick () {
TELLSTICK_PACKAGES=(
# homeassistant.components.tellstick
libtelldus-core2
)

# Add Tellstick repository
echo "deb http://download.telldus.com/debian/ stable main" >> /etc/apt/sources.list.d/telldus.list
wget -qO - http://download.telldus.se/debian/telldus-public.key | apt-key add -

apt-get update
apt-get install -y --no-install-recommends ${TELLSTICK_PACKAGES[@]}
}

install_openalpr () {
OPENALPR_PACKAGES=(
# homeassistant.components.image_processing.openalpr_local
libopencv-dev libtesseract-dev libleptonica-dev liblog4cplus-dev
)
apt-get install -y --no-install-recommends ${OPENALPR_PACKAGES[@]}
# Clone the latest code from GitHub
git clone https://github.com/openalpr/openalpr.git /usr/local/src/openalpr
# Setup the build directory
cd /usr/local/src/openalpr/src
mkdir -p build
cd build
# Setup the compile environment
cmake -DWITH_TEST=FALSE -DWITH_BINDING_JAVA=FALSE --DWITH_BINDING_PYTHON=FALSE --DWITH_BINDING_GO=FALSE -DWITH_DAEMON=FALSE -DCMAKE_INSTALL_PREFIX:PATH=/usr/local ..
# compile the library
make
# Install the binaries/libraries to your local system (prefix is /usr/local)
make install
}

install_ffmpeg () {
apt-get install -y --no-install-recommends -t jessie-backports ffmpeg
}

# Stop on errors
set -e

cd "$(dirname "$0")/.."

# Add Tellstick repository
echo "deb http://download.telldus.com/debian/ stable main" >> /etc/apt/sources.list.d/telldus.list
wget -qO - http://download.telldus.se/debian/telldus-public.key | apt-key add -

# Add jessie-backports
echo "Adding jessie-backports"
echo "deb http://deb.debian.org/debian jessie-backports main" >> /etc/apt/sources.list

# Install packages
echo "Updating Apt repositories"
apt-get update
echo "Installing packages"
apt-get install -y --no-install-recommends ${PACKAGES[@]} ${PACKAGES_DEV[@]}
apt-get install -y --no-install-recommends -t jessie-backports ${PACKAGES_BACKPORTS[@]}

if [ "$INSTALL_TELLSTICK" == "yes" ]; then
echo "Installing tellstick"
install_tellstick
fi

if [ "$INSTALL_OPENALPR" == "yes" ]; then
echo "Installing openalpr"
install_openalpr
fi

if [ "$INSTALL_FFPMEG" == "yes" ]; then
echo "Installing ffmpeg"
install_ffmpeg
fi

# Build and install openzwave
script/build_python_openzwave
echo "Installing python-openzwave"
/usr/src/app/script/build_python_openzwave
mkdir -p /usr/local/share/python-openzwave
cp -R /usr/src/app/build/python-openzwave/openzwave/config /usr/local/share/python-openzwave/config

# Build and install libcec
script/build_libcec
echo "Installing libcec"
/usr/src/app/script/build_libcec

# Install phantomjs
script/install_phantomjs
if [ "$INSTALL_PHANTOMJS" == "yes" ]; then
# Install phantomjs
script/install_phantomjs
fi

# Remove packages
echo "Removing dev packages"
apt-get remove -y --purge ${PACKAGES_DEV[@]}
apt-get -y --purge autoremove

Expand Down

0 comments on commit d65f078

Please sign in to comment.