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

Contents of /eclass/intel-sdp.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (show annotations) (download)
Mon Jul 29 09:50:09 2013 UTC (15 months ago) by jlec
Branch: MAIN
Changes since 1.13: +56 -21 lines
Intel-sdp.eclass: Allow single package downloads, custom suffix, full specified rpm target location

1 # Copyright 1999-2013 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.13 2013/07/19 14:00:50 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 a 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 for p in ${INTEL_BIN_RPMS}; do
352 for a in ${arch}; do
353 if [ ${p} == $(basename ${p}) ]; then
354 INTEL_RPMS+=( intel-${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.${a}.rpm )
355 else
356 INTEL_RPMS_FULL+=( ${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.${a}.rpm )
357 fi
358 done
359 done
360 for p in ${INTEL_DAT_RPMS}; do
361 if [ ${p} == $(basename ${p}) ]; then
362 INTEL_RPMS+=( intel-${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.noarch.rpm )
363 else
364 INTEL_RPMS_FULL+=( ${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.noarch.rpm )
365 fi
366 done
367
368 case "${EAPI:-0}" in
369 0|1|2|3) intel-sdp_pkg_pretend ;;
370 esac
371 }
372
373 # @FUNCTION: intel-sdp_src_unpack
374 # @DESCRIPTION:
375 # Unpacking necessary rpms from tarball, extract them and rearrange the output.
376 intel-sdp_src_unpack() {
377 local l r subdir rb t list=() debug_list
378
379 for t in ${A}; do
380 for r in ${INTEL_RPMS[@]}; do
381 rpmdir=${t%%.*}/${INTEL_RPMS_DIR}
382 list+=( ${rpmdir}/${r} )
383 done
384
385 for r in ${INTEL_RPMS_FULL[@]}; do
386 list+=( ${t%%.*}/${r} )
387 done
388
389 debug_list="$(IFS=$'\n'; echo ${list[@]} )"
390
391 debug-print "Adding to decompression list:"
392 debug-print ${debug_list}
393
394 tar xvf "${DISTDIR}"/${t} ${list[@]} &> "${T}"/rpm-extraction.log
395
396 for r in ${list[@]}; do
397 rb=$(basename ${r})
398 l=.${rb}_$(date +'%d%m%y_%H%M%S').log
399 einfo "Unpacking ${rb}"
400 rpm2tar -O ${r} | tar xvf - | sed -e \
401 "s:^\.:${EROOT#/}:g" > ${l}; assert "unpacking ${r} failed"
402 mv ${l} opt/intel/ || die "failed moving extract log file"
403 done
404 done
405
406 mv opt/intel/* ${INTEL_SDP_DIR} || die "mv to INTEL_SDP_DIR failed"
407 }
408
409 # @FUNCTION: intel-sdp_src_install
410 # @DESCRIPTION:
411 # Install everything
412 intel-sdp_src_install() {
413 if [[ -d "${INTEL_SDP_DIR}"/Documentation ]]; then
414 dodoc -r "${INTEL_SDP_DIR}"/Documentation/*
415
416 ebegin "Cleaning out documentation"
417 find "${INTEL_SDP_DIR}"/Documentation -delete || die
418 eend
419 fi
420
421 if [[ -d "${INTEL_SDP_DIR}"/Samples ]]; then
422 if use examples ; then
423 insinto /usr/share/${P}/examples/
424 doins -r "${INTEL_SDP_DIR}"/Samples/*
425 fi
426 ebegin "Cleaning out examples"
427 find "${INTEL_SDP_DIR}"/Samples -delete || die
428 eend
429 fi
430
431 if [[ -d "${INTEL_SDP_DIR}"/eclipse_support ]]; then
432 if has eclipse ${IUSE} && use eclipse; then
433 _isdp_link_eclipse_plugins
434 else
435 ebegin "Cleaning out eclipse plugin"
436 find "${INTEL_SDP_DIR}"/eclipse_support -delete || die
437 eend
438 fi
439 fi
440
441 if [[ -d "${INTEL_SDP_DIR}"/man ]]; then
442 doman "${INTEL_SDP_DIR}"/man/en_US/man1/*
443 if has linguas_ja ${IUSE} && use linguas_ja; then
444 doman -i18n=ja_JP "${INTEL_SDP_DIR}"/man/ja_JP/man1/*
445 fi
446
447 find "${INTEL_SDP_DIR}"/man -delete || die
448 fi
449
450 ebegin "Tagging ${PN}"
451 find opt -name \*sh -type f -exec sed -i \
452 -e "s:<.*DIR>:${INTEL_SDP_EDIR}:g" \
453 '{}' + || die
454 eend
455
456 [[ -d "${ED}" ]] || dodir /
457 mv opt "${ED}"/ || die "moving files failed"
458
459 dodir "${INTEL_SDP_DIR}"/licenses /opt/intel/ism/rm
460 keepdir "${INTEL_SDP_DIR}"/licenses /opt/intel/ism/rm
461 }
462
463 # @FUNCTION: intel-sdp_pkg_postinst
464 # @DESCRIPTION:
465 # Add things to intel database
466 intel-sdp_pkg_postinst() {
467 # add product registry to intel "database"
468 local l r
469 for r in ${INTEL_RPMS}; do
470 l="$(ls -1 ${EROOT%/}/opt/intel/.${r}_*.log | head -n 1)"
471 echo >> ${INTEL_SDP_DB} \
472 "<:${r%-${_INTEL_PV4}*}-${_INTEL_PV4}:${r}:${INTEL_SDP_EDIR}:${l}:>"
473 done
474 _isdp_run-test
475 }
476
477 # @FUNCTION: intel-sdp_pkg_postrm
478 # @DESCRIPTION:
479 # Sanitize intel database
480 intel-sdp_pkg_postrm() {
481 # remove from intel "database"
482 if [[ -e ${INTEL_SDP_DB} ]]; then
483 local r
484 for r in ${INTEL_RPMS}; do
485 sed -i \
486 -e "/${r}/d" \
487 ${INTEL_SDP_DB}
488 done
489 fi
490 }
491
492 EXPORT_FUNCTIONS pkg_setup src_unpack src_install pkg_postinst pkg_postrm
493 case "${EAPI:-0}" in
494 0|1|2|3) ;;
495 4|5) EXPORT_FUNCTIONS pkg_pretend ;;
496 *) die "EAPI=${EAPI} is not supported" ;;
497 esac

  ViewVC Help
Powered by ViewVC 1.1.20