From patchwork Thu Dec 11 18:24:46 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: 420214 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ozlabs.org (Postfix) with ESMTP id 89A391400EA for ; Fri, 12 Dec 2014 05:25:00 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id C9FDB96078; Thu, 11 Dec 2014 18:24:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6M4WKg9SZ6pL; Thu, 11 Dec 2014 18:24:58 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 1519B89E76; Thu, 11 Dec 2014 18:24:58 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 6630E1C2854 for ; Thu, 11 Dec 2014 18:24:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 62DC892586 for ; Thu, 11 Dec 2014 18:24:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 41-LXPtnmKxw for ; Thu, 11 Dec 2014 18:24:54 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by whitealder.osuosl.org (Postfix) with ESMTPS id 2EEF592580 for ; Thu, 11 Dec 2014 18:24:54 +0000 (UTC) Received: by mail-wi0-f181.google.com with SMTP id r20so181756wiv.8 for ; Thu, 11 Dec 2014 10:24:52 -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=3SWol97ytBC78U2kHldbf/ZOc759Dcj039yr2CupYDs=; b=MHIjpnz+OnPC6HS3krGwPKuVmt99rUBMqClT2jyQwGWaSt/YjIjSW2nzT6nQJk77uh fgyui80IFlOSoMg3oLyvGho/37S6fYkfIby7SY1s+9wY5xfpIHaVwTD4Wa+kpDrhQ24O 362qbeH/Y1WqW3TM2nj0Br3kZUrHtS2NrwneZFp1L2kq6mqrYau5uT9Of0GpvUcDnfS+ JDkR9nIznRq15idYC2GjYfWn16+uPVZnGMvYQqGWMSU0tOpSitqlxlLm12QL5Co4uR6V 3a4JLxvCTjJtaZPQ3x+eJ3tqMQ95lg9aIpyuOFen+D8M2pdt+ytB9DHmFa4DfwJs2cOd gUjA== X-Received: by 10.194.235.193 with SMTP id uo1mr19010580wjc.105.1418322292702; Thu, 11 Dec 2014 10:24:52 -0800 (PST) Received: from gourin.bzh.lan (ks3095497.kimsufi.com. [94.23.60.27]) by mx.google.com with ESMTPSA id l3sm2668776wje.12.2014.12.11.10.24.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Dec 2014 10:24:52 -0800 (PST) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Thu, 11 Dec 2014 19:24:46 +0100 Message-Id: <09c8290b9f3c9bb15d9fd72617d0aeeb9cd861e4.1418322200.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 v4] 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 b1b9158..8713424 100755 --- a/support/download/dl-wrapper +++ b/support/download/dl-wrapper @@ -49,6 +49,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.