+parse_mpss_info() {
+ local file="$1"
+ local build="$2"
+ local distro="$3"
+
+ [ -r "$file" ] || fatal 1 "Could not find MPSS info file"
+
+ # convert to MPSS distro naming
+ distro=${distro/sles/suse}
+ distro_name=${distro%%-*}
+
+ # extract links from MPSS info file
+ local urls=$(cat "$file" | \
+ tr -d '\t\r\n' | sed -e 's?\(</[a-zA-Z]*>\)?\1\n?g' | \
+ grep '.intel.com/' | \
+ sed -e 's/^.*[hH][rR][eE][fF]="\([^>"]\+\)".*$/\1/g' | \
+ grep '.tar')
+ local res2=""
+ local res3=""
+ for url in $urls; do
+ # Try to match with MPSS 3.1 distro package
+ if [[ $url =~ mpss-[0-9].[0-9]-$distro.tar ]]; then
+ local bid=${url##*mpss-}
+ bid="${bid%%-$distro.tar}.0-0"
+ if [ -z "$build" ]; then
+ res3="$bid"
+ elif [ "$build" = "$bid" ]; then
+ res3="$res3 $url"
+ fi
+ # Try to match with MPSS 3.1 source package
+ elif [[ $url =~ mpss-src-[0-9].[0-9].tar ]]; then
+ local bid=${url##*mpss-src-}
+ bid="${bid%%.tar}.0-0"
+ if [ -z "$build" ]; then
+ res3="$bid"
+ elif [ "$build" = "$bid" ]; then
+ res3="$res3 $url"
+ fi
+ # Try to match with MPSS 3.1 cross compiler package
+ elif [[ $url =~ mpss-[0-9].[0-9]-k1om.tar ]]; then
+ local bid=${url##*mpss-}
+ bid="${bid%%-k1om.tar}.0-0"
+ if [ -z "$build" ]; then
+ res3="$bid"
+ elif [ "$build" = "$bid" ]; then
+ res3="$res3 $url"
+ fi
+ # Try to match with MPSS 2.1 source package
+ elif [[ $url =~ _src-[0-9].[0-9].[0-9]*-[0-9]*_$distro_name.tar ]]; then
+ local bid=${url##*_src-}
+ bid=${bid%%_$distro_name.tar}
+ if [ -z "$build" ]; then
+ res2="$bid"
+ elif [ "$build" = "$bid" ]; then
+ res2="$res2 $url"
+ fi
+ fi
+ done
+
+ if [ -z "$build" ]; then
+ # return a last version of MPSS
+ if [ -n "$res3" ]; then
+ echo "$res3"
+ else
+ echo "$res2"
+ fi
+ elif [ "${build%%.*}" = "3" ]; then
+ local ver=${build%.*}
+ local bid=${build%%-*}
+ bid=${bid##$ver.}
+ if [ $bid -eq 0 ]; then
+ # return URLs from MPSS info file
+ echo "$res3"
+ else
+ # return URLs from internal site with MPSS builds
+ # kernel sources:
+ echo "${MPSS_BUILDS:-"http://mic-bld.pdx.intel.com/builds/mpss/rc"}/$bid/release/knightscorner/package/mpss-src-$ver.tar"
+ # kernel configs:
+ echo "${MPSS_BUILDS:-"http://mic-bld.pdx.intel.com/builds/mpss/rc"}/$bid/release/knightscorner/package/mpss-$ver-k1om.tar"
+ # OFED headers:
+ echo "${MPSS_BUILDS:-"http://mic-bld.pdx.intel.com/builds/mpss/rc"}/$bid/release/knightscorner/package/mpss-$ver-$distro.tar"
+ fi
+ else
+ # return URLs from MPSS info file
+ echo "$res2"
+ fi
+}
+
+# Get public information about last releases of
+# Intel Manycore Platform Software Stack (MPSS)
+download_mpss_info() {
+ local file="$1"
+ local force="${2:-true}"
+ local url=${MPSS_URL:-"http://software.intel.com/en-us/articles/intel-manycore-platform-software-stack-mpss"}
+
+ download_file "$url" "$file" "$force"
+}
+
+download_mpss() {
+ local file="$1"
+ local force="${2:-false}"
+ local urls=$(parse_mpss_info "$file" ${MPSS_VERSION} ${MPSS_DISTRO})
+
+ [ -z "$urls" ] && fatal 1 "Could not determine the URLs of MPSS $MPSS_VERSION"
+
+ # force re-download if build number is zero
+ [[ $MPSS_VERSION = [0-9].[0-9].0-0 ]] && force=true
+
+ local url
+ local i=0
+ for url in $urls; do
+ file="$KERNELTREE/mpss_src-${MPSS_VERSION}-${MPSS_DISTRO}-part$i.tar"
+ download_file "$url" "$file" "$force"
+ i=$((i+1))
+ done
+}
+