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