From 680194deaf7a35caaa629abc16e886d71baff636 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Fri, 21 Nov 2014 18:09:12 -0500 Subject: automate keeping the About SL -> Licenses tab correct --- scripts/packages-formatter.py | 73 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 scripts/packages-formatter.py (limited to 'scripts/packages-formatter.py') diff --git a/scripts/packages-formatter.py b/scripts/packages-formatter.py new file mode 100755 index 0000000000..1432cdaebe --- /dev/null +++ b/scripts/packages-formatter.py @@ -0,0 +1,73 @@ +#!/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 re +import subprocess + +autobuild=os.getenv('AUTOBUILD', + 'autobuild' if not ( sys.platform == 'win32' or sys.platform == 'cygwin') + else 'autobuild.cmd') + +pkg_line=re.compile('^([\w-]+):\s+(.*)$') + +version={} +versions=subprocess.Popen([autobuild, 'install', '--versions'], + stdin=None, stdout=subprocess.PIPE, universal_newlines=True).stdout +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=subprocess.Popen([autobuild, 'install', '--copyrights'], + stdin=None, stdout=subprocess.PIPE, universal_newlines=True).stdout +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) -- cgit v1.2.3 From 20de60576f464aa87a38b5a270a5a72330452670 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 12 Dec 2014 14:33:20 -0500 Subject: Wrap call to autobuild in some diagnostic code. Hopefully this will make certain errors clearer, notably failure to launch autobuild due to "cannot find the file specified". --- scripts/packages-formatter.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'scripts/packages-formatter.py') diff --git a/scripts/packages-formatter.py b/scripts/packages-formatter.py index 1432cdaebe..34fc92e44c 100755 --- a/scripts/packages-formatter.py +++ b/scripts/packages-formatter.py @@ -26,18 +26,41 @@ $/LicenseInfo$ """ import os import sys +import errno import re import subprocess -autobuild=os.getenv('AUTOBUILD', +_autobuild=os.getenv('AUTOBUILD', 'autobuild' if not ( sys.platform == 'win32' or sys.platform == 'cygwin') else 'autobuild.cmd') 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=subprocess.Popen([autobuild, 'install', '--versions'], - stdin=None, stdout=subprocess.PIPE, universal_newlines=True).stdout +versions=autobuild('install', '--versions') for line in versions: pkg_info = pkg_line.match(line) if pkg_info: @@ -50,8 +73,7 @@ for line in versions: sys.exit("Unrecognized --versions output: %s" % line) copyright={} -copyrights=subprocess.Popen([autobuild, 'install', '--copyrights'], - stdin=None, stdout=subprocess.PIPE, universal_newlines=True).stdout +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) -- cgit v1.2.3 From 9635923d5587588e9db71685234265e1f78856cf Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 22 Dec 2014 15:27:28 -0500 Subject: Temporarily work around cygwin /cygdrive/c pathname in AUTOBUILD. --- scripts/packages-formatter.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts/packages-formatter.py') diff --git a/scripts/packages-formatter.py b/scripts/packages-formatter.py index 34fc92e44c..7e5e690e49 100755 --- a/scripts/packages-formatter.py +++ b/scripts/packages-formatter.py @@ -33,6 +33,8 @@ import subprocess _autobuild=os.getenv('AUTOBUILD', 'autobuild' if not ( sys.platform == 'win32' or sys.platform == 'cygwin') else 'autobuild.cmd') +# HACK: temporarily work around cygwin /cygdrive/c madness +_autobuild = re.sub(r"^/cygdrive/(.)/", r"\1:/", _autobuild) pkg_line=re.compile('^([\w-]+):\s+(.*)$') -- cgit v1.2.3 From 355d00685137aa0c42fdd93853096ac718a474b2 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 8 Jan 2015 16:48:29 -0500 Subject: Rationalize use of AUTOBUILD environment variable across languages. Ensure that AUTOBUILD is always in native path syntax on every platform. Remove local build.sh logic to infer AUTOBUILD: either the generic build.sh has set it properly, or scream for help. Since cygwin bash scripts need a cygwin-syntax path to autobuild, convert to a local 'autobuild' variable using shell_path. Remove kludges in other languages involving cygdrive twiddling. --- scripts/packages-formatter.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'scripts/packages-formatter.py') diff --git a/scripts/packages-formatter.py b/scripts/packages-formatter.py index 7e5e690e49..4e66cf9ed4 100755 --- a/scripts/packages-formatter.py +++ b/scripts/packages-formatter.py @@ -30,11 +30,7 @@ import errno import re import subprocess -_autobuild=os.getenv('AUTOBUILD', - 'autobuild' if not ( sys.platform == 'win32' or sys.platform == 'cygwin') - else 'autobuild.cmd') -# HACK: temporarily work around cygwin /cygdrive/c madness -_autobuild = re.sub(r"^/cygdrive/(.)/", r"\1:/", _autobuild) +_autobuild=os.getenv('AUTOBUILD', 'autobuild') pkg_line=re.compile('^([\w-]+):\s+(.*)$') -- cgit v1.2.3