Gentoo Archives: gentoo-commits

From: Justin Lecher <jlec@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/sci:master commit in: eclass/
Date: Tue, 27 Nov 2012 19:35:34
Message-Id: 1354044116.9f99559289c34154330b786bee028c8c5233dcd1.jlec@gentoo
1 commit: 9f99559289c34154330b786bee028c8c5233dcd1
2 Author: Justin Lecher <jlec <AT> gentoo <DOT> org>
3 AuthorDate: Thu Nov 15 15:50:15 2012 +0000
4 Commit: Justin Lecher <jlec <AT> gentoo <DOT> org>
5 CommitDate: Tue Nov 27 19:21:56 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/sci.git;a=commit;h=9f995592
7
8 Enhancement of intel-sdp.eclass
9
10 * Add support for USE="doc examples"
11 * Check for license before installation
12
13 Signed-off-by: Justin Lecher <jlec <AT> gentoo.org>
14
15 ---
16 eclass/intel-sdp.eclass | 220 ++++++++++++++++++++++++++++++++++++++++++++---
17 1 files changed, 206 insertions(+), 14 deletions(-)
18
19 diff --git a/eclass/intel-sdp.eclass b/eclass/intel-sdp.eclass
20 index baeb2e2..eafb523 100644
21 --- a/eclass/intel-sdp.eclass
22 +++ b/eclass/intel-sdp.eclass
23 @@ -93,7 +93,7 @@ LICENSE="Intel-SDP"
24 # Future work, #394411
25 #SLOT="${_INTEL_PV1}.${_INTEL_PV2}"
26 SLOT="0"
27 -IUSE="multilib"
28 +IUSE="doc examples multilib"
29 KEYWORDS="-* ~amd64 ~x86 ~amd64-linux ~x86-linux"
30
31 RESTRICT="mirror"
32 @@ -135,6 +135,23 @@ intel-sdp_pkg_pretend() {
33 # e.g. amd64-multilib -> INTEL_ARCH="intel64 ia32"
34
35 intel-sdp_pkg_setup() {
36 + local _warn=1 _dirs i _ret
37 + _dirs=(
38 + "${INTEL_SDP_EDIR}/licenses"
39 + "${INTEL_SDP_EDIR}/Licenses"
40 + "${EPREFIX}/opt/intel/licenses"
41 + )
42 + for ((i = 0; i < ${#_dirs[@]}; i++)); do
43 + ebegin "Checking for a license in: ${_dirs[$i]}"
44 + [[ $( ls "${_dirs[$i]}"/*lic 2>/dev/null ) ]]; _ret=$?
45 + eend ${_ret}
46 + if [[ ${_ret} == "0" ]]; then
47 + _warn=${_ret}
48 + break
49 + fi
50 + done
51 + [[ ${_warn} == "0" ]] || big-warning pre-check
52 +
53 local arch a p
54 if use x86; then
55 arch=${INTEL_X86}
56 @@ -164,6 +181,7 @@ intel-sdp_pkg_setup() {
57
58 intel-sdp_src_unpack() {
59 local l r t rpmdir
60 + debug-print "INTEL_RPMS_DIRS are \"${INTEL_RPMS_DIRS}\""
61 for t in ${A}; do
62 for r in ${INTEL_RPMS}; do
63 # Find which subdirectory of the archive the rpm is in
64 @@ -179,6 +197,8 @@ intel-sdp_src_unpack() {
65 "s:^\.:${EROOT#/}:g" > ${l} || die "unpacking ${r} failed"
66 mv ${l} opt/intel/ || die "failed moving extract log file"
67 done
68 + [[ "${rpm_found}" == "false" ]] && \
69 + debug-print "RPM \"${r}\" not found in ${t}"
70 done
71 done
72 mv -v opt/intel/* ${INTEL_SDP_DIR} || die "mv to INTEL_SDP_DIR failed"
73 @@ -207,18 +227,194 @@ intel_link_eclipse_plugins() {
74 }
75
76 intel-sdp_src_install() {
77 - [[ -d ${INTEL_SDP_DIR}/eclipse_support ]] && \
78 - has eclipse ${IUSE} && \
79 - use eclipse && \
80 - intel_link_eclipse_plugins
81 + if ! use doc && [[ -d "${INTEL_SDP_DIR}"/Documentation ]]; then
82 + ebegin "Cleaning out documentation"
83 + find "${INTEL_SDP_DIR}"/Documentation -delete || die
84 + eend
85 + fi
86 + if ! use examples && [[ -d "${INTEL_SDP_DIR}"/Samples ]]; then
87 + ebegin "Cleaning out examples"
88 + find "${INTEL_SDP_DIR}"/Samples -delete || die
89 + eend
90 + fi
91 + if [[ -d "${INTEL_SDP_DIR}"/eclipse_support ]]; then
92 + if has eclipse ${IUSE} && use eclipse; then
93 + intel_link_eclipse_plugins
94 + else
95 + ebegin "Cleaning out eclipse plugin"
96 + find "${INTEL_SDP_DIR}"/eclipse_support -delete || die
97 + eend
98 + fi
99 + fi
100 +
101 + if [[ -d "${INTEL_SDP_DIR}"/man ]]; then
102 + doman "${INTEL_SDP_DIR}"/man/en_US/man1/*
103 + [[ ${LINGUAS} == "*ja_JP*" ]] && \
104 + doman -i18n=ja_JP "${INTEL_SDP_DIR}"/man/ja_JP/man1/*
105 +
106 + find "${INTEL_SDP_DIR}"/man -delete || die
107 + fi
108 +
109 einfo "Tagging ${PN}"
110 find opt -name \*sh -type f -exec sed -i \
111 -e "s:<.*DIR>:${INTEL_SDP_EDIR}:g" \
112 - '{}' \;
113 - mkdir -p "${ED:-${D}}"/ || die
114 - mv opt "${ED:-${D}}"/ || die "moving files failed"
115 + '{}' + || die
116 +
117 + [[ -d "${ED}" ]] || dodir /
118 + mv opt "${ED}"/ || die "moving files failed"
119 +
120 + dodir "${INTEL_SDP_EDIR}"/licenses
121 + keepdir "${INTEL_SDP_EDIR}"/licenses
122 }
123
124 +# @ECLASS-FUNCTION: big-warning
125 +# @INTERNAL
126 +# warn user that we really require a license
127 +
128 +big-warning() {
129 + case ${1} in
130 + test-failed )
131 + echo
132 + ewarn "Function test failed. Most probably due to an invalid license."
133 + ewarn "This means you already tried to bypass the license check once."
134 + ;;
135 + esac
136 +
137 + echo ""
138 + ewarn "Make sure you have recieved the an Intel license."
139 + ewarn "To receive a non-commercial license, you need to register at:"
140 + ewarn "http://software.intel.com/en-us/articles/non-commercial-software-development/"
141 + ewarn "Install the license file into ${INTEL_SDP_EDIR}/licenses/"
142 +
143 + case ${1} in
144 + pre-check )
145 + ewarn "before proceeding with installation of ${P}"
146 + echo ""
147 + ;;
148 + * )
149 + echo ""
150 + ;;
151 + esac
152 +}
153 +
154 +# @ECLASS-FUNCTION: _version_test
155 +# @INTERNAL
156 +# Testing for valid license by asking for version information of the compiler
157 +_version-test() {
158 + local _comp _comp_full _arch _file _warn
159 + case ${PN} in
160 + ifc )
161 + _comp=ifort
162 + ;;
163 + icc )
164 + _comp=icc
165 + ;;
166 + *)
167 + die "${PN} is not supported for testing"
168 + ;;
169 + esac
170 +
171 + for _arch in ${INTEL_ARCH}; do
172 + case ${EBUILD_PHASE} in
173 + install )
174 + _comp_full="${ED}/${INTEL_SDP_DIR}/bin/${_arch}/${_comp}"
175 + ;;
176 + postinst )
177 + _comp_full="${INTEL_SDP_EDIR}/bin/${_arch}/${_comp}"
178 + ;;
179 + * )
180 + ewarn "Compile test not supported in ${EBUILD_PHASE}"
181 + continue
182 + ;;
183 + esac
184 +
185 + debug-print "LD_LIBRARY_PATH=\"${INTEL_SDP_EDIR}/bin/${_arch}/\" \"${_comp_full}\" -V"
186 +
187 + LD_LIBRARY_PATH="${INTEL_SDP_EDIR}/bin/${_arch}/" "${_comp_full}" -V &>/dev/null
188 + [[ $? -ne 0 ]] && _warn=yes
189 + done
190 + [[ "${_warn}" == "yes" ]] && big-warning test-failed
191 +}
192 +
193 +# @ECLASS-FUNCTION: _compile-test
194 +# @INTERNAL
195 +# Testing for valid license with small compile test
196 +_compile-test() {
197 + local _comp _comp_full _arch _file _warn
198 + case ${1} in
199 + fortran )
200 + _file="${T}/${1}.f"
201 + cat > "${_file}" <<- EOF
202 + end
203 + EOF
204 + _comp=ifort
205 + ;;
206 + c )
207 + _file="${T}/${1}.c"
208 + cat > "${_file}" <<- EOF
209 + main() {
210 + ;
211 + }
212 + EOF
213 + _comp=icc
214 + ;;
215 + *)
216 + die "This ${1} is not supported for testing"
217 + ;;
218 + esac
219 +
220 + for _arch in ${INTEL_ARCH}; do
221 + case ${EBUILD_PHASE} in
222 + install )
223 + _comp_full="${ED}/${INTEL_SDP_DIR}/bin/${_arch}/${_comp}"
224 + ;;
225 + postinst )
226 + _comp_full="${INTEL_SDP_EDIR}/bin/${_arch}/${_comp}"
227 + ;;
228 + * )
229 + ewarn "Compile test not supported in ${EBUILD_PHASE}"
230 + continue
231 + ;;
232 + esac
233 +
234 +# debug-print "LD_LIBRARY_PATH=\"${INTEL_SDP_EDIR}/bin/${_arch}/\" \"${_comp_full}\" -c \"${_file}"
235 +
236 +# LD_LIBRARY_PATH="${INTEL_SDP_EDIR}/bin/${_arch}/" "${_comp_full}" -c "${_file}" &>/dev/null
237 +
238 + debug-print "LD_LIBRARY_PATH=\"${INTEL_SDP_EDIR}/bin/${_arch}/\" \"${_comp_full}\" -V"
239 +
240 + LD_LIBRARY_PATH="${INTEL_SDP_EDIR}/bin/${_arch}/" "${_comp_full}" -V &>/dev/null
241 + [[ $? -ne 0 ]] && _warn=yes
242 + done
243 + [[ "${_warn}" == "yes" ]] && big-warning test-failed
244 +}
245 +
246 +# @ECLASS-FUNCTION: _compile-fortran
247 +# @INTERNAL
248 +# Run fortran compile test
249 +_compile-fortran() { _compile-test fortran; }
250 +
251 +# @ECLASS-FUNCTION: _compile-c
252 +# @INTERNAL
253 +# Run c compile test
254 +_compile-c() { _compile-test c; }
255 +
256 +# @ECLASS-FUNCTION: run-test
257 +# @INTERNAL
258 +# Test if installed compiler is working
259 +run-test() {
260 + case ${PN} in
261 + ifc )
262 + debug-print "Testing ifort"
263 + _compile-fortran ;;
264 + icc )
265 + debug-print "Testing icc"
266 + _compile-c ;;
267 + * )
268 + debug-print "No test available for ${PN}"
269 + ;;
270 + esac
271 +}
272
273 # @ECLASS-VARIABLE: INTEL_SDP_DB
274 # @DESCRIPTION:
275 @@ -226,11 +422,6 @@ intel-sdp_src_install() {
276 INTEL_SDP_DB="${EROOT%/}"/opt/intel/intel-sdp-products.db
277
278 intel-sdp_pkg_postinst() {
279 - elog "Make sure you have recieved the an Intel license."
280 - elog "To receive a non-commercial license, you need to register at:"
281 - elog "http://software.intel.com/en-us/articles/non-commercial-software-development/"
282 - elog "Install the license file into ${EROOT}opt/intel/licenses."
283 -
284 # add product registry to intel "database"
285 local l r
286 for r in ${INTEL_RPMS}; do
287 @@ -238,6 +429,7 @@ intel-sdp_pkg_postinst() {
288 echo >> ${INTEL_SDP_DB} \
289 "<:${r%-${_INTEL_PV4}*}-${_INTEL_PV4}:${r}:${INTEL_SDP_EDIR}:${l}:>"
290 done
291 + run-test
292 }
293
294 intel-sdp_pkg_postrm() {
295 @@ -255,6 +447,6 @@ intel-sdp_pkg_postrm() {
296 EXPORT_FUNCTIONS pkg_setup src_unpack src_install pkg_postinst pkg_postrm
297 case "${EAPI:-0}" in
298 0|1|2|3) ;;
299 - 4) EXPORT_FUNCTIONS pkg_pretend ;;
300 + 4|5) EXPORT_FUNCTIONS pkg_pretend ;;
301 *) die "EAPI=${EAPI} is not supported" ;;
302 esac