diff options
author | Oz Linden <oz@lindenlab.com> | 2015-06-08 16:33:02 -0400 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2015-06-08 16:33:02 -0400 |
commit | 949942c730b0b7463338c2cb3bc411ac12f4f648 (patch) | |
tree | 159b9cf6bb6a9de9b538f17e3d721be25a15b79a /scripts/packages-formatter.py | |
parent | a219cf1c98527faa0e7addeb9660f679208bb0e7 (diff) | |
parent | f3c58f765c0168f25bb13c4427e34b4bdad2f671 (diff) |
merge changes for 3.7.29-release
Diffstat (limited to 'scripts/packages-formatter.py')
-rwxr-xr-x | scripts/packages-formatter.py | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/scripts/packages-formatter.py b/scripts/packages-formatter.py new file mode 100755 index 0000000000..4e66cf9ed4 --- /dev/null +++ b/scripts/packages-formatter.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python +"""\ +This module formats the package version and copyright information for the +viewer and its dependent packages. + +$LicenseInfo:firstyear=2014&license=viewerlgpl$ +Second Life Viewer Source Code +Copyright (C) 2014, Linden Research, Inc. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; +version 2.1 of the License only. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +$/LicenseInfo$ +""" +import os +import sys +import errno +import re +import subprocess + +_autobuild=os.getenv('AUTOBUILD', 'autobuild') + +pkg_line=re.compile('^([\w-]+):\s+(.*)$') + +def autobuild(*args): + """ + Launch autobuild with specified command-line arguments. + Return its stdout pipe from which the caller can read. + """ + # subprocess wants a list, not a tuple + command = [_autobuild] + list(args) + try: + child = subprocess.Popen(command, + stdin=None, stdout=subprocess.PIPE, + universal_newlines=True) + except OSError as err: + if err.errno != errno.ENOENT: + # Don't attempt to interpret anything but ENOENT + raise + # Here it's ENOENT: subprocess can't find the autobuild executable. + print >>sys.stderr, "packages-formatter on %s: can't run autobuild:\n%s\n%s" % \ + (sys.platform, ' '.join(command), err) + sys.exit(1) + + # no exceptions yet, let caller read stdout + return child.stdout + +version={} +versions=autobuild('install', '--versions') +for line in versions: + pkg_info = pkg_line.match(line) + if pkg_info: + pkg = pkg_info.group(1) + if pkg not in version: + version[pkg] = pkg_info.group(2).strip() + else: + sys.exit("Duplicate version for %s" % pkg) + else: + sys.exit("Unrecognized --versions output: %s" % line) + +copyright={} +copyrights=autobuild('install', '--copyrights') +viewer_copyright = copyrights.readline() # first line is the copyright for the viewer itself +for line in copyrights: + pkg_info = pkg_line.match(line) + if pkg_info: + pkg = pkg_info.group(1) + if pkg not in copyright: + copyright[pkg] = pkg_info.group(2).strip() + else: + sys.exit("Duplicate copyright for %s" % pkg) + else: + sys.exit("Unrecognized --copyrights output: %s" % line) + +print viewer_copyright +for pkg in sorted(version): + print ': '.join([pkg, version[pkg]]) + if pkg in copyright: + print copyright[pkg] + else: + sys.exit("No copyright for %s" % pkg) |