From 25352208642a62c23c84245ef64709c38d694b5c Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 5 Apr 2018 18:46:34 +0200 Subject: [PATCH] mk: add tarball support License: MIT Signed-off-by: Jakub Sztandera --- .gitignore | 5 +++++ Rules.mk | 2 ++ bin/maketarball.sh | 22 ++++++++++++++++++++++ cmd/ipfs/Rules.mk | 2 +- mk/git.mk | 1 + mk/gx.mk | 3 +++ mk/tarball.mk | 13 +++++++++++++ 7 files changed, 47 insertions(+), 1 deletion(-) create mode 100755 bin/maketarball.sh create mode 100644 mk/git.mk create mode 100644 mk/tarball.mk diff --git a/.gitignore b/.gitignore index a711c7f81f9..1e21b5cc2fe 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,8 @@ gx-workspace-update.json bin/gx bin/gx* bin/tmp + + +vendor +.tarball +go-ipfs-source.tar.gz diff --git a/Rules.mk b/Rules.mk index c89f186accb..864002d4913 100644 --- a/Rules.mk +++ b/Rules.mk @@ -8,6 +8,8 @@ TEST_SHORT := all: help # all has to be first defined target .PHONY: all +include mk/git.mk # has to be before tarball.mk +include mk/tarball.mk include mk/util.mk include mk/golang.mk include mk/gx.mk diff --git a/bin/maketarball.sh b/bin/maketarball.sh new file mode 100755 index 00000000000..7d28d70a748 --- /dev/null +++ b/bin/maketarball.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# vim: set expandtab sw=2 ts=2: + +# bash safe mode +set -euo pipefail +IFS=$'\n\t' + + +OUTPUT=$(realpath ${1:-go-ipfs-source.tar.gz}) + +TMPDIR="$(mktemp -d)" +NEWIPFS="$TMPDIR/github.com/ipfs/go-ipfs" +mkdir -p "$NEWIPFS" +cp -r . "$NEWIPFS" +( cd "$NEWIPFS" && + echo $PWD && + GOPATH="$TMPDIR" gx install --local && + (git rev-parse --short HEAD || true) > .tarball && + tar -czf "$OUTPUT" --exclude="./.git" . +) + +rm -rf "$TMPDIR" diff --git a/cmd/ipfs/Rules.mk b/cmd/ipfs/Rules.mk index 175b098eea2..2a5b07edfb9 100644 --- a/cmd/ipfs/Rules.mk +++ b/cmd/ipfs/Rules.mk @@ -13,7 +13,7 @@ PATH := $(realpath $(d)):$(PATH) # DEPS_OO_$(d) += merkledag/pb/merkledag.pb.go namesys/pb/namesys.pb.go # DEPS_OO_$(d) += pin/internal/pb/header.pb.go unixfs/pb/unixfs.pb.go -$(d)_flags =-ldflags="-X "github.com/ipfs/go-ipfs/repo/config".CurrentCommit=$(shell git rev-parse --short HEAD)" +$(d)_flags =-ldflags="-X "github.com/ipfs/go-ipfs/repo/config".CurrentCommit=$(git-hash)" $(d)-try-build $(IPFS_BIN_$(d)): GOFLAGS += $(cmd/ipfs_flags) diff --git a/mk/git.mk b/mk/git.mk new file mode 100644 index 00000000000..010f92a5315 --- /dev/null +++ b/mk/git.mk @@ -0,0 +1 @@ +git-commit:=$(shell git rev-parse --short HEAD 2>/dev/null) diff --git a/mk/gx.mk b/mk/gx.mk index cd38c78484f..8f1744f2684 100644 --- a/mk/gx.mk +++ b/mk/gx.mk @@ -7,5 +7,8 @@ gx-deps: ifneq ($(IPFS_GX_USE_GLOBAL),1) gx-deps: bin/gx bin/gx-go endif +.PHONY: gx-deps +ifeq ($(tarball-is),0) DEPS_GO += gx-deps +endif diff --git a/mk/tarball.mk b/mk/tarball.mk new file mode 100644 index 00000000000..0c72988d104 --- /dev/null +++ b/mk/tarball.mk @@ -0,0 +1,13 @@ + + +ifeq (,$(wildcard .tarball)) +tarball-is:=0 +else +tarball-is:=1 +# override git hash +git-hash:=$(shell cat .tarball) +endif + + +go-ipfs-source.tar.gz: distclean + bin/maketarball.sh $@