From patchwork Sun Jan 12 23:44:45 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: 309658 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 EECE72C0098 for ; Mon, 13 Jan 2014 10:45:05 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 264F08B73F; Sun, 12 Jan 2014 23:45:04 +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 J3BNj8JMUptg; Sun, 12 Jan 2014 23:45:01 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 57B988B74F; Sun, 12 Jan 2014 23:45:00 +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 E2AC91BF841 for ; Sun, 12 Jan 2014 23:44:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id D9BEE8BA54 for ; Sun, 12 Jan 2014 23:44:56 +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 9rP9nyMmKLEl for ; Sun, 12 Jan 2014 23:44:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-we0-f179.google.com (mail-we0-f179.google.com [74.125.82.179]) by whitealder.osuosl.org (Postfix) with ESMTPS id CE3558BA87 for ; Sun, 12 Jan 2014 23:44:54 +0000 (UTC) Received: by mail-we0-f179.google.com with SMTP id w62so741774wes.38 for ; Sun, 12 Jan 2014 15:44:53 -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=4N3izIK8keDiuVb9FF3IrIVtAw6pbgdk99V95TlE0+A=; b=ZvMhWKrJqq9nL77X3M35oi3WOht4V9YJ3y1W1DNS9sYw6oi1vqohlb9ALxKRocoKkG YopTvLeET9Bkl5O1uaNSzRwybKUJKTeECJQhDUCBSQXf4E4tWeQec+bHCN3dlkMn1gEJ mp2eP4czFZtyGSwuI/Q7VQ6/tynLluIJYMxy+pSzCDfkfnIOqaZREG2PYiv50p1lrT4m JvA3n0Lif945qHl41OrAAUBvFspFlFuWeHQop2In8neoYwroKzYwPn0KcbTrl0xEC0ix FBq6ZEXGQwz+L5mK7Rhs4bZwm36cswStvZagmlZnFhPGUgaJSIdSxk5wToWHkGsUm9AC dOuA== X-Received: by 10.194.174.197 with SMTP id bu5mr80531wjc.71.1389570293294; Sun, 12 Jan 2014 15:44:53 -0800 (PST) Received: from gourin.bzh.lan (ks3095497.kimsufi.com. [94.23.60.27]) by mx.google.com with ESMTPSA id z2sm14900365wiy.11.2014.01.12.15.44.52 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 12 Jan 2014 15:44:52 -0800 (PST) From: "Yann E. MORIN" To: buildroot@busybox.net Date: Mon, 13 Jan 2014 00:44:45 +0100 Message-Id: X-Mailer: git-send-email 1.8.1.2 In-Reply-To: References: Cc: Thomas Petazzoni , "Yann E. MORIN" , Peter Korsgaard Subject: [Buildroot] [PATCH 2/6] pkg-infra: move git 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 From: "Yann E. MORIN" The git download helper is getting a bit more complex, and does not raise an error when a PKG_VERSION is a sha1 that does not exist in the repository. Instead, it generates an empty archive. Fixing it in the Makefile proves to be challenging, to say the least. Move it into a shell script in support/download/git, which will make it much easier to read, maintain, fix an enhance in the future. Signed-off-by: "Yann E. MORIN" Cc: Peter Korsgaard Cc: Thomas Petazzoni Acked-by: Luca Ceresoli --- package/pkg-download.mk | 16 +++------------- support/download/git | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 13 deletions(-) create mode 100755 support/download/git diff --git a/package/pkg-download.mk b/package/pkg-download.mk index c00689b..8e6f7a3 100644 --- a/package/pkg-download.mk +++ b/package/pkg-download.mk @@ -12,7 +12,7 @@ WGET := $(call qstrip,$(BR2_WGET)) $(QUIET) SVN := $(call qstrip,$(BR2_SVN)) CVS := $(call qstrip,$(BR2_CVS)) BZR := $(call qstrip,$(BR2_BZR)) -GIT := $(call qstrip,$(BR2_GIT)) +export GIT := $(call qstrip,$(BR2_GIT)) HG := $(call qstrip,$(BR2_HG)) $(QUIET) SCP := $(call qstrip,$(BR2_SCP)) $(QUIET) SSH := $(call qstrip,$(BR2_SSH)) $(QUIET) @@ -84,18 +84,8 @@ github = https://github.com/$(1)/$(2)/tarball/$(3) # problems define DOWNLOAD_GIT test -e $(DL_DIR)/$($(PKG)_SOURCE) || \ - (pushd $(DL_DIR) > /dev/null && \ - ((test "`git ls-remote $($(PKG)_SITE) $($(PKG)_DL_VERSION)`" && \ - echo "Doing shallow clone" && \ - $(GIT) clone --depth 1 -b $($(PKG)_DL_VERSION) --bare $($(PKG)_SITE) $($(PKG)_BASE_NAME)) || \ - (echo "Doing full clone" && \ - $(GIT) clone --bare $($(PKG)_SITE) $($(PKG)_BASE_NAME))) && \ - pushd $($(PKG)_BASE_NAME) > /dev/null && \ - $(GIT) archive --format=tar --prefix=$($(PKG)_BASE_NAME)/ $($(PKG)_DL_VERSION) | \ - gzip -c > $(DL_DIR)/$($(PKG)_SOURCE) && \ - popd > /dev/null && \ - rm -rf $($(PKG)_DL_DIR) && \ - popd > /dev/null) + $(EXTRA_ENV) support/download/git $($(PKG)_SITE) $($(PKG)_DL_VERSION) \ + $($(PKG)_BASE_NAME)/ $(DL_DIR)/$($(PKG)_SOURCE) endef # TODO: improve to check that the given PKG_DL_VERSION exists on the remote diff --git a/support/download/git b/support/download/git new file mode 100755 index 0000000..99ea1b2 --- /dev/null +++ b/support/download/git @@ -0,0 +1,36 @@ +#!/bin/sh +set -e + +# Download helper for git +# Call it with: +# $1: git repo +# $2: git cset +# $3: prefix/ +# $4: output file +# And this environment: +# GIT : the git command to call +# BUILD_DIR: path to Buildroot's build dir + +repo="${1}" +cset="${2}" +prefix="${3}" +output="${4}" + +pushd "${BUILD_DIR}" >/dev/null +rm -rf .git-tmp-repo # In case a previous attempt was interrupted + +if [ -n "$(${GIT} ls-remote "${repo}" "${cset}" 2>&1)" ]; then + printf "Doing shallow clone\n" + ${GIT} clone --depth 1 -b "${cset}" --bare "${repo}" .git-tmp-repo +else + printf "Doing full clone\n" + ${GIT} clone --bare "${repo}" .git-tmp-repo +fi + +pushd .git-tmp-repo >/dev/null +${GIT} archive --prefix="${prefix}" --format=tar "${cset}" \ +|gzip -c >"${output}" +popd >/dev/null + +rm -rf .git-tmp-repo +popd >/dev/null