Created
October 15, 2015 08:40
-
-
Save folkevil/aaa0c383d1852b549e8f to your computer and use it in GitHub Desktop.
thumbor on CentOS6 with GraphicsMagick, opencv and python2.7
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
| #!/bin/bash | |
| WORK_DIR=/usr/src/louvre | |
| INSTALL_DIR=/opt/louvre | |
| export LD_LIBRARY_PATH=/opt/louvre/lib | |
| export PATH=/opt/louvre/bin:$PATH | |
| if [ ! -d ${INSTALL_DIR} ]; then | |
| mkdir ${INSTALL_DIR} | |
| fi | |
| if [ ! -d ${WORK_DIR} ]; then | |
| mkdir ${WORK_DIR} | |
| fi | |
| function install_rpm_packages() { | |
| yum install -y \ | |
| boost-devel \ | |
| cmake \ | |
| make \ | |
| autoconf \ | |
| automake \ | |
| libtool \ | |
| gcc \ | |
| gcc-c++ \ | |
| eigen3-devel \ | |
| tbb-devel \ | |
| perl-devel \ | |
| pngcrush \ | |
| libwmf-devel \ | |
| libtool-ltdl-devel \ | |
| lcms2-devel \ | |
| jasper-devel \ | |
| libtiff-devel \ | |
| libwebp-devel \ | |
| ghostscript-devel \ | |
| libjpeg-turbo-devel \ | |
| gd-devel \ | |
| bzip2-devel \ | |
| libpng-devel \ | |
| readline-devel \ | |
| wget \ | |
| pngquant \ | |
| libxml2-devel \ | |
| libxslt-devel \ | |
| git \ | |
| curl-devel \ | |
| unzip \ | |
| openssl-devel \ | |
| patch | |
| } | |
| function build_python27() { | |
| VERSION="2.7.10" | |
| cd ${WORK_DIR} | |
| if [ ! -e Python-${VERSION}.tgz ]; then | |
| wget https://www.python.org/ftp/python/${VERSION}/Python-${VERSION}.tgz | |
| fi | |
| if [ -d Python-${VERSION} ]; then | |
| rm -rf Python-${VERSION} | |
| fi | |
| tar xzf Python-${VERSION}.tgz | |
| cd Python-${VERSION} | |
| ./configure --prefix=${INSTALL_DIR} --enable-shared --disable-ipv6 --with-ensurepip=upgrade | |
| make -j2 | |
| make install | |
| pip install --upgrade pip | |
| pip install matplotlib | |
| pip install thumbor | |
| pip install git+https://github.com/thumbor/thumbor-plugins.git | |
| } | |
| function build_opencv() { | |
| VERSION="2.4.11" | |
| cd ${WORK_DIR} | |
| if [ ! -e ${VERSION}.zip ]; then | |
| wget https://github.com/Itseez/opencv/archive/${VERSION}.zip | |
| fi | |
| if [ -d opencv-${VERSION} ]; then | |
| rm -rf opencv-${VERSION} | |
| fi | |
| unzip ${VERSION}.zip | |
| cd opencv-${VERSION} | |
| mkdir build | |
| cd build | |
| PYTHON_LIBRARIES=${INSTALL_DIR}/lib PYTHON_INCLUDE_DIRS=${INSTALL_DIR}/include cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=${INSTALL_DIR} -D WITH_TBB=ON -D WITH_EIGEN=ON -D BUILD_opencv_gpu=OFF -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D WITH_GSTREAMER=OFF -D WITH_GTK=OFF -D WITH_V4L=OFF -D BUILD_SHARED_LIBS=ON -D WITH_OPENMP=ON .. | |
| make -j2 | |
| make install | |
| } | |
| function build_graphicsmagick() { | |
| VERSION="1.3.18" | |
| cd ${WORK_DIR} | |
| if [ ! -e GraphicsMagick-${VERSION}.tar.gz ]; then | |
| wget http://ftp.icm.edu.pl/pub/unix/graphics/GraphicsMagick/1.3/GraphicsMagick-${VERSION}.tar.gz | |
| fi | |
| if [ -d GraphicsMagick-${VERSION} ]; then | |
| rm -rf GraphicsMagick-${VERSION} | |
| fi | |
| tar xzf GraphicsMagick-${VERSION}.tar.gz | |
| cd GraphicsMagick-${VERSION} | |
| ./configure --without-dps --without-gslib --with-modules --with-perl --with-perl-options=INSTALLDIRS=vendor --enable-shared --disable-static --prefix=${INSTALL_DIR} | |
| make -j2 | |
| make install | |
| } | |
| function build_pgmagick() { | |
| VERSION="0.5.11" | |
| cd ${WORK_DIR} | |
| if [ ! -e pgmagick-${VERSION}.tar.gz ]; then | |
| wget https://pypi.python.org/packages/source/p/pgmagick/pgmagick-${VERSION}.tar.gz | |
| fi | |
| if [ ! -e pgmagick.patch ]; then | |
| wget https://gist.github.com/albix/590b242bd77c3013282c/raw/eec483fb560cf8d34c97e7b6aa9d081961a56b3a/pgmagick.patch | |
| fi | |
| if [ -d pgmagick-${VERSION} ]; then | |
| rm -rf pgmagick-${VERSION} | |
| fi | |
| tar xzf pgmagick-${VERSION}.tar.gz | |
| cd pgmagick-${VERSION} | |
| patch -p1 < ../pgmagick.patch | |
| pip install . | |
| pip install graphicsmagick-engine | |
| } | |
| function build_rpm() { | |
| ITERATION="2" | |
| yum install -y rpm-build ruby-devel rubygems | |
| gem install fpm | |
| find /opt/louvre -type f -name "*.pyc" -delete | |
| find /opt/louvre -type f -name "*.pyo" -delete | |
| fpm -s dir \ | |
| --rpm-use-file-permissions \ | |
| -n s24louvre \ | |
| -t rpm \ | |
| --description "Shopping24 Thumbor Installation" \ | |
| --verbose \ | |
| --version 1.0.0 \ | |
| --iteration ${ITERATION} \ | |
| --rpm-dist s24 \ | |
| --url https://developer.s24.com/ \ | |
| -d 'lcms2' \ | |
| -d 'freetype' \ | |
| -d 'libXext' \ | |
| -d 'libX11' \ | |
| -d 'bzip2-libs' \ | |
| -d 'zlib' \ | |
| -d 'libtool-ltdl' \ | |
| -d 'libgomp' \ | |
| -d 'libxcb' \ | |
| -d 'libXau' \ | |
| -d 'tbb' \ | |
| -d 'libstdc++' \ | |
| -d 'libgcc' \ | |
| -d 'libjpeg-turbo' \ | |
| -d 'libpng' \ | |
| -d 'libtiff' \ | |
| -d 'jasper-libs' \ | |
| -d 'libwebp' \ | |
| -d 'boost' /opt/louvre | |
| } | |
| install_rpm_packages | |
| build_python27 | |
| build_opencv | |
| build_graphicsmagick | |
| build_pgmagick | |
| build_rpm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment