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

Contents of /eclass/intel-sdp.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (hide annotations) (download)
Wed Jan 23 11:14:33 2013 UTC (17 months, 4 weeks ago) by jlec
Branch: MAIN
Changes since 1.8: +3 -3 lines
Add dummy dir to avoid sandbox violations when emerging with FEATURES=-userpriv, #437512

1 jlec 1.6 # Copyright 1999-2013 Gentoo Foundation
2 jlec 1.1 # Distributed under the terms of the GNU General Public License v2
3 jlec 1.9 # $Header: /var/cvsroot/gentoo-x86/eclass/intel-sdp.eclass,v 1.8 2013/01/23 09:49:30 jlec Exp $
4 jlec 1.1
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_SUBDIR
45     # @DEFAULT_UNSET
46     # @DESCRIPTION:
47     # The package sub-directory where it will end-up in /opt/intel
48     # To find out its value, you have to do a raw install from the Intel tar ball
49    
50     # @ECLASS-VARIABLE: INTEL_RPMS_DIRS
51     # @DESCRIPTION:
52     # List of subdirectories in the main archive which contains the
53     # rpms to extract.
54     : ${INTEL_RPMS_DIRS:=rpm}
55    
56     # @ECLASS-VARIABLE: INTEL_X86
57     # @DESCRIPTION:
58     # 32bit arch in rpm names
59     #
60     # e.g. i484
61     : ${INTEL_X86:=i486}
62    
63     # @ECLASS-VARIABLE: INTEL_BIN_RPMS
64     # @DEFAULT_UNSET
65     # @DESCRIPTION:
66     # Functional name of rpm without any version/arch tag
67     #
68     # e.g. compilerprof
69    
70     # @ECLASS-VARIABLE: INTEL_DAT_RPMS
71     # @DEFAULT_UNSET
72     # @DESCRIPTION:
73     # Functional name of rpm of common data which are arch free
74     # without any version tag
75     #
76     # e.g. openmp
77    
78 jlec 1.5 # @ECLASS-VARIABLE: INTEL_SDP_DB
79     # @DESCRIPTION:
80     # Full path to intel registry db
81     INTEL_SDP_DB="${EROOT%/}"/opt/intel/intel-sdp-products.db
82    
83 jlec 1.1 inherit check-reqs multilib versionator
84    
85     _INTEL_PV1=$(get_version_component_range 1)
86     _INTEL_PV2=$(get_version_component_range 2)
87     _INTEL_PV3=$(get_version_component_range 3)
88     _INTEL_PV4=$(get_version_component_range 4)
89     _INTEL_URI="http://registrationcenter-download.intel.com/irc_nas/${INTEL_DID}/${INTEL_DPN}"
90    
91     SRC_URI="
92     amd64? ( multilib? ( ${_INTEL_URI}_${INTEL_DPV}.tgz ) )
93     amd64? ( !multilib? ( ${_INTEL_URI}_${INTEL_DPV}_intel64.tgz ) )
94 jlec 1.5 x86? ( ${_INTEL_URI}_${INTEL_DPV}_ia32.tgz )"
95 jlec 1.1
96     LICENSE="Intel-SDP"
97     # Future work, #394411
98     #SLOT="${_INTEL_PV1}.${_INTEL_PV2}"
99     SLOT="0"
100 jlec 1.5 IUSE="examples multilib"
101 jlec 1.4 KEYWORDS="-* ~amd64 ~x86 ~amd64-linux ~x86-linux"
102 jlec 1.1
103     RESTRICT="mirror"
104    
105     RDEPEND=""
106 jlec 1.5 DEPEND="app-arch/rpm2targz"
107 jlec 1.1
108     _INTEL_SDP_YEAR=${INTEL_DPV%_update*}
109     _INTEL_SDP_YEAR=${INTEL_DPV%_sp*}
110    
111     # @ECLASS-VARIABLE: INTEL_SDP_DIR
112     # @DEFAULT_UNSET
113     # @DESCRIPTION:
114     # Full rootless path to installation dir
115     INTEL_SDP_DIR="opt/intel/${INTEL_SUBDIR}-${_INTEL_SDP_YEAR:-${_INTEL_PV1}}.${_INTEL_PV3}.${_INTEL_PV4}"
116    
117     # @ECLASS-VARIABLE: INTEL_SDP_EDIR
118     # @DEFAULT_UNSET
119     # @DESCRIPTION:
120     # Full rooted path to installation dir
121     INTEL_SDP_EDIR="${EROOT%/}/${INTEL_SDP_DIR}"
122    
123     S="${WORKDIR}"
124    
125     QA_PREBUILT="${INTEL_SDP_DIR}/*"
126    
127     # @ECLASS-VARIABLE: INTEL_ARCH
128     # @DEFAULT_UNSET
129     # @DESCRIPTION:
130     # Intels internal names of the arches; will be set at runtime accordingly
131     #
132     # e.g. amd64-multilib -> INTEL_ARCH="intel64 ia32"
133    
134 jlec 1.5 # @FUNCTION: _isdp_link_eclipse_plugins
135     # @INTERNAL
136     # @DESCRIPTION:
137     # Creating necessary links to use intel compiler with eclipse
138     _isdp_link_eclipse_plugins() {
139     local c f
140     pushd ${INTEL_SDP_DIR}/eclipse_support > /dev/null
141     for c in cdt*; do
142     local cv=${c#cdt} ev=3.$(( ${cv:0:1} - 1))
143     if has_version "dev-util/eclipse-sdk:${ev}"; then
144     einfo "Linking eclipse (v${ev}) plugin cdt (v${cv})"
145     for f in cdt${cv}/eclipse/features/*; do
146     dodir /usr/$(get_libdir)/eclipse-${ev}/features
147     dosym "${INTEL_SDP_EDIR}"/eclipse_support/${f} \
148     /usr/$(get_libdir)/eclipse-${ev}/features/ || die
149     done
150     for f in cdt${cv}/eclipse/plugins/*; do
151     dodir /usr/$(get_libdir)/eclipse-${ev}/plugins
152     dosym "${INTEL_SDP_EDIR}"/eclipse_support/${f} \
153     /usr/$(get_libdir)/eclipse-${ev}/plugins/ || die
154     done
155     fi
156     done
157     popd > /dev/null
158     }
159    
160     # @FUNCTION: _isdp_big-warning
161     # @USAGE: [pre-check | test-failed]
162     # @INTERNAL
163     # @DESCRIPTION:
164     # warn user that we really require a license
165     _isdp_big-warning() {
166     case ${1} in
167     pre-check )
168     echo ""
169     ewarn "License file not found!"
170     ;;
171    
172     test-failed )
173     echo
174     ewarn "Function test failed. Most probably due to an invalid license."
175     ewarn "This means you already tried to bypass the license check once."
176     ;;
177     esac
178    
179     echo ""
180     ewarn "Make sure you have recieved the an Intel license."
181     ewarn "To receive a non-commercial license, you need to register at:"
182     ewarn "http://software.intel.com/en-us/articles/non-commercial-software-development/"
183     ewarn "Install the license file into ${INTEL_SDP_EDIR}/licenses/"
184    
185     case ${1} in
186     pre-check )
187     ewarn "before proceeding with installation of ${P}"
188     echo ""
189     ;;
190     * )
191     echo ""
192     ;;
193     esac
194     }
195    
196     # @FUNCTION: _isdp_version_test
197     # @INTERNAL
198     # @DESCRIPTION:
199     # Testing for valid license by asking for version information of the compiler
200     _isdp_version_test() {
201     local comp comp_full arch warn
202     case ${PN} in
203     ifc )
204     debug-print "Testing ifort"
205     comp=ifort
206     ;;
207     icc )
208     debug-print "Testing icc"
209     comp=icc
210     ;;
211     *)
212     die "${PN} is not supported for testing"
213     ;;
214     esac
215    
216     for arch in ${INTEL_ARCH}; do
217     case ${EBUILD_PHASE} in
218     install )
219     comp_full="${ED}/${INTEL_SDP_DIR}/bin/${arch}/${comp}"
220     ;;
221     postinst )
222     comp_full="${INTEL_SDP_EDIR}/bin/${arch}/${comp}"
223     ;;
224     * )
225     ewarn "Compile test not supported in ${EBUILD_PHASE}"
226     continue
227     ;;
228     esac
229    
230     debug-print "LD_LIBRARY_PATH=\"${INTEL_SDP_EDIR}/bin/${arch}/\" \"${comp_full}\" -V"
231    
232     LD_LIBRARY_PATH="${INTEL_SDP_EDIR}/bin/${arch}/" "${comp_full}" -V &>/dev/null
233     [[ $? -ne 0 ]] && warn=yes
234     done
235     [[ "${warn}" == "yes" ]] && _isdp_big-warning test-failed
236     }
237    
238     # @FUNCTION: _isdp_run-test
239     # @INTERNAL
240     # Test if installed compiler is working
241     _isdp_run-test() {
242     case ${PN} in
243     ifc | icc )
244     _isdp_version_test ;;
245     * )
246     debug-print "No test available for ${PN}"
247     ;;
248     esac
249     }
250    
251     # @FUNCTION: intel-sdp_pkg_pretend
252     # @DESCRIPTION:
253     # @CODE
254     # * Check that the user has a (valid) license file before going on.
255     # * Check for space requirements being fullfilled
256     # @CODE
257     intel-sdp_pkg_pretend() {
258     local warn=1 dir dirs ret arch a p
259    
260     : ${CHECKREQS_DISK_BUILD:=256M}
261     check-reqs_pkg_pretend
262    
263 jlec 1.8 if echo ${INTEL_LICENSE_FILE} | grep -q @; then
264 jlec 1.7 einfo "Looks like you are using following license server:"
265     einfo " ${INTEL_LICENSE_FILE}"
266     return 0
267     fi
268    
269 jlec 1.5 dirs=(
270     "${INTEL_SDP_EDIR}/licenses"
271     "${INTEL_SDP_EDIR}/Licenses"
272     "${EPREFIX}/opt/intel/licenses"
273     )
274     for dir in "${dirs[@]}" ; do
275     ebegin "Checking for a license in: ${dir}"
276     #maybe use nullglob or [[ $(echo ${dir/*lic) != "${dir}/*lic" ]]
277     [[ $( ls "${dir}"/*lic 2>/dev/null ) ]]; ret=$?
278     eend ${ret}
279     if [[ ${ret} == "0" ]]; then
280     warn=${ret}
281     break
282     fi
283     done
284     if [[ ${warn} == "1" ]]; then
285     _isdp_big-warning pre-check
286     die "Could not find license file"
287     fi
288     }
289    
290     # @FUNCTION: intel-sdp_pkg_setup
291     # @DESCRIPTION:
292     # Setting up and sorting some internal variables
293 jlec 1.1 intel-sdp_pkg_setup() {
294     local arch a p
295 jlec 1.5
296 jlec 1.1 if use x86; then
297     arch=${INTEL_X86}
298     INTEL_ARCH="ia32"
299     elif use amd64; then
300     arch=x86_64
301     INTEL_ARCH="intel64"
302     if has_multilib_profile; then
303     arch="x86_64 ${INTEL_X86}"
304     INTEL_ARCH="intel64 ia32"
305     fi
306     fi
307     INTEL_RPMS=""
308     for p in ${INTEL_BIN_RPMS}; do
309     for a in ${arch}; do
310 jlec 1.5 INTEL_RPMS+=" intel-${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.${a}.rpm"
311 jlec 1.1 done
312     done
313     for p in ${INTEL_DAT_RPMS}; do
314 jlec 1.5 INTEL_RPMS+=" intel-${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.noarch.rpm"
315 jlec 1.1 done
316    
317     case "${EAPI:-0}" in
318     0|1|2|3) intel-sdp_pkg_pretend ;;
319     esac
320     }
321    
322 jlec 1.5 # @FUNCTION: intel-sdp_src_unpack
323     # @DESCRIPTION:
324     # Unpacking necessary rpms from tarball, extract them and rearrange the output.
325 jlec 1.1 intel-sdp_src_unpack() {
326 jlec 1.5 local l r subdir rb t list=()
327    
328 jlec 1.1 for t in ${A}; do
329     for r in ${INTEL_RPMS}; do
330     for subdir in ${INTEL_RPMS_DIRS}; do
331     rpmdir=${t%%.*}/${subdir}
332 jlec 1.5 list+=( ${rpmdir}/${r})
333 jlec 1.1 done
334     done
335 jlec 1.5 tar xf "${DISTDIR}"/${t} ${list[@]} 2> /dev/null || die
336     for r in ${list[@]}; do
337     rb=$(basename ${r})
338     l=.${rb}_$(date +'%d%m%y_%H%M%S').log
339     einfo "Unpacking ${rb}"
340     rpm2tar -O ${r} | tar xvf - | sed -e \
341     "s:^\.:${EROOT#/}:g" > ${l} || die "unpacking ${r} failed"
342     mv ${l} opt/intel/ || die "failed moving extract log file"
343     done
344 jlec 1.1 done
345 jlec 1.5
346     mv opt/intel/* ${INTEL_SDP_DIR} || die "mv to INTEL_SDP_DIR failed"
347 jlec 1.1 }
348    
349 jlec 1.5 # @FUNCTION: intel-sdp_src_install
350     # @DESCRIPTION:
351     # Install everything
352     intel-sdp_src_install() {
353     if [[ -d "${INTEL_SDP_DIR}"/Documentation ]]; then
354     dodoc -r "${INTEL_SDP_DIR}"/Documentation/*
355    
356     ebegin "Cleaning out documentation"
357     find "${INTEL_SDP_DIR}"/Documentation -delete || die
358     eend
359     fi
360    
361     if [[ -d "${INTEL_SDP_DIR}"/Samples ]]; then
362     if use examples ; then
363     insinto /usr/share/${P}/examples/
364     doins -r "${INTEL_SDP_DIR}"/Samples/*
365     fi
366     ebegin "Cleaning out examples"
367     find "${INTEL_SDP_DIR}"/Samples -delete || die
368     eend
369     fi
370    
371     if [[ -d "${INTEL_SDP_DIR}"/eclipse_support ]]; then
372     if has eclipse ${IUSE} && use eclipse; then
373     _isdp_link_eclipse_plugins
374     else
375     ebegin "Cleaning out eclipse plugin"
376     find "${INTEL_SDP_DIR}"/eclipse_support -delete || die
377     eend
378     fi
379     fi
380    
381     if [[ -d "${INTEL_SDP_DIR}"/man ]]; then
382     doman "${INTEL_SDP_DIR}"/man/en_US/man1/*
383     if has linguas_ja ${IUSE} && use linguas_ja; then
384     doman -i18n=ja_JP "${INTEL_SDP_DIR}"/man/ja_JP/man1/*
385 jlec 1.1 fi
386    
387 jlec 1.5 find "${INTEL_SDP_DIR}"/man -delete || die
388     fi
389    
390     ebegin "Tagging ${PN}"
391 jlec 1.1 find opt -name \*sh -type f -exec sed -i \
392     -e "s:<.*DIR>:${INTEL_SDP_EDIR}:g" \
393 jlec 1.5 '{}' + || die
394     eend
395    
396     [[ -d "${ED}" ]] || dodir /
397     mv opt "${ED}"/ || die "moving files failed"
398    
399 jlec 1.9 dodir "${INTEL_SDP_DIR}"/licenses /opt/intel/ism/rm
400     keepdir "${INTEL_SDP_DIR}"/licenses /opt/intel/ism/rm
401 jlec 1.1 }
402    
403 jlec 1.5 # @FUNCTION: intel-sdp_pkg_postinst
404 jlec 1.1 # @DESCRIPTION:
405 jlec 1.5 # Add things to intel database
406 jlec 1.1 intel-sdp_pkg_postinst() {
407     # add product registry to intel "database"
408     local l r
409     for r in ${INTEL_RPMS}; do
410     l="$(ls -1 ${EROOT%/}/opt/intel/.${r}_*.log | head -n 1)"
411     echo >> ${INTEL_SDP_DB} \
412     "<:${r%-${_INTEL_PV4}*}-${_INTEL_PV4}:${r}:${INTEL_SDP_EDIR}:${l}:>"
413     done
414 jlec 1.5 _isdp_run-test
415 jlec 1.1 }
416    
417 jlec 1.5 # @FUNCTION: intel-sdp_pkg_postrm
418     # @DESCRIPTION:
419     # Sanitize intel database
420 jlec 1.1 intel-sdp_pkg_postrm() {
421     # remove from intel "database"
422     if [[ -e ${INTEL_SDP_DB} ]]; then
423     local r
424     for r in ${INTEL_RPMS}; do
425     sed -i \
426     -e "/${r}/d" \
427     ${INTEL_SDP_DB}
428     done
429     fi
430     }
431    
432     EXPORT_FUNCTIONS pkg_setup src_unpack src_install pkg_postinst pkg_postrm
433     case "${EAPI:-0}" in
434     0|1|2|3) ;;
435 jlec 1.5 4|5) EXPORT_FUNCTIONS pkg_pretend ;;
436 jlec 1.1 *) die "EAPI=${EAPI} is not supported" ;;
437     esac

  ViewVC Help
Powered by ViewVC 1.1.20