/[gentoo-x86]/eclass/intel-sdp.eclass
Gentoo

Contents of /eclass/intel-sdp.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.18 - (show annotations) (download)
Mon Sep 15 17:54:11 2014 UTC (3 days ago) by jlec
Branch: MAIN
CVS Tags: HEAD
Changes since 1.17: +15 -5 lines
Allow RPMS specified as array

1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/intel-sdp.eclass,v 1.17 2014/02/21 16:07:25 jlec Exp $
4
5 # @ECLASS: intel-sdp.eclass
6 # @MAINTAINER:
7 # Justin Lecher <jlec@gentoo.org>
8 # Sci Team <sci@gentoo.org>
9 # @BLURB: Handling of Intel's Software Development Products package management
10
11 # @ECLASS-VARIABLE: INTEL_DID
12 # @DEFAULT_UNSET
13 # @DESCRIPTION:
14 # The package download ID from Intel.
15 # To find out its value, see the links to download in
16 # https://registrationcenter.intel.com/RegCenter/MyProducts.aspx
17 #
18 # e.g. 2504
19 #
20 # Must be defined before inheriting the eclass
21
22 # @ECLASS-VARIABLE: INTEL_DPN
23 # @DEFAULT_UNSET
24 # @DESCRIPTION:
25 # The package name to download from Intel.
26 # To find out its value, see the links to download in
27 # https://registrationcenter.intel.com/RegCenter/MyProducts.aspx
28 #
29 # e.g. parallel_studio_xe
30 #
31 # Must be defined before inheriting the eclass
32
33 # @ECLASS-VARIABLE: INTEL_DPV
34 # @DEFAULT_UNSET
35 # @DESCRIPTION:
36 # The package download version from Intel.
37 # To find out its value, see the links to download in
38 # https://registrationcenter.intel.com/RegCenter/MyProducts.aspx
39 #
40 # e.g. 2011_sp1_update2
41 #
42 # Must be defined before inheriting the eclass
43
44 # @ECLASS-VARIABLE: INTEL_TARX
45 # @DEFAULT_UNSET
46 # @DESCRIPTION:
47 # The package extention.
48 # To find out its value, see the links to download in
49 # https://registrationcenter.intel.com/RegCenter/MyProducts.aspx
50 #
51 # e.g. tar.gz
52 #
53 # Must be defined before inheriting the eclass
54 : ${INTEL_TARX:=tgz}
55
56 # @ECLASS-VARIABLE: INTEL_SUBDIR
57 # @DEFAULT_UNSET
58 # @DESCRIPTION:
59 # The package sub-directory where it will end-up in /opt/intel
60 # To find out its value, you have to do a raw install from the Intel tar ball
61
62 # @ECLASS-VARIABLE: INTEL_SKIP_LICENSE
63 # @DEFAULT_UNSET
64 # @DESCRIPTION:
65 # Possibility to skip the mandatory check for licenses. Only set this if there
66 # is really no fix.
67
68 # @ECLASS-VARIABLE: INTEL_RPMS_DIR
69 # @DESCRIPTION:
70 # Main subdirectory which contains the rpms to extract.
71 : ${INTEL_RPMS_DIR:=rpm}
72
73 # @ECLASS-VARIABLE: INTEL_X86
74 # @DESCRIPTION:
75 # 32bit arch in rpm names
76 #
77 # e.g. i484
78 : ${INTEL_X86:=i486}
79
80 # @ECLASS-VARIABLE: INTEL_BIN_RPMS
81 # @DEFAULT_UNSET
82 # @DESCRIPTION:
83 # Functional name of rpm without any version/arch tag
84 #
85 # e.g. compilerprof
86 #
87 # if the rpm is located in a directory different to INTEL_RPMS_DIR you can
88 # specify the full path
89 #
90 # e.g. CLI_install/rpm/intel-vtune-amplifier-xe-cli
91
92 # @ECLASS-VARIABLE: INTEL_DAT_RPMS
93 # @DEFAULT_UNSET
94 # @DESCRIPTION:
95 # Functional name of rpm of common data which are arch free
96 # without any version tag
97 #
98 # e.g. openmp
99 #
100 # if the rpm is located in a directory different to INTEL_RPMS_DIR you can
101 # specify the full path
102 #
103 # e.g. CLI_install/rpm/intel-vtune-amplifier-xe-cli-common
104
105 # @ECLASS-VARIABLE: INTEL_SINGLE_ARCH
106 # @DESCRIPTION:
107 # Unset, if only the multilib package will be provided by intel
108 : ${INTEL_SINGLE_ARCH:=true}
109
110 # @ECLASS-VARIABLE: INTEL_SDP_DB
111 # @DESCRIPTION:
112 # Full path to intel registry db
113 INTEL_SDP_DB="${EROOT%/}"/opt/intel/intel-sdp-products.db
114
115 inherit check-reqs multilib versionator
116
117 _INTEL_PV1=$(get_version_component_range 1)
118 _INTEL_PV2=$(get_version_component_range 2)
119 _INTEL_PV3=$(get_version_component_range 3)
120 _INTEL_PV4=$(get_version_component_range 4)
121 _INTEL_URI="http://registrationcenter-download.intel.com/irc_nas/${INTEL_DID}/${INTEL_DPN}"
122
123 if [ ${INTEL_SINGLE_ARCH} == true ]; then
124 SRC_URI="
125 amd64? ( multilib? ( ${_INTEL_URI}_${INTEL_DPV}.${INTEL_TARX} ) )
126 amd64? ( !multilib? ( ${_INTEL_URI}_${INTEL_DPV}_intel64.${INTEL_TARX} ) )
127 x86? ( ${_INTEL_URI}_${INTEL_DPV}_ia32.${INTEL_TARX} )"
128 else
129 SRC_URI="${_INTEL_URI}_${INTEL_DPV}.${INTEL_TARX}"
130 fi
131
132 LICENSE="Intel-SDP"
133 # Future work, #394411
134 #SLOT="${_INTEL_PV1}.${_INTEL_PV2}"
135 SLOT="0"
136 IUSE="examples multilib"
137
138 RESTRICT="mirror"
139
140 RDEPEND=""
141 DEPEND="app-arch/rpm2targz"
142
143 _INTEL_SDP_YEAR=${INTEL_DPV%_update*}
144 _INTEL_SDP_YEAR=${INTEL_DPV%_sp*}
145
146 # @ECLASS-VARIABLE: INTEL_SDP_DIR
147 # @DEFAULT_UNSET
148 # @DESCRIPTION:
149 # Full rootless path to installation dir
150 INTEL_SDP_DIR="opt/intel/${INTEL_SUBDIR}-${_INTEL_SDP_YEAR:-${_INTEL_PV1}}.${_INTEL_PV3}.${_INTEL_PV4}"
151
152 # @ECLASS-VARIABLE: INTEL_SDP_EDIR
153 # @DEFAULT_UNSET
154 # @DESCRIPTION:
155 # Full rooted path to installation dir
156 INTEL_SDP_EDIR="${EROOT%/}/${INTEL_SDP_DIR}"
157
158 S="${WORKDIR}"
159
160 QA_PREBUILT="${INTEL_SDP_DIR}/*"
161
162 # @ECLASS-VARIABLE: INTEL_ARCH
163 # @DEFAULT_UNSET
164 # @DESCRIPTION:
165 # Intels internal names of the arches; will be set at runtime accordingly
166 #
167 # e.g. amd64-multilib -> INTEL_ARCH="intel64 ia32"
168
169 # @FUNCTION: _isdp_link_eclipse_plugins
170 # @INTERNAL
171 # @DESCRIPTION:
172 # Creating necessary links to use intel compiler with eclipse
173 _isdp_link_eclipse_plugins() {
174 local c f
175 pushd ${INTEL_SDP_DIR}/eclipse_support > /dev/null
176 for c in cdt*; do
177 local cv=${c#cdt} ev=3.$(( ${cv:0:1} - 1))
178 if has_version "dev-util/eclipse-sdk:${ev}"; then
179 einfo "Linking eclipse (v${ev}) plugin cdt (v${cv})"
180 for f in cdt${cv}/eclipse/features/*; do
181 dodir /usr/$(get_libdir)/eclipse-${ev}/features
182 dosym "${INTEL_SDP_EDIR}"/eclipse_support/${f} \
183 /usr/$(get_libdir)/eclipse-${ev}/features/ || die
184 done
185 for f in cdt${cv}/eclipse/plugins/*; do
186 dodir /usr/$(get_libdir)/eclipse-${ev}/plugins
187 dosym "${INTEL_SDP_EDIR}"/eclipse_support/${f} \
188 /usr/$(get_libdir)/eclipse-${ev}/plugins/ || die
189 done
190 fi
191 done
192 popd > /dev/null
193 }
194
195 # @FUNCTION: _isdp_big-warning
196 # @USAGE: [pre-check | test-failed]
197 # @INTERNAL
198 # @DESCRIPTION:
199 # warn user that we really require a license
200 _isdp_big-warning() {
201 case ${1} in
202 pre-check )
203 echo ""
204 ewarn "License file not found!"
205 ;;
206
207 test-failed )
208 echo
209 ewarn "Function test failed. Most probably due to an invalid license."
210 ewarn "This means you already tried to bypass the license check once."
211 ;;
212 esac
213
214 echo ""
215 ewarn "Make sure you have recieved the an Intel license."
216 ewarn "To receive a non-commercial license, you need to register at:"
217 ewarn "http://software.intel.com/en-us/articles/non-commercial-software-development/"
218 ewarn "Install the license file into ${INTEL_SDP_EDIR}/licenses/"
219
220 case ${1} in
221 pre-check )
222 ewarn "before proceeding with installation of ${P}"
223 echo ""
224 ;;
225 * )
226 echo ""
227 ;;
228 esac
229 }
230
231 # @FUNCTION: _isdp_version_test
232 # @INTERNAL
233 # @DESCRIPTION:
234 # Testing for valid license by asking for version information of the compiler
235 _isdp_version_test() {
236 local comp comp_full arch warn
237 case ${PN} in
238 ifc )
239 debug-print "Testing ifort"
240 comp=ifort
241 ;;
242 icc )
243 debug-print "Testing icc"
244 comp=icc
245 ;;
246 *)
247 die "${PN} is not supported for testing"
248 ;;
249 esac
250
251 for arch in ${INTEL_ARCH}; do
252 case ${EBUILD_PHASE} in
253 install )
254 comp_full="${ED}/${INTEL_SDP_DIR}/bin/${arch}/${comp}"
255 ;;
256 postinst )
257 comp_full="${INTEL_SDP_EDIR}/bin/${arch}/${comp}"
258 ;;
259 * )
260 ewarn "Compile test not supported in ${EBUILD_PHASE}"
261 continue
262 ;;
263 esac
264
265 debug-print "LD_LIBRARY_PATH=\"${INTEL_SDP_EDIR}/bin/${arch}/\" \"${comp_full}\" -V"
266
267 LD_LIBRARY_PATH="${INTEL_SDP_EDIR}/bin/${arch}/" "${comp_full}" -V &>/dev/null
268 [[ $? -ne 0 ]] && warn=yes
269 done
270 [[ "${warn}" == "yes" ]] && _isdp_big-warning test-failed
271 }
272
273 # @FUNCTION: _isdp_run-test
274 # @INTERNAL
275 # Test if installed compiler is working
276 _isdp_run-test() {
277 if [[ -z ${INTEL_SKIP_LICENSE} ]]; then
278 case ${PN} in
279 ifc | icc )
280 _isdp_version_test ;;
281 * )
282 debug-print "No test available for ${PN}"
283 ;;
284 esac
285 fi
286 }
287
288 # @FUNCTION: intel-sdp_pkg_pretend
289 # @DESCRIPTION:
290 # @CODE
291 # * Check that the user has a (valid) license file before going on.
292 # * Check for space requirements being fullfilled
293 # @CODE
294 intel-sdp_pkg_pretend() {
295 local warn=1 dir dirs ret arch a p
296
297 : ${CHECKREQS_DISK_BUILD:=256M}
298 check-reqs_pkg_pretend
299
300 if [[ -z ${INTEL_SKIP_LICENSE} ]]; then
301 if echo ${INTEL_LICENSE_FILE} | grep -q @; then
302 einfo "Looks like you are using following license server:"
303 einfo " ${INTEL_LICENSE_FILE}"
304 return 0
305 fi
306
307 dirs=(
308 "${INTEL_SDP_EDIR}/licenses"
309 "${INTEL_SDP_EDIR}/Licenses"
310 "${EPREFIX}/opt/intel/licenses"
311 )
312 for dir in "${dirs[@]}" ; do
313 ebegin "Checking for a license in: ${dir}"
314 #maybe use nullglob or [[ $(echo ${dir/*lic) != "${dir}/*lic" ]]
315 [[ $( ls "${dir}"/*lic 2>/dev/null ) ]]; ret=$?
316 eend ${ret}
317 if [[ ${ret} == "0" ]]; then
318 warn=${ret}
319 break
320 fi
321 done
322 if [[ ${warn} == "1" ]]; then
323 _isdp_big-warning pre-check
324 die "Could not find license file"
325 fi
326 else
327 eqawarn "The ebuild doesn't check for presents of a proper intel license!"
328 eqawarn "This shouldn't be done unless there is a serious reason."
329 fi
330 }
331
332 # @FUNCTION: intel-sdp_pkg_setup
333 # @DESCRIPTION:
334 # Setting up and sorting some internal variables
335 intel-sdp_pkg_setup() {
336 local arch a p
337
338 if use x86; then
339 arch=${INTEL_X86}
340 INTEL_ARCH="ia32"
341 elif use amd64; then
342 arch=x86_64
343 INTEL_ARCH="intel64"
344 if has_multilib_profile; then
345 arch="x86_64 ${INTEL_X86}"
346 INTEL_ARCH="intel64 ia32"
347 fi
348 fi
349 INTEL_RPMS=()
350 INTEL_RPMS_FULL=()
351 if [[ $(declare -p INTEL_BIN_RPMS) = "declare -a "* ]] ; then
352 _INTEL_BIN_RPMS=( ${INTEL_BIN_RPMS[@]} )
353 else
354 read -r -d '' -a _INTEL_BIN_RPMS <<<"${INTEL_BIN_RPMS}"
355 fi
356 for p in "${_INTEL_BIN_RPMS[@]}"; do
357 for a in ${arch}; do
358 if [ ${p} == $(basename ${p}) ]; then
359 INTEL_RPMS+=( intel-${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.${a}.rpm )
360 else
361 INTEL_RPMS_FULL+=( ${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.${a}.rpm )
362 fi
363 done
364 done
365 if [[ $(declare -p INTEL_DAT_RPMS) = "declare -a "* ]] ; then
366 _INTEL_DAT_RPMS=( ${INTEL_DAT_RPMS[@]} )
367 else
368 read -r -d '' -a _INTEL_DAT_RPMS <<<"${INTEL_DAT_RPMS}"
369 fi
370 for p in "${_INTEL_DAT_RPMS[@]}"; do
371 if [ ${p} == $(basename ${p}) ]; then
372 INTEL_RPMS+=( intel-${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.noarch.rpm )
373 else
374 INTEL_RPMS_FULL+=( ${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.noarch.rpm )
375 fi
376 done
377 }
378
379 # @FUNCTION: intel-sdp_src_unpack
380 # @DESCRIPTION:
381 # Unpacking necessary rpms from tarball, extract them and rearrange the output.
382 intel-sdp_src_unpack() {
383 local l r subdir rb t list=() debug_list
384
385 for t in ${A}; do
386 for r in "${INTEL_RPMS[@]}"; do
387 rpmdir=${t%%.*}/${INTEL_RPMS_DIR}
388 list+=( ${rpmdir}/${r} )
389 done
390
391 for r in "${INTEL_RPMS_FULL[@]}"; do
392 list+=( ${t%%.*}/${r} )
393 done
394
395 debug_list="$(IFS=$'\n'; echo ${list[@]} )"
396
397 debug-print "Adding to decompression list:"
398 debug-print ${debug_list}
399
400 tar xvf "${DISTDIR}"/${t} ${list[@]} &> "${T}"/rpm-extraction.log
401
402 for r in ${list[@]}; do
403 rb=$(basename ${r})
404 l=.${rb}_$(date +'%d%m%y_%H%M%S').log
405 einfo "Unpacking ${rb}"
406 rpm2tar -O ${r} | tar xvf - | sed -e \
407 "s:^\.:${EROOT#/}:g" > ${l}; assert "unpacking ${r} failed"
408 mv ${l} opt/intel/ || die "failed moving extract log file"
409 done
410 done
411
412 mv opt/intel/* ${INTEL_SDP_DIR} || die "mv to INTEL_SDP_DIR failed"
413 }
414
415 # @FUNCTION: intel-sdp_src_install
416 # @DESCRIPTION:
417 # Install everything
418 intel-sdp_src_install() {
419 if [[ -d "${INTEL_SDP_DIR}"/Documentation ]]; then
420 dodoc -r "${INTEL_SDP_DIR}"/Documentation/*
421
422 ebegin "Cleaning out documentation"
423 find "${INTEL_SDP_DIR}"/Documentation -delete || die
424 eend
425 fi
426
427 if [[ -d "${INTEL_SDP_DIR}"/Samples ]]; then
428 if use examples ; then
429 insinto /usr/share/${P}/examples/
430 doins -r "${INTEL_SDP_DIR}"/Samples/*
431 fi
432 ebegin "Cleaning out examples"
433 find "${INTEL_SDP_DIR}"/Samples -delete || die
434 eend
435 fi
436
437 if [[ -d "${INTEL_SDP_DIR}"/eclipse_support ]]; then
438 if has eclipse ${IUSE} && use eclipse; then
439 _isdp_link_eclipse_plugins
440 else
441 ebegin "Cleaning out eclipse plugin"
442 find "${INTEL_SDP_DIR}"/eclipse_support -delete || die
443 eend
444 fi
445 fi
446
447 if [[ -d "${INTEL_SDP_DIR}"/man ]]; then
448 nonfatal doman "${INTEL_SDP_DIR}"/man/en_US/man1/*
449 nonfatal doman "${INTEL_SDP_DIR}"/man/man1/*
450 if has linguas_ja ${IUSE} && use linguas_ja; then
451 doman -i18n=ja_JP "${INTEL_SDP_DIR}"/man/ja_JP/man1/*
452 fi
453
454 find "${INTEL_SDP_DIR}"/man -delete || die
455 fi
456
457 ebegin "Tagging ${PN}"
458 find opt -name \*sh -type f -exec sed -i \
459 -e "s:<.*DIR>:${INTEL_SDP_EDIR}:g" \
460 '{}' + || die
461 eend
462
463 [[ -d "${ED}" ]] || dodir /
464 mv opt "${ED}"/ || die "moving files failed"
465
466 dodir "${INTEL_SDP_DIR}"/licenses /opt/intel/ism/rm
467 keepdir "${INTEL_SDP_DIR}"/licenses /opt/intel/ism/rm
468 }
469
470 # @FUNCTION: intel-sdp_pkg_postinst
471 # @DESCRIPTION:
472 # Add things to intel database
473 intel-sdp_pkg_postinst() {
474 # add product registry to intel "database"
475 local l r
476 for r in ${INTEL_RPMS}; do
477 l="$(ls -1 ${EROOT%/}/opt/intel/.${r}_*.log | head -n 1)"
478 echo >> ${INTEL_SDP_DB} \
479 "<:${r%-${_INTEL_PV4}*}-${_INTEL_PV4}:${r}:${INTEL_SDP_EDIR}:${l}:>"
480 done
481 _isdp_run-test
482
483 if [[ ${PN} = icc ]] && has_version ">=dev-util/ccache-3.1.9-r2" ; then
484 #add ccache links as icc might get installed after ccache
485 "${EROOT}"/usr/bin/ccache-config --install-links
486 fi
487 }
488
489 # @FUNCTION: intel-sdp_pkg_postrm
490 # @DESCRIPTION:
491 # Sanitize intel database
492 intel-sdp_pkg_postrm() {
493 # remove from intel "database"
494 if [[ -e ${INTEL_SDP_DB} ]]; then
495 local r
496 for r in ${INTEL_RPMS}; do
497 sed -i \
498 -e "/${r}/d" \
499 ${INTEL_SDP_DB}
500 done
501 fi
502
503 if [[ ${PN} = icc ]] && has_version ">=dev-util/ccache-3.1.9-r2" && [[ -z ${REPLACED_BY_VERSION} ]]; then
504 # --remove-links would remove all links, --install-links updates them
505 "${EROOT}"/usr/bin/ccache-config --install-links
506 fi
507 }
508
509 EXPORT_FUNCTIONS pkg_setup src_unpack src_install pkg_postinst pkg_postrm pkg_pretend
510 case "${EAPI:-0}" in
511 0|1|2|3)die "EAPI=${EAPI} is not supported anymore" ;;
512 4|5) ;;
513 *) die "EAPI=${EAPI} is not supported" ;;
514 esac

  ViewVC Help
Powered by ViewVC 1.1.20