Exemple #1
0
def _install(installDir, userDataDir, suppressShortcut, destDir=None):
    normInstallDir = normpath(expanduser(installDir))
    absInstallDir = abspath(normInstallDir)
    pyInstallDir = join(absInstallDir, "lib", "python")
    mozInstallDir = join(absInstallDir, "lib", "mozilla")
    log.info("Installing ActiveState Komodo to '%s'...", normInstallDir)
    _validateInstallDir(absInstallDir)
    log.debug("redirect userDataDir to '%s'", userDataDir)
    log.debug("user environment: %s", pprint.pformat(dict(os.environ)))

    # "destDir", if defined, is the ultimate final install location. We
    # want to relocate to that dir.
    if destDir is None:
        absRelocDir = absInstallDir
        pyRelocDir = pyInstallDir
    else:
        absRelocDir = abspath(normpath(expanduser(destDir)))
        pyRelocDir = join(absRelocDir, "lib", "python")

    # copy the entire "Komodo" tree to the installDir
    if not exists(absInstallDir):
         os.makedirs(absInstallDir)
    for path in glob(join(dirname(dirname(__file__)), "INSTALLDIR", "*")):
        if isdir(path):
            shutil.copytree(path, join(absInstallDir, basename(path)),
                            symlinks=True)
        else:
            shutil.copy2(path, absInstallDir)

    log.debug("Preparing internal Python...")
    import activestate
    activestate.relocate_python(pyRelocDir,
                                verbose=log.isEnabledFor(logging.DEBUG))

    # Make sure that we use symlinks for libpython.so, bug 98337
    pyLibName = "libpython%s.%s.so" % sys.version_info[:2]
    pyLibReal = abspath(join(pyInstallDir, "lib", "%s.1.0" % (pyLibName,)))
    pyLibs = set(abspath(join(libdir, libname))
                 for libdir in (mozInstallDir, join(pyInstallDir, "lib"))
                 for libname in (pyLibName, "%s.1.0" % (pyLibName,)))
    pyLibs.discard(pyLibReal)
    if not exists(pyLibReal) or islink(pyLibReal):
        # we don't have the real file? See if we can grab one of the others
        log.warning("%s is not a file; trying to find alternative...", pyLibReal)
        for pyLib in pyLibs:
            if not exists(pyLib) or islink(pyLib):
                continue
            if exists(pyLibReal):
                os.unlink(pyLibReal)
            os.rename(pyLib, pyLibReal)
            break
        else:
            log.error("Could not find a valid libpython; your Komodo is broken."
                      "  Please try re-downloading the installer.")
            sys.exit(1)
    for pyLib in pyLibs:
        if exists(pyLib):
            os.unlink(pyLib)
        try:
            os.symlink(relpath(pyLibReal, dirname(pyLib)), pyLib)
        except OSError:
            log.error("Failed to create a symlink at %s; Komodo will be broken."
                      "  Komodo needs to be installed on a filesystem that "
                      "supports symlinks.", pyLib)
            sys.exit(1)

    log.debug("pre-compile .py files in siloed Python")
    pyLibDir = join(pyInstallDir, "lib", "python%s.%s" % sys.version_info[:2])
    # Skip .pyc's only, just .pyo's are necessary because we always run
    # Python in optimized mode.
    cmds = ['"%s" -W "ignore:hex/oct constants" -O "%s/compileall.py" '
            '-q -x test/ "%s"'
            % (sys.executable, pyLibDir, pyLibDir)]
    for cmd in cmds:
        log.debug("running '%s'" % cmd)
        retval = os.system(cmd)
        if retval:
            log.warn("error running '%s'" % cmd)

    # Configure siloed GTK2 libs (if any).
    log.debug("Configuring GTK2...")
    files = [join(mozInstallDir, "pango", "pangorc"),
             join(mozInstallDir, "pango", "pango.modules"),
             join(mozInstallDir, "gdk-pixbuf", "gdk-pixbuf.loaders")]
    token = "__PATH_TO_INSTALLED_KOMODO__"
    for file in files:
        if not exists(file):
            continue
        log.debug("fixing up '%s'", file)
        fin = open(file, 'r')
        try:
            content = fin.read()
        finally:
            fin.close()
        content = content.replace(token, absInstallDir)
        os.chmod(file, 0644)
        fout = open(file, 'w')
        try:
            fout.write(content)
        finally:
            fout.close()

    _symlink_komodo_executable(absInstallDir)
    _install_desktop_shortcut(absInstallDir, suppressShortcut)
    _selinux_prepare(absInstallDir)

    print """
%s
__GNOME_DESKTOP_NAME__ has been successfully installed to:
    %s
    
You might want to add 'komodo' to your PATH by adding the 
install dir to you PATH. Bash users can add the following
to their ~/.bashrc file:

    export PATH="%s/bin:$PATH"

Or you could create a symbolic link to 'komodo', e.g.:

    ln -s "%s/bin/komodo" /usr/local/bin/komodo

Documentation is available in Komodo or on the web here:
    http://docs.activestate.com/komodo

Please send us any feedback you have through one of the
channels below:
    [email protected]
    irc://irc.mozilla.org/komodo
    https://github.com/Komodo/KomodoEdit/issues

Thank you for using Komodo.
%s
""" % (_banner(None), absInstallDir, absInstallDir, absInstallDir,
       _banner(None))
Exemple #2
0
def _install(installDir, userDataDir, suppressShortcut, destDir=None):
    normInstallDir = normpath(expanduser(installDir))
    absInstallDir = abspath(normInstallDir)
    pyInstallDir = join(absInstallDir, "lib", "python")
    mozInstallDir = join(absInstallDir, "lib", "mozilla")
    log.info("Installing ActiveState Komodo to '%s'...", normInstallDir)
    _validateInstallDir(absInstallDir)
    log.debug("redirect userDataDir to '%s'", userDataDir)
    log.debug("user environment: %s", pprint.pformat(dict(os.environ)))

    # "destDir", if defined, is the ultimate final install location. We
    # want to relocate to that dir.
    if destDir is None:
        absRelocDir = absInstallDir
        pyRelocDir = pyInstallDir
    else:
        absRelocDir = abspath(normpath(expanduser(destDir)))
        pyRelocDir = join(absRelocDir, "lib", "python")

    # copy the entire "Komodo" tree to the installDir
    if not exists(absInstallDir):
         os.makedirs(absInstallDir)
    for path in glob(join(dirname(dirname(__file__)), "INSTALLDIR", "*")):
        if isdir(path):
            shutil.copytree(path, join(absInstallDir, basename(path)),
                            symlinks=True)
        else:
            shutil.copy2(path, absInstallDir)

    log.debug("Preparing internal Python...")
    import activestate
    activestate.relocate_python(pyRelocDir,
                                verbose=log.isEnabledFor(logging.DEBUG))

    # Make sure that we use symlinks for libpython.so, bug 98337
    pyLibName = "libpython%s.%s.so" % sys.version_info[:2]
    pyLibReal = abspath(join(pyInstallDir, "lib", "%s.1.0" % (pyLibName,)))
    pyLibs = set(abspath(join(libdir, libname))
                 for libdir in (mozInstallDir, join(pyInstallDir, "lib"))
                 for libname in (pyLibName, "%s.1.0" % (pyLibName,)))
    pyLibs.discard(pyLibReal)
    if not exists(pyLibReal) or islink(pyLibReal):
        # we don't have the real file? See if we can grab one of the others
        log.warning("%s is not a file; trying to find alternative...", pyLibReal)
        for pyLib in pyLibs:
            if not exists(pyLib) or islink(pyLib):
                continue
            if exists(pyLibReal):
                os.unlink(pyLibReal)
            os.rename(pyLib, pyLibReal)
            break
        else:
            log.error("Could not find a valid libpython; your Komodo is broken."
                      "  Please try re-downloading the installer.")
            sys.exit(1)
    for pyLib in pyLibs:
        if exists(pyLib):
            os.unlink(pyLib)
        try:
            os.symlink(relpath(pyLibReal, dirname(pyLib)), pyLib)
        except OSError:
            log.error("Failed to create a symlink at %s; Komodo will be broken."
                      "  Komodo needs to be installed on a filesystem that "
                      "supports symlinks.", pyLib)
            sys.exit(1)

    log.debug("pre-compile .py files in siloed Python")
    pyLibDir = join(pyInstallDir, "lib", "python%s.%s" % sys.version_info[:2])
    # Skip .pyc's only, just .pyo's are necessary because we always run
    # Python in optimized mode.
    cmds = ['"%s" -W "ignore:hex/oct constants" -O "%s/compileall.py" '
            '-q -x test/ "%s"'
            % (sys.executable, pyLibDir, pyLibDir)]
    for cmd in cmds:
        log.debug("running '%s'" % cmd)
        retval = os.system(cmd)
        if retval:
            log.warn("error running '%s'" % cmd)

    # Configure siloed GTK2 libs (if any).
    log.debug("Configuring GTK2...")
    files = [join(mozInstallDir, "pango", "pangorc"),
             join(mozInstallDir, "pango", "pango.modules"),
             join(mozInstallDir, "gdk-pixbuf", "gdk-pixbuf.loaders")]
    token = "__PATH_TO_INSTALLED_KOMODO__"
    for file in files:
        if not exists(file):
            continue
        log.debug("fixing up '%s'", file)
        fin = open(file, 'r')
        try:
            content = fin.read()
        finally:
            fin.close()
        content = content.replace(token, absInstallDir)
        os.chmod(file, 0644)
        fout = open(file, 'w')
        try:
            fout.write(content)
        finally:
            fout.close()

    _symlink_komodo_executable(absInstallDir)
    _install_desktop_shortcut(absInstallDir, suppressShortcut)
    _selinux_prepare(absInstallDir)

    print """
%s
__GNOME_DESKTOP_NAME__ has been successfully installed to:
    %s
    
You might want to add 'komodo' to your PATH by adding the 
install dir to you PATH. Bash users can add the following
to their ~/.bashrc file:

    export PATH="%s/bin:$PATH"

Or you could create a symbolic link to 'komodo', e.g.:

    ln -s "%s/bin/komodo" /usr/local/bin/komodo

Documentation is available in Komodo or on the web here:
    http://docs.activestate.com/komodo

Please send us any feedback you have through one of the
channels below:
    [email protected]
    irc://irc.mozilla.org/komodo
    http://bugs.activestate.com/

Thank you for using Komodo.
%s
""" % (_banner(None), absInstallDir, absInstallDir, absInstallDir,
       _banner(None))