xref: /imagick/imagemagick_dependency.sh (revision 2d1de9db)
1#!/bin/sh
2
3#give an error if the download fails.
4set -e
5set -x
6
7imagemagick_fetch_and_build () {
8    local version=$1
9
10    im_dir=${HOME}/im/imagemagick-${version}
11
12    echo "version is ${version}, im_dir=${im_dir}"
13
14    case $version in
15        git7)
16            ;;
17        git6)
18            ;;
19        dev)
20            ;;
21        *)
22    # Both individual commits, and tagged versions are cacheable
23        if [ -d "${im_dir}" ]; then
24            echo "Using cached directory ${im_dir}"
25            return
26        else
27            echo "No cache available. Need to download and compile IM."
28        fi
29        ;;
30    esac
31
32
33    case $version in
34
35    git7)
36        wget -O ImageMagick-7.tar.gz https://github.com/ImageMagick/ImageMagick/archive/main.tar.gz
37        tar xvfz ImageMagick-7.tar.gz
38        cd ImageMagick-main
39        ;;
40    git6)
41        wget -O ImageMagick-6.tar.gz https://github.com/ImageMagick/ImageMagick6/archive/main.tar.gz
42        tar xvfz ImageMagick-6.tar.gz
43        cd ImageMagick6-main
44        ;;
45    dev)
46        svn co https://www.imagemagick.org/subversion/ImageMagick/branches/ImageMagick-6/ imagemagick-dev
47        cd imagemagick-dev
48        ;;
49    *)
50        set +e
51        #this can error
52        start_str=${version:0:6}
53        set -e
54
55        if [ "${start_str}" == "commit" ]; then
56
57            sha=${version:7:47}
58            wget -O "ImageMagick-${sha}.tar.gz" "https://github.com/ImageMagick/ImageMagick/archive/${sha}.tar.gz"
59            tar xvfz ImageMagick-${sha}.tar.gz
60
61            cd "ImageMagick-${sha}"
62        else
63            set +e
64            #this can error
65            major_version=${version:0:1}
66            set -e
67
68            echo "Major version is ${major_version}"
69
70            if [ $major_version == "7" ]; then
71                echo "Fetching from IM7 repo"
72                wget "https://github.com/ImageMagick/ImageMagick/archive/${version}.tar.gz" -O ImageMagick-${version}.tar.gz
73            else
74                echo "Fetching from IM6 repo"
75                wget "https://launchpad.net/imagemagick/main/${version}/+download/ImageMagick-${version}.tar.gz"
76                # Not all of the old releases are available through github, as some releases pre-date
77                # ImageMagick being available on Github.
78                # wget "https://github.com/ImageMagick/ImageMagick6/archive/${version}.tar.gz" -O ImageMagick-${version}.tar.gz
79            fi
80
81            tar xfz ImageMagick-${version}.tar.gz
82            # verbose version for debugging
83            # tar xvfz ImageMagick-${version}.tar.gz
84            ls -l
85            cd "ImageMagick-${version}"
86        fi
87        ;;
88    esac
89
90#ignore compile warnings/errors
91set +e
92
93
94./configure \
95  --prefix="${HOME}/im/imagemagick-${version}" \
96  --without-magick-plus-plus \
97  --without-perl \
98  --disable-openmp \
99  --disable-docs \
100  --with-gvc=no \
101  --with-urw-base35-font-dir=/usr/share/fonts/type1/urw-base35/
102    make -j 8
103    make install
104    cd ..
105
106}
107
108imagemagick_fetch_and_build $1