From patchwork Sun Aug 3 17:53:39 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: 376081 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ozlabs.org (Postfix) with ESMTP id 29C571400A3 for ; Mon, 4 Aug 2014 03:54:38 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 4752D8B8BD; Sun, 3 Aug 2014 17:54:37 +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 GRz1vKAQgrN1; Sun, 3 Aug 2014 17:54:33 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 127058BD8A; Sun, 3 Aug 2014 17:54:08 +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 A88D61C1059 for ; Sun, 3 Aug 2014 17:54:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 9DD258AF3F for ; Sun, 3 Aug 2014 17:54:05 +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 Q5Ukmu3gVtRv for ; Sun, 3 Aug 2014 17:53:59 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by whitealder.osuosl.org (Postfix) with ESMTPS id 54B828B15C for ; Sun, 3 Aug 2014 17:53:53 +0000 (UTC) Received: by mail-wi0-f182.google.com with SMTP id d1so3815606wiv.9 for ; Sun, 03 Aug 2014 10:53:51 -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=snKCtIYxUWtEjEeDpyyCboklXZ/JO21B48HX3VqW4Gc=; b=LAYqOzjJ/9txwnVe3HZe/ANFMc45jsPYUoWxE+tsTBbTt2YJqWqh2VeY01zeOLIaxA 60cFrxPb51x2xaJfKpHl33Q67byvIMfMSgyitqEWQAdSYUHoKmpxogl2vymgaGu2lBEu 4w5PYIM+LZ7s+o5aGQarm7V/gBfvmByz9KdeDwMsU2ApUBsC8KuJTVXk6bO4zyE8tsFU GCacT7oX/WXR/qYLCoBR+CbmuRy8UEnog7yEzMYUWDbfpwSZ+ts9VMaAHbYb/YM84FVM 8RBky8vvXKr8pyUHcC1Su5Pk/poS4cVfdibAmereXTP7Q8NRtAO5VQcr1LHhc/zStZpl 3OXw== X-Received: by 10.180.187.197 with SMTP id fu5mr23652016wic.64.1407088431890; Sun, 03 Aug 2014 10:53:51 -0700 (PDT) Received: from gourin.bzh.lan (ks3095497.kimsufi.com. [94.23.60.27]) by mx.google.com with ESMTPSA id fc7sm37336190wjc.37.2014.08.03.10.53.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 03 Aug 2014 10:53:51 -0700 (PDT) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Sun, 3 Aug 2014 19:53:39 +0200 Message-Id: <0ff18dfb028d5181c9b2db1a48b5e8ee916f9656.1407088287.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 6/9 v4] support/download: convert Hg to use the wrapper 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 This drastically simplifies the hg helper, as it no longer has to deal with atomically saving the downloaded archive. Signed-off-by: "Yann E. MORIN" Tested-by: Thomas De Schampheleire (Tested by running 'make vim-source') --- Changes v3 -> v4: - tweak the usage comment (Thomas DS) --- package/pkg-download.mk | 7 +++++-- support/download/hg | 52 ++++++++++++++----------------------------------- 2 files changed, 20 insertions(+), 39 deletions(-) diff --git a/package/pkg-download.mk b/package/pkg-download.mk index 1649c83..7878c66 100644 --- a/package/pkg-download.mk +++ b/package/pkg-download.mk @@ -184,8 +184,11 @@ endef define DOWNLOAD_HG test -e $(DL_DIR)/$($(PKG)_SOURCE) || \ - $(EXTRA_ENV) support/download/hg $($(PKG)_SITE) $($(PKG)_DL_VERSION) \ - $($(PKG)_BASE_NAME) $(DL_DIR)/$($(PKG)_SOURCE) + $(EXTRA_ENV) support/download/wrapper hg \ + $(DL_DIR)/$($(PKG)_SOURCE) \ + $($(PKG)_SITE) \ + $($(PKG)_DL_VERSION) \ + $($(PKG)_BASE_NAME) endef # TODO: improve to check that the given PKG_DL_VERSION exists on the remote diff --git a/support/download/hg b/support/download/hg index 6e9e26b..747dd34 100755 --- a/support/download/hg +++ b/support/download/hg @@ -1,46 +1,24 @@ #!/bin/bash -# We want to catch any command failure, and exit immediately +# We want to catch any unexpected failure, and exit immediately set -e -# Download helper for hg -# Call it with: -# $1: hg repo -# $2: hg cset -# $3: package's basename (eg. foobar-1.2.3) -# $4: output file +# Download helper for hg, to be called from the download wrapper script +# Expected arguments: +# $1: output file +# $2: hg repo +# $3: hg cset +# $4: package's basename (eg. foobar-1.2.3) # And this environment: # HG : the hg command to call -# BUILD_DIR: path to Buildroot's build dir -repo="${1}" -cset="${2}" -basename="${3}" -output="${4}" +output="${1}" +repo="${2}" +cset="${3}" +basename="${4}" -repodir="${basename}.tmp-hg-checkout" -tmp_output="$( mktemp "${output}.XXXXXX" )" +${HG} clone --noupdate --rev "${cset}" "${repo}" "${basename}" -cd "${BUILD_DIR}" -# Remove leftovers from a previous failed run -rm -rf "${repodir}" - -# Play tic-tac-toe with temp files -# - first, we download to a trashable location (the build-dir) -# - then we create a temporary tarball in the final location, so it is -# on the same filesystem as the final file -# - finally, we atomically rename to the final file - -ret=1 -if ${HG} clone --noupdate --rev "${cset}" "${repo}" "${repodir}"; then - if ${HG} archive --repository "${repodir}" --type tgz \ - --prefix "${basename}" --rev "${cset}" \ - "${tmp_output}"; then - mv "${tmp_output}" "${output}" - ret=0 - fi -fi - -# Cleanup -rm -rf "${repodir}" "${tmp_output}" -exit ${ret} +${HG} archive --repository "${basename}" --type tgz \ + --prefix "${basename}" --rev "${cset}" \ + "${output}"