[lxc-devel] [lxd/master] Improve `dist` tarball

stgraber on Github lxc-bot at linuxcontainers.org
Tue Jul 16 15:26:56 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190716/6e27850b/attachment.bin>
-------------- next part --------------
From 8369930e1e71cdb74a6043cd166b932796f2b56e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 16 Jul 2019 10:45:21 -0400
Subject: [PATCH 1/2] Makefile: Make it easier to build from tarball
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #5965

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 Makefile | 41 +++++++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 16 deletions(-)

diff --git a/Makefile b/Makefile
index 691209a041..bfedf4a0c9 100644
--- a/Makefile
+++ b/Makefile
@@ -34,22 +34,26 @@ lxd-p2c:
 deps:
 	# sqlite
 	@if [ -d "$(GOPATH)/deps/sqlite" ]; then \
-		cd "$(GOPATH)/deps/sqlite"; \
-		git pull; \
+		if [ -d "$(GOPATH)/deps/sqlite/.git" ]; then \
+			cd "$(GOPATH)/deps/sqlite"; \
+			git pull; \
+		fi; \
 	else \
 		git clone --depth=1 "https://github.com/CanonicalLtd/sqlite" "$(GOPATH)/deps/sqlite"; \
+		git log -1 --format="format:%ci%n" | sed -e 's/ [-+].*$$//;s/ /T/;s/^/D /' > manifest; \
+		git log -1 --format="format:%H" > manifest.uuid; \
 	fi
 
 	cd "$(GOPATH)/deps/sqlite" && \
 		./configure --enable-replication --disable-amalgamation --disable-tcl && \
-		git log -1 --format="format:%ci%n" | sed -e 's/ [-+].*$$//;s/ /T/;s/^/D /' > manifest && \
-		git log -1 --format="format:%H" > manifest.uuid && \
 		make
 
 	# libco
 	@if [ -d "$(GOPATH)/deps/libco" ]; then \
-		cd "$(GOPATH)/deps/libco"; \
-		git pull; \
+		if [ -d "$(GOPATH)/deps/libco/.git" ]; then \
+			cd "$(GOPATH)/deps/libco"; \
+			git pull; \
+		fi; \
 	else \
 		git clone --depth=1 "https://github.com/freeekanayaka/libco" "$(GOPATH)/deps/libco"; \
 	fi
@@ -59,8 +63,10 @@ deps:
 
 	# raft
 	@if [ -d "$(GOPATH)/deps/raft" ]; then \
-		cd "$(GOPATH)/deps/raft"; \
-		git pull; \
+		if [ -d "$(GOPATH)/deps/raft/.git" ]; then \
+			cd "$(GOPATH)/deps/raft"; \
+			git pull; \
+		fi; \
 	else \
 		git clone --depth=1 "https://github.com/CanonicalLtd/raft" "$(GOPATH)/deps/raft"; \
 	fi
@@ -72,8 +78,10 @@ deps:
 
 	# dqlite
 	@if [ -d "$(GOPATH)/deps/dqlite" ]; then \
-		cd "$(GOPATH)/deps/dqlite"; \
-		git pull; \
+		if [ -d "$(GOPATH)/deps/dqlite/.git" ]; then \
+			cd "$(GOPATH)/deps/dqlite"; \
+			git pull; \
+		fi; \
 	else \
 		git clone --depth=1 "https://github.com/CanonicalLtd/dqlite" "$(GOPATH)/deps/dqlite"; \
 	fi
@@ -140,12 +148,13 @@ dist:
 	cd $(TMP)/lxd-$(VERSION) && GOPATH=$(TMP)/dist go get -t -v -d ./...
 
 	# Download the cluster-enabled sqlite/dqlite
-	git clone --depth=1 https://github.com/CanonicalLtd/dqlite $(TMP)/dist/dqlite
-	git clone --depth=1 https://github.com/CanonicalLtd/sqlite $(TMP)/dist/sqlite
-	git clone --depth=1 https://github.com/freeekanayaka/libco $(TMP)/dist/libco
-	git clone --depth=1 https://github.com/CanonicalLtd/raft $(TMP)/dist/raft
-	cd $(TMP)/dist/sqlite && git log -1 --format="format:%ci%n" | sed -e 's/ [-+].*$$//;s/ /T/;s/^/D /' > manifest
-	cd $(TMP)/dist/sqlite && git log -1 --format="format:%H" > manifest.uuid
+	mkdir $(TMP)/dist/deps/
+	git clone --depth=1 https://github.com/CanonicalLtd/dqlite $(TMP)/dist/deps/dqlite
+	git clone --depth=1 https://github.com/CanonicalLtd/sqlite $(TMP)/dist/deps/sqlite
+	git clone --depth=1 https://github.com/freeekanayaka/libco $(TMP)/dist/deps/libco
+	git clone --depth=1 https://github.com/CanonicalLtd/raft $(TMP)/dist/deps/raft
+	cd $(TMP)/dist/deps/sqlite && git log -1 --format="format:%ci%n" | sed -e 's/ [-+].*$$//;s/ /T/;s/^/D /' > manifest
+	cd $(TMP)/dist/deps/sqlite && git log -1 --format="format:%H" > manifest.uuid
 
 	# 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

From b4e3f839141bad34f4683a2a967b01ae1d8f79a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 16 Jul 2019 10:57:22 -0400
Subject: [PATCH 2/2] Makefile: Rename dist to _dist to avoid Go recursion
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 Makefile | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/Makefile b/Makefile
index bfedf4a0c9..06a232a943 100644
--- a/Makefile
+++ b/Makefile
@@ -141,28 +141,28 @@ dist:
 	# Create build dir
 	$(eval TMP := $(shell mktemp -d))
 	git archive --prefix=lxd-$(VERSION)/ HEAD | tar -x -C $(TMP)
-	mkdir -p $(TMP)/dist/src/github.com/lxc
-	ln -s ../../../../lxd-$(VERSION) $(TMP)/dist/src/github.com/lxc/lxd
+	mkdir -p $(TMP)/_dist/src/github.com/lxc
+	ln -s ../../../../lxd-$(VERSION) $(TMP)/_dist/src/github.com/lxc/lxd
 
 	# Download dependencies
-	cd $(TMP)/lxd-$(VERSION) && GOPATH=$(TMP)/dist go get -t -v -d ./...
+	cd $(TMP)/lxd-$(VERSION) && GOPATH=$(TMP)/_dist go get -t -v -d ./...
 
 	# Download the cluster-enabled sqlite/dqlite
-	mkdir $(TMP)/dist/deps/
-	git clone --depth=1 https://github.com/CanonicalLtd/dqlite $(TMP)/dist/deps/dqlite
-	git clone --depth=1 https://github.com/CanonicalLtd/sqlite $(TMP)/dist/deps/sqlite
-	git clone --depth=1 https://github.com/freeekanayaka/libco $(TMP)/dist/deps/libco
-	git clone --depth=1 https://github.com/CanonicalLtd/raft $(TMP)/dist/deps/raft
-	cd $(TMP)/dist/deps/sqlite && git log -1 --format="format:%ci%n" | sed -e 's/ [-+].*$$//;s/ /T/;s/^/D /' > manifest
-	cd $(TMP)/dist/deps/sqlite && git log -1 --format="format:%H" > manifest.uuid
+	mkdir $(TMP)/_dist/deps/
+	git clone --depth=1 https://github.com/CanonicalLtd/dqlite $(TMP)/_dist/deps/dqlite
+	git clone --depth=1 https://github.com/CanonicalLtd/sqlite $(TMP)/_dist/deps/sqlite
+	git clone --depth=1 https://github.com/freeekanayaka/libco $(TMP)/_dist/deps/libco
+	git clone --depth=1 https://github.com/CanonicalLtd/raft $(TMP)/_dist/deps/raft
+	cd $(TMP)/_dist/deps/sqlite && git log -1 --format="format:%ci%n" | sed -e 's/ [-+].*$$//;s/ /T/;s/^/D /' > manifest
+	cd $(TMP)/_dist/deps/sqlite && git log -1 --format="format:%H" > manifest.uuid
 
 	# 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
+	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/lxd
-	ln -s ../../../../ $(TMP)/dist/src/github.com/lxc/lxd
-	mv $(TMP)/dist $(TMP)/lxd-$(VERSION)/
+	rm $(TMP)/_dist/src/github.com/lxc/lxd
+	ln -s ../../../../ $(TMP)/_dist/src/github.com/lxc/lxd
+	mv $(TMP)/_dist $(TMP)/lxd-$(VERSION)/
 	tar --exclude-vcs -C $(TMP) -zcf $(ARCHIVE).gz lxd-$(VERSION)/
 
 	# Cleanup


More information about the lxc-devel mailing list