Merge branch 'stable-2.16'

* stable-2.16:
  Add custom stamp to add its-base revision to version number

Change-Id: Ic4e9a92d2da276b6042d0b032880d455243a081f
diff --git a/tools/workspace_status_release.py b/tools/workspace_status_release.py
new file mode 100644
index 0000000..fea9351
--- /dev/null
+++ b/tools/workspace_status_release.py
@@ -0,0 +1,30 @@
+import os
+import sys
+
+# As this plugin is typically only sym-linked into a gerrit checkout and both os.getcwd and
+# os.path.abspath follow symbolic links, they would not allow us to find the gerrit root
+# directory. So we have to resort to the PWD environment variable to find the place we're
+# symlinked to.
+#
+# We append __file__ to avoid having to require to run it from a well-know directory.
+ABS_FILE_PARTS = os.path.join(os.getenv('PWD'), __file__).split(os.sep)
+PLUGIN_NAME = ABS_FILE_PARTS[-3]
+GERRIT_ROOT = os.sep.join(ABS_FILE_PARTS[:-4])
+
+sys.path = [os.sep.join([GERRIT_ROOT, 'tools'])] + sys.path
+from workspace_status_release import revision
+
+def get_plugin_revision(name):
+    os.chdir(os.path.join(GERRIT_ROOT, 'plugins', name))
+    ret=revision(GERRIT_VERSION)
+    return ret
+
+os.chdir(GERRIT_ROOT)
+GERRIT_VERSION=revision()
+
+ITS_BASE_VERSION=get_plugin_revision('its-base')
+PLUGIN_RAW_VERSION=get_plugin_revision(PLUGIN_NAME)
+
+PLUGIN_FULL_VERSION="%s(its-base:%s)" % (PLUGIN_RAW_VERSION, ITS_BASE_VERSION)
+
+print("STABLE_BUILD_%s_LABEL %s" % (PLUGIN_NAME.upper(), PLUGIN_FULL_VERSION))