From 4e8637961489101dd61ee7ea21acc6c3375b7ca6 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Tue, 26 Aug 2008 14:52:53 +0000 Subject: [PATCH] Add a script for creating a standard SCons development system on Ubuntu Hardy. Rewrite subsidiary scripts for install Python and SCons versions in Python (from shell). git-svn-id: http://scons.tigris.org/svn/scons/trunk@3313 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- bin/Command.py | 129 ++++++++++++++++++++++++++ bin/install-python.sh | 119 ------------------------ bin/install-scons.sh | 183 ------------------------------------ bin/install_python.py | 135 +++++++++++++++++++++++++++ bin/install_scons.py | 200 ++++++++++++++++++++++++++++++++++++++++ bin/scons_dev_master.py | 196 +++++++++++++++++++++++++++++++++++++++ src/CHANGES.txt | 4 + 7 files changed, 664 insertions(+), 302 deletions(-) create mode 100644 bin/Command.py delete mode 100644 bin/install-python.sh delete mode 100644 bin/install-scons.sh create mode 100644 bin/install_python.py create mode 100644 bin/install_scons.py create mode 100644 bin/scons_dev_master.py diff --git a/bin/Command.py b/bin/Command.py new file mode 100644 index 00000000..ebdf589f --- /dev/null +++ b/bin/Command.py @@ -0,0 +1,129 @@ +#!/usr/bin/env python +# +# XXX Python script template +# +# XXX Describe what the script does here. +# + +import getopt +import os +import sys + +class Usage(Exception): + def __init__(self, msg): + self.msg = msg + +class CommandRunner: + """ + Representation of a command to be executed. + """ + + def __init__(self, dictionary={}): + self.subst_dictionary(dictionary) + + def subst_dictionary(self, dictionary): + self._subst_dictionary = dictionary + + def subst(self, string, dictionary=None): + """ + Substitutes (via the format operator) the values in the specified + dictionary into the specified command. + + The command can be an (action, string) tuple. In all cases, we + perform substitution on strings and don't worry if something isn't + a string. (It's probably a Python function to be executed.) + """ + if dictionary is None: + dictionary = self._subst_dictionary + if dictionary: + try: + string = string % dictionary + except TypeError: + pass + return string + + def do_display(self, string): + if type(string) == type(()): + func = string[0] + args = string[1:] + s = '%s(%s)' % (func.__name__, ', '.join(map(repr, args))) + else: + s = self.subst(string) + if not s.endswith('\n'): + s += '\n' + sys.stdout.write(s) + sys.stdout.flush() + + def do_not_display(self, string): + pass + + def do_execute(self, command): + if type(command) == type(()): + func = command[0] + args = command[1:] + return func(*args) + else: + return os.system(self.subst(command)) + + def do_not_execute(self, command): + pass + + display = do_display + execute = do_execute + + def run(self, command, display=None): + """ + Runs this command, displaying it first. + + The actual display() and execute() methods we call may be + overridden if we're printing but not executing, or vice versa. + """ + if display is None: + display = command + self.display(display) + return self.execute(command) + +def main(argv=None): + if argv is None: + argv = sys.argv + + short_options = 'hnq' + long_options = ['help', 'no-exec', 'quiet'] + + helpstr = """\ +Usage: script-template.py [-hnq] + + -h, --help Print this help and exit + -n, --no-exec No execute, just print the command line + -q, --quiet Quiet, don't print the command line +""" + + try: + try: + opts, args = getopt.getopt(argv[1:], short_options, long_options) + except getopt.error, msg: + raise Usage(msg) + + for o, a in opts: + if o in ('-h', '--help'): + print helpstr + sys.exit(0) + elif o in ('-n', '--no-exec'): + Command.execute = Command.do_not_execute + elif o in ('-q', '--quiet'): + Command.display = Command.do_not_display + except Usage, err: + sys.stderr.write(err.msg) + sys.stderr.write('use -h to get help') + return 2 + + commands = [ + ] + + for command in [ Command(c) for c in commands ]: + status = command.run(command) + if status: + sys.exit(status) + +if __name__ == "__main__": + sys.exit(main()) diff --git a/bin/install-python.sh b/bin/install-python.sh deleted file mode 100644 index a0a0ecc0..00000000 --- a/bin/install-python.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/sh -# -# A script for unpacking and installing different historic versions of -# Python in a consistent manner for side-by-side development testing. -# -# This was written for a Linux system (specifically Ubuntu) but should -# be reasonably generic to any POSIX-style system with a /usr/local -# hierarchy. - -USAGE="\ -Usage: $0 [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] -" - -PRINT="echo" -EXECUTE="eval" - -DOWNLOADS=Downloads -DOWNLOADS_URL=http://www.python.org/ftp/python -SUDO=sudo -PREFIX=/usr/local - -while getopts "ad:hnq" FLAG; do - case ${FLAG} in - a ) - ALL="1" - ;; - d ) - DOWNLOADS="${OPTARG}" - ;; - h ) - echo "${USAGE}" - exit 0 - ;; - n ) - EXECUTE=":" - ;; - p ) - PREFIX="${OPTARG}" - ;; - q ) - PRINT=":" - ;; - * ) - echo "$0: unknown option ${FLAG}; use -h for help." >&2 - exit 1 - ;; - esac -done - -shift `expr ${OPTIND} - 1` - -VERSIONS="$*" - -if test "X${ALL}" != "X"; then - if test "${VERSIONS}"; then - msg="$0: -a and version arguments both specified on the command line" - echo "${msg}" >&2 - exit 1 - fi - VERSIONS=" - 1.5.2 - 2.0.1 - 2.1.3 - 2.2 - 2.3.7 - 2.4.5 - " - # 2.5.2 -fi - -Command() -{ - ${PRINT} "$*" - ARGS=`echo "$*" | sed 's/\\$/\\\\$/'` - ${EXECUTE} "$*" -} - -for VERSION in $VERSIONS; do - PYTHON=Python-${VERSION} - - TAR_GZ=${PYTHON}.tgz - if test ! -f ${DOWNLOADS}/${TAR_GZ}; then - if test ! -d ${DOWNLOADS}; then - Command mkdir ${DOWNLOADS} - fi - Command "( cd ${DOWNLOADS} && wget ${DOWNLOADS_URL}/${VERSION}/${TAR_GZ} )" - fi - - Command tar zxf ${DOWNLOADS}/${TAR_GZ} - - ( - Command cd ${PYTHON} - - case ${VERSION} in - 1.5* ) - CONFIGUREFLAGS="--with-threads" - ;; - 1.6* | 2.0* ) - # Add the zlib module so we get zipfile compression. - Command ed Modules/Setup.in <&1 | tee configure.out - Command make 2>&1 | tee make.out - Command ${SUDO} make install - - Command ${SUDO} rm -f ${PREFIX}/bin/{idle,pydoc,python,python-config,smtpd.py} - - ${PRINT} cd .. - ) - - Command rm -rf ${PYTHON} -done diff --git a/bin/install-scons.sh b/bin/install-scons.sh deleted file mode 100644 index 1ffd3c2f..00000000 --- a/bin/install-scons.sh +++ /dev/null @@ -1,183 +0,0 @@ -#!/bin/sh -# -# A script for unpacking and installing different historic versions of -# SCons in a consistent manner for side-by-side development testing. -# -# This abstracts the changes we've made to the SCons setup.py scripts in -# different versions so that, no matter what version is specified, it ends -# up install the necessary script(s) and library into version-specific -# names that won't interfere with other things. -# -# We expect to extract the .tar.gz files from a Downloads subdirectory -# in the current directory. -# -# Note that this script cleans up after itself, removing the extracted -# directory in which we do the build. -# -# This was written for a Linux system (specifically Ubuntu) but should -# be reasonably generic to any POSIX-style system with a /usr/local -# hierarchy. - -USAGE="\ -Usage: $0 [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] -" - -PRINT="echo" -EXECUTE="eval" - -DOWNLOADS=Downloads -DOWNLOADS_URL=http://downloads.sourceforge.net/scons -SUDO=sudo -PREFIX=/usr/local - -while getopts "ad:hnq" FLAG; do - case ${FLAG} in - a ) - ALL="1" - ;; - d ) - DOWNLOADS="${OPTARG}" - ;; - h ) - echo "${USAGE}" - exit 0 - ;; - n ) - EXECUTE=":" - ;; - p ) - PREFIX="${OPTARG}" - ;; - q ) - PRINT=":" - ;; - * ) - echo "$0: unknown option ${FLAG}; use -h for help." >&2 - exit 1 - ;; - esac -done - -shift `expr ${OPTIND} - 1` - -VERSIONS="$*" - -if test "X${ALL}" != "X"; then - if test "${VERSIONS}"; then - msg="$0: -a and version arguments both specified on the command line" - echo "${msg}" >&2 - exit 1 - fi - VERSIONS=" - 0.01 - 0.02 - 0.03 - 0.04 - 0.05 - 0.06 - 0.07 - 0.08 - 0.09 - 0.10 - 0.11 - 0.12 - 0.13 - 0.14 - 0.90 - 0.91 - 0.92 - 0.93 - 0.94 - 0.94.1 - 0.95 - 0.95.1 - 0.96 - 0.96.1 - 0.96.90 - 0.96.91 - 0.96.92 - 0.96.93 - 0.96.94 - 0.96.95 - 0.96.96 - 0.97 - 0.97.0d20070809 - 0.97.0d20070918 - 0.97.0d20071212 - 0.98.0 - 0.98.1 - 0.98.2 - 0.98.3 - 0.98.4 - 0.98.5 - 1.0.0 - " -fi - -Command() -{ - ${PRINT} "$*" - ARGS=`echo "$*" | sed 's/\\$/\\\\$/'` - ${EXECUTE} "$*" -} - -for VERSION in $VERSIONS; do - SCONS=scons-${VERSION} - - TAR_GZ=${SCONS}.tar.gz - if test ! -f ${DOWNLOADS}/${TAR_GZ}; then - if test ! -d ${DOWNLOADS}; then - Command mkdir ${DOWNLOADS} - fi - Command "( cd ${DOWNLOADS} && wget ${DOWNLOADS_URL}/${TAR_GZ} )" - fi - - Command tar zxf ${DOWNLOADS}/${TAR_GZ} - - ( - Command cd ${SCONS} - - case ${VERSION} in - 0.0[123456789] | 0.10 ) - # 0.01 through 0.10 install /usr/local/bin/scons and - # /usr/local/lib/scons. The "scons" script knows how to - # look up the library in a version-specific directory, but - # we have to move both it and the library directory into - # the right version-specific name by hand. - Command python setup.py build - Command ${SUDO} python setup.py install --prefix=${PREFIX} - Command ${SUDO} mv ${PREFIX}/bin/scons ${PREFIX}/bin/scons-${VERSION} - Command ${SUDO} mv ${PREFIX}/lib/scons ${PREFIX}/lib/scons-${VERSION} - ;; - 0.1[1234] | 0.90 ) - # 0.11 through 0.90 install /usr/local/bin/scons and - # /usr/local/lib/scons-${VERSION}. We just need to move - # the script to a version-specific name. - Command python setup.py build - Command ${SUDO} python setup.py install --prefix=${PREFIX} - Command ${SUDO} mv ${PREFIX}/bin/scons ${PREFIX}/bin/scons-${VERSION} - ;; - 0.9[123456] | 0.9[456].1 | 0.96.90 ) - # 0.91 through 0.96.90 install /usr/local/bin/scons, - # /usr/local/bin/sconsign and /usr/local/lib/scons-${VERSION}. - # We need to move both scripts to version-specific names. - Command python setup.py build - Command ${SUDO} python setup.py install --prefix=${PREFIX} - Command ${SUDO} mv ${PREFIX}/bin/scons ${PREFIX}/bin/scons-${VERSION} - Command ${SUDO} mv ${PREFIX}/bin/sconsign ${PREFIX}/bin/sconsign-${VERSION} - if test -d ${PREFIX}/lib/scons; then - Command ${SUDO} mv ${PREFIX}/lib/scons ${PREFIX}/lib/scons-${VERSION} - fi - ;; - * ) - # Versions from 0.96.91 and later (through at least 0.97) - # support what we want with a --no-scons-script option. - Command python setup.py build - Command ${SUDO} python setup.py install --prefix=${PREFIX} --no-scons-script - ;; - esac - - ${PRINT} cd .. - ) - Command rm -rf ${SCONS} -done diff --git a/bin/install_python.py b/bin/install_python.py new file mode 100644 index 00000000..47b97d52 --- /dev/null +++ b/bin/install_python.py @@ -0,0 +1,135 @@ +#!/usr/bin/env python +# +# A script for unpacking and installing different historic versions of +# Python in a consistent manner for side-by-side development testing. +# +# This was written for a Linux system (specifically Ubuntu) but should +# be reasonably generic to any POSIX-style system with a /usr/local +# hierarchy. + +import getopt +import os +import shutil +import sys + +from Command import CommandRunner, Usage + +all_versions = [ + #'1.5.2', # no longer available at python.org + '2.0.1', + '2.1.3', + '2.2', + '2.3.7', + '2.4.5', + #'2.5.2', +] + +def main(argv=None): + if argv is None: + argv = sys.argv + + all = False + downloads_dir = 'Downloads' + downloads_url = 'http://www.python.org/ftp/python' + sudo = 'sudo' + prefix = '/usr/local' + + short_options = 'ad:hnp:q' + long_options = ['all', 'help', 'no-exec', 'prefix=', 'quiet'] + + helpstr = """\ +sage: installs-scons.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] + + -a, --all Install all SCons versions. + -d DIR, --downloads=DIR Downloads directory. + -h, --help Print this help and exit + -n, --no-exec No execute, just print the command line + -p PREFIX, --prefix=PREFIX Installation prefix. + -q, --quiet Quiet, don't print the command line +""" + + try: + try: + opts, args = getopt.getopt(argv[1:], short_options, long_options) + except getopt.error, msg: + raise Usage(msg) + + for o, a in opts: + if o in ('-a', '--all'): + all = True + elif o in ('-d', '--downloads'): + downloads_dir = a + elif o in ('-h', '--help'): + print helpstr + sys.exit(0) + elif o in ('-n', '--no-exec'): + CommandRunner.execute = CommandRunner.do_not_execute + elif o in ('-p', '--prefix'): + prefix = a + elif o in ('-q', '--quiet'): + CommandRunner.display = CommandRunner.do_not_display + except Usage, err: + sys.stderr.write(str(err.msg) + '\n') + sys.stderr.write('use -h to get help\n') + return 2 + + if all: + if args: + msg = 'install-scons.py: -a and version arguments both specified' + sys.stderr.write(msg) + sys.exit(1) + + args = all_versions + + cmd = CommandRunner() + + for version in args: + python = 'Python-' + version + tar_gz = os.path.join(downloads_dir, python + '.tgz') + tar_gz_url = os.path.join(downloads_url, version, python + '.tgz') + + if (version.startswith('1.5') or + version.startswith('1.6') or + version.startswith('2.0')): + + configureflags = '--with-threads' + + else: + + configureflags = '' + + cmd.subst_dictionary(locals()) + + if not os.path.exists(tar_gz): + if not os.path.exists(downloads_dir): + cmd.run((os.mkdir, downloads_dir), + 'mkdir %(downloads_dir)s') + cmd.run('wget -O %(tar_gz)s %(tar_gz_url)s') + + cmd.run('tar zxf %(tar_gz)s') + + cmd.run((os.chdir, python), 'cd %(python)s') + + if (version.startswith('1.6') or + version.startswith('2.0')): + + def edit_modules_setup_in(): + content = open('Modules/Setup.in', 'r').read() + content = content.replace('\n#zlib', '\nzlib') + open('Modules/Setup.in', 'w').write(content) + + display = 'ed Modules/Setup.in <&1 | tee configure.out') + cmd.run('make 2>&1 | tee make.out') + cmd.run('%(sudo)s make install') + + cmd.run('%(sudo)s rm -f %(prefix)s/bin/{idle,pydoc,python,python-config,smtpd.py}') + + cmd.run((os.chdir, '..'), 'cd ..') + + cmd.run((shutil.rmtree, python), 'rm -rf %(python)s') + +if __name__ == "__main__": + sys.exit(main()) diff --git a/bin/install_scons.py b/bin/install_scons.py new file mode 100644 index 00000000..8a5c5b77 --- /dev/null +++ b/bin/install_scons.py @@ -0,0 +1,200 @@ +#!/usr/bin/env python +# +# A script for unpacking and installing different historic versions of +# SCons in a consistent manner for side-by-side development testing. +# +# This abstracts the changes we've made to the SCons setup.py scripts in +# different versions so that, no matter what version is specified, it ends +# up installing the necessary script(s) and library into version-specific +# names that won't interfere with other things. +# +# By default, we expect to extract the .tar.gz files from a Downloads +# subdirectory in the current directory. +# +# Note that this script cleans up after itself, removing the extracted +# directory in which we do the build. +# +# This was written for a Linux system (specifically Ubuntu) but should +# be reasonably generic to any POSIX-style system with a /usr/local +# hierarchy. + +import getopt +import os +import shutil +import sys + +from Command import CommandRunner, Usage + +all_versions = [ + '0.01', + '0.02', + '0.03', + '0.04', + '0.05', + '0.06', + '0.07', + '0.08', + '0.09', + '0.10', + '0.11', + '0.12', + '0.13', + '0.14', + '0.90', + '0.91', + '0.92', + '0.93', + '0.94', + #'0.94.1', + '0.95', + #'0.95.1', + '0.96', + '0.96.1', + '0.96.90', + '0.96.91', + '0.96.92', + '0.96.93', + '0.96.94', + '0.96.95', + '0.96.96', + '0.97', + '0.97.0d20070809', + '0.97.0d20070918', + '0.97.0d20071212', + '0.98.0', + '0.98.1', + '0.98.2', + '0.98.3', + '0.98.4', + '0.98.5', + #'1.0.0', +] + +def main(argv=None): + if argv is None: + argv = sys.argv + + all = False + downloads_dir = 'Downloads' + downloads_url = 'http://downloads.sourceforge.net/scons' + sudo = 'sudo' + prefix = '/usr/local' + python = sys.executable + + short_options = 'ad:hnp:q' + long_options = ['all', 'help', 'no-exec', 'prefix=', 'quiet'] + + helpstr = """\ +Usage: install-scons.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] + + -a, --all Install all SCons versions. + -d DIR, --downloads=DIR Downloads directory. + -h, --help Print this help and exit + -n, --no-exec No execute, just print the command line + -p PREFIX, --prefix=PREFIX Installation prefix. + -q, --quiet Quiet, don't print the command line +""" + + try: + try: + opts, args = getopt.getopt(argv[1:], short_options, long_options) + except getopt.error, msg: + raise Usage(msg) + + for o, a in opts: + if o in ('-a', '--all'): + all = True + elif o in ('-d', '--downloads'): + downloads_dir = a + elif o in ('-h', '--help'): + print helpstr + sys.exit(0) + elif o in ('-n', '--no-exec'): + CommandRunner.execute = CommandRunner.do_not_execute + elif o in ('-p', '--prefix'): + prefix = a + elif o in ('-q', '--quiet'): + CommandRunner.display = CommandRunner.do_not_display + except Usage, err: + sys.stderr.write(str(err.msg) + '\n') + sys.stderr.write('use -h to get help\n') + return 2 + + if all: + if args: + msg = 'install-scons.py: -a and version arguments both specified' + sys.stderr.write(msg) + sys.exit(1) + + args = all_versions + + cmd = CommandRunner() + + for version in args: + scons = 'scons-' + version + tar_gz = os.path.join(downloads_dir, scons + '.tar.gz') + tar_gz_url = os.path.join(downloads_url, scons + '.tar.gz') + + cmd.subst_dictionary(locals()) + + if not os.path.exists(tar_gz): + if not os.path.exists(downloads_dir): + cmd.run((os.mkdir, downloads_dir), + 'mkdir %(downloads_dir)s') + cmd.run('wget -O %(tar_gz)s %(tar_gz_url)s') + + cmd.run('tar zxf %(tar_gz)s') + + cmd.run((os.chdir, scons), 'cd %(scons)s') + + if version in ('0.01', '0.02', '0.03', '0.04', '0.05', + '0.06', '0.07', '0.08', '0.09', '0.10'): + + # 0.01 through 0.10 install /usr/local/bin/scons and + # /usr/local/lib/scons. The "scons" script knows how to + # look up the library in a version-specific directory, but + # we have to move both it and the library directory into + # the right version-specific name by hand. + cmd.run('%(python)s setup.py build') + cmd.run('%(sudo)s %(python)s setup.py install --prefix=%(prefix)s') + cmd.run('%(sudo)s mv %(prefix)s/bin/scons %(prefix)s/bin/scons-%(version)s') + cmd.run('%(sudo)s mv %(prefix)s/lib/scons %(prefix)s/lib/scons-%(version)s') + + elif version in ('0.11', '0.12', '0.13', '0.14', '0.90'): + + # 0.11 through 0.90 install /usr/local/bin/scons and + # /usr/local/lib/scons-%(version)s. We just need to move + # the script to a version-specific name. + cmd.run('%(python)s setup.py build') + cmd.run('%(sudo)s %(python)s setup.py install --prefix=%(prefix)s') + cmd.run('%(sudo)s mv %(prefix)s/bin/scons %(prefix)s/bin/scons-%(version)s') + + elif version in ('0.91', '0.92', '0.93', + '0.94', '0.94.1', + '0.95', '0.95.1', + '0.96', '0.96.1', '0.96.90'): + + # 0.91 through 0.96.90 install /usr/local/bin/scons, + # /usr/local/bin/sconsign and /usr/local/lib/scons-%(version)s. + # We need to move both scripts to version-specific names. + cmd.run('%(python)s setup.py build') + cmd.run('%(sudo)s %(python)s setup.py install --prefix=%(prefix)s') + cmd.run('%(sudo)s mv %(prefix)s/bin/scons %(prefix)s/bin/scons-%(version)s') + cmd.run('%(sudo)s mv %(prefix)s/bin/sconsign %(prefix)s/bin/sconsign-%(version)s') + lib_scons = os.path.join(prefix, 'lib', 'scons') + if os.path.isdir(lib_scons): + cmd.run('%(sudo)s mv %(prefix)s/lib/scons %(prefix)s/lib/scons-%(version)s') + + else: + + # Versions from 0.96.91 and later support what we want + # with a --no-scons-script option. + cmd.run('%(python)s setup.py build') + cmd.run('%(sudo)s %(python)s setup.py install --prefix=%(prefix)s --no-scons-script') + + cmd.run((os.chdir, '..'), 'cd ..') + + cmd.run((shutil.rmtree, scons), 'rm -rf %(scons)s') + +if __name__ == "__main__": + sys.exit(main()) diff --git a/bin/scons_dev_master.py b/bin/scons_dev_master.py new file mode 100644 index 00000000..fc9747c6 --- /dev/null +++ b/bin/scons_dev_master.py @@ -0,0 +1,196 @@ +#!/bin/sh +# + +# A script for turning a generic Ubuntu system into a master for +# SCons development. + +import getopt +import sys + +from Command import CommandRunner, Usage + +INITIAL_PACKAGES = [ + 'subversion', +] + +INSTALL_PACKAGES = [ + 'wget', +] + +PYTHON_PACKAGES = [ + 'g++', + 'gcc', + 'make', + 'zlib1g-dev', +] + +BUILDING_PACKAGES = [ + 'docbook', + 'docbook-dsssl', + 'docbook-utils', + 'docbook-xml', + 'groff-base', + 'jade', + 'jadetex', + 'man2html', + 'python-epydoc', + 'rpm', + 'sp', + 'tar', + + # additional packages that Bill Deegan's web page suggests + #'docbook-to-man', + #'docbook-xsl', + #'docbook2x', + #'tetex-bin', + #'tetex-latex', +] + +DOCUMENTATION_PACKAGES = [ + 'docbook-doc', + 'epydoc-doc', + 'gcc-doc', + 'python-doc', + 'sun-java5-doc', + 'sun-java6-doc', + 'swig-doc', + 'texlive-doc', +] + +TESTING_PACKAGES = [ + 'bison', + 'cssc', + 'cvs', + 'flex', + 'g++', + 'gcc', + 'gcj', + 'ghostscript', + 'libgcj7-dev', + 'm4', + 'openssh-client', + 'openssh-server', + 'python-profiler', + 'rcs', + 'rpm', + 'sun-java5-jdk', + 'sun-java6-jdk', + 'swig', + 'texlive-base-bin', + 'texlive-latex-base', + 'texlive-latex-extra', + 'zip', +] + +default_args = [ + 'upgrade', + 'checkout', + 'building', + 'testing', + 'python-versions', + 'scons-versions', +] + +def main(argv=None): + if argv is None: + argv = sys.argv + + short_options = 'hnqy' + long_options = ['help', 'no-exec', 'password=', 'quiet', 'username=', + 'yes', 'assume-yes'] + + helpstr = """\ +Usage: scons_dev_master.py [-hnqy] [--password PASSWORD] [--username USER] + [ACTIONS ...] + + ACTIONS (in default order): + upgrade Upgrade the system + checkout Check out SCons + building Install packages for building SCons + testing Install packages for testing SCons + scons-versions Install versions of SCons + python-versions Install versions of Python +""" + + scons_url = 'http://scons.tigris.org/svn/scons/trunk' + sudo = 'sudo' + password = '""' + username = 'guest' + yesflag = '' + + try: + try: + opts, args = getopt.getopt(argv[1:], short_options, long_options) + except getopt.error, msg: + raise Usage(msg) + + for o, a in opts: + if o in ('-h', '--help'): + print helpstr + sys.exit(0) + elif o in ('-n', '--no-exec'): + CommandRunner.execute = CommandRunner.do_not_execute + elif o in ('--password'): + password = a + elif o in ('-q', '--quiet'): + CommandRunner.display = CommandRunner.do_not_display + elif o in ('--username'): + username = a + elif o in ('-y', '--yes', '--assume-yes'): + yesflag = o + except Usage, err: + sys.stderr.write(str(err.msg) + '\n') + sys.stderr.write('use -h to get help\n') + return 2 + + if not args: + args = default_args + + initial_packages = ' '.join(INITIAL_PACKAGES) + install_packages = ' '.join(INSTALL_PACKAGES) + building_packages = ' '.join(BUILDING_PACKAGES) + testing_packages = ' '.join(TESTING_PACKAGES) + python_packages = ' '.join(PYTHON_PACKAGES) + + cmd = CommandRunner(locals()) + + for arg in args: + if arg == 'upgrade': + cmd.run('%(sudo)s apt-get %(yesflag)s upgrade') + elif arg == 'checkout': + cmd.run('%(sudo)s apt-get %(yesflag)s install %(initial_packages)s') + cmd.run('svn co --username guest --password "" %(scons_url)s') + elif arg == 'building': + cmd.run('%(sudo)s apt-get %(yesflag)s install %(building_packages)s') + elif arg == 'testing': + cmd.run('%(sudo)s apt-get %(yesflag)s install %(testing_packages)s') + elif arg == 'python-versions': + if install_packages: + cmd.run('%(sudo)s apt-get %(yesflag)s install %(install_packages)s') + install_packages = None + cmd.run('%(sudo)s apt-get %(yesflag)s install %(python_packages)s') + try: + import install_python + except ImportError: + msg = 'Could not import install_python; skipping python-versions.\n' + sys.stderr.write(msg) + else: + install_python.main(['install_python.py', '-a']) + elif arg == 'scons-versions': + if install_packages: + cmd.run('%(sudo)s apt-get %(yesflag)s install %(install_packages)s') + install_packages = None + try: + import install_scons + except ImportError: + msg = 'Could not import install_scons; skipping scons-versions.\n' + sys.stderr.write(msg) + else: + install_scons.main(['install_scons.py', '-a']) + else: + msg = '%s: unknown argument %s\n' + sys.stderr.write(msg % (argv[0], repr(arg))) + sys.exit(1) + +if __name__ == "__main__": + sys.exit(main()) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 9cc05f91..58550537 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -31,6 +31,10 @@ RELEASE 1.0.0 - XXX - Have the env.Execute() method print an error message if the executed command fails. + - Add a script for creating a standard SCons development system on + Ubuntu Hardy. Rewrite subsidiary scripts for install Python and + SCons versions in Python (from shell). + From Greg Noel: - Handle yacc/bison on newer Mac OS X versions creating file.hpp, -- 2.26.2