Hi,

next patch for intel-sdp.eclass

Problem:
If the intel compiler are installed but no valid license is present,
several buildsystem including cmake generate sandbox violations.

Solution:
Do not let the user install the package without valid license. Its
useless anyway without.
Realized in two checks, first in pkg_pretend check for simple existence
of a license file; second check in pkg_postinst calls for version
informations from compiler (runtime test).
First test is deadly; Second not, because user already intervened
manually to bypass first check and we consider this as
he-knows-what-he-is-doing.

Thanks justin

+# @ECLASS-FUNCTION: big-warning
+# @INTERNAL
+# warn user that we really require a license
+big-warning() {
+    case ${1} in
+			pre-check )
+				echo ""
+				ewarn "License file not found!"
+				;;
+        test-failed )
+            echo
+            ewarn "Function test failed. Most probably due to an invalid license."
+            ewarn "This means you already tried to bypass the license check once."
+            ;;
+    esac
+
+    echo ""
+    ewarn "Make sure you have recieved the an Intel license."
+    ewarn "To receive a non-commercial license, you need to register at:"
+    ewarn "http://software.intel.com/en-us/articles/non-commercial-software-development/";
+    ewarn "Install the license file into ${INTEL_SDP_EDIR}/licenses/"
+
+    case ${1} in
+        pre-check )
+            ewarn "before proceeding with installation of ${P}"
+            echo ""
+            ;;
+        * )
+            echo ""
+            ;;
+            esac
+}
+
+# @ECLASS-FUNCTION: _version_test
+# @INTERNAL
+# Testing for valid license by asking for version information of the compiler
+_version_test() {
+    local _comp _comp_full _arch _file _warn
+    case ${PN} in
+        ifc )
+            debug-print "Testing ifort"
+            _comp=ifort
+            ;;
+        icc )
+            debug-print "Testing icc"
+            _comp=icc
+            ;;
+        *)
+            die "${PN} is not supported for testing"
+            ;;
+    esac
+
+    for _arch in ${INTEL_ARCH}; do
+        case ${EBUILD_PHASE} in
+            install )
+                _comp_full="${ED}/${INTEL_SDP_DIR}/bin/${_arch}/${_comp}"
+                ;;
+            postinst )
+                _comp_full="${INTEL_SDP_EDIR}/bin/${_arch}/${_comp}"
+                ;;
+            * )
+                ewarn "Compile test not supported in ${EBUILD_PHASE}"
+                continue
+                ;;
+        esac
+
+        debug-print "LD_LIBRARY_PATH=\"${INTEL_SDP_EDIR}/bin/${_arch}/\" \"${_comp_full}\" -V"
+
+        LD_LIBRARY_PATH="${INTEL_SDP_EDIR}/bin/${_arch}/" "${_comp_full}" -V &>/dev/null
+        [[ $? -ne 0 ]] && _warn=yes
+    done
+    [[ "${_warn}" == "yes" ]] && big-warning test-failed
+}
+
+# @ECLASS-FUNCTION: run-test
+# @INTERNAL
+# Test if installed compiler is working
+run-test() {
+    case ${PN} in
+        ifc | icc )
+            _version_test ;;
+        * )
+            debug-print "No test available for ${PN}"
+            ;;
+    esac
+}
+
+# @ECLASS-FUNCTION: intel-sdp_pkg_pretend
+# @DESCRIPTION:
+# * Check that the user has a (valid) license file before going on.
+#
+# * Check for space requirements being fullfilled
+intel-sdp_pkg_pretend() {
+	local _warn=1 _dirs i _ret arch a p
+
+	: ${CHECKREQS_DISK_BUILD:=256M}
+	check-reqs_pkg_pretend
+
+	_dirs=(
+		"${INTEL_SDP_EDIR}/licenses"
+		"${INTEL_SDP_EDIR}/Licenses"
+		"${EPREFIX}/opt/intel/licenses"
+		)
+	for ((i = 0; i < ${#_dirs[@]}; i++)); do
+		ebegin "Checking for a license in: ${_dirs[$i]}"
+		[[ $( ls "${_dirs[$i]}"/*lic 2>/dev/null ) ]]; _ret=$?
+		eend ${_ret}
+		if [[ ${_ret} == "0" ]]; then
+			_warn=${_ret}
+			break
+		fi
+	done
+	if [[ ${_warn} == "1" ]]; then
+		big-warning pre-check
+		die "Could not find license file"
+	fi
+}

@@ -238,8 +390,12 @@ intel-sdp_pkg_postinst() {
 		echo >> ${INTEL_SDP_DB} \
 			"<:${r%-${_INTEL_PV4}*}-${_INTEL_PV4}:${r}:${INTEL_SDP_EDIR}:${l}:>"
 	done
+	run-test
 }

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to