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

Contents of /eclass/intel-sdp.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (show annotations) (download)
Fri Jul 19 13:05:23 2013 UTC (17 months ago) by jlec
Branch: MAIN
Changes since 1.11: +18 -5 lines
Support different tarball extentions

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

  ViewVC Help
Powered by ViewVC 1.1.20