[lxc-devel] [distrobuilder/master] Makefile: Add dist target

monstermunchkin on Github lxc-bot at linuxcontainers.org
Mon Oct 21 07:02:55 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20191021/78dbd4fe/attachment.bin>
-------------- next part --------------
From 3721b86fb1a932c35d7020cc2b4de27b948b29a2 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Mon, 21 Oct 2019 09:01:45 +0200
Subject: [PATCH] Makefile: Add dist target

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 Makefile | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 11fea26..98e4b7c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,7 @@
-.PHONY: default check
+VERSION=$(shell grep "var Version" shared/version/version.go | cut -d'"' -f2)
+ARCHIVE=distrobuidler-$(VERSION).tar
+
+.PHONY: default check dist
 
 default:
 	gofmt -s -w .
@@ -13,3 +16,28 @@ check: default
 	golint -set_exit_status ./...
 	deadcode ./
 	go vet ./...
+
+dist:
+	# Cleanup
+	rm -Rf $(ARCHIVE).gz
+
+	# Create build dir
+	$(eval TMP := $(shell mktemp -d))
+	git archive --prefix=distrobuilder-$(VERSION)/ HEAD | tar -x -C $(TMP)
+	mkdir -p $(TMP)/_dist/src/github.com/lxc
+	ln -s ../../../../distrobuilder-$(VERSION) $(TMP)/_dist/src/github.com/lxc/distrobuilder
+
+	# Download dependencies
+	cd $(TMP)/distrobuilder-$(VERSION) && GOPATH=$(TMP)/_dist go get -t -v -d ./...
+
+	# Write a manifest
+	cd $(TMP)/_dist && find . -type d -name .git | while read line; do GITDIR=$$(dirname $$line); echo "$${GITDIR}: $$(cd $${GITDIR} && git show-ref HEAD $${GITDIR} | cut -d' ' -f1)"; done | sort > $(TMP)/_dist/MANIFEST
+
+	# Assemble tarball
+	rm $(TMP)/_dist/src/github.com/lxc/distrobuilder
+	ln -s ../../../../ $(TMP)/_dist/src/github.com/lxc/distrobuilder
+	mv $(TMP)/_dist $(TMP)/distrobuilder-$(VERSION)/
+	tar --exclude-vcs -C $(TMP) -zcf $(ARCHIVE).gz distrobuilder-$(VERSION)/
+
+	# Cleanup
+	rm -Rf $(TMP)


More information about the lxc-devel mailing list