예제 #1
0
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

    ACTIONS (optional):
        buildbot                Install packages for running BuildBot
"""

    scons_url = 'http://scons.tigris.org/svn/scons/trunk'
    sudo = 'sudo'
    password = '******'
    username = '******'
    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
예제 #2
0
def main(argv=None):
    if argv is None:
        argv = sys.argv

    all = False
    downloads_dir = 'Downloads'
    downloads_url = 'http://downloads.sourceforge.net/scons'
    if sys.platform == 'win32':
        sudo = ''
        prefix = sys.prefix
    else:
        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 command lines
  -p PREFIX, --prefix=PREFIX    Installation prefix.
  -q, --quiet                   Quiet, don't print command lines
"""

    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
예제 #3
0
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

    ACTIONS (optional):
        buildbot                Install packages for running BuildBot
"""

    scons_url = 'https://github.com/SCons/scons.git'
    sudo = 'sudo'
    password = '******'
    username = '******'
    yesflag = ''

    try:
        try:
            opts, args = getopt.getopt(argv[1:], short_options, long_options)
        except getopt.error as 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 as 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)
    buildbot_packages = ' '.join(BUILDBOT_PACKAGES)
    python_packages = ' '.join(PYTHON_PACKAGES)
    doc_packages = ' '.join(DOCUMENTATION_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('git clone" %(scons_url)s')
        elif arg == 'building':
            cmd.run(
                '%(sudo)s apt-get %(yesflag)s install %(building_packages)s')
        elif arg == 'docs':
            cmd.run('%(sudo)s apt-get %(yesflag)s install %(doc_packages)s')
        elif arg == 'testing':
            cmd.run(
                '%(sudo)s apt-get %(yesflag)s install %(testing_packages)s')
            #TODO: maybe copy ipkg-build from openwrt git
            #cmd.run('%(sudo)s wget https://raw.githubusercontent.com/openwrt/openwrt/master/scripts/ipkg-build SOMEWHERE')
        elif arg == 'buildbot':
            cmd.run(
                '%(sudo)s apt-get %(yesflag)s install %(buildbot_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)
예제 #4
0
def main(argv=None):
    if argv is None:
        argv = sys.argv

    all = False
    downloads_dir = 'Downloads'
    downloads_url = 'http://downloads.sourceforge.net/scons'
    if sys.platform == 'win32':
        sudo = ''
        prefix = sys.prefix
    else:
        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 command lines
  -p PREFIX, --prefix=PREFIX    Installation prefix.
  -q, --quiet                   Quiet, don't print command lines
"""

    try:
        try:
            opts, args = getopt.getopt(argv[1:], short_options, long_options)
        except getopt.error as 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 as 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 = "%s/%s.tar.gz" % (downloads_url, scons)

        cmd.subst_dictionary(locals())

        if not os.path.exists(tar_gz):
            if not os.path.exists(downloads_dir):
                cmd.run('mkdir %(downloads_dir)s')
            cmd.run((urlretrieve, tar_gz_url, tar_gz),
                    'wget -O %(tar_gz)s %(tar_gz_url)s')

        def extract(tar_gz):
            tarfile.open(tar_gz, "r:gz").extractall()

        cmd.run((extract, tar_gz), 'tar zxf %(tar_gz)s')

        cmd.run('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('cd ..')

        cmd.run((shutil.rmtree, scons), 'rm -rf %(scons)s')
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 = """\
Usage:  install_python.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 command lines
  -p PREFIX, --prefix=PREFIX    Installation prefix.
  -q, --quiet                   Quiet, don't print command lines
"""

    try:
        try:
            opts, args = getopt.getopt(argv[1:], short_options, long_options)
        except getopt.error as 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 as 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')

        cmd.subst_dictionary(locals())

        if not os.path.exists(tar_gz):
            if not os.path.exists(downloads_dir):
                cmd.run('mkdir %(downloads_dir)s')
            cmd.run('wget -O %(tar_gz)s %(tar_gz_url)s')

        cmd.run('tar zxf %(tar_gz)s')

        cmd.run('cd %(python)s')

        cmd.run(
            './configure --prefix=%(prefix)s %(configureflags)s 2>&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('cd ..')

        cmd.run((shutil.rmtree, python), 'rm -rf %(python)s')