1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: intel-sdp.eclass
6 # Justin Lecher <jlec@gentoo.org>
7 # Sci Team <sci@gentoo.org>
8 # @BLURB: Handling of Intel's Software Development Products package management
10 if [[ ! ${_INTEL_SDP_ECLASS_} ]]; then
14 *) die "EAPI=${EAPI} is not supported" ;;
17 # @ECLASS-VARIABLE: INTEL_DID
20 # The package download ID from Intel.
21 # To find out its value, see the links to download in
22 # https://registrationcenter.intel.com/RegCenter/MyProducts.aspx
26 # Must be defined before inheriting the eclass
28 # @ECLASS-VARIABLE: INTEL_DPN
31 # The package name to download from Intel.
32 # To find out its value, see the links to download in
33 # https://registrationcenter.intel.com/RegCenter/MyProducts.aspx
35 # e.g. parallel_studio_xe
37 # Must be defined before inheriting the eclass
39 # @ECLASS-VARIABLE: INTEL_DPV
42 # The package download version from Intel.
43 # To find out its value, see the links to download in
44 # https://registrationcenter.intel.com/RegCenter/MyProducts.aspx
46 # e.g. 2011_sp1_update2
48 # Must be defined before inheriting the eclass
50 # @ECLASS-VARIABLE: INTEL_TARX
52 # The package extention.
53 # To find out its value, see the links to download in
54 # https://registrationcenter.intel.com/RegCenter/MyProducts.aspx
58 # Must be defined before inheriting the eclass
61 # @ECLASS-VARIABLE: INTEL_SUBDIR
64 # The package sub-directory where it will end-up in /opt/intel
65 # To find out its value, you have to do a raw install from the Intel tar ball
67 # @ECLASS-VARIABLE: INTEL_SKIP_LICENSE
70 # Possibility to skip the mandatory check for licenses. Only set this if there
73 # @ECLASS-VARIABLE: INTEL_RPMS_DIR
75 # Main subdirectory which contains the rpms to extract.
76 : ${INTEL_RPMS_DIR:=rpm}
78 # @ECLASS-VARIABLE: INTEL_X86
80 # 32bit arch in rpm names
85 # @ECLASS-VARIABLE: INTEL_BIN_RPMS
87 # Functional name of rpm without any version/arch tag
91 # if the rpm is located in a directory different to INTEL_RPMS_DIR you can
92 # specify the full path
94 # e.g. CLI_install/rpm/intel-vtune-amplifier-xe-cli
95 : ${INTEL_BIN_RPMS:=""}
97 # @ECLASS-VARIABLE: INTEL_DAT_RPMS
99 # Functional name of rpm of common data which are arch free
100 # without any version tag
104 # if the rpm is located in a directory different to INTEL_RPMS_DIR you can
105 # specify the full path
107 # e.g. CLI_install/rpm/intel-vtune-amplifier-xe-cli-common
108 : ${INTEL_DAT_RPMS:=""}
110 # @ECLASS-VARIABLE: INTEL_SINGLE_ARCH
112 # Unset, if only the multilib package will be provided by intel
113 : ${INTEL_SINGLE_ARCH:=true}
115 # @ECLASS-VARIABLE: INTEL_SDP_DB
117 # Full path to intel registry db
118 INTEL_SDP_DB="${EROOT%/}"/opt/intel/intel-sdp-products.db
120 inherit check-reqs eutils multilib versionator
122 _INTEL_PV1=$(get_version_component_range 1)
123 _INTEL_PV2=$(get_version_component_range 2)
124 _INTEL_PV3=$(get_version_component_range 3)
125 _INTEL_PV4=$(get_version_component_range 4)
126 _INTEL_URI="http://registrationcenter-download.intel.com/irc_nas/${INTEL_DID}/${INTEL_DPN}"
128 if [ ${INTEL_SINGLE_ARCH} == true ]; then
130 amd64? ( multilib? ( ${_INTEL_URI}_${INTEL_DPV}.${INTEL_TARX} ) )
131 amd64? ( !multilib? ( ${_INTEL_URI}_${INTEL_DPV}_intel64.${INTEL_TARX} ) )
132 x86? ( ${_INTEL_URI}_${INTEL_DPV}_ia32.${INTEL_TARX} )"
134 SRC_URI="${_INTEL_URI}_${INTEL_DPV}.${INTEL_TARX}"
138 # Future work, #394411
139 #SLOT="${_INTEL_PV1}.${_INTEL_PV2}"
141 IUSE="examples multilib"
146 DEPEND="app-arch/rpm2targz"
148 _INTEL_SDP_YEAR=${INTEL_DPV%_update*}
149 _INTEL_SDP_YEAR=${INTEL_DPV%_sp*}
151 # @ECLASS-VARIABLE: INTEL_SDP_DIR
153 # Full rootless path to installation dir
154 INTEL_SDP_DIR="opt/intel/${INTEL_SUBDIR}-${_INTEL_SDP_YEAR:-${_INTEL_PV1}}.${_INTEL_PV3}.${_INTEL_PV4}"
156 # @ECLASS-VARIABLE: INTEL_SDP_EDIR
158 # Full rooted path to installation dir
159 INTEL_SDP_EDIR="${EROOT%/}/${INTEL_SDP_DIR}"
163 QA_PREBUILT="${INTEL_SDP_DIR}/*"
165 # @ECLASS-VARIABLE: INTEL_ARCH
168 # Intels internal names of the arches; will be set at runtime accordingly
170 # e.g. amd64-multilib -> INTEL_ARCH="intel64 ia32"
172 # @FUNCTION: _isdp_big-warning
173 # @USAGE: [pre-check | test-failed]
176 # warn user that we really require a license
177 _isdp_big-warning() {
178 debug-print-function ${FUNCNAME} "${@}"
183 ewarn "License file not found!"
188 ewarn "Function test failed. Most probably due to an invalid license."
189 ewarn "This means you already tried to bypass the license check once."
194 ewarn "Make sure you have received an Intel license."
195 ewarn "To receive a non-commercial license, you need to register at:"
196 ewarn "https://software.intel.com/en-us/qualify-for-free-software"
197 ewarn "Install the license file into ${INTEL_SDP_EDIR}/licenses/"
201 ewarn "before proceeding with installation of ${P}"
210 # @FUNCTION: _isdp_version_test
213 # Testing for valid license by asking for version information of the compiler
214 _isdp_version_test() {
215 debug-print-function ${FUNCNAME} "${@}"
217 local comp comp_full arch warn
220 debug-print "Testing ifort"
224 debug-print "Testing icc"
228 die "${PN} is not supported for testing"
232 for arch in ${INTEL_ARCH}; do
233 case ${EBUILD_PHASE} in
235 comp_full="${ED}/${INTEL_SDP_DIR}/bin/${arch}/${comp}"
238 comp_full="${INTEL_SDP_EDIR}/bin/${arch}/${comp}"
241 ewarn "Compile test not supported in ${EBUILD_PHASE}"
246 debug-print "LD_LIBRARY_PATH=\"${INTEL_SDP_EDIR}/bin/${arch}/\" \"${comp_full}\" -V"
248 LD_LIBRARY_PATH="${INTEL_SDP_EDIR}/bin/${arch}/" "${comp_full}" -V &>/dev/null
249 [[ $? -ne 0 ]] && warn=yes
251 [[ "${warn}" == "yes" ]] && _isdp_big-warning test-failed
254 # @FUNCTION: _isdp_run-test
257 # Test if installed compiler is working
259 debug-print-function ${FUNCNAME} "${@}"
261 if [[ -z ${INTEL_SKIP_LICENSE} ]]; then
264 _isdp_version_test ;;
266 debug-print "No test available for ${PN}"
272 # @FUNCTION: intel-sdp_pkg_pretend
275 # * Check that the user has a (valid) license file before going on.
277 # * Check for space requirements being fullfilled
278 intel-sdp_pkg_pretend() {
279 debug-print-function ${FUNCNAME} "${@}"
281 local warn=1 dir dirs ret arch a p
283 : ${CHECKREQS_DISK_BUILD:=256M}
284 check-reqs_pkg_pretend
286 if [[ -z ${INTEL_SKIP_LICENSE} ]]; then
287 if echo ${INTEL_LICENSE_FILE} | grep -q @; then
288 einfo "Looks like you are using following license server:"
289 einfo " ${INTEL_LICENSE_FILE}"
294 "${INTEL_SDP_EDIR}/licenses"
295 "${INTEL_SDP_EDIR}/Licenses"
296 "${EPREFIX}/opt/intel/licenses"
298 for dir in "${dirs[@]}" ; do
299 ebegin "Checking for a license in: ${dir}"
300 #maybe use nullglob or [[ $(echo ${dir/*lic) != "${dir}/*lic" ]]
301 [[ $( ls "${dir}"/*lic 2>/dev/null ) ]]; ret=$?
303 if [[ ${ret} == "0" ]]; then
308 if [[ ${warn} == "1" ]]; then
309 _isdp_big-warning pre-check
310 die "Could not find license file"
313 eqawarn "The ebuild doesn't check for presents of a proper intel license!"
314 eqawarn "This shouldn't be done unless there is a serious reason."
318 # @FUNCTION: intel-sdp_pkg_setup
320 # Setting up and sorting some internal variables
321 intel-sdp_pkg_setup() {
322 debug-print-function ${FUNCNAME} "${@}"
331 if has_multilib_profile; then
332 arch="x86_64 ${INTEL_X86}"
333 INTEL_ARCH="intel64 ia32"
338 if [[ $(declare -p INTEL_BIN_RPMS) = "declare -a "* ]] ; then
339 _INTEL_BIN_RPMS=( ${INTEL_BIN_RPMS[@]} )
341 read -r -d '' -a _INTEL_BIN_RPMS <<<"${INTEL_BIN_RPMS}"
343 for p in "${_INTEL_BIN_RPMS[@]}"; do
345 if [ ${p} == $(basename ${p}) ]; then
346 INTEL_RPMS+=( intel-${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.${a}.rpm )
348 INTEL_RPMS_FULL+=( ${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.${a}.rpm )
352 if [[ $(declare -p INTEL_DAT_RPMS) = "declare -a "* ]] ; then
353 _INTEL_DAT_RPMS=( ${INTEL_DAT_RPMS[@]} )
355 read -r -d '' -a _INTEL_DAT_RPMS <<<"${INTEL_DAT_RPMS}"
357 for p in "${_INTEL_DAT_RPMS[@]}"; do
358 if [ ${p} == $(basename ${p}) ]; then
359 INTEL_RPMS+=( intel-${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.noarch.rpm )
361 INTEL_RPMS_FULL+=( ${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.noarch.rpm )
366 # @FUNCTION: intel-sdp_src_unpack
368 # Unpacking necessary rpms from tarball, extract them and rearrange the output.
369 intel-sdp_src_unpack() {
370 local l r subdir rb t list=() debug_list
373 for r in "${INTEL_RPMS[@]}"; do
374 rpmdir=${t%%.*}/${INTEL_RPMS_DIR}
375 list+=( ${rpmdir}/${r} )
378 for r in "${INTEL_RPMS_FULL[@]}"; do
379 list+=( ${t%%.*}/${r} )
382 debug_list="$(IFS=$'\n'; echo ${list[@]} )"
384 debug-print "Adding to decompression list:"
385 debug-print ${debug_list}
387 tar xvf "${DISTDIR}"/${t} ${list[@]} &> "${T}"/rpm-extraction.log
389 for r in ${list[@]}; do
391 l=.${rb}_$(date +'%d%m%y_%H%M%S').log
392 einfo "Unpacking ${rb}"
393 rpm2tar -O ${r} | tar xvf - | sed -e \
394 "s:^\.:${EROOT#/}:g" > ${l}; assert "unpacking ${r} failed"
395 mv ${l} opt/intel/ || die "failed moving extract log file"
399 mv opt/intel/* ${INTEL_SDP_DIR} || die "mv to INTEL_SDP_DIR failed"
402 # @FUNCTION: intel-sdp_src_install
405 intel-sdp_src_install() {
406 debug-print-function ${FUNCNAME} "${@}"
408 if path_exists "${INTEL_SDP_DIR}"/uninstall*; then
409 ebegin "Cleaning out uninstall information"
410 find "${INTEL_SDP_DIR}"/uninstall* -delete || die
414 if path_exists "${INTEL_SDP_DIR}"/Documentation; then
415 dodoc -r "${INTEL_SDP_DIR}"/Documentation/*
417 ebegin "Cleaning out documentation"
418 find "${INTEL_SDP_DIR}"/Documentation -delete || die
422 if path_exists "${INTEL_SDP_DIR}"/Samples; then
423 if use examples ; then
424 insinto /usr/share/${P}/examples/
425 doins -r "${INTEL_SDP_DIR}"/Samples/*
427 ebegin "Cleaning out examples"
428 find "${INTEL_SDP_DIR}"/Samples -delete || die
432 if path_exists "${INTEL_SDP_DIR}"/man; then
433 path_exists "${INTEL_SDP_DIR}"/man/en_US/man1/* && \
434 doman "${INTEL_SDP_DIR}"/man/en_US/man1/*
435 path_exists "${INTEL_SDP_DIR}"/man/man1/* && \
436 doman "${INTEL_SDP_DIR}"/man/man1/*
437 has linguas_ja ${IUSE} && use linguas_ja && \
438 doman -i18n=ja_JP "${INTEL_SDP_DIR}"/man/ja_JP/man1/*
440 find "${INTEL_SDP_DIR}"/man -delete || die
443 ebegin "Tagging ${PN}"
444 find opt -name \*sh -type f -exec sed -i \
445 -e "s:<.*DIR>:${INTEL_SDP_EDIR}:g" \
449 [[ -d "${ED}" ]] || dodir /
450 mv opt "${ED}"/ || die "moving files failed"
452 dodir "${INTEL_SDP_DIR}"/licenses /opt/intel/ism/rm
453 keepdir "${INTEL_SDP_DIR}"/licenses /opt/intel/ism/rm
456 # @FUNCTION: intel-sdp_pkg_postinst
458 # Add things to intel database
459 intel-sdp_pkg_postinst() {
460 debug-print-function ${FUNCNAME} "${@}"
462 # add product registry to intel "database"
464 for r in ${INTEL_RPMS}; do
465 l="$(ls -1 ${EROOT%/}/opt/intel/.${r}_*.log | head -n 1)"
466 echo >> ${INTEL_SDP_DB} \
467 "<:${r%-${_INTEL_PV4}*}-${_INTEL_PV4}:${r}:${INTEL_SDP_EDIR}:${l}:>"
471 if [[ ${PN} = icc ]] && has_version ">=dev-util/ccache-3.1.9-r2" ; then
472 #add ccache links as icc might get installed after ccache
473 "${EROOT}"/usr/bin/ccache-config --install-links
477 # @FUNCTION: intel-sdp_pkg_postrm
479 # Sanitize intel database
480 intel-sdp_pkg_postrm() {
481 debug-print-function ${FUNCNAME} "${@}"
483 # remove from intel "database"
484 if [[ -e ${INTEL_SDP_DB} ]]; then
486 for r in ${INTEL_RPMS}; do
493 if [[ ${PN} = icc ]] && has_version ">=dev-util/ccache-3.1.9-r2" && [[ -z ${REPLACED_BY_VERSION} ]]; then
494 # --remove-links would remove all links, --install-links updates them
495 "${EROOT}"/usr/bin/ccache-config --install-links
499 EXPORT_FUNCTIONS pkg_setup src_unpack src_install pkg_postinst pkg_postrm pkg_pretend