Skip to content

Commit

Permalink
Merge pull request lxc#249 from monstermunchkin/misc/Makefile
Browse files Browse the repository at this point in the history
Makefile: Add dist target
  • Loading branch information
stgraber authored Oct 21, 2019
2 parents 5eb5463 + acfc32e commit 3a905ba
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.PHONY: default check
VERSION=$(shell grep "var Version" shared/version/version.go | cut -d'"' -f2)
ARCHIVE=distrobuilder-$(VERSION).tar

.PHONY: default check dist

default:
gofmt -s -w .
Expand All @@ -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)

0 comments on commit 3a905ba

Please sign in to comment.