From patchwork Thu Dec 11 22:52:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 420276 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id 016D21400F1 for ; Fri, 12 Dec 2014 09:52:19 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 27CF23400A; Thu, 11 Dec 2014 22:52:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tKWkifDInXXz; Thu, 11 Dec 2014 22:52:16 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 693EB33FF9; Thu, 11 Dec 2014 22:52:16 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 9627A1BFA34 for ; Thu, 11 Dec 2014 22:52:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 910CEA1806 for ; Thu, 11 Dec 2014 22:52:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YuLRmoprVJkd for ; Thu, 11 Dec 2014 22:52:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 6BB75A17FE for ; Thu, 11 Dec 2014 22:52:14 +0000 (UTC) Received: by mail-wi0-f180.google.com with SMTP id n3so872306wiv.1 for ; Thu, 11 Dec 2014 14:52:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=sDB0w8hQSYI832Ub3tIUvzUTwLwX+R5ekowmSqJVejA=; b=CuLxSDm6gFkDGL48WnsUIr2s+ylX2RjZofGS/g18ZdIOWppLJ0F8sSrzUQv6FiWtct 5gUSO6FQUeID8i6jLZ2wx9dmdXAQIZYpcVaUsd0Z3LFNPha3jQpCBs6SzwXIx0DAbMcI 4FMKcBn18nMXn31CZso9z5ngtirYLckbCFaEmB6uK3UQkgr1Bueu0z2K1LRYDTc6Du5V 5e8MEF3yh2W6y5VazNCGu1Ws6X9a+dISHbhvxoguzE3JNqXnHbW41guBvT9IdjtIkvce fHxI7Q2xWzivLSlxaAcKV/ET38hvD7TNYPqKmWe76llvmaTRIevvQaTv/IyYzLI2ssPs 2uwQ== X-Received: by 10.194.235.193 with SMTP id uo1mr20796018wjc.105.1418338333037; Thu, 11 Dec 2014 14:52:13 -0800 (PST) Received: from gourin.bzh.lan (ks3095497.kimsufi.com. [94.23.60.27]) by mx.google.com with ESMTPSA id l3sm3387299wje.12.2014.12.11.14.52.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Dec 2014 14:52:11 -0800 (PST) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Thu, 11 Dec 2014 23:52:06 +0100 Message-Id: <1a5c19dcd6ab7bc036d2e25009a6178a2e0bce53.1418337531.git.yann.morin.1998@free.fr> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Cc: Thomas Petazzoni , "Yann E. MORIN" , Peter Korsgaard Subject: [Buildroot] [PATCH 2/4 v5] pkg-download: check for already downloaded file in the download wrapper X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Instead of repeating the same test again and again in all our download rules, just delegate the check for an already downloaded file to the download wrapper. This clears up the path for doing the hash checks on a cached file before the download. Signed-off-by: "Yann E. MORIN" Cc: Thomas Petazzoni Cc: Peter Korsgaard Cc: Gustavo Zacarias Reviewed-by: Thomas Petazzoni --- package/pkg-download.mk | 8 -------- support/download/dl-wrapper | 5 +++++ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/package/pkg-download.mk b/package/pkg-download.mk index 8424eca..c021e92 100644 --- a/package/pkg-download.mk +++ b/package/pkg-download.mk @@ -96,7 +96,6 @@ endef # Messages for the type of clone used are provided to ease debugging in case of # problems define DOWNLOAD_GIT - test -e $(DL_DIR)/$($(PKG)_SOURCE) || \ $(EXTRA_ENV) $(DL_WRAPPER) -b git \ -o $(DL_DIR)/$($(PKG)_SOURCE) \ -- \ @@ -117,7 +116,6 @@ endef define DOWNLOAD_BZR - test -e $(DL_DIR)/$($(PKG)_SOURCE) || \ $(EXTRA_ENV) $(DL_WRAPPER) -b bzr \ -o $(DL_DIR)/$($(PKG)_SOURCE) \ -- \ @@ -135,7 +133,6 @@ define SHOW_EXTERNAL_DEPS_BZR endef define DOWNLOAD_CVS - test -e $(DL_DIR)/$($(PKG)_SOURCE) || \ $(EXTRA_ENV) $(DL_WRAPPER) -b cvs \ -o $(DL_DIR)/$($(PKG)_SOURCE) \ -- \ @@ -155,7 +152,6 @@ define SHOW_EXTERNAL_DEPS_CVS endef define DOWNLOAD_SVN - test -e $(DL_DIR)/$($(PKG)_SOURCE) || \ $(EXTRA_ENV) $(DL_WRAPPER) -b svn \ -o $(DL_DIR)/$($(PKG)_SOURCE) \ -- \ @@ -176,7 +172,6 @@ endef # Note that filepath is relative to the user's home directory, so you may want # to prepend the path with a slash: scp://[user@]host:/absolutepath define DOWNLOAD_SCP - test -e $(DL_DIR)/$(2) || \ $(EXTRA_ENV) $(DL_WRAPPER) -b scp \ -o $(DL_DIR)/$(2) \ -- \ @@ -194,7 +189,6 @@ endef define DOWNLOAD_HG - test -e $(DL_DIR)/$($(PKG)_SOURCE) || \ $(EXTRA_ENV) $(DL_WRAPPER) -b hg \ -o $(DL_DIR)/$($(PKG)_SOURCE) \ -- \ @@ -215,7 +209,6 @@ endef define DOWNLOAD_WGET - test -e $(DL_DIR)/$(2) || \ $(EXTRA_ENV) $(DL_WRAPPER) -b wget \ -o $(DL_DIR)/$(2) \ -- \ @@ -232,7 +225,6 @@ define SHOW_EXTERNAL_DEPS_WGET endef define DOWNLOAD_LOCALFILES - test -e $(DL_DIR)/$(2) || \ $(EXTRA_ENV) $(DL_WRAPPER) -b cp \ -o $(DL_DIR)/$(2) \ -- \ diff --git a/support/download/dl-wrapper b/support/download/dl-wrapper index f1bb73a..dc5b4b0 100755 --- a/support/download/dl-wrapper +++ b/support/download/dl-wrapper @@ -43,6 +43,11 @@ main() { error "no output specified, use -o\n" fi + # If the output file already exists, do not download it again + if [ -e "${output}" ]; then + exit 0 + fi + # tmpd is a temporary directory in which backends may store intermediate # by-products of the download. # tmpf is the file in which the backends should put the downloaded content.