Skip to content
Browse files

Determine package name based on dependency changes

  • Loading branch information...
1 parent 286f365 commit af091a4984486806163a1abf6ea45889b98d787f @jaredmorrow jaredmorrow committed
Showing with 119 additions and 63 deletions.
  1. +87 −33 Makefile
  2. +5 −5 package/Makefile
  3. +7 −7 package/deb/Makefile
  4. +7 −7 package/osx/Makefile
  5. +11 −9 package/rpm/Makefile
  6. +2 −2 package/solaris/Makefile
View
120 Makefile
@@ -1,7 +1,4 @@
-REPO ?= riak
-RIAK_TAG = $(shell git describe --tags)
-REVISION ?= $(shell echo $(RIAK_TAG) | sed -e 's/^$(REPO)-//')
-PKG_VERSION ?= $(shell echo $(REVISION) | tr - .)
+REPO ?= riak
.PHONY: rel stagedevrel deps
@@ -97,39 +94,96 @@ cleanplt:
sleep 5
rm $(COMBO_PLT)
-# Release tarball creation
-# Generates a tarball that includes all the deps sources so no checkouts are necessary
-archivegit = git archive --format=tar --prefix=$(1)/ HEAD | (cd $(2) && tar xf -)
-archivehg = hg archive $(2)/$(1)
-archive = if [ -d ".git" ]; then \
- $(call archivegit,$(1),$(2)); \
- else \
- $(call archivehg,$(1),$(2)); \
- fi
-
-buildtar = mkdir distdir && \
- git clone . distdir/riak-clone && \
- cd distdir/riak-clone && \
- git checkout $(RIAK_TAG) && \
- $(call archive,$(RIAK_TAG),..) && \
- mkdir ../$(RIAK_TAG)/deps && \
+##
+## Version and naming variables for distribution and packaging
+##
+
+# Tag from git with style <tagname>-<commits_since_tag>-<current_commit_hash>
+# Ex: When on a tag: riak-1.0.3 (no commits since tag)
+# For most normal Commits: riak-1.1.0pre1-27-g1170096
+# Last tag: riak-1.1.0pre1
+# Commits since tag: 27
+# Hash of commit: g1170096
+REPO_TAG := $(shell git describe --tags)
+
+# Split off repo name
+# Changes to 1.0.3 or 1.1.0pre1-27-g1170096 from example above
+REVISION ?= $(shell echo $(REPO_TAG) | sed -e 's/^$(REPO)-//')
+
+# Primary version identifier, strip off commmit information
+# Changes to 1.0.3 or 1.1.0pre1 from example above
+MAJOR_VERSION ?= $(shell echo $(REVISION) | sed -e 's/\([0-9.]*\)-.*/\1/')
+
+
+##
+## Release tarball creation
+## Generates a tarball that includes all the deps sources so no checkouts are necessary
+##
+
+# Use git archive to copy a repository at a current revision to a new directory
+archive_git = git archive --format=tar --prefix=$(1)/ HEAD | (cd $(2) && tar xf -)
+
+# Checkout tag, fetch deps (so we don't have to do it multiple times) and collect
+# the version of all the dependencies into the MANIFEST_FILE
+CLONEDIR := riak-clone
+MANIFEST_FILE := dependency_manifest.git
+get_dist_deps = mkdir distdir && \
+ git clone . distdir/$(CLONEDIR) && \
+ cd distdir/$(CLONEDIR) && \
+ git checkout $(REPO_TAG) && \
make deps; \
+ echo "Dependencies and their tags at build time of $(REPO) at $(REPO_TAG)" > $(MANIFEST_FILE); \
for dep in deps/*; do \
- cd $${dep} && \
- $(call archive,$${dep},../../../$(RIAK_TAG)) && \
- mkdir -p ../../../$(RIAK_TAG)/$${dep}/priv && \
- git describe --tags > ../../../$(RIAK_TAG)/$${dep}/priv/vsn.git && \
- cd ../..; done
+ cd $${dep} && \
+ printf "$${dep} version `git describe --tags`\n" >> ../../$(MANIFEST_FILE) && \
+ cd ../..; done
+
+
+# Name resulting direcotry & tar file based on current status of the git tag
+# If it is a tagged release (REVISION == MAJOR_VERSION), use the toplevel
+# tag as the package name, otherwise generate a unique hash of all the
+# dependencies revisions to make the package name unique.
+# This enables the toplevel repository package to change names
+# when underlying dependencies change.
+NAME_HASH = $(shell git hash-object distdir/$(CLONEDIR)/$(MANIFEST_FILE) | cut -c 1-8)
+ifeq ($(REVISION), $(MAJOR_VERSION))
+DISTNAME := $(REPO_TAG)
+else
+DISTNAME = $(REPO)-$(MAJOR_VERSION)-$(NAME_HASH)
+endif
+
+# To ensure a clean build, copy the CLONEDIR at a specific tag to a new directory
+# which will be the basis of the src tar file (and packages)
+build_clean_dir = cd distdir/$(CLONEDIR) && \
+ $(call archive_git,$(DISTNAME),..) && \
+ cp $(MANIFEST_FILE) ../$(DISTNAME)/ && \
+ mkdir ../$(DISTNAME)/deps; \
+ for dep in deps/*; do \
+ cd $${dep} && \
+ $(call archive_git,$${dep},../../../$(DISTNAME)) && \
+ cd ../..; done
+
+distdirprep:
+ $(if $(REPO_TAG), $(call get_dist_deps), $(error "You can't generate a release tarball from a non-tagged revision. Run 'git checkout <tag>', then 'make dist'"))
+
+distdir: distdirprep
+ $(call build_clean_dir)
+
+dist $(DISTNAME).tar.gz: distdir
+ cd distdir && \
+ tar czf ../$(DISTNAME).tar.gz $(DISTNAME)
-distdir:
- $(if $(RIAK_TAG), $(call buildtar), $(error "You can't generate a release tarball from a non-tagged revision. Run 'git checkout <tag>', then 'make dist'"))
+ballclean:
+ rm -rf $(DISTNAME).tar.gz distdir
-dist $(RIAK_TAG).tar.gz: distdir
- cd distdir; \
- tar czf ../$(RIAK_TAG).tar.gz $(RIAK_TAG)
-ballclean:
- rm -rf $(RIAK_TAG).tar.gz distdir
+##
+## Packaging targets reside in package directory
+##
+
+# Strip off repo name for packaging
+PKG_VERSION = $(shell echo $(DISTNAME) | sed -e 's/^$(REPO)-//')
+
package: dist
$(MAKE) -C package package
@@ -138,4 +192,4 @@ pkgclean:
$(MAKE) -C package pkgclean
.PHONY: package
-export PKG_VERSION REPO REVISION RIAK_TAG
+export PKG_VERSION REPO DISTNAME
View
10 package/Makefile
@@ -31,23 +31,23 @@ BUILDDIR = osxbuild
endif
DATE = $(shell date +%Y-%m-%d)
-VERSIONSTRING = $(APP) ($(REVISION) $(DATE)) $(OSNAME) $(ARCH)
+VERSIONSTRING = $(APP) ($(PKG_VERSION) $(DATE)) $(OSNAME) $(ARCH)
APP = $(shell echo "$(REPO)" | sed -e 's/_/-/g')
# Assumes CURDIR is .../$(APP)/package/$(APP)/
RIAK_PATH ?= ..
RELEASE ?=
-$(APP)-$(REVISION).tar.gz: ../$(RIAK_TAG).tar.gz
+$(APP)-$(PKG_VERSION).tar.gz: ../$(DISTNAME).tar.gz
ln -s $< $@
pkgclean: $(PKGERDIR)/pkgclean
- rm -rf $(APP)-$(REVISION).tar.gz working rpmbuild debuild packages osxbuild
+ rm -rf $(APP)-$(PKG_VERSION).tar.gz working rpmbuild debuild packages osxbuild
pkgcheck:
- $(if $(RIAK_TAG),,$(error "You can't generate a release tarball from a non-tagged revision. Run 'git checkout <tag>', then 'make dist'"))
+ $(if $(DISTNAME),,$(error "You can't generate a release tarball from a non-tagged revision. Run 'git checkout <tag>', then 'make dist'"))
$(if $(RELEASE),,$(error "You must provide a package release number via RELEASE= on the command line"))
- @echo "Packaging \"$(RIAK_TAG)\""
+ @echo "Packaging \"$(DISTNAME)\""
# The heavy lifting is done by the individual packager Makefiles
package: pkgcheck build
View
14 package/deb/Makefile
@@ -1,25 +1,25 @@
-BUILDPATH = debuild/$(APP)-$(REVISION)
+BUILDPATH = debuild/$(APP)-$(PKG_VERSION)
build: $(BUILDPATH)/debian \
- debuild/$(APP)_$(REVISION).orig.tar.gz
+ debuild/$(APP)_$(PKG_VERSION).orig.tar.gz
export DEBFULLNAME="Basho Buildbot Packager"; \
export DEBEMAIL="support@basho.com"; \
dch --noquery -c $(BUILDPATH)/debian/changelog \
- -b -v "$(REVISION)-$(RELEASE)" "pants on head"
+ -b -v "$(PKG_VERSION)-$(RELEASE)" "pants on head"
cd $(BUILDPATH) && debuild --no-lintian \
--prepend-path=$(ERLANG_BIN) \
- -e REVISION=$(REVISION) \
+ -e REVISION=$(PKG_VERSION) \
-e RELEASE=$(RELEASE) \
-e VERSIONSTRING="$(VERSIONSTRING)" \
-uc -us
mkdir -p packages
- mv debuild/$(APP)_$(REVISION)-$(RELEASE)_*.deb packages
+ mv debuild/$(APP)_$(PKG_VERSION)-$(RELEASE)_*.deb packages
cd packages && \
for debfile in `ls *.deb`; do \
sha256sum $${debfile} > $${debfile}.sha \
; done
-$(BUILDPATH): $(APP)-$(REVISION).tar.gz
+$(BUILDPATH): $(APP)-$(PKG_VERSION).tar.gz
mkdir -p debuild
tar xz -C debuild -f $^
@@ -27,7 +27,7 @@ $(BUILDPATH)/debian: $(BUILDPATH)
cp -a $(PKGERDIR) $@
rm -rf $@/.hg $@/Makefile $@/.*.swp
-debuild/$(APP)_$(REVISION).orig.tar.gz: $(APP)-$(REVISION).tar.gz
+debuild/$(APP)_$(PKG_VERSION).orig.tar.gz: $(APP)-$(PKG_VERSION).tar.gz
cp $^ $@
$(PKGERDIR)/pkgclean:
View
14 package/osx/Makefile
@@ -1,26 +1,26 @@
-PKGNAME = $(APP)-$(REVISION)-osx-$(ARCH).tar.gz
+PKGNAME = $(APP)-$(PKG_VERSION)-osx-$(ARCH).tar.gz
# simply tar up the rel directory and sha the file
build: buildrel
@echo "Building package $(PKGNAME)"
mkdir -p packages
- cd $(BUILDDIR)/$(APP)-$(REVISION) && \
- cp -R rel/riak $(APP)-$(REVISION) && \
- tar -czf ../../packages/$(PKGNAME) $(APP)-$(REVISION)
+ cd $(BUILDDIR)/$(APP)-$(PKG_VERSION) && \
+ cp -R rel/riak $(APP)-$(PKG_VERSION) && \
+ tar -czf ../../packages/$(PKGNAME) $(APP)-$(PKG_VERSION)
cd packages && \
for tarfile in `ls *.gz`; do \
shasum -a 256 $${tarfile} > $${tarfile}.sha \
; done
# Build the release we need to package
-buildrel: $(BUILDDIR)/$(APP)-$(REVISION)
+buildrel: $(BUILDDIR)/$(APP)-$(PKG_VERSION)
cd $^ && \
cp rel/files/riak rel/files/riak.tmp && \
sed -e "s/^RIAK_VERSION.*$$/RIAK_VERSION=\"${VERSIONSTRING}\"/" < rel/files/riak.tmp > rel/files/riak && \
$(MAKE) deps compile rel
-$(BUILDDIR)/$(APP)-$(REVISION): $(BUILDDIR) $(APP)-$(REVISION).tar.gz
- tar xz -C $(BUILDDIR) -f $(APP)-$(REVISION).tar.gz
+$(BUILDDIR)/$(APP)-$(PKG_VERSION): $(BUILDDIR) $(APP)-$(PKG_VERSION).tar.gz
+ tar xz -C $(BUILDDIR) -f $(APP)-$(PKG_VERSION).tar.gz
$(BUILDDIR):
mkdir -p $@
View
20 package/rpm/Makefile
@@ -1,11 +1,13 @@
-DISTRO = $(shell head -1 /etc/redhat-release| awk \
- '{if ($$0 ~ /CentOS release 5/) { print ".el5."} else { print "." }} ')
+DISTRO = $(shell head -1 /etc/redhat-release| awk \
+ '{if ($$0 ~ /CentOS release 5/) { print ".el5."} else { print "." }} ')
-build: $(PKGERDIR)/SOURCES/$(APP)-$(REVISION).tar.gz rpmbuild
+PKG_VERSION_NO_H ?= $(shell echo $(PKG_VERSION) | tr - .)
+
+build: $(PKGERDIR)/SOURCES/$(APP)-$(PKG_VERSION).tar.gz rpmbuild
@echo "DISTRO = $(DISTRO)"
@echo "RIAK_TAG = $(RIAK_TAG)"
- @echo "REVISION = $(REVISION)"
+ @echo "REVISION = $(PKG_VERSION)"
@echo "RELEASE = $(RELEASE)"
rpmbuild --define "_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}$(DISTRO)%%{ARCH}.rpm" \
--define '_topdir $(CURDIR)/rpmbuild' \
@@ -13,8 +15,8 @@ build: $(PKGERDIR)/SOURCES/$(APP)-$(REVISION).tar.gz rpmbuild
--define '_specdir $(CURDIR)/$(PKGERDIR)/SPECS' \
--define '_rpmdir $(CURDIR)/packages' \
--define '_srcrpmdir $(CURDIR)/packages' \
- --define "_revision $(REVISION)" \
- --define "_version $(PKG_VERSION)" \
+ --define "_revision $(PKG_VERSION)" \
+ --define "_version $(PKG_VERSION_NO_H)" \
--define "_release $(RELEASE)" \
--define "_versionstring $(VERSIONSTRING)" \
-ba $(PKGERDIR)/SPECS/$(APP).spec
@@ -31,9 +33,9 @@ rpmbuild:
$(PKGERDIR)/SOURCES:
@mkdir -m 0755 -p $(PKGERDIR)/SOURCES
-$(PKGERDIR)/SOURCES/$(APP)-$(REVISION).tar.gz: $(APP)-$(REVISION).tar.gz \
- $(PKGERDIR)/SOURCES
- cp $(APP)-$(REVISION).tar.gz $(PKGERDIR)/SOURCES
+$(PKGERDIR)/SOURCES/$(APP)-$(PKG_VERSION).tar.gz: $(APP)-$(PKG_VERSION).tar.gz \
+ $(PKGERDIR)/SOURCES
+ cp $(APP)-$(PKG_VERSION).tar.gz $(PKGERDIR)/SOURCES
$(PKGERDIR)/pkgclean:
@echo
View
4 package/solaris/Makefile
@@ -2,7 +2,7 @@
PKG = BASHO$(APP)
# possible ARCH values are i386, sparc, all
SOLARIS_VER ?= $(shell echo "$(KERNEL)" | sed -e 's/^5\.//')
-PKGFILE = $(PKG)-$(REVISION)-$(RELEASE)-$(DISTRO)$(SOLARIS_VER)-$(ARCH).pkg
+PKGFILE = $(PKG)-$(PKG_VERSION)-$(RELEASE)-$(DISTRO)$(SOLARIS_VER)-$(ARCH).pkg
build: buildrel depend pkginfo prototype
cp $(PKGERDIR)/copyright $(PKGERDIR)/preinstall $(PKGERDIR)/*.preserve .
@@ -38,7 +38,7 @@ depend:
fi
pkginfo:
- sed -e 's/@@VERSION@@/$(REVISION)-$(RELEASE)/g' \
+ sed -e 's/@@VERSION@@/$(PKG_VERSION)-$(RELEASE)/g' \
-e 's/@@PKG@@/$(PKG)/g' \
-e 's/@@PKGNAME@@/$(APP)/g' \
< $(PKGERDIR)/pkginfo.tmpl > pkginfo

0 comments on commit af091a4

Please sign in to comment.
Something went wrong with that request. Please try again.