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

Contents of /eclass/intel-sdp.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (hide annotations) (download)
Thu Feb 14 16:29:00 2013 UTC (20 months ago) by jlec
Branch: MAIN
Changes since 1.10: +43 -30 lines
Make it possible to bypass license check from ebuilds

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

  ViewVC Help
Powered by ViewVC 1.1.20