media-gfx/imagemagick: bump to v6.9.10-67 & 7.0.8-67
[gentoo.git] / media-gfx / imagemagick / imagemagick-6.9.10.67.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5
6 inherit eapi7-ver eutils flag-o-matic libtool perl-functions toolchain-funcs multilib
7
8 MY_PV="$(ver_rs 3 '-')"
9 MY_P="ImageMagick-${MY_PV}"
10
11 DESCRIPTION="A collection of tools and libraries for many image formats"
12 HOMEPAGE="https://www.imagemagick.org/"
13 SRC_URI="mirror://imagemagick/${MY_P}.tar.xz"
14
15 LICENSE="imagemagick"
16 SLOT="0/${PV}"
17 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~x64-solaris ~x86-solaris"
18 IUSE="bzip2 corefonts cxx djvu fftw fontconfig fpx graphviz hdri heif jbig jpeg jpeg2k lcms lqr lzma opencl openexr openmp pango perl png postscript q32 q8 raw static-libs svg test tiff truetype webp wmf X xml zlib"
19
20 RESTRICT="perl? ( userpriv )"
21
22 RDEPEND="
23         dev-libs/libltdl:0
24         bzip2? ( app-arch/bzip2 )
25         corefonts? ( media-fonts/corefonts )
26         djvu? ( app-text/djvu )
27         fftw? ( sci-libs/fftw:3.0 )
28         fontconfig? ( media-libs/fontconfig )
29         fpx? ( >=media-libs/libfpx-1.3.0-r1 )
30         graphviz? ( media-gfx/graphviz )
31         heif? ( media-libs/libheif:= )
32         jbig? ( >=media-libs/jbigkit-2:= )
33         jpeg? ( virtual/jpeg:0 )
34         jpeg2k? ( >=media-libs/openjpeg-2.1.0:2 )
35         lcms? ( media-libs/lcms:2= )
36         lqr? ( media-libs/liblqr )
37         opencl? ( virtual/opencl )
38         openexr? ( media-libs/openexr:0= )
39         pango? ( x11-libs/pango )
40         perl? ( >=dev-lang/perl-5.8.8:0= )
41         png? ( media-libs/libpng:0= )
42         postscript? ( app-text/ghostscript-gpl )
43         raw? ( media-libs/libraw:= )
44         svg? ( gnome-base/librsvg )
45         tiff? ( media-libs/tiff:0= )
46         truetype? (
47                 media-fonts/urw-fonts
48                 >=media-libs/freetype-2
49                 )
50         webp? ( media-libs/libwebp:0= )
51         wmf? ( media-libs/libwmf )
52         X? (
53                 x11-libs/libICE
54                 x11-libs/libSM
55                 x11-libs/libXext
56                 x11-libs/libXt
57                 )
58         xml? ( dev-libs/libxml2:= )
59         lzma? ( app-arch/xz-utils )
60         zlib? ( sys-libs/zlib:= )"
61 DEPEND="${RDEPEND}
62         !media-gfx/graphicsmagick[imagemagick]
63         virtual/pkgconfig
64         X? ( x11-base/xorg-proto )"
65
66 REQUIRED_USE="corefonts? ( truetype )
67         test? ( corefonts )"
68
69 S="${WORKDIR}/${MY_P}"
70
71 src_prepare() {
72         default
73
74         # Apply hardening #664236
75         cp "${FILESDIR}"/policy-hardening.snippet "${S}" || die
76         sed -i -e '/^<policymap>$/ {
77                         r policy-hardening.snippet
78                         d
79                 }' \
80                 config/policy.xml || \
81                 die "Failed to apply hardening of policy.xml"
82         einfo "policy.xml hardened"
83
84         elibtoolize # for Darwin modules
85
86         # For testsuite, see https://bugs.gentoo.org/show_bug.cgi?id=500580#c3
87         local mesa_cards ati_cards nvidia_cards render_cards
88         shopt -s nullglob
89         ati_cards=$(echo -n /dev/ati/card* | sed 's/ /:/g')
90         if test -n "${ati_cards}"; then
91                 addpredict "${ati_cards}"
92         fi
93         mesa_cards=$(echo -n /dev/dri/card* | sed 's/ /:/g')
94         if test -n "${mesa_cards}"; then
95                 addpredict "${mesa_cards}"
96         fi
97         nvidia_cards=$(echo -n /dev/nvidia** | sed 's/ /:/g')
98         if test -n "${nvidia_cards}"; then
99                 addpredict "${nvidia_cards}"
100         fi
101         render_cards=$(echo -n /dev/dri/renderD128* | sed 's/ /:/g')
102         if test -n "${render_cards}"; then
103                 addpredict "${render_cards}"
104         fi
105         shopt -u nullglob
106         addpredict /dev/nvidiactl
107 }
108
109 src_configure() {
110         local depth=16
111         use q8 && depth=8
112         use q32 && depth=32
113
114         local openmp=disable
115         use openmp && { tc-has-openmp && openmp=enable; }
116
117         use perl && perl_check_env
118
119         [[ ${CHOST} == *-solaris* ]] && append-ldflags -lnsl -lsocket
120
121         local myeconfargs=(
122                 $(use_enable static-libs static)
123                 $(use_enable hdri)
124                 $(use_enable opencl)
125                 --with-threads
126                 --with-modules
127                 --with-quantum-depth=${depth}
128                 $(use_with cxx magick-plus-plus)
129                 $(use_with perl)
130                 --with-perl-options='INSTALLDIRS=vendor'
131                 --with-gs-font-dir="${EPREFIX}"/usr/share/fonts/urw-fonts
132                 $(use_with bzip2 bzlib)
133                 $(use_with X x)
134                 $(use_with zlib)
135                 --without-autotrace
136                 $(use_with postscript dps)
137                 $(use_with djvu)
138                 --with-dejavu-font-dir="${EPREFIX}"/usr/share/fonts/dejavu
139                 $(use_with fftw)
140                 $(use_with fpx)
141                 $(use_with fontconfig)
142                 $(use_with truetype freetype)
143                 $(use_with postscript gslib)
144                 $(use_with graphviz gvc)
145                 $(use_with heif heic)
146                 $(use_with jbig)
147                 $(use_with jpeg)
148                 $(use_with jpeg2k openjp2)
149                 $(use_with lcms)
150                 $(use_with lqr)
151                 $(use_with lzma)
152                 $(use_with openexr)
153                 $(use_with pango)
154                 $(use_with png)
155                 $(use_with raw)
156                 $(use_with svg rsvg)
157                 $(use_with tiff)
158                 $(use_with webp)
159                 $(use_with corefonts windows-font-dir "${EPREFIX}"/usr/share/fonts/corefonts)
160                 $(use_with wmf)
161                 $(use_with xml)
162                 --${openmp}-openmp
163                 --with-gcc-arch=no-automagic
164         )
165         CONFIG_SHELL=$(type -P bash) econf "${myeconfargs[@]}"
166 }
167
168 src_test() {
169         # Install default (unrestricted) policy in $HOME for test suite #664238
170         local _im_local_config_home="${HOME}/.config/ImageMagick"
171         mkdir -p "${_im_local_config_home}" || \
172                 die "Failed to create IM config dir in '${_im_local_config_home}'"
173         cp "${FILESDIR}"/policy.test.xml "${_im_local_config_home}/policy.xml" || \
174                 die "Failed to install default blank policy.xml in '${_im_local_config_home}'"
175
176         local im_command= IM_COMMANDS=()
177         IM_COMMANDS+=( "identify -version | grep -q -- \"${MY_PV}\"" ) # Verify that we are using version we just built
178         IM_COMMANDS+=( "identify -list policy" ) # Verify that policy.xml is used
179         IM_COMMANDS+=( "emake check" ) # Run tests
180
181         for im_command in "${IM_COMMANDS[@]}"; do
182                 eval "${S}"/magick.sh \
183                         ${im_command} || \
184                         die "Failed to run \"${im_command}\""
185         done
186 }
187
188 src_install() {
189         # Ensure documentation installation files and paths with each release!
190         emake \
191                 DESTDIR="${D}" \
192                 DOCUMENTATION_PATH="${EPREFIX}"/usr/share/doc/${PF}/html \
193                 install
194
195         rm -f "${ED%/}"/usr/share/doc/${PF}/html/{ChangeLog,LICENSE,NEWS.txt}
196         dodoc {AUTHORS,README}.txt ChangeLog
197
198         if use perl; then
199                 find "${ED}" -type f -name perllocal.pod -exec rm -f {} +
200                 find "${ED}" -depth -mindepth 1 -type d -empty -exec rm -rf {} +
201         fi
202
203         find "${ED}" -name '*.la' -exec sed -i -e "/^dependency_libs/s:=.*:='':" {} +
204
205         if use opencl; then
206                 cat <<-EOF > "${T}"/99${PN}
207                 SANDBOX_PREDICT="/dev/nvidiactl:/dev/nvidia-uvm:/dev/ati/card:/dev/dri/card:/dev/dri/renderD128"
208                 EOF
209
210                 insinto /etc/sandbox.d
211                 doins "${T}"/99${PN} #472766
212         fi
213
214         insinto /usr/share/${PN}
215         doins config/*icm
216 }
217
218 pkg_postinst() {
219         local _show_policy_xml_notice=
220
221         if [[ -z "${REPLACING_VERSIONS}" ]]; then
222                 # This is a new installation
223                 _show_policy_xml_notice=yes
224         else
225                 local v
226                 for v in ${REPLACING_VERSIONS}; do
227                         if ! ver_test "${v}" -gt "6.9.10.10-r2"; then
228                                 # This is an upgrade
229                                 _show_policy_xml_notice=yes
230
231                                 # Show this elog only once
232                                 break
233                         fi
234                 done
235         fi
236
237         if [[ -n "${_show_policy_xml_notice}" ]]; then
238                 elog "For security reasons, a policy.xml file was installed in /etc/ImageMagick-6"
239                 elog "which will prevent the usage of the following coders by default:"
240                 elog ""
241                 elog "  - PS"
242                 elog "  - PS2"
243                 elog "  - PS3"
244                 elog "  - EPS"
245                 elog "  - PDF"
246                 elog "  - XPS"
247         fi
248 }