- local force="${1:-false}"
-
- if [ -z "$OFED_VERSION" -o "$OFED_VERSION" = "inkernel" ]; then
- return 0
- fi
-
- local OFED_BASE_VERSION=$OFED_VERSION
- if [[ $OFED_VERSION = *.*.*.* ]]; then
- OFED_BASE_VERSION=${OFED_VERSION%.*}
- fi
-
- local location="http://www.openfabrics.org/downloads/OFED/ofed-${OFED_BASE_VERSION}/"
-
- if [[ $OFED_VERSION = *-[rR][cC][0-9] ]]; then
- local Mmv
- Mmv=${OFED_VERSION%%-[rR][cC][0-9]}
- location="http://www.openfabrics.org/downloads/OFED/ofed-${Mmv}/"
- fi
-
- if [[ $OFED_VERSION = daily-* ]]; then
- local Mmv daily
- OFED_VERSION=${OFED_VERSION/daily-/}
- Mmv=${OFED_VERSION%%-*}
- daily=${OFED_VERSION##$Mmv-}
- location="http://www.openfabrics.org/downloads/OFED/ofed-${Mmv}-daily/"
- # find the filename for the version for the date specified
- OFED_VERSION=$(curl -s "$location" | sed -nre "/${daily}-/s/.*href=\"OFED-(${Mmv//./\\.}-${daily}-[0-9]{4,4}).tgz.*$/\1/p" | tail -1)
- if [ -z "$OFED_VERSION" ]; then
- fatal 1 "Could not determine the filename of the OFED snapshot for ${daily}"
- fi
- fi
-
- local file="OFED-${OFED_VERSION}.tgz"
- download_file "$location/$file" "$KERNELTREE" "$force"
-
-}
-
-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
- local ver2=""
- local ver3=""
- # Try to match with MPSS 3.x or 3.x.x distro package
- if [[ $url =~ mpss-[0-9].[0-9](.[0-9]*)?-$distro.tar ]]; then
- ver3=${url##*mpss-}
- ver3=${ver3%%-$distro.tar}
- # Try to match with MPSS 3.x or 3.x.x source package
- elif [[ $url =~ mpss-src-[0-9].[0-9](.[0-9]*)?.tar ]]; then
- ver3=${url##*mpss-src-}
- ver3=${ver3%%.tar}
- # Try to match with MPSS 3.x or 3.x.x cross compiler package
- elif [[ $url =~ mpss-[0-9].[0-9](.[0-9]*)?-k1om.tar ]]; then
- ver3=${url##*mpss-}
- ver3=${ver3%%-k1om.tar}
- # Try to match with MPSS 2.1.x source package
- elif [[ $url =~ _src-[0-9].[0-9].[0-9]*-[0-9]*_$distro_name.tar ]]; then
- ver2=${url##*_src-}
- ver2=${ver2%%_$distro_name.tar}
- fi
-
- if [ -n "$ver3" ]; then
- # Check for MPSS 3.x or MPSS 3.x.x
- if [[ $ver3 =~ [0-9].[0-9].[0-9]* ]]; then
- ver3="${ver3}-0"
- else
- ver3="${ver3}.0-0"
- fi
- if [ -z "$build" ]; then
- res3="$ver3"
- elif [ "$build" = "$ver3" ]; then
- res3="$res3 $url"
- fi
- elif [ -n "$ver2" ]; then
- if [ -z "$build" ]; then
- res2="$ver2"
- elif [ "$build" = "$ver2" ]; 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##*-}
- if [ $bid -eq 0 ]; then
- # return URLs from MPSS info file
- echo "$res3"
- else
- # Check for MPSS 3.x or MPSS 3.x.x
- if [ ${ver##*.} -eq 0 ]; then
- ver=${ver%.*}
- fi
- # return URLs from internal site with MPSS builds
- # kernel sources:
- echo "${MPSS_BUILDS:-"http://mic-bld.pdx.intel.com/release"}/$ver/$bid/release/knightscorner/package/mpss-src-$ver.tar"
- # kernel configs:
- echo "${MPSS_BUILDS:-"http://mic-bld.pdx.intel.com/release"}/$ver/$bid/release/knightscorner/package/mpss-$ver-k1om.tar"
- # OFED headers:
- echo "${MPSS_BUILDS:-"http://mic-bld.pdx.intel.com/release"}/$ver/$bid/release/knightscorner/package/mpss-$ver-$distro.tar"
- fi
- else
- # return URLs from MPSS info file
- echo "$res2"
- fi
-}
+ local ofed_type="$1"
+ local ofed_version="$2"
+ local force="${3:-false}"
+ local distro_name="${DISTRO}"
+ local arch="${TARGET_ARCH}"
+ local location
+ local file
+
+ #if a src tarball has been given in the command line, we use it
+ #The format of the tarball must be OFED-${OFED_VERSION}.tgz
+ [ -n "${OFED_SRC}" ] && return 0
+
+ case $ofed_type in
+ ofa)
+ location="https://www.openfabrics.org/downloads/OFED/ofed-${ofed_version}/"
+ # version include RC
+ if [[ $ofed_version = *-[rR][cC][0-9] ]]; then
+ ofed_version_loc=${ofed_version%%-[rR][cC][0-9]}
+ location="https://www.openfabrics.org/downloads/OFED/ofed-${ofed_version_loc}/"
+ fi
+ # daily build
+ if [[ $ofed_version = *-daily ]]; then
+ ofed_version=${ofed_version/-daily/}
+ location="https://www.openfabrics.org/downloads/OFED/ofed-${ofed_version}-daily/"
+ # find the filename for latest version
+ ofed_version=$(curl -1 -s "$location" | sed -nre "s/.*href=\"OFED-(${ofed_version//./\\.}-[0-9]{8}-[0-9]{4}).tgz.*$/\1/p" | tail -1)
+ if [ -z "$ofed_version" ]; then
+ fatal 1 "Could not determine the filename of the OFED snapshot from daily "
+ fi
+ fi
+
+ file="OFED-${ofed_version}.tgz"
+ download_file "$location/$file" "$KERNELTREE" "$force"
+ ;;
+ mlnx)
+ location="http://www.mellanox.com/downloads/ofed/MLNX_OFED-${ofed_version}"
+ # this is a work around for suse distro (sles11.3). what we need is
+ # sles11sp3. We really need to redesign how we use target and distro
+ [[ $distro_name =~ sles ]] && distro_name=${DISTRO/./sp}
+ file="MLNX_OFED_LINUX-${ofed_version}-${distro_name}-${arch}.tgz"
+ download_file "$location/$file" "$KERNELTREE" "$force"
+ ;;
+ ifs)
+ location="http://downloadmirror.intel.com/24625/eng/"
+ file="IntelIB-Basic.$(echo ${distro_name%%.*} | tr '[:lower:]' '[:upper:]')-${arch}.${ofed_version}.tgz"
+ download_file "$location/$file" "$KERNELTREE" "$force"
+ ;;
+ *)
+ fatal 1 "Error: unknown OFED type: $ofed_type"
+
+ esac
+ # version might change due to detect daily version
+ OFED_VERSION=${ofed_version}