1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: intel-sdp.eclass
7 # Justin Lecher <jlec@gentoo.org>
8 # Sci Team <sci@gentoo.org>
9 # @BLURB: Handling of Intel's Software Development Products package management
11 # @ECLASS-VARIABLE: INTEL_DID
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
20 # Must be defined before inheriting the eclass
22 # @ECLASS-VARIABLE: INTEL_DPN
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
29 # e.g. parallel_studio_xe
31 # Must be defined before inheriting the eclass
33 # @ECLASS-VARIABLE: INTEL_DPV
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
40 # e.g. 2011_sp1_update2
42 # Must be defined before inheriting the eclass
44 # @ECLASS-VARIABLE: INTEL_TARX
47 # The package extention.
48 # To find out its value, see the links to download in
49 # https://registrationcenter.intel.com/RegCenter/MyProducts.aspx
53 # Must be defined before inheriting the eclass
56 # @ECLASS-VARIABLE: INTEL_SUBDIR
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
62 # @ECLASS-VARIABLE: INTEL_SKIP_LICENSE
65 # Possibility to skip the mandatory check for licenses. Only set this if there
68 # @ECLASS-VARIABLE: INTEL_RPMS_DIR
70 # Main subdirectory which contains the rpms to extract.
71 : ${INTEL_RPMS_DIR:=rpm}
73 # @ECLASS-VARIABLE: INTEL_X86
75 # 32bit arch in rpm names
80 # @ECLASS-VARIABLE: INTEL_BIN_RPMS
83 # Functional name of rpm without any version/arch tag
87 # if the rpm is located in a directory different to INTEL_RPMS_DIR you can
88 # specify the full path
90 # e.g. CLI_install/rpm/intel-vtune-amplifier-xe-cli
92 # @ECLASS-VARIABLE: INTEL_DAT_RPMS
95 # Functional name of rpm of common data which are arch free
96 # without any version tag
100 # if the rpm is located in a directory different to INTEL_RPMS_DIR you can
101 # specify the full path
103 # e.g. CLI_install/rpm/intel-vtune-amplifier-xe-cli-common
105 # @ECLASS-VARIABLE: INTEL_SINGLE_ARCH
107 # Unset, if only the multilib package will be provided by intel
108 : ${INTEL_SINGLE_ARCH:=true}
110 # @ECLASS-VARIABLE: INTEL_SDP_DB
112 # Full path to intel registry db
113 INTEL_SDP_DB="${EROOT%/}"/opt/intel/intel-sdp-products.db
115 inherit check-reqs eutils multilib versionator
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}"
123 if [ ${INTEL_SINGLE_ARCH} == true ]; then
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} )"
129 SRC_URI="${_INTEL_URI}_${INTEL_DPV}.${INTEL_TARX}"
133 # Future work, #394411
134 #SLOT="${_INTEL_PV1}.${_INTEL_PV2}"
136 IUSE="examples multilib"
141 DEPEND="app-arch/rpm2targz"
143 _INTEL_SDP_YEAR=${INTEL_DPV%_update*}
144 _INTEL_SDP_YEAR=${INTEL_DPV%_sp*}
146 # @ECLASS-VARIABLE: INTEL_SDP_DIR
149 # Full rootless path to installation dir
150 INTEL_SDP_DIR="opt/intel/${INTEL_SUBDIR}-${_INTEL_SDP_YEAR:-${_INTEL_PV1}}.${_INTEL_PV3}.${_INTEL_PV4}"
152 # @ECLASS-VARIABLE: INTEL_SDP_EDIR
155 # Full rooted path to installation dir
156 INTEL_SDP_EDIR="${EROOT%/}/${INTEL_SDP_DIR}"
160 QA_PREBUILT="${INTEL_SDP_DIR}/*"
162 # @ECLASS-VARIABLE: INTEL_ARCH
165 # Intels internal names of the arches; will be set at runtime accordingly
167 # e.g. amd64-multilib -> INTEL_ARCH="intel64 ia32"
169 # @FUNCTION: _isdp_link_eclipse_plugins
172 # Creating necessary links to use intel compiler with eclipse
173 _isdp_link_eclipse_plugins() {
175 pushd ${INTEL_SDP_DIR}/eclipse_support > /dev/null || die
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
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
192 popd > /dev/null || die
195 # @FUNCTION: _isdp_big-warning
196 # @USAGE: [pre-check | test-failed]
199 # warn user that we really require a license
200 _isdp_big-warning() {
204 ewarn "License file not found!"
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."
215 ewarn "Make sure you have received an Intel license."
216 ewarn "To receive a non-commercial license, you need to register at:"
217 ewarn "https://software.intel.com/en-us/qualify-for-free-software"
218 ewarn "Install the license file into ${INTEL_SDP_EDIR}/licenses/"
222 ewarn "before proceeding with installation of ${P}"
231 # @FUNCTION: _isdp_version_test
234 # Testing for valid license by asking for version information of the compiler
235 _isdp_version_test() {
236 local comp comp_full arch warn
239 debug-print "Testing ifort"
243 debug-print "Testing icc"
247 die "${PN} is not supported for testing"
251 for arch in ${INTEL_ARCH}; do
252 case ${EBUILD_PHASE} in
254 comp_full="${ED}/${INTEL_SDP_DIR}/bin/${arch}/${comp}"
257 comp_full="${INTEL_SDP_EDIR}/bin/${arch}/${comp}"
260 ewarn "Compile test not supported in ${EBUILD_PHASE}"
265 debug-print "LD_LIBRARY_PATH=\"${INTEL_SDP_EDIR}/bin/${arch}/\" \"${comp_full}\" -V"
267 LD_LIBRARY_PATH="${INTEL_SDP_EDIR}/bin/${arch}/" "${comp_full}" -V &>/dev/null
268 [[ $? -ne 0 ]] && warn=yes
270 [[ "${warn}" == "yes" ]] && _isdp_big-warning test-failed
273 # @FUNCTION: _isdp_run-test
275 # Test if installed compiler is working
277 if [[ -z ${INTEL_SKIP_LICENSE} ]]; then
280 _isdp_version_test ;;
282 debug-print "No test available for ${PN}"
288 # @FUNCTION: intel-sdp_pkg_pretend
291 # * Check that the user has a (valid) license file before going on.
292 # * Check for space requirements being fullfilled
294 intel-sdp_pkg_pretend() {
295 local warn=1 dir dirs ret arch a p
297 : ${CHECKREQS_DISK_BUILD:=256M}
298 check-reqs_pkg_pretend
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}"
308 "${INTEL_SDP_EDIR}/licenses"
309 "${INTEL_SDP_EDIR}/Licenses"
310 "${EPREFIX}/opt/intel/licenses"
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=$?
317 if [[ ${ret} == "0" ]]; then
322 if [[ ${warn} == "1" ]]; then
323 _isdp_big-warning pre-check
324 die "Could not find license file"
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."
332 # @FUNCTION: intel-sdp_pkg_setup
334 # Setting up and sorting some internal variables
335 intel-sdp_pkg_setup() {
344 if has_multilib_profile; then
345 arch="x86_64 ${INTEL_X86}"
346 INTEL_ARCH="intel64 ia32"
351 if [[ $(declare -p INTEL_BIN_RPMS) = "declare -a "* ]] ; then
352 _INTEL_BIN_RPMS=( ${INTEL_BIN_RPMS[@]} )
354 read -r -d '' -a _INTEL_BIN_RPMS <<<"${INTEL_BIN_RPMS}"
356 for p in "${_INTEL_BIN_RPMS[@]}"; do
358 if [ ${p} == $(basename ${p}) ]; then
359 INTEL_RPMS+=( intel-${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.${a}.rpm )
361 INTEL_RPMS_FULL+=( ${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.${a}.rpm )
365 if [[ $(declare -p INTEL_DAT_RPMS) = "declare -a "* ]] ; then
366 _INTEL_DAT_RPMS=( ${INTEL_DAT_RPMS[@]} )
368 read -r -d '' -a _INTEL_DAT_RPMS <<<"${INTEL_DAT_RPMS}"
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 )
374 INTEL_RPMS_FULL+=( ${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.noarch.rpm )
379 # @FUNCTION: intel-sdp_src_unpack
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
386 for r in "${INTEL_RPMS[@]}"; do
387 rpmdir=${t%%.*}/${INTEL_RPMS_DIR}
388 list+=( ${rpmdir}/${r} )
391 for r in "${INTEL_RPMS_FULL[@]}"; do
392 list+=( ${t%%.*}/${r} )
395 debug_list="$(IFS=$'\n'; echo ${list[@]} )"
397 debug-print "Adding to decompression list:"
398 debug-print ${debug_list}
400 tar xvf "${DISTDIR}"/${t} ${list[@]} &> "${T}"/rpm-extraction.log
402 for r in ${list[@]}; do
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"
412 mv opt/intel/* ${INTEL_SDP_DIR} || die "mv to INTEL_SDP_DIR failed"
415 # @FUNCTION: intel-sdp_src_install
418 intel-sdp_src_install() {
419 if path_exists "${INTEL_SDP_DIR}"/uninstall*; then
420 ebegin "Cleaning out uninstall information"
421 find "${INTEL_SDP_DIR}"/uninstall* -delete || die
425 if path_exists "${INTEL_SDP_DIR}"/Documentation; then
426 dodoc -r "${INTEL_SDP_DIR}"/Documentation/*
428 ebegin "Cleaning out documentation"
429 find "${INTEL_SDP_DIR}"/Documentation -delete || die
433 if path_exists "${INTEL_SDP_DIR}"/Samples; then
434 if use examples ; then
435 insinto /usr/share/${P}/examples/
436 doins -r "${INTEL_SDP_DIR}"/Samples/*
438 ebegin "Cleaning out examples"
439 find "${INTEL_SDP_DIR}"/Samples -delete || die
443 if path_exists "${INTEL_SDP_DIR}"/eclipse_support; then
444 if has eclipse ${IUSE} && use eclipse; then
445 _isdp_link_eclipse_plugins
447 ebegin "Cleaning out eclipse plugin"
448 find "${INTEL_SDP_DIR}"/eclipse_support -delete || die
453 if path_exists "${INTEL_SDP_DIR}"/man; then
454 path_exists "${INTEL_SDP_DIR}"/man/en_US/man1/* && \
455 doman "${INTEL_SDP_DIR}"/man/en_US/man1/*
456 path_exists "${INTEL_SDP_DIR}"/man/man1/* && \
457 doman "${INTEL_SDP_DIR}"/man/man1/*
458 has linguas_ja ${IUSE} && use linguas_ja && \
459 doman -i18n=ja_JP "${INTEL_SDP_DIR}"/man/ja_JP/man1/*
461 find "${INTEL_SDP_DIR}"/man -delete || die
464 ebegin "Tagging ${PN}"
465 find opt -name \*sh -type f -exec sed -i \
466 -e "s:<.*DIR>:${INTEL_SDP_EDIR}:g" \
470 [[ -d "${ED}" ]] || dodir /
471 mv opt "${ED}"/ || die "moving files failed"
473 dodir "${INTEL_SDP_DIR}"/licenses /opt/intel/ism/rm
474 keepdir "${INTEL_SDP_DIR}"/licenses /opt/intel/ism/rm
477 # @FUNCTION: intel-sdp_pkg_postinst
479 # Add things to intel database
480 intel-sdp_pkg_postinst() {
481 # add product registry to intel "database"
483 for r in ${INTEL_RPMS}; do
484 l="$(ls -1 ${EROOT%/}/opt/intel/.${r}_*.log | head -n 1)"
485 echo >> ${INTEL_SDP_DB} \
486 "<:${r%-${_INTEL_PV4}*}-${_INTEL_PV4}:${r}:${INTEL_SDP_EDIR}:${l}:>"
490 if [[ ${PN} = icc ]] && has_version ">=dev-util/ccache-3.1.9-r2" ; then
491 #add ccache links as icc might get installed after ccache
492 "${EROOT}"/usr/bin/ccache-config --install-links
496 # @FUNCTION: intel-sdp_pkg_postrm
498 # Sanitize intel database
499 intel-sdp_pkg_postrm() {
500 # remove from intel "database"
501 if [[ -e ${INTEL_SDP_DB} ]]; then
503 for r in ${INTEL_RPMS}; do
510 if [[ ${PN} = icc ]] && has_version ">=dev-util/ccache-3.1.9-r2" && [[ -z ${REPLACED_BY_VERSION} ]]; then
511 # --remove-links would remove all links, --install-links updates them
512 "${EROOT}"/usr/bin/ccache-config --install-links
516 EXPORT_FUNCTIONS pkg_setup src_unpack src_install pkg_postinst pkg_postrm pkg_pretend
518 0|1|2|3)die "EAPI=${EAPI} is not supported anymore" ;;
520 *) die "EAPI=${EAPI} is not supported" ;;