Add tarball distribution

Package Gerrit's distribution war, the native packages
plugins and the startup configuration into a platform-independent
tarball, which can be used in other type of distributions.

First use of the tarball is homebrew taps on github.com/GerritForge.

Change-Id: Ie5e455f5351c7c389747385b45bee25e626a9479
diff --git a/tarball/Makefile b/tarball/Makefile
new file mode 100644
index 0000000..2efe8ee
--- /dev/null
+++ b/tarball/Makefile
@@ -0,0 +1,57 @@
+WAR_VERSION=3.11.0-rc0
+BRANCH=stable-3.11
+URL=https://storage.googleapis.com/gerrit-releases/gerrit-$(WAR_VERSION).war
+CI_URL=https://gerrit-ci.gerritforge.com
+
+NAME=gerrit
+OUT=$(shell pwd)/out
+BUILD_ROOT=$(shell pwd)/build
+
+WAR=$(BUILD_ROOT)/bin/gerrit.war
+PLUGINS_CI=https://gerrit-ci.gerritforge.com/job
+LIBS_JOBS= \
+  plugin-out-of-the-box-bazel-master-$(BRANCH)/lastSuccessfulBuild/artifact/bazel-bin/plugins/out-of-the-box/out-of-the-box.jar
+PLUGINS_JOBS= \
+  plugin-avatars-gravatar-bazel-master-$(BRANCH)/lastSuccessfulBuild/artifact/bazel-bin/plugins/avatars-gravatar/avatars-gravatar.jar \
+  plugin-uploadvalidator-bazel-master-$(BRANCH)/lastSuccessfulBuild/artifact/bazel-bin/plugins/uploadvalidator/uploadvalidator.jar
+
+TAR_OUT=$(OUT)/gerrit-$(WAR_VERSION).tar.gz
+CONFIGS=$(wildcard etc/*)
+
+all: prepare $(TAR_OUT)
+
+clean:
+	rm -Rf $(OUT)
+
+prepare: $(CONFIGS)
+	mkdir -p $(OUT)
+	mkdir -p $(BUILD_ROOT)/etc
+	mkdir -p $(BUILD_ROOT)/bin
+	mkdir -p $(BUILD_ROOT)/plugins
+	mkdir -p $(BUILD_ROOT)/lib
+	mkdir -p $(BUILD_ROOT)/cache
+	mkdir -p $(BUILD_ROOT)/db
+	mkdir -p $(BUILD_ROOT)/git
+	mkdir -p $(BUILD_ROOT)/index
+	cp -R $(CONFIGS) $(BUILD_ROOT)/etc
+
+clobber: clean
+	rm -Rf $(BUILD_ROOT)
+
+$(WAR): $(basedir $(WAR))
+	curl -f -o $@  $(URL)
+
+plugins:
+	for job in $(PLUGINS_JOBS); \
+          do set -e && echo ">> Download: $$job" && curl -f -o $(BUILD_ROOT)/plugins/`basename $$job` $(PLUGINS_CI)/$$job; \
+        done
+
+libs:
+	for job in $(LIBS_JOBS); \
+          do set -e && echo ">> Download: $$job" && curl -f -o $(BUILD_ROOT)/lib/`basename $$job` $(PLUGINS_CI)/$$job; \
+        done
+
+$(TAR_OUT): $(WAR) plugins libs $(CONFIGS)
+	tar -C $(BUILD_ROOT) -f $@ -cvz .
+
+.PHONY: clean clobber prepare plugins libs
diff --git a/tarball/etc/gerrit.config b/tarball/etc/gerrit.config
new file mode 100644
index 0000000..c6abc85
--- /dev/null
+++ b/tarball/etc/gerrit.config
@@ -0,0 +1,18 @@
+[gerrit]
+	basePath = git
+[index]
+	type = LUCENE
+[auth]
+	type = DEVELOPMENT_BECOME_ANY_ACCOUNT
+[sendemail]
+	smtpServer = localhost
+[sshd]
+	listenAddress = *:29418
+[httpd]
+	listenUrl = http://*:8080/
+	filterClass = com.googlesource.gerrit.plugins.ootb.FirstTimeRedirect
+	firstTimeRedirectUrl = /login/%23%2F?account_id=1000000
+[cache]
+	directory = cache
+[plugins]
+	allowRemoteAdmin = true