Created
July 18, 2013 16:13
-
-
Save asimihsan/6030657 to your computer and use it in GitHub Desktop.
Puppet module class for installing OpenCV from source on Ubuntu.
This file contains hidden or 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
class opencv { | |
Exec { path => "/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin", } | |
$version = "2.4.6.1" | |
$libopencv_core_filename = "libopencv_core.so.2.4.6" | |
case $operatingsystem { | |
# Install OpenCV from source. This is an instructive example | |
# and may come in handy if we need to move to a version of | |
# OpenCV newer than is packaged in the OS. | |
ubuntu: { | |
$packages = ["libjpeg-dev", | |
"libtiff4-dev", | |
"libjasper-dev", | |
"libgtk2.0-dev", | |
"libavcodec-dev", | |
"libavformat-dev", | |
"libswscale-dev", | |
"libdc1394-22-dev", | |
"libv4l-dev", | |
"libxine-dev", | |
"libgstreamer0.10-dev", | |
"libgstreamer-plugins-base0.10-dev", | |
"libtbb-dev", | |
"python-numpy", | |
"libqt4-dev"] | |
package { $packages: ensure => latest } | |
exec{"download_opencv": | |
require => [Package[$packages], | |
Class["development"]], | |
command => "bash -c \"cd /home/stb-tester/Downloads; wget http://netcologne.dl.sourceforge.net/project/opencvlibrary/opencv-unix/${version}/opencv-${version}.tar.gz\"", | |
creates => "/home/stb-tester/Downloads/opencv-${version}.tar.gz", | |
} | |
exec {"extract_opencv": | |
require => Exec["download_opencv"], | |
command => "tar xvf opencv-${version}.tar.gz", | |
cwd => '/home/stb-tester/Downloads', | |
creates => "/home/stb-tester/Downloads/opencv-${version}", | |
} | |
file { "/home/stb-tester/Downloads/opencv-${version}/build": | |
require => Exec["extract_opencv"], | |
ensure => "directory", | |
} | |
exec {"build_opencv_make": | |
require => [File["/home/stb-tester/Downloads/opencv-${version}/build"], | |
Class["development"]], | |
command => 'cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..', | |
cwd => "/home/stb-tester/Downloads/opencv-${version}/build", | |
} | |
exec {"build_opencv": | |
require => Exec["build_opencv_make"], | |
command => 'bash -c "make; make install"', | |
cwd => "/home/stb-tester/Downloads/opencv-${version}/build", | |
timeout => 1800, | |
creates => "/usr/local/lib/${libopencv_core_filename}", | |
} | |
exec {"load_module": | |
require => Exec["build_opencv"], | |
command => "ldconfig", | |
} | |
} | |
/(centos|redhat|oel)/: { | |
package { "opencv": ensure => latest } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment