Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/maint-helper.py
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2007-06-24 10:05:52 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2007-06-24 10:05:52 (GMT)
commit90c0ace5c0a3efd5c5bf9e9c736b9097ca18a10e (patch)
tree65aefbad40b54e80228850522e918a7cdb3a3495 /maint-helper.py
parente894c8a2e407b10b5d252fe33e3dec744c5586eb (diff)
Add a license checker.
Remove obsolete testint infrastructure.
Diffstat (limited to 'maint-helper.py')
-rwxr-xr-xmaint-helper.py93
1 files changed, 93 insertions, 0 deletions
diff --git a/maint-helper.py b/maint-helper.py
new file mode 100755
index 0000000..e1d2593
--- /dev/null
+++ b/maint-helper.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2007, Red Hat, 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import os
+import sys
+import re
+
+def get_name_and_version():
+ f = open('configure.ac', 'r')
+ config = f.read()
+ f.close()
+
+ exp = 'AC_INIT\(\[[^\]]+\],\[([^\]]+)\],\[\],\[([^\]]+)\]'
+ match = re.search(exp, config)
+ if not match:
+ print 'Cannot find the package name and version.'
+ sys.exit(0)
+
+ return [ match.group(2), match.group(1) ]
+
+def cmd_help():
+ print 'Usage: \n\
+maint-helper.py build-snapshot - build a source snapshot \n\
+maint-helper.py check-licenses - check licenses in the source'
+
+def cmd_build_snapshot():
+ [ name, version ] = get_name_and_version()
+
+ cmd = 'git-show-ref --hash=10 refs/heads/master'
+ alphatag = os.popen(cmd).readline().strip()
+
+ tarball = '%s-%s-git%s.tar.bz2' % (name, version, alphatag)
+
+ os.spawnlp(os.P_WAIT, 'make', 'make', 'distcheck')
+
+ os.rename('%s-%s.tar.bz2' % (name, version), tarball)
+
+def check_licenses(path, license, missing):
+ matchers = { 'LGPL' : 'GNU Lesser General Public',
+ 'GPL' : 'GNU General Public License' }
+
+ license_file = os.path.join(path, '.license')
+ if os.path.isfile(license_file):
+ f = open(license_file, 'r')
+ license = f.readline().strip()
+ f.close()
+
+ for item in os.listdir(path):
+ full_path = os.path.join(path, item)
+
+ if item.endswith('.py'):
+ f = open(full_path, 'r')
+ source = f.read()
+ if source.find(matchers[license]) == -1:
+ if not missing.has_key(license):
+ missing[license] = []
+ missing[license].append(full_path)
+ f.close()
+
+ if os.path.isdir(full_path):
+ check_licenses(full_path, license, missing)
+
+def cmd_check_licenses():
+ missing = {}
+ check_licenses(os.getcwd(), 'GPL', missing)
+
+ for item in missing.keys():
+ print '%s:\n' % item
+ for path in missing[item]:
+ print path
+ print '\n'
+
+if len(sys.argv) < 2:
+ cmd_help()
+elif sys.argv[1] == 'build-snapshot':
+ cmd_build_snapshot()
+elif sys.argv[1] == 'check-licenses':
+ cmd_check_licenses()