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