diff --git a/dist/sources/download-and-copy-drivers.sh b/dist/sources/download-and-copy-drivers.sh index a3386b50c1e0..badaee5ad8fd 100755 --- a/dist/sources/download-and-copy-drivers.sh +++ b/dist/sources/download-and-copy-drivers.sh @@ -10,24 +10,27 @@ check_url_reachable() } thirdparty_mlnx(){ + # This script may run at dist/sources/ directory or drivers/thirdparty/ directory. + # "make dist-srpm" will run dist-drivers in dist/Makefile, which will cd to dist/sources/ dir + # to run download-and-copy-drivers.sh. + # "make dist-rpm" will run BuildConfig in dist/templates/kernel.template.spec, which will cd + # to drivers/thirdparty/ dir to run download-and-copy-drivers.sh. mlnx_tgz_url=$(../../drivers/thirdparty/release-drivers/mlnx/get_mlnx_info.sh mlnx_url) mlnx_tgz_name=$(../../drivers/thirdparty/release-drivers/mlnx/get_mlnx_info.sh mlnx_tgz_name) mlnx_tgz_sha256=$(../../drivers/thirdparty/release-drivers/mlnx/get_mlnx_info.sh mlnx_tgz_sha256) get_mlnx_tgz_ok=1 if [ $(stat -c%s ${mlnx_tgz_name}) -gt 1024 ]; then return 0; fi - mv ${mlnx_tgz_name} ${mlnx_tgz_name}_ori + + rm -f ${mlnx_tgz_name} timeout 900 wget -q $mlnx_tgz_url || get_mlnx_tgz_ok=0 sha256_tmp=$(sha256sum ${mlnx_tgz_name} | awk '{printf $1}') if [[ $sha256_tmp != $mlnx_tgz_sha256 ]]; then get_mlnx_tgz_ok=0; fi if (( $get_mlnx_tgz_ok == 0 )); then - mv -f ${mlnx_tgz_name}_ori ${mlnx_tgz_name} echo "Download MLNX_OFED_LINUX-*.tgz fail!" exit 1 - else - rm -f ${mlnx_tgz_name}_ori fi } diff --git a/dist/templates/kernel.template.spec b/dist/templates/kernel.template.spec index 0229502f2850..5f477f69b6cb 100644 --- a/dist/templates/kernel.template.spec +++ b/dist/templates/kernel.template.spec @@ -632,16 +632,21 @@ case $KernUnameR in # Prepare Kernel config BuildConfig() { # Copy mlnx drivers to drivers/thirdparty/release-drivers/mlnx/ dir + pushd ${_KernSrc}/drivers/thirdparty %if %{with_ofed} - pushd ${_KernSrc}/drivers/thirdparty rm -f download-and-copy-drivers.sh; cp -a %{SOURCE3000} ./ - if [ -e ../../dist/sources ]; then - ./copy-drivers.sh - else + ## Real MLNX_OFED_LINUX-*.tgz will more than 1024 bytes. + ## Dummy MLNX_OFED_LINUX-*.tgz will less than 1024 bytes. + if [ $(stat -c%s %{SOURCE3001}) -gt 1024 ]; then cp -a %{SOURCE3001} release-drivers/mlnx/ + ./copy-drivers.sh without_mlnx + else + ./copy-drivers.sh fi - popd + %else + ./copy-drivers.sh without_mlnx %endif + popd mkdir -p $_KernBuild pushd $_KernBuild diff --git a/drivers/thirdparty/copy-drivers.sh b/drivers/thirdparty/copy-drivers.sh index 9180b7876204..2aa3d00c5c1f 100755 --- a/drivers/thirdparty/copy-drivers.sh +++ b/drivers/thirdparty/copy-drivers.sh @@ -1,24 +1,17 @@ #!/bin/bash -thirdparty_prepare_source_code(){ +thirdparty_mlnx(){ mlnx_tgz_name=$(release-drivers/mlnx/get_mlnx_info.sh mlnx_tgz_name) if [ ! -e release-drivers/mlnx/${mlnx_tgz_name} ] ; then - ## This script will only be called when existing ../../dist/sources dir - if [ $(stat -c%s ../../dist/sources/${mlnx_tgz_name}) -lt 1024 ]; then - ## Real MLNX_OFED_LINUX-*.tgz will more than 1024 bytes. - ## Real MLNX_OFED_LINUX-*.tgz will more than 1024 bytes. - pushd ../../dist/sources - ./download-and-copy-drivers.sh - popd - fi - cp -a ../../dist/sources/${mlnx_tgz_name} release-drivers/mlnx/ + ./download-and-copy-drivers.sh + mv ${mlnx_tgz_name} release-drivers/mlnx/ fi } thirdparty_bnxt(){ if [ -e release-drivers/bnxt ]; then - rm -rf ../../drivers/net/thirdparty_bnxtethernet/broadcom/bnxt + rm -rf ../../drivers/net/ethernet/broadcom/bnxt cp -a release-drivers/bnxt ../../drivers/net/ethernet/broadcom/ ## Use sed to replace "&& BNXT" with "&& BNXT && !THIRDPARTY_BNXT" in @@ -32,6 +25,8 @@ thirdparty_bnxt(){ ## ## main , script start run at here. ## -thirdparty_prepare_source_code +if [[ $1 != without_mlnx ]]; then + thirdparty_mlnx +fi thirdparty_bnxt