Makefile: Add new dist target for releases
authorMichael Hanselmann <hansmi@google.com>
Mon, 8 Nov 2010 19:43:39 +0000 (20:43 +0100)
committerMichael Hanselmann <hansmi@google.com>
Tue, 9 Nov 2010 13:40:37 +0000 (14:40 +0100)
A new script, autotools/check-tar, is used to check the resulting
.tar.gz file for unwanted contents like wrong file owners or
permissions.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

Makefile.am
autotools/check-tar [new file with mode: 0755]

index 51f23c3..ceaa04f 100644 (file)
@@ -282,6 +282,7 @@ EXTRA_DIST = \
        autotools/build-bash-completion \
        autotools/check-python-code \
        autotools/check-man \
+       autotools/check-tar \
        autotools/docbook-wrapper \
        autotools/gen-coverage \
        autotools/testrunner \
@@ -669,9 +670,17 @@ distcheck-hook:
        fi
 
 # When building a release, stricter checks should be used
-distcheck-release: export BUILD_RELEASE = 1
+distcheck-release dist-release: export BUILD_RELEASE = 1
 distcheck-release: distcheck
 
+dist-release: dist
+       set -e; \
+       for i in $(DIST_ARCHIVES); do \
+               echo -n "Checking $$i ... "; \
+               autotools/check-tar < $$i; \
+               echo OK; \
+       done
+
 install-exec-local:
        @mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
          "$(DESTDIR)${localstatedir}/log/ganeti" \
diff --git a/autotools/check-tar b/autotools/check-tar
new file mode 100755 (executable)
index 0000000..d540763
--- /dev/null
@@ -0,0 +1,60 @@
+#!/usr/bin/python
+#
+
+# Copyright (C) 2010 Google Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+
+"""Script to check tarball generated by Automake.
+
+"""
+
+import sys
+import stat
+import tarfile
+
+
+def ReportError(member, msg):
+  print >>sys.stderr, "%s: %s" % (member.name, msg)
+
+
+def main():
+  tf = tarfile.open(fileobj=sys.stdin)
+
+  success = True
+
+  for member in tf.getmembers():
+    if member.uid != 0:
+      success = False
+      ReportError(member, "Owned by UID %s, not UID 0" % member.uid)
+
+    if member.gid != 0:
+      success = False
+      ReportError(member, "Owned by GID %s, not GID 0" % member.gid)
+
+    if member.mode & (stat.S_IWGRP | stat.S_IWOTH):
+      success = False
+      ReportError(member, "World or group writeable (mode is %o)" % member.mode)
+
+  if success:
+    sys.exit(0)
+
+  sys.exit(1)
+
+
+if __name__ == "__main__":
+  main()