Whamcloud - gitweb
LU-8636 build: prevent src download at the same time 39/22939/7
authorMinh Diep <minh.diep@intel.com>
Tue, 4 Oct 2016 22:11:36 +0000 (15:11 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 20 Oct 2016 10:39:30 +0000 (10:39 +0000)
If the lbuild kernelsrc/kernelrpm directory is shared
among the builders, we need to keep them from using
it while it's being downloaded

Test-Parameters: trivial

Change-Id: I240996c84ea541f5985b8d6ec73e3c6a56d2d805
Signed-off-by: Minh Diep <minh.diep@intel.com>
Reviewed-on: http://review.whamcloud.com/22939
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
contrib/lbuild/lbuild

index cac706e..f4f43d5 100755 (executable)
@@ -445,36 +445,27 @@ fetch_url() {
 }
 
 download_srpm() {
-    local target=$1
-    local srpm=$2
-    local force="${3:-false}"
-
-    if $force || [ ! -r "$KERNELDIR/$srpm" ] ||
-       [ ! -s "$KERNELDIR/$srpm" ]; then
-        if $DOWNLOAD; then
-            local location="https://downloads.hpdd.intel.com/public/kernels/$target/old"
-            # get the location from a distro specific method if it exists
-            if type -p kernel_srpm_location; then
-                location=$(kernel_srpm_location)
-            fi
-            echo "Downloading $location/$srpm..."
-            if ! fetch_url "$location/$srpm" "$KERNELDIR/$srpm" 2>&1 ||
-               [ ! -s "$KERNELDIR/$srpm" ]; then
-                rm -f $KERNELDIR/$srpm
-                # punt to a distro specific method if it exists
-                if ! type -p download_srpm-$DISTROMAJ; then
-                    fatal 1 "Could not download target $target's kernel SRPM $srpm from $location."
-                else
-                    if ! download_srpm-$DISTROMAJ "$target" "$srpm" "$force"; then
-                        fatal 1 "Could not download target $target's kernel SRPM $srpm using download_srpm-$DISTROMAJ."
-                    fi
-                fi
-            fi
-        else
-            fatal 1 "$srpm not found in directory $KERNELDIR."
-        fi
-    fi
-
+       local target=$1
+       local srpm=$2
+       local force="${3:-false}"
+
+       # let the download_file handle the concurrency
+       if $DOWNLOAD; then
+               local location= \
+               "https://downloads.hpdd.intel.com/public/kernels/$target/old"
+               # get the location from a distro specific method if it exists
+               if type -p kernel_srpm_location; then
+                       location=$(kernel_srpm_location)
+               fi
+               echo "Downloading $location/$srpm..."
+               if ! download_file \
+                       "$location/$srpm" "$KERNELDIR/$srpm" "$force" 2>&1 ||
+                       [ ! -s "$KERNELDIR/$srpm" ]; then
+                       rm -f $KERNELDIR/$srpm
+                       fatal 1 "Could not download target $target's kernel \
+SRPM $srpm from $location."
+               fi
+       fi
 }
 
 download_file() {
@@ -1379,10 +1370,8 @@ build_kernel_with_srpm() {
     if ! $USE_BUILD_CACHE || ! reuse kernel "$TOPDIR" "$CAN_LINK_FOR_REUSE" \
                                    "$REUSE_SIGNATURE"; then
         # nothing cached, build from scratch
-        if [ ! -r "$KERNELDIR/$KERNEL_SRPM" ]; then
-            echo "Downloading kernel SRPM" >&${outfd}
-            download_srpm "$CANONICAL_TARGET" "$KERNEL_SRPM" >&${outfd}
-        fi
+       echo "Downloading kernel SRPM" >&${outfd}
+       download_srpm "$CANONICAL_TARGET" "$KERNEL_SRPM" >&${outfd}
 
         if ! rpm -ivh $KERNELDIR/$KERNEL_SRPM \
                   --define "_topdir $TOPDIR" >&${outfd} 2>&1; then