compiler-errors - 如何在Travis CI容器中安装具有webp支持的较新imagemagick?

标签 compiler-errors imagemagick ubuntu-12.04 travis-ci webp

我想在travis中将png图像转换为webp替代文件,但是Travis CI使用了相当老的Ubuntu 12.04版本,因此 bundle 的imagemagick并不是最新的:

$ convert -version
Version: ImageMagick 6.6.9-7 2014-03-06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP

我知道我可以使用sudo: required在虚拟机中使用travis并在那里安装和构建东西。相反,我想将容器化的构建环境与sudo: false一起使用,因为它的速度要快得多。

如果我尝试编译libwepbimagemagick,则travis会给我权限被拒绝的错误,因为我没有对/usr/local/文件夹的权限:
$ make install
...
 /bin/mkdir -p '/usr/local/include/webp'
/bin/mkdir: cannot create directory `/usr/local/include/webp': Permission denied
...
The command "make install" failed and exited with 2 during .

最佳答案

Travis允许用户更改$PATH并将二进制文件安装到$HOME目录中。

这是 ruby 的完整示例。它只编译一次二进制文件并将其缓存。如果版本号不匹配,它将仅重新安装它们。

language: ruby
sudo: false
dist: precise

cache:
  directories:
  - "$HOME/opt"

addons:
  apt:
    packages:
      - libjpeg-dev
      - libpng-dev
      - libgif-dev
env:
  global:
  - IMAGEMAGICK_VERSION: '7.0.3-10'
  - LIBWEBP_VERSION: '0.5.1'

# Install newer libwebp and imagemagick
before_install:
  # Update PATH so that travis can find newer imagemagick
  - export PATH=$HOME/opt/bin:$PATH

  # Checks if Imagemagick is already sufficient version
  # If not installs it from the sources
  - convert -version | grep $IMAGEMAGICK_VERSION || {
    export CORES=$(nproc) &&
    echo "Using $CORES cores for compiling..." &&
    cd /tmp &&
    curl -O https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-$LIBWEBP_VERSION.tar.gz &&
    tar xvzf libwebp-$LIBWEBP_VERSION.tar.gz &&
    cd libwebp-* &&
    ./configure --prefix=$HOME/opt &&
    make -j$CORES &&
    make install -j$CORES &&
    cd /tmp &&
    curl -O https://www.imagemagick.org/download/ImageMagick-$IMAGEMAGICK_VERSION.tar.gz &&
    tar xvzf ImageMagick-$IMAGEMAGICK_VERSION.tar.gz &&
    cd ImageMagick-* &&
    ./configure --prefix=$HOME/opt &&
    make -j$CORES &&
    make install -j$CORES &&
    $HOME/opt/bin/magick -version | grep $IMAGEMAGICK_VERSION &&
    cd $TRAVIS_BUILD_DIR; }

  # Update library paths for programs
  - export LD_FLAGS=-L$HOME/opt/lib
  - export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:$HOME/opt/lib
  - export CPATH=$CPATH:$HOME/opt/include

积分:我看了一下这个ruby库是如何安装libwebp的,找出其余的内容很容易:https://github.com/le0pard/webp-ffi/blob/master/.travis.yml

关于compiler-errors - 如何在Travis CI容器中安装具有webp支持的较新imagemagick?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41138404/

相关文章:

java - JUnit错误我该如何解决?

compiler-errors - fatal error : apr_time.h: No such file or directory

c# - Magick.NET 减少 gif 文件大小

image - 将 SVG 图像分片

Linux:如何找出我的库的哪个(子)依赖项需要特定的库?

benchmarking - 在 httperf 中更改文件描述符大小

compiler-errors - Haxe错误 "Invalid build parameters"的原因是什么

c++ - 如何在 Visual Studio 中查看模板编译器错误详细信息

imagemagick - Python Magickwand pdf 到图像转换并调整图像大小

Python GET 在浏览器中不起作用