From 4852e26a1344c407ec8a13e4d3bc77fe7a590c52 Mon Sep 17 00:00:00 2001 From: Minh Diep Date: Tue, 4 Oct 2016 15:11:36 -0700 Subject: [PATCH] LU-8636 build: prevent src download at the same time 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 Reviewed-on: http://review.whamcloud.com/22939 Reviewed-by: Dmitry Eremin Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bob Glossman Reviewed-by: Oleg Drokin --- contrib/lbuild/lbuild | 57 +++++++++++++++++++++------------------------------ 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/contrib/lbuild/lbuild b/contrib/lbuild/lbuild index cac706e..f4f43d5 100755 --- a/contrib/lbuild/lbuild +++ b/contrib/lbuild/lbuild @@ -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 -- 1.8.3.1