* [gentoo-dev] RFC: intel-sdp.eclass check user license
@ 2012-11-27 12:26 justin
2012-11-27 23:04 ` Mike Frysinger
0 siblings, 1 reply; 3+ messages in thread
From: justin @ 2012-11-27 12:26 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1.1: Type: text/plain, Size: 648 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: license.patch --]
[-- Type: text/x-patch; name="license.patch", Size: 3545 bytes --]
+# @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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 261 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-dev] RFC: intel-sdp.eclass check user license
2012-11-27 12:26 [gentoo-dev] RFC: intel-sdp.eclass check user license justin
@ 2012-11-27 23:04 ` Mike Frysinger
2012-11-28 7:37 ` justin
0 siblings, 1 reply; 3+ messages in thread
From: Mike Frysinger @ 2012-11-27 23:04 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: Text/Plain, Size: 1111 bytes --]
On Tuesday 27 November 2012 07:26:50 justin wrote:
> next patch for intel-sdp.eclass
your code has a lot of whitespace damage (leading spaces instead of tabs).
you should fix that up.
> +# @ECLASS-FUNCTION: big-warning
> +# @INTERNAL
> +# warn user that we really require a license
there should be @DESCRIPTION line before the description
you can run /usr/portage/app-portage/eclass-manpages/files/eclass-to-manpage.sh
against the eclass to check for errors.
also, just because they're @INTERNAL doesn't mean short names like "big-
warning" and "run-test" are OK. your eclass is putting funcs into global
scope which can collide with other eclasses/ebuilds and possibly things in
$PATH (dejagnu provides a standard program called `runtest`). best to give
them a unique prefix like _isdp_big_warning().
> +_version_test() {
> + local _comp _comp_full _arch _file _warn
you've declared the vars all local. there's no need for the _ prefix.
> + for ((i = 0; i < ${#_dirs[@]}; i++)); do
for dir in "${dirs[@]}" ; do
that avoids indexing dirs constantly
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-dev] RFC: intel-sdp.eclass check user license
2012-11-27 23:04 ` Mike Frysinger
@ 2012-11-28 7:37 ` justin
0 siblings, 0 replies; 3+ messages in thread
From: justin @ 2012-11-28 7:37 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1755 bytes --]
On 28/11/12 00:04, Mike Frysinger wrote:
> On Tuesday 27 November 2012 07:26:50 justin wrote:
>> next patch for intel-sdp.eclass
>
> your code has a lot of whitespace damage (leading spaces instead of tabs).
> you should fix that up.
I am sorry for that and we fix it up. Did some writing on mac where the
editor did magic tab -> whitespace conversion.
>
>> +# @ECLASS-FUNCTION: big-warning
>> +# @INTERNAL
>> +# warn user that we really require a license
>
> there should be @DESCRIPTION line before the description
>
I have overlooked that. Fixed now.
> you can run /usr/portage/app-portage/eclass-manpages/files/eclass-to-manpage.sh
> against the eclass to check for errors.
Didn't know, that you can run it on single files. Nice to know, Thanks.
>
> also, just because they're @INTERNAL doesn't mean short names like "big-
> warning" and "run-test" are OK. your eclass is putting funcs into global
> scope which can collide with other eclasses/ebuilds and possibly things in
> $PATH (dejagnu provides a standard program called `runtest`). best to give
> them a unique prefix like _isdp_big_warning().
You are right. I will prefix and name them correctly.
>
>> +_version_test() {
>> + local _comp _comp_full _arch _file _warn
>
> you've declared the vars all local. there's no need for the _ prefix.
>
>> + for ((i = 0; i < ${#_dirs[@]}; i++)); do
>
> for dir in "${dirs[@]}" ; do
I can't remember what was my problem, but somehow I didn't manage to
iterate properly over the array. So I looked that up and found this syntax.
But maybe something else was wrong too.
>
> that avoids indexing dirs constantly
> -mike
>
thanks for your comments mike,
Jusitn
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 261 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-11-28 7:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-27 12:26 [gentoo-dev] RFC: intel-sdp.eclass check user license justin
2012-11-27 23:04 ` Mike Frysinger
2012-11-28 7:37 ` justin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox