.PHONY: dist-rpm

RPM_WORKSPACE=$(shell pwd)/build
RPM_DIR=$(RPM_WORKSPACE)/rpmbuild
RPM_VER=$(shell echo $(VERSION) | awk -F_ '{ print $$1 }')
RPM_REL=$(shell echo $(VERSION) | awk -F_ '{ sub(/g/, "", $$3); print $$2"_"$$3 }')

dist-rpm: dist
	rm -rf $(RPM_WORKSPACE)
	mkdir -p $(RPM_DIR)
	mkdir $(RPM_DIR)/SOURCES
	mkdir $(RPM_DIR)/BUILD
	mkdir $(RPM_DIR)/RPMS
	mkdir $(RPM_DIR)/SRPMS
	cp $(PACKAGE)-$(VERSION).tar.gz $(RPM_DIR)/SOURCES
	sed 's/@VERSION@/$(RPM_VER)/g;s/@RELEASE@/$(RPM_REL)/g' < packaging/rpm/$(PACKAGE).spec.in > $(RPM_WORKSPACE)/$(PACKAGE).spec
	(cd $(RPM_WORKSPACE); rpmbuild -ba $(PACKAGE).spec)
	mv $(RPM_DIR)/RPMS/*/*.rpm `pwd`
	mv $(RPM_DIR)/SRPMS/*.rpm `pwd`
	rm -rf $(RPM_WORKSPACE)

.PHONY: dist-rpm

RPM_WORKSPACE=$(shell pwd)/build
RPM_DIR=$(RPM_WORKSPACE)/rpmbuild
RPM_VER=$(shell echo $(VERSION) | awk -F_ '{ print $$1 }')
RPM_REL=$(shell echo $(VERSION) | awk -F_ '{ print $$2"_"$$3 }')

dist-rpm: dist
	rm -rf $(RPM_WORKSPACE)
	mkdir -p $(RPM_DIR)
	mkdir $(RPM_DIR)/SOURCES
	mkdir $(RPM_DIR)/BUILD
	mkdir $(RPM_DIR)/RPMS
	mkdir $(RPM_DIR)/SRPMS
	cp $(PACKAGE)-$(VERSION).tar.gz $(RPM_DIR)/SOURCES
	sed 's/@VERSION@/$(RPM_VER)/g;s/@RELEASE@/$(RPM_REL)/g' < packaging/rpm/$(PACKAGE).spec.in > $(RPM_WORKSPACE)/$(PACKAGE).spec
	(cd $(RPM_WORKSPACE); rpmbuild -ba $(PACKAGE).spec)
	mv $(RPM_DIR)/RPMS/*/*.rpm `pwd`
	mv $(RPM_DIR)/SRPMS/*.rpm `pwd`
	rm -rf $(RPM_WORKSPACE)

Revert "Remove 'g' prefix from the version". MB-4647
Revert "Remove 'g' prefix from the version".  MB-4647

This change broke packaging on RHEL. See more detail in
http://www.couchbase.org/issues/browse/MB-4647

This reverts commit 4860db327c885c677859b64a2d6410b49491e388.

Change-Id: I0ba7a289995f65d1bdddd77e3fc46a61e5741a31
Reviewed-on: http://review.couchbase.org/12417
Reviewed-by: Matt Ingenthron <1fa2ef4755a9226cb9a0a4840bd89b158ac71391@couchbase.com>
Tested-by: Matt Ingenthron <1fa2ef4755a9226cb9a0a4840bd89b158ac71391@couchbase.com>
