From patchwork Mon Jun 30 22:26:25 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: 365786 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ozlabs.org (Postfix) with ESMTP id E5B2D140116 for ; Tue, 1 Jul 2014 08:27:02 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 38D838B61A; Mon, 30 Jun 2014 22:26:57 +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 MFPH_gOW9fYG; Mon, 30 Jun 2014 22:26:56 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 20F3C8B1E4; Mon, 30 Jun 2014 22:26:52 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 0821C1C1654 for ; Mon, 30 Jun 2014 22:26:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 03D34321A6 for ; Mon, 30 Jun 2014 22:26:45 +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 ggzQRVETLDxh for ; Mon, 30 Jun 2014 22:26:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by silver.osuosl.org (Postfix) with ESMTPS id 1FB3031E0F for ; Mon, 30 Jun 2014 22:26:43 +0000 (UTC) Received: by mail-we0-f182.google.com with SMTP id q59so8877648wes.27 for ; Mon, 30 Jun 2014 15:26:42 -0700 (PDT) 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=GxKq+GRwUs26VaXShyVlegymZ54Ko7l3TJJfVc6SQfA=; b=rcxo0OVnupsNX+bKC5UM5iWml7CyYea/w9oU1w7Nq4dXiGnko4/osprjknz9SZ7nbt ANbtfDI7c1E9v+kRor4FmVd/vTdpp7yo04Qn2HnI7EUUPAkozPV+A6nDdhAkc7EkRFPw 7NdNUcPK7Wc2ik0BGqOsU7P9QgcUvmMUcrLofAYZlrpEexsdeSAJsNpk9s7gEdU1L/rf 1YEjSl520sz49JoUJywVcfXo1VBTum/mumcGXH6QAs8w6ZnsAnVSXcx2xIT/1wyn+ZKQ 5FfSWcdhNU0xVv452FBn6i2JUXK5T7uLCX88pi/l8R/bW8es/fRcv1MdSEdkdNulFtFC CKbw== X-Received: by 10.180.109.168 with SMTP id ht8mr31818551wib.68.1404167202499; Mon, 30 Jun 2014 15:26:42 -0700 (PDT) Received: from gourin.bzh.lan (ks3095497.kimsufi.com. [94.23.60.27]) by mx.google.com with ESMTPSA id o12sm36042951wiw.5.2014.06.30.15.26.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Jun 2014 15:26:41 -0700 (PDT) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Tue, 1 Jul 2014 00:26:25 +0200 Message-Id: <5b7f846b8d3e7f210a95a7a8e1bee0f625eef326.1404167061.git.yann.morin.1998@free.fr> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Cc: "Yann E. MORIN" Subject: [Buildroot] [PATCH 07/14] pkg-infra: move the wget download helper to a script X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 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-bounces@busybox.net Maintaining the download helpers in the Makefile has proved to be a bit complex, so move it to a shell script. Signed-off-by: "Yann E. MORIN" Reviewed-by: Samuel Martin --- package/pkg-download.mk | 13 +++---------- support/download/wget | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 10 deletions(-) create mode 100755 support/download/wget diff --git a/package/pkg-download.mk b/package/pkg-download.mk index 3290b6b..7554582 100644 --- a/package/pkg-download.mk +++ b/package/pkg-download.mk @@ -8,7 +8,7 @@ ################################################################################ # Download method commands -WGET := $(call qstrip,$(BR2_WGET)) $(QUIET) +export WGET := $(call qstrip,$(BR2_WGET)) $(QUIET) export SVN := $(call qstrip,$(BR2_SVN)) export CVS := $(call qstrip,$(BR2_CVS)) BZR := $(call qstrip,$(BR2_BZR)) @@ -175,17 +175,10 @@ define SHOW_EXTERNAL_DEPS_HG echo $($(PKG)_SOURCE) endef -# Download a file using wget. Only download the file if it doesn't -# already exist in the download directory. If the download fails, -# remove the file (because wget -O creates a 0-byte file even if the -# download fails). To handle an interrupted download as well, download -# to a temporary file first. The temporary file will be overwritten -# the next time the download is tried. + define DOWNLOAD_WGET test -e $(DL_DIR)/$(2) || \ - ($(WGET) -O $(DL_DIR)/$(2).tmp '$(call qstrip,$(1))' && \ - mv $(DL_DIR)/$(2).tmp $(DL_DIR)/$(2)) || \ - (rm -f $(DL_DIR)/$(2).tmp ; exit 1) + $(EXTRA_ENV) support/download/wget '$(call qstrip,$(1))' $(DL_DIR)/$(2) endef define SOURCE_CHECK_WGET diff --git a/support/download/wget b/support/download/wget new file mode 100755 index 0000000..7865517 --- /dev/null +++ b/support/download/wget @@ -0,0 +1,21 @@ +#!/bin/sh + +# We want to catch any command failure, and exit immediately +set -e + +# Download helper for wget +# Call it with: +# $1: URL +# $2: output file +# And this environment: +# WGET : the wget command to call + +url="${1}" +output="${2}" + +if ${WGET} -O "${output}.tmp" "${url}"; then + mv "${output}.tmp" "${output}" +else + rm -f "${output}.tmp" + exit 1 +fi