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

Contents of /eclass/intel-sdp.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Wed Dec 5 19:41:21 2012 UTC (21 months, 3 weeks ago) by jlec
Branch: MAIN
Changes since 1.4: +237 -66 lines
Add EAPI=5 support; add check for presents of license; handle docs, examples and man page in a more sane way;sort functions and document eclass for man-pages; Drop Sebastion as maintainer

1 # Copyright 1999-2012 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.4 2012/09/20 13:54:56 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_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 # @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 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 x86? ( ${_INTEL_URI}_${INTEL_DPV}_ia32.tgz )"
95
96 LICENSE="Intel-SDP"
97 # Future work, #394411
98 #SLOT="${_INTEL_PV1}.${_INTEL_PV2}"
99 SLOT="0"
100 IUSE="examples multilib"
101 KEYWORDS="-* ~amd64 ~x86 ~amd64-linux ~x86-linux"
102
103 RESTRICT="mirror"
104
105 RDEPEND=""
106 DEPEND="app-arch/rpm2targz"
107
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 # @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 dirs=(
264 "${INTEL_SDP_EDIR}/licenses"
265 "${INTEL_SDP_EDIR}/Licenses"
266 "${EPREFIX}/opt/intel/licenses"
267 )
268 for dir in "${dirs[@]}" ; do
269 ebegin "Checking for a license in: ${dir}"
270 #maybe use nullglob or [[ $(echo ${dir/*lic) != "${dir}/*lic" ]]
271 [[ $( ls "${dir}"/*lic 2>/dev/null ) ]]; ret=$?
272 eend ${ret}
273 if [[ ${ret} == "0" ]]; then
274 warn=${ret}
275 break
276 fi
277 done
278 if [[ ${warn} == "1" ]]; then
279 _isdp_big-warning pre-check
280 die "Could not find license file"
281 fi
282 }
283
284 # @FUNCTION: intel-sdp_pkg_setup
285 # @DESCRIPTION:
286 # Setting up and sorting some internal variables
287 intel-sdp_pkg_setup() {
288 local arch a p
289
290 if use x86; then
291 arch=${INTEL_X86}
292 INTEL_ARCH="ia32"
293 elif use amd64; then
294 arch=x86_64
295 INTEL_ARCH="intel64"
296 if has_multilib_profile; then
297 arch="x86_64 ${INTEL_X86}"
298 INTEL_ARCH="intel64 ia32"
299 fi
300 fi
301 INTEL_RPMS=""
302 for p in ${INTEL_BIN_RPMS}; do
303 for a in ${arch}; do
304 INTEL_RPMS+=" intel-${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.${a}.rpm"
305 done
306 done
307 for p in ${INTEL_DAT_RPMS}; do
308 INTEL_RPMS+=" intel-${p}-${_INTEL_PV4}-${_INTEL_PV1}.${_INTEL_PV2}-${_INTEL_PV3}.noarch.rpm"
309 done
310
311 case "${EAPI:-0}" in
312 0|1|2|3) intel-sdp_pkg_pretend ;;
313 esac
314 }
315
316 # @FUNCTION: intel-sdp_src_unpack
317 # @DESCRIPTION:
318 # Unpacking necessary rpms from tarball, extract them and rearrange the output.
319 intel-sdp_src_unpack() {
320 local l r subdir rb t list=()
321
322 for t in ${A}; do
323 for r in ${INTEL_RPMS}; do
324 for subdir in ${INTEL_RPMS_DIRS}; do
325 rpmdir=${t%%.*}/${subdir}
326 list+=( ${rpmdir}/${r})
327 done
328 done
329 tar xf "${DISTDIR}"/${t} ${list[@]} 2> /dev/null || die
330 for r in ${list[@]}; do
331 rb=$(basename ${r})
332 l=.${rb}_$(date +'%d%m%y_%H%M%S').log
333 einfo "Unpacking ${rb}"
334 rpm2tar -O ${r} | tar xvf - | sed -e \
335 "s:^\.:${EROOT#/}:g" > ${l} || die "unpacking ${r} failed"
336 mv ${l} opt/intel/ || die "failed moving extract log file"
337 done
338 done
339
340 mv opt/intel/* ${INTEL_SDP_DIR} || die "mv to INTEL_SDP_DIR failed"
341 }
342
343 # @FUNCTION: intel-sdp_src_install
344 # @DESCRIPTION:
345 # Install everything
346 intel-sdp_src_install() {
347 if [[ -d "${INTEL_SDP_DIR}"/Documentation ]]; then
348 dodoc -r "${INTEL_SDP_DIR}"/Documentation/*
349
350 ebegin "Cleaning out documentation"
351 find "${INTEL_SDP_DIR}"/Documentation -delete || die
352 eend
353 fi
354
355 if [[ -d "${INTEL_SDP_DIR}"/Samples ]]; then
356 if use examples ; then
357 insinto /usr/share/${P}/examples/
358 doins -r "${INTEL_SDP_DIR}"/Samples/*
359 fi
360 ebegin "Cleaning out examples"
361 find "${INTEL_SDP_DIR}"/Samples -delete || die
362 eend
363 fi
364
365 if [[ -d "${INTEL_SDP_DIR}"/eclipse_support ]]; then
366 if has eclipse ${IUSE} && use eclipse; then
367 _isdp_link_eclipse_plugins
368 else
369 ebegin "Cleaning out eclipse plugin"
370 find "${INTEL_SDP_DIR}"/eclipse_support -delete || die
371 eend
372 fi
373 fi
374
375 if [[ -d "${INTEL_SDP_DIR}"/man ]]; then
376 doman "${INTEL_SDP_DIR}"/man/en_US/man1/*
377 if has linguas_ja ${IUSE} && use linguas_ja; then
378 doman -i18n=ja_JP "${INTEL_SDP_DIR}"/man/ja_JP/man1/*
379 fi
380
381 find "${INTEL_SDP_DIR}"/man -delete || die
382 fi
383
384 ebegin "Tagging ${PN}"
385 find opt -name \*sh -type f -exec sed -i \
386 -e "s:<.*DIR>:${INTEL_SDP_EDIR}:g" \
387 '{}' + || die
388 eend
389
390 [[ -d "${ED}" ]] || dodir /
391 mv opt "${ED}"/ || die "moving files failed"
392
393 dodir "${INTEL_SDP_EDIR}"/licenses
394 keepdir "${INTEL_SDP_EDIR}"/licenses
395 }
396
397 # @FUNCTION: intel-sdp_pkg_postinst
398 # @DESCRIPTION:
399 # Add things to intel database
400 intel-sdp_pkg_postinst() {
401 # add product registry to intel "database"
402 local l r
403 for r in ${INTEL_RPMS}; do
404 l="$(ls -1 ${EROOT%/}/opt/intel/.${r}_*.log | head -n 1)"
405 echo >> ${INTEL_SDP_DB} \
406 "<:${r%-${_INTEL_PV4}*}-${_INTEL_PV4}:${r}:${INTEL_SDP_EDIR}:${l}:>"
407 done
408 _isdp_run-test
409 }
410
411 # @FUNCTION: intel-sdp_pkg_postrm
412 # @DESCRIPTION:
413 # Sanitize intel database
414 intel-sdp_pkg_postrm() {
415 # remove from intel "database"
416 if [[ -e ${INTEL_SDP_DB} ]]; then
417 local r
418 for r in ${INTEL_RPMS}; do
419 sed -i \
420 -e "/${r}/d" \
421 ${INTEL_SDP_DB}
422 done
423 fi
424 }
425
426 EXPORT_FUNCTIONS pkg_setup src_unpack src_install pkg_postinst pkg_postrm
427 case "${EAPI:-0}" in
428 0|1|2|3) ;;
429 4|5) EXPORT_FUNCTIONS pkg_pretend ;;
430 *) die "EAPI=${EAPI} is not supported" ;;
431 esac

  ViewVC Help
Powered by ViewVC 1.1.20